Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions js/examples/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ The UI includes request buttons matching the browser example presets:
- Device Legacy
- Selfie Check Legacy

The `/arena` route includes grouped mobile implementation test cases for
World ID 3.0 presets, World ID 4.0 constraints, migration fallback behavior,
and 4.0 error handling.

## Run

From repo root:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { bytesToHex, hexToBytes, keccak256, type Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";

type TestCaseId =
type RpContextCaseId =
| "valid_success"
| "invalid_rp_signature"
| "duplicate_nonce"
Expand All @@ -28,12 +28,12 @@ type RpContextPayload = {
};

type RequestBody = {
caseId: TestCaseId;
caseId: RpContextCaseId;
action?: string;
nonce?: string;
};

const KNOWN_CASES = new Set<TestCaseId>([
const KNOWN_CASES = new Set<RpContextCaseId>([
"valid_success",
"invalid_rp_signature",
"duplicate_nonce",
Expand All @@ -47,7 +47,7 @@ const KNOWN_CASES = new Set<TestCaseId>([
"rp_signature_expired",
]);

const DEFAULT_ACTION = "idkit-test-case";
const DEFAULT_ACTION = "idkit-arena";
const DEFAULT_TTL_SEC = 300;
const RP_ID_FORMAT = /^rp_[0-9a-fA-F]{1,16}$/;

Expand Down Expand Up @@ -167,7 +167,10 @@ export async function POST(request: Request): Promise<Response> {
try {
const body = (await request.json()) as RequestBody;
if (!KNOWN_CASES.has(body.caseId)) {
return jsonError(`Unknown test case: ${String(body.caseId)}`, 400);
return jsonError(
`Unknown Arena context case: ${String(body.caseId)}`,
400,
);
}

const signingKey = process.env.RP_SIGNING_KEY;
Expand Down Expand Up @@ -314,7 +317,7 @@ export async function POST(request: Request): Promise<Response> {
note,
});
} catch (error) {
console.error("Error generating test-case RP context:", error);
console.error("Error generating Arena RP context:", error);
return jsonError(
error instanceof Error ? error.message : "Unknown server error",
500,
Expand Down
18 changes: 18 additions & 0 deletions js/examples/nextjs/app/arena/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ReactElement } from "react";
import { ArenaClient } from "./ui";

export default function ArenaPage(): ReactElement {
return (
<main>
<a className="nav-link" href="/">
Back to demo
</a>
<h1>IDKit Arena</h1>
<p>
Run World ID 3.0 preset, World ID 4.0 constraint, migration fallback,
and error-path cases against a local World App build.
</p>
<ArenaClient />
</main>
);
}
Loading
Loading