Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid React.createContext import with verifyCloudProof #283

Open
khanhngn-dev opened this issue Oct 11, 2024 · 1 comment
Open

Invalid React.createContext import with verifyCloudProof #283

khanhngn-dev opened this issue Oct 11, 2024 · 1 comment

Comments

@khanhngn-dev
Copy link

khanhngn-dev commented Oct 11, 2024

IDKit version: 1.3.0
Framework: NextJS (App router)

Issues:

React.createContext() is being imported when calling verifyCloudProof() causing an error despite the function being called from a route.ts file as NextJS App API handler.

image

This happens when testing with the WorldID simulator.

Here is the rough implementation of the code

// /api/world-id/verify/route.ts
import { type IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit';
import { NextRequest, NextResponse } from 'next/server';

export const POST = async (req: NextRequest) => {
  const proof = await req.json();
  const app_id = process.env.NEXT_PUBLIC_WORLD_ID_CLIENT_ID! as `app_${string}`;
  const action_id = process.env.NEXT_PUBLIC_WORLD_ID_ZKP_ID!;

  try {
    const verifyRes = (await verifyCloudProof(
      proof,
      app_id,
      action_id,
    )) as IVerifyResponse;

    if (!verifyRes.success) {
      return NextResponse.json(verifyRes, { status: 400 });
    }
    return NextResponse.json(verifyRes);
  } catch (error) {
    console.log(error);
    return NextResponse.json('Failed to verify', { status: 500 });
  }
};

Expected result

The route handler should compile normally and verify the proof received.

@Hichambour1980
Copy link

// /api/world-id/verify/route.ts
import { type IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit';
import { NextRequest, NextResponse } from 'next/server';

export const POST = async (req: NextRequest) => {
const proof = await req.json();
const app_id = process.env.NEXT_PUBLIC_WORLD_ID_CLIENT_ID! as app_${string};
const action_id = process.env.NEXT_PUBLIC_WORLD_ID_ZKP_ID!;

try {
const verifyRes = (await verifyCloudProof(
proof,
app_id,
action_id,
)) as IVerifyResponse;

if (!verifyRes.success) {
  return NextResponse.json(verifyRes, { status: 400 });
}
return NextResponse.json(verifyRes);

} catch (error) {
console.log(error);
return NextResponse.json('Failed to verify', { status: 500 });
}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants