-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Respect minikit supported version #142
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,20 @@ export function isInWorldApp(): boolean { | |
| return typeof window !== "undefined" && Boolean((window as any).WorldApp); | ||
| } | ||
|
|
||
| /** | ||
| * Detects the highest verify command version supported by the host World App. | ||
| * | ||
| * Reads `window.WorldApp.supported_commands` and looks for the "verify" entry. | ||
| * Returns `2` when the host explicitly lists version 2; defaults to `1` | ||
| * otherwise (safest for older Android builds that reject unknown versions). | ||
| */ | ||
| export function getWorldAppVerifyVersion(): 1 | 2 { | ||
| const cmds = (window as any).WorldApp?.supported_commands; | ||
| if (!Array.isArray(cmds)) return 1; | ||
| const verify = cmds.find((c: any) => c.name === "verify"); | ||
| return verify?.supported_versions?.includes(2) ? 2 : 1; | ||
| } | ||
|
|
||
| // ───────────────────────────────────────────────────────────────────────────── | ||
| // Builder config types (shared with request.ts) | ||
| // ───────────────────────────────────────────────────────────────────────────── | ||
|
|
@@ -84,19 +98,26 @@ let _activeNativeRequest: NativeIDKitRequest | null = null; | |
| * @param wasmPayload - Pre-built payload from the WASM module (same format as bridge) | ||
| * @param config - Builder config (used for response normalization) | ||
| * @param signalHashes - Pre-computed signal hashes keyed by identifier (credential type) | ||
| * @param version - Verify command version to send in the postMessage envelope (1 or 2, default 2) | ||
| */ | ||
| export function createNativeRequest( | ||
| wasmPayload: unknown, | ||
| config: BuilderConfig, | ||
| signalHashes: Record<string, string> = {}, | ||
| version: 1 | 2, | ||
|
Comment on lines
103
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| ): IDKitRequest { | ||
| if (_activeNativeRequest?.isPending()) { | ||
| console.warn( | ||
| "IDKit native request already in flight. Reusing active request.", | ||
| ); | ||
| return _activeNativeRequest; | ||
| } | ||
| const request = new NativeIDKitRequest(wasmPayload, config, signalHashes); | ||
| const request = new NativeIDKitRequest( | ||
| wasmPayload, | ||
| config, | ||
| signalHashes, | ||
| version, | ||
| ); | ||
| _activeNativeRequest = request; | ||
| return request; | ||
| } | ||
|
|
@@ -117,6 +138,7 @@ class NativeIDKitRequest implements IDKitRequest { | |
| wasmPayload: unknown, | ||
| config: BuilderConfig, | ||
| signalHashes: Record<string, string> = {}, | ||
| version: 1 | 2, | ||
| ) { | ||
| this.requestId = | ||
| crypto.randomUUID?.() ?? `native-${Date.now()}-${++_requestCounter}`; | ||
|
|
@@ -178,7 +200,7 @@ class NativeIDKitRequest implements IDKitRequest { | |
| // Wrap the WASM-built payload in the postMessage envelope | ||
| const sendPayload = { | ||
| command: "verify", | ||
| version: 2, | ||
| version, | ||
| payload: wasmPayload, | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The broad
catchin the v1 preset branch rewrites every failure into a "verify v2 is not supported" message, including unrelated issues like malformed RP context or other payload-construction errors thrown inside thetryblock. On hosts that only support v1, this misdiagnoses real configuration problems and points developers to the wrong fix instead of surfacing the actual error.Useful? React with 👍 / 👎.