@worldcoin/idkit-core 4.0.1-dev.123c6a8 → 4.0.1-dev.370b7c0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -146
- package/dist/hashing.cjs +28 -0
- package/dist/hashing.d.cts +9 -0
- package/dist/hashing.d.ts +9 -0
- package/dist/hashing.js +26 -0
- package/dist/idkit_wasm_bg.wasm +0 -0
- package/dist/index.cjs +712 -289
- package/dist/index.d.cts +337 -196
- package/dist/index.d.ts +337 -196
- package/dist/index.js +708 -286
- package/dist/signing.cjs +76 -0
- package/dist/signing.d.cts +36 -0
- package/dist/signing.d.ts +36 -0
- package/dist/signing.js +73 -0
- package/package.json +16 -3
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/wasm/idkit_wasm.d.ts +0 -523
- package/wasm/idkit_wasm.js +0 -1879
- package/wasm/idkit_wasm_bg.wasm +0 -0
- package/wasm/idkit_wasm_bg.wasm.d.ts +0 -54
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export { RpSignature, signRequest } from './signing.cjs';
|
|
2
|
+
export { hashSignal } from './hashing.cjs';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Configuration types for IDKit
|
|
3
6
|
*
|
|
@@ -13,11 +16,10 @@ type AbiEncodedValue = Brand<{
|
|
|
13
16
|
values: unknown[];
|
|
14
17
|
}, "AbiEncodedValue">;
|
|
15
18
|
/**
|
|
16
|
-
* Relying Party context for
|
|
19
|
+
* Relying Party context for IDKit requests
|
|
17
20
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* and signed by your backend.
|
|
21
|
+
* Contains RP-specific data needed to construct a ProofRequest.
|
|
22
|
+
* This should be generated and signed by your backend.
|
|
21
23
|
*/
|
|
22
24
|
type RpContext = {
|
|
23
25
|
/** The registered RP ID (e.g., "rp_123456789abcdef0") */
|
|
@@ -45,69 +47,184 @@ type IDKitRequestConfig = {
|
|
|
45
47
|
action_description?: string;
|
|
46
48
|
/** URL to a third-party bridge to use when connecting to the World App. Optional. */
|
|
47
49
|
bridge_url?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to accept legacy (v3) World ID proofs as fallback.
|
|
52
|
+
*
|
|
53
|
+
* - `true`: Accept both v3 and v4 proofs. Use during migration.
|
|
54
|
+
* You must track both v3 and v4 nullifiers to prevent double-claims.
|
|
55
|
+
* - `false`: Only accept v4 proofs. Use after migration cutoff or for new apps.
|
|
56
|
+
*/
|
|
57
|
+
allow_legacy_proofs: boolean;
|
|
58
|
+
/** Optional override for the connect base URL (e.g., for staging environments) */
|
|
59
|
+
override_connect_base_url?: string;
|
|
60
|
+
/** Optional environment override. Defaults to "production". */
|
|
61
|
+
environment?: "production" | "staging";
|
|
48
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Configuration for IDKit.createSession() and IDKit.proveSession()
|
|
65
|
+
*
|
|
66
|
+
* Session requests don't have an action field - they're used for session-based
|
|
67
|
+
* authentication where the user proves they're the same person across visits.
|
|
68
|
+
*
|
|
69
|
+
* Sessions are always World ID v4 - there is no legacy (v3) session support.
|
|
70
|
+
*/
|
|
71
|
+
type IDKitSessionConfig = {
|
|
72
|
+
/** Unique identifier for the app verifying the session. This should be the app ID obtained from the Developer Portal. */
|
|
73
|
+
app_id: `app_${string}`;
|
|
74
|
+
/** RP context for protocol-level proof requests (required) */
|
|
75
|
+
rp_context: RpContext;
|
|
76
|
+
/** The description of the action (shown to users in World App). Optional. */
|
|
77
|
+
action_description?: string;
|
|
78
|
+
/** URL to a third-party bridge to use when connecting to the World App. Optional. */
|
|
79
|
+
bridge_url?: string;
|
|
80
|
+
/** Optional override for the connect base URL (e.g., for staging environments) */
|
|
81
|
+
override_connect_base_url?: string;
|
|
82
|
+
/** Optional environment override. Defaults to "production". */
|
|
83
|
+
environment?: "production" | "staging";
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
interface OrbLegacyPreset {
|
|
87
|
+
type: "OrbLegacy";
|
|
88
|
+
signal?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface SecureDocumentLegacyPreset {
|
|
92
|
+
type: "SecureDocumentLegacy";
|
|
93
|
+
signal?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface DocumentLegacyPreset {
|
|
97
|
+
type: "DocumentLegacy";
|
|
98
|
+
signal?: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
type Preset = OrbLegacyPreset | SecureDocumentLegacyPreset | DocumentLegacyPreset;
|
|
102
|
+
|
|
103
|
+
|
|
49
104
|
|
|
50
|
-
/** V4 response item
|
|
105
|
+
/** V4 response item for World ID v4 uniqueness proofs */
|
|
51
106
|
interface ResponseItemV4 {
|
|
52
|
-
/** Credential identifier */
|
|
53
|
-
identifier:
|
|
54
|
-
/**
|
|
55
|
-
|
|
107
|
+
/** Credential identifier (e.g., "orb", "face", "document") */
|
|
108
|
+
identifier: string;
|
|
109
|
+
/** Signal hash (optional, included if signal was provided in request) */
|
|
110
|
+
signal_hash?: string;
|
|
111
|
+
/** Encoded World ID proof: first 4 elements are compressed Groth16 proof, 5th is Merkle root (hex strings). Compatible with WorldIDVerifier.sol */
|
|
112
|
+
proof: string[];
|
|
56
113
|
/** RP-scoped nullifier (hex) */
|
|
57
114
|
nullifier: string;
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
/** Credential issuer schema ID (hex) */
|
|
63
|
-
issuer_schema_id: string;
|
|
115
|
+
/** Credential issuer schema ID (1=orb, 2=face, 3=secure_document, 4=document, 5=device) */
|
|
116
|
+
issuer_schema_id: number;
|
|
117
|
+
/** Minimum expiration timestamp (unix seconds) */
|
|
118
|
+
expires_at_min: number;
|
|
64
119
|
}
|
|
65
120
|
|
|
66
|
-
/** V3 response item
|
|
121
|
+
/** V3 response item for World ID v3 (legacy format) */
|
|
67
122
|
interface ResponseItemV3 {
|
|
68
|
-
/** Credential identifier */
|
|
69
|
-
identifier:
|
|
123
|
+
/** Credential identifier (e.g., "orb", "face") */
|
|
124
|
+
identifier: string;
|
|
125
|
+
/** Signal hash (optional, included if signal was provided in request) */
|
|
126
|
+
signal_hash?: string;
|
|
70
127
|
/** ABI-encoded proof (hex) */
|
|
71
128
|
proof: string;
|
|
72
129
|
/** Merkle root (hex) */
|
|
73
130
|
merkle_root: string;
|
|
74
|
-
/** Nullifier
|
|
75
|
-
|
|
131
|
+
/** Nullifier (hex) */
|
|
132
|
+
nullifier: string;
|
|
76
133
|
}
|
|
77
134
|
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
135
|
+
/** Session response item for World ID v4 session proofs */
|
|
136
|
+
interface ResponseItemSession {
|
|
137
|
+
/** Credential identifier (e.g., "orb", "face", "document") */
|
|
138
|
+
identifier: string;
|
|
139
|
+
/** Signal hash (optional, included if signal was provided in request) */
|
|
140
|
+
signal_hash?: string;
|
|
141
|
+
/** Encoded World ID proof: first 4 elements are compressed Groth16 proof, 5th is Merkle root (hex strings). Compatible with WorldIDVerifier.sol */
|
|
142
|
+
proof: string[];
|
|
143
|
+
/** Session nullifier: 1st element is the session nullifier, 2nd is the generated action (hex strings) */
|
|
144
|
+
session_nullifier: string[];
|
|
145
|
+
/** Credential issuer schema ID (1=orb, 2=face, 3=secure_document, 4=document, 5=device) */
|
|
146
|
+
issuer_schema_id: number;
|
|
147
|
+
/** Minimum expiration timestamp (unix seconds) */
|
|
148
|
+
expires_at_min: number;
|
|
149
|
+
}
|
|
83
150
|
|
|
84
151
|
/** V3 result (legacy format - no session support) */
|
|
85
152
|
interface IDKitResultV3 {
|
|
86
153
|
/** Protocol version 3.0 */
|
|
87
154
|
protocol_version: "3.0";
|
|
155
|
+
/** Nonce used in the request */
|
|
156
|
+
nonce: string;
|
|
157
|
+
/** Action identifier (only for uniqueness proofs) */
|
|
158
|
+
action?: string;
|
|
159
|
+
/** Action description (only if provided in input) */
|
|
160
|
+
action_description?: string;
|
|
88
161
|
/** Array of V3 credential responses */
|
|
89
162
|
responses: ResponseItemV3[];
|
|
163
|
+
/** The environment used for this request ("production" or "staging") */
|
|
164
|
+
environment: string;
|
|
90
165
|
}
|
|
91
166
|
|
|
92
|
-
/** V4 result
|
|
167
|
+
/** V4 result for uniqueness proofs */
|
|
93
168
|
interface IDKitResultV4 {
|
|
94
169
|
/** Protocol version 4.0 */
|
|
95
170
|
protocol_version: "4.0";
|
|
96
|
-
/**
|
|
97
|
-
|
|
171
|
+
/** Nonce used in the request */
|
|
172
|
+
nonce: string;
|
|
173
|
+
/** Action identifier (required for uniqueness proofs) */
|
|
174
|
+
action: string;
|
|
175
|
+
/** Action description (only if provided in input) */
|
|
176
|
+
action_description?: string;
|
|
98
177
|
/** Array of V4 credential responses */
|
|
99
178
|
responses: ResponseItemV4[];
|
|
179
|
+
/** The environment used for this request ("production" or "staging") */
|
|
180
|
+
environment: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** V4 result for session proofs */
|
|
184
|
+
interface IDKitResultSession {
|
|
185
|
+
/** Protocol version 4.0 */
|
|
186
|
+
protocol_version: "4.0";
|
|
187
|
+
/** Nonce used in the request */
|
|
188
|
+
nonce: string;
|
|
189
|
+
/** Action description (only if provided in input) */
|
|
190
|
+
action_description?: string;
|
|
191
|
+
/** Session ID returned by the World App */
|
|
192
|
+
session_id: string;
|
|
193
|
+
/** Array of session credential responses */
|
|
194
|
+
responses: ResponseItemSession[];
|
|
195
|
+
/** The environment used for this request ("production" or "staging") */
|
|
196
|
+
environment: string;
|
|
100
197
|
}
|
|
101
198
|
|
|
102
|
-
/**
|
|
103
|
-
|
|
199
|
+
/**
|
|
200
|
+
* The unified result structure for all proof types.
|
|
201
|
+
* Check `session_id` to determine if this is a session proof:
|
|
202
|
+
* - session_id !== undefined → session proof
|
|
203
|
+
* - session_id === undefined → uniqueness proof
|
|
204
|
+
*/
|
|
205
|
+
type IDKitResult = IDKitResultV3 | IDKitResultV4 | IDKitResultSession;
|
|
206
|
+
|
|
207
|
+
/** Error codes from World App (mirrors Rust AppError) */
|
|
208
|
+
type IDKitErrorCode =
|
|
209
|
+
| "user_rejected"
|
|
210
|
+
| "verification_rejected"
|
|
211
|
+
| "credential_unavailable"
|
|
212
|
+
| "malformed_request"
|
|
213
|
+
| "invalid_network"
|
|
214
|
+
| "inclusion_proof_pending"
|
|
215
|
+
| "inclusion_proof_failed"
|
|
216
|
+
| "unexpected_response"
|
|
217
|
+
| "connection_failed"
|
|
218
|
+
| "max_verifications_reached"
|
|
219
|
+
| "failed_by_host_app"
|
|
220
|
+
| "generic_error";
|
|
104
221
|
|
|
105
222
|
/** Status returned from pollForStatus() */
|
|
106
223
|
type Status$1 =
|
|
107
224
|
| { type: "waiting_for_connection" }
|
|
108
225
|
| { type: "awaiting_confirmation" }
|
|
109
226
|
| { type: "confirmed"; result: IDKitResult }
|
|
110
|
-
| { type: "failed"; error:
|
|
227
|
+
| { type: "failed"; error: IDKitErrorCode };
|
|
111
228
|
|
|
112
229
|
|
|
113
230
|
|
|
@@ -115,8 +232,10 @@ type CredentialType = "orb" | "face" | "secure_document" | "document" | "device"
|
|
|
115
232
|
|
|
116
233
|
interface CredentialRequestType {
|
|
117
234
|
type: CredentialType;
|
|
118
|
-
|
|
235
|
+
/** Signal can be a string or raw bytes (Uint8Array) */
|
|
236
|
+
signal?: string | Uint8Array;
|
|
119
237
|
genesis_issued_at_min?: number;
|
|
238
|
+
expires_at_min?: number;
|
|
120
239
|
}
|
|
121
240
|
|
|
122
241
|
type ConstraintNode =
|
|
@@ -124,88 +243,45 @@ type ConstraintNode =
|
|
|
124
243
|
| { any: ConstraintNode[] }
|
|
125
244
|
| { all: ConstraintNode[] };
|
|
126
245
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
interface RpSignature {
|
|
130
|
-
sig: string;
|
|
131
|
-
nonce: string;
|
|
132
|
-
createdAt: number;
|
|
133
|
-
expiresAt: number;
|
|
134
|
-
toJSON(): { sig: string; nonce: string; createdAt: number; expiresAt: number };
|
|
135
|
-
}
|
|
136
|
-
declare class RpSignature {
|
|
137
|
-
private constructor();
|
|
138
|
-
free(): void;
|
|
139
|
-
[Symbol.dispose](): void;
|
|
140
|
-
/**
|
|
141
|
-
* Converts to JSON
|
|
142
|
-
*
|
|
143
|
-
* # Errors
|
|
144
|
-
*
|
|
145
|
-
* Returns an error if setting object properties fails
|
|
146
|
-
*/
|
|
147
|
-
toJSON(): any;
|
|
148
|
-
/**
|
|
149
|
-
* Gets the creation timestamp
|
|
150
|
-
*/
|
|
151
|
-
readonly createdAt: bigint;
|
|
152
|
-
/**
|
|
153
|
-
* Gets the expiration timestamp
|
|
154
|
-
*/
|
|
155
|
-
readonly expiresAt: bigint;
|
|
156
|
-
/**
|
|
157
|
-
* Gets the signature as hex string (0x-prefixed, 65 bytes)
|
|
158
|
-
*/
|
|
159
|
-
readonly sig: string;
|
|
160
|
-
/**
|
|
161
|
-
* Gets the nonce as hex string (0x-prefixed field element)
|
|
162
|
-
*/
|
|
163
|
-
readonly nonce: string;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
246
|
/**
|
|
167
|
-
*
|
|
247
|
+
* Result types - re-exported from WASM bindings
|
|
248
|
+
*
|
|
249
|
+
* Source of truth: rust/core/src/wasm_bindings.rs (typescript_custom_section)
|
|
168
250
|
*/
|
|
169
251
|
|
|
170
252
|
/**
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* Safe to call multiple times - initialization only happens once
|
|
253
|
+
* IDKit error codes enum — runtime values for matching against errors.
|
|
254
|
+
* Values mirror Rust's AppError enum (snake_case via serde rename_all).
|
|
255
|
+
* Includes client-side codes (timeout, cancelled) not from World App.
|
|
175
256
|
*/
|
|
176
|
-
declare
|
|
177
|
-
|
|
178
|
-
* Initializes the WASM module for Node.js/server environments
|
|
179
|
-
* Uses fs-based loading since Node.js fetch doesn't support file:// URLs
|
|
180
|
-
* This must be called before using any WASM-powered functions
|
|
181
|
-
* Safe to call multiple times - initialization only happens once
|
|
182
|
-
*/
|
|
183
|
-
declare function initIDKitServer(): Promise<void>;
|
|
184
|
-
|
|
185
|
-
declare enum AppErrorCodes {
|
|
186
|
-
ConnectionFailed = "connection_failed",
|
|
257
|
+
declare enum IDKitErrorCodes {
|
|
258
|
+
UserRejected = "user_rejected",
|
|
187
259
|
VerificationRejected = "verification_rejected",
|
|
188
|
-
MaxVerificationsReached = "max_verifications_reached",
|
|
189
260
|
CredentialUnavailable = "credential_unavailable",
|
|
190
261
|
MalformedRequest = "malformed_request",
|
|
191
262
|
InvalidNetwork = "invalid_network",
|
|
192
|
-
InclusionProofFailed = "inclusion_proof_failed",
|
|
193
263
|
InclusionProofPending = "inclusion_proof_pending",
|
|
264
|
+
InclusionProofFailed = "inclusion_proof_failed",
|
|
194
265
|
UnexpectedResponse = "unexpected_response",
|
|
266
|
+
ConnectionFailed = "connection_failed",
|
|
267
|
+
MaxVerificationsReached = "max_verifications_reached",
|
|
195
268
|
FailedByHostApp = "failed_by_host_app",
|
|
196
|
-
GenericError = "generic_error"
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
PreparingClient = "loading_widget",
|
|
200
|
-
WaitingForConnection = "awaiting_connection",
|
|
201
|
-
WaitingForApp = "awaiting_app",
|
|
202
|
-
Confirmed = "confirmed",
|
|
203
|
-
Failed = "failed"
|
|
269
|
+
GenericError = "generic_error",
|
|
270
|
+
Timeout = "timeout",
|
|
271
|
+
Cancelled = "cancelled"
|
|
204
272
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
273
|
+
|
|
274
|
+
interface BuilderConfig {
|
|
275
|
+
type: "request" | "session" | "proveSession";
|
|
276
|
+
app_id: string;
|
|
277
|
+
action?: string;
|
|
278
|
+
session_id?: string;
|
|
279
|
+
rp_context?: RpContext;
|
|
280
|
+
action_description?: string;
|
|
281
|
+
bridge_url?: string;
|
|
282
|
+
allow_legacy_proofs?: boolean;
|
|
283
|
+
override_connect_base_url?: string;
|
|
284
|
+
environment?: string;
|
|
209
285
|
}
|
|
210
286
|
|
|
211
287
|
/**
|
|
@@ -213,7 +289,7 @@ declare enum ResponseStatus {
|
|
|
213
289
|
* Pure functional API for World ID verification - no dependencies
|
|
214
290
|
*/
|
|
215
291
|
|
|
216
|
-
/** Options for
|
|
292
|
+
/** Options for pollUntilCompletion() */
|
|
217
293
|
interface WaitOptions {
|
|
218
294
|
/** Milliseconds between polls (default: 1000) */
|
|
219
295
|
pollInterval?: number;
|
|
@@ -226,8 +302,16 @@ interface WaitOptions {
|
|
|
226
302
|
interface Status {
|
|
227
303
|
type: "waiting_for_connection" | "awaiting_confirmation" | "confirmed" | "failed";
|
|
228
304
|
result?: IDKitResult;
|
|
229
|
-
error?:
|
|
305
|
+
error?: IDKitErrorCodes;
|
|
230
306
|
}
|
|
307
|
+
/** Result from pollUntilCompletion() — discriminated union, never throws */
|
|
308
|
+
type IDKitCompletionResult = {
|
|
309
|
+
success: true;
|
|
310
|
+
result: IDKitResult;
|
|
311
|
+
} | {
|
|
312
|
+
success: false;
|
|
313
|
+
error: IDKitErrorCodes;
|
|
314
|
+
};
|
|
231
315
|
|
|
232
316
|
/**
|
|
233
317
|
* A World ID verification request
|
|
@@ -243,24 +327,27 @@ interface IDKitRequest {
|
|
|
243
327
|
/** Poll once for current status (for manual polling) */
|
|
244
328
|
pollOnce(): Promise<Status>;
|
|
245
329
|
/** Poll continuously until completion or timeout */
|
|
246
|
-
|
|
330
|
+
pollUntilCompletion(options?: WaitOptions): Promise<IDKitCompletionResult>;
|
|
247
331
|
}
|
|
248
332
|
/**
|
|
249
333
|
* Creates a CredentialRequest for a credential type
|
|
250
334
|
*
|
|
251
335
|
* @param credential_type - The type of credential to request (e.g., 'orb', 'face')
|
|
252
|
-
* @param options - Optional signal and
|
|
336
|
+
* @param options - Optional signal, genesis_issued_at_min, and expires_at_min
|
|
253
337
|
* @returns A CredentialRequest object
|
|
254
338
|
*
|
|
255
339
|
* @example
|
|
256
340
|
* ```typescript
|
|
257
341
|
* const orb = CredentialRequest('orb', { signal: 'user-123' })
|
|
258
342
|
* const face = CredentialRequest('face')
|
|
343
|
+
* // Require credential to be valid for at least one year
|
|
344
|
+
* const withExpiry = CredentialRequest('orb', { expires_at_min: Date.now() / 1000 + 60 * 60 * 60 * 24 * 365 })
|
|
259
345
|
* ```
|
|
260
346
|
*/
|
|
261
347
|
declare function CredentialRequest(credential_type: CredentialType, options?: {
|
|
262
348
|
signal?: string;
|
|
263
349
|
genesis_issued_at_min?: number;
|
|
350
|
+
expires_at_min?: number;
|
|
264
351
|
}): CredentialRequestType;
|
|
265
352
|
/**
|
|
266
353
|
* Creates an OR constraint - at least one child must be satisfied
|
|
@@ -290,23 +377,11 @@ declare function any(...nodes: ConstraintNode[]): {
|
|
|
290
377
|
declare function all(...nodes: ConstraintNode[]): {
|
|
291
378
|
all: ConstraintNode[];
|
|
292
379
|
};
|
|
293
|
-
|
|
294
|
-
* OrbLegacy preset configuration
|
|
295
|
-
*/
|
|
296
|
-
interface OrbLegacyPreset {
|
|
297
|
-
type: "OrbLegacy";
|
|
298
|
-
data: {
|
|
299
|
-
signal?: string;
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Preset types for simplified session creation
|
|
304
|
-
*/
|
|
305
|
-
type Preset = OrbLegacyPreset;
|
|
380
|
+
|
|
306
381
|
/**
|
|
307
382
|
* Creates an OrbLegacy preset for World ID 3.0 legacy support
|
|
308
383
|
*
|
|
309
|
-
* This preset creates
|
|
384
|
+
* This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
|
|
310
385
|
* Use this when you need backward compatibility with older World App versions.
|
|
311
386
|
*
|
|
312
387
|
* @param opts - Optional configuration with signal
|
|
@@ -314,7 +389,7 @@ type Preset = OrbLegacyPreset;
|
|
|
314
389
|
*
|
|
315
390
|
* @example
|
|
316
391
|
* ```typescript
|
|
317
|
-
* const
|
|
392
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
318
393
|
* .preset(orbLegacy({ signal: 'user-123' }))
|
|
319
394
|
* ```
|
|
320
395
|
*/
|
|
@@ -322,11 +397,51 @@ declare function orbLegacy(opts?: {
|
|
|
322
397
|
signal?: string;
|
|
323
398
|
}): OrbLegacyPreset;
|
|
324
399
|
/**
|
|
325
|
-
*
|
|
400
|
+
* Creates a SecureDocumentLegacy preset for World ID 3.0 legacy support
|
|
401
|
+
*
|
|
402
|
+
* This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
|
|
403
|
+
* Use this when you need backward compatibility with older World App versions.
|
|
404
|
+
*
|
|
405
|
+
* @param opts - Optional configuration with signal
|
|
406
|
+
* @returns A SecureDocumentLegacy preset
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```typescript
|
|
410
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
411
|
+
* .preset(secureDocumentLegacy({ signal: 'user-123' }))
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
declare function secureDocumentLegacy(opts?: {
|
|
415
|
+
signal?: string;
|
|
416
|
+
}): SecureDocumentLegacyPreset;
|
|
417
|
+
/**
|
|
418
|
+
* Creates a DocumentLegacy preset for World ID 3.0 legacy support
|
|
419
|
+
*
|
|
420
|
+
* This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
|
|
421
|
+
* Use this when you need backward compatibility with older World App versions.
|
|
422
|
+
*
|
|
423
|
+
* @param opts - Optional configuration with signal
|
|
424
|
+
* @returns A DocumentLegacy preset
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```typescript
|
|
428
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
429
|
+
* .preset(documentLegacy({ signal: 'user-123' }))
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
432
|
+
declare function documentLegacy(opts?: {
|
|
433
|
+
signal?: string;
|
|
434
|
+
}): DocumentLegacyPreset;
|
|
435
|
+
/**
|
|
436
|
+
* Builder for IDKit requests
|
|
437
|
+
*
|
|
438
|
+
* Stores configuration and defers transport selection to `.preset()` / `.constraints()`.
|
|
439
|
+
* In World App: uses native postMessage transport (no WASM needed).
|
|
440
|
+
* On web: uses WASM bridge transport (QR code + polling).
|
|
326
441
|
*/
|
|
327
|
-
declare class
|
|
442
|
+
declare class IDKitBuilder {
|
|
328
443
|
private config;
|
|
329
|
-
constructor(config:
|
|
444
|
+
constructor(config: BuilderConfig);
|
|
330
445
|
/**
|
|
331
446
|
* Creates an IDKit request with the given constraints
|
|
332
447
|
*
|
|
@@ -335,100 +450,148 @@ declare class IDKitRequestBuilder {
|
|
|
335
450
|
*
|
|
336
451
|
* @example
|
|
337
452
|
* ```typescript
|
|
338
|
-
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
339
|
-
* .constraints(any(CredentialRequest('orb'), CredentialRequest('face')))
|
|
453
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: false })
|
|
454
|
+
* .constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
340
455
|
* ```
|
|
341
456
|
*/
|
|
342
457
|
constraints(constraints: ConstraintNode): Promise<IDKitRequest>;
|
|
343
458
|
/**
|
|
344
|
-
* Creates an IDKit request from a preset
|
|
459
|
+
* Creates an IDKit request from a preset (works for all request types)
|
|
345
460
|
*
|
|
346
461
|
* Presets provide a simplified way to create requests with predefined
|
|
347
|
-
* credential configurations.
|
|
348
|
-
* constraints and World ID 3.0 legacy fields for backward compatibility.
|
|
462
|
+
* credential configurations.
|
|
349
463
|
*
|
|
350
|
-
* @param preset - A preset object from orbLegacy()
|
|
464
|
+
* @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), or documentLegacy()
|
|
351
465
|
* @returns A new IDKitRequest instance
|
|
352
466
|
*
|
|
353
467
|
* @example
|
|
354
468
|
* ```typescript
|
|
355
|
-
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
356
|
-
* .preset(orbLegacy({ signal: 'user-123' }))
|
|
469
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
470
|
+
* .preset(orbLegacy({ signal: 'user-123' }));
|
|
357
471
|
* ```
|
|
358
472
|
*/
|
|
359
473
|
preset(preset: Preset): Promise<IDKitRequest>;
|
|
360
474
|
}
|
|
361
475
|
/**
|
|
362
|
-
* Creates an IDKit request builder
|
|
476
|
+
* Creates an IDKit verification request builder
|
|
363
477
|
*
|
|
364
478
|
* This is the main entry point for creating World ID verification requests.
|
|
365
|
-
* Use the builder pattern with constraints to specify
|
|
479
|
+
* Use the builder pattern with `.preset()` or `.constraints()` to specify
|
|
480
|
+
* which credentials to accept.
|
|
366
481
|
*
|
|
367
482
|
* @param config - Request configuration
|
|
368
|
-
* @returns
|
|
483
|
+
* @returns IDKitBuilder - A builder instance
|
|
369
484
|
*
|
|
370
485
|
* @example
|
|
371
486
|
* ```typescript
|
|
372
|
-
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
373
|
-
*
|
|
374
|
-
* // Initialize WASM (only needed once)
|
|
375
|
-
* await IDKit.init()
|
|
487
|
+
* import { IDKit, CredentialRequest, any, orbLegacy } from '@worldcoin/idkit-core'
|
|
376
488
|
*
|
|
377
|
-
* //
|
|
378
|
-
* const
|
|
379
|
-
*
|
|
489
|
+
* // With preset (legacy support)
|
|
490
|
+
* const request = await IDKit.request({
|
|
491
|
+
* app_id: 'app_staging_xxxxx',
|
|
492
|
+
* action: 'my-action',
|
|
493
|
+
* rp_context: { ... },
|
|
494
|
+
* allow_legacy_proofs: true,
|
|
495
|
+
* }).preset(orbLegacy({ signal: 'user-123' }));
|
|
380
496
|
*
|
|
381
|
-
* //
|
|
497
|
+
* // With constraints (v4 only)
|
|
382
498
|
* const request = await IDKit.request({
|
|
383
499
|
* app_id: 'app_staging_xxxxx',
|
|
384
500
|
* action: 'my-action',
|
|
385
|
-
* rp_context: {
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
* console.log('Scan this:', request.connectorURI)
|
|
396
|
-
*
|
|
397
|
-
* // Wait for proof
|
|
398
|
-
* const proof = await request.pollForUpdates()
|
|
399
|
-
* console.log('Success:', proof)
|
|
501
|
+
* rp_context: { ... },
|
|
502
|
+
* allow_legacy_proofs: false,
|
|
503
|
+
* }).constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
504
|
+
*
|
|
505
|
+
* // In World App: connectorURI is empty, result comes via postMessage
|
|
506
|
+
* // On web: connectorURI is the QR URL to display
|
|
507
|
+
* console.log(request.connectorURI);
|
|
508
|
+
*
|
|
509
|
+
* // Wait for result — same interface in both environments
|
|
510
|
+
* const proof = await request.pollUntilCompletion();
|
|
400
511
|
* ```
|
|
401
512
|
*/
|
|
402
|
-
declare function createRequest(config: IDKitRequestConfig):
|
|
513
|
+
declare function createRequest(config: IDKitRequestConfig): IDKitBuilder;
|
|
403
514
|
/**
|
|
404
|
-
*
|
|
515
|
+
* Creates a new session builder (no action, no existing session_id)
|
|
516
|
+
*
|
|
517
|
+
* Use this when creating a new session for a user who doesn't have one yet.
|
|
518
|
+
* The response will include a `session_id` that should be saved for future
|
|
519
|
+
* session proofs with `proveSession()`.
|
|
520
|
+
*
|
|
521
|
+
* @param config - Session configuration (no action field)
|
|
522
|
+
* @returns IDKitBuilder - A builder instance
|
|
405
523
|
*
|
|
406
524
|
* @example
|
|
407
525
|
* ```typescript
|
|
408
526
|
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
409
527
|
*
|
|
410
|
-
* //
|
|
411
|
-
* await IDKit.
|
|
528
|
+
* // Create a new session (user doesn't have session_id yet)
|
|
529
|
+
* const request = await IDKit.createSession({
|
|
530
|
+
* app_id: 'app_staging_xxxxx',
|
|
531
|
+
* rp_context: { ... },
|
|
532
|
+
* }).constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
533
|
+
*
|
|
534
|
+
* // Display QR, wait for proof
|
|
535
|
+
* const result = await request.pollUntilCompletion();
|
|
536
|
+
* // result.session_id -> save this for future sessions
|
|
537
|
+
* // result.responses[0].session_nullifier -> for session tracking
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
declare function createSession(config: IDKitSessionConfig): IDKitBuilder;
|
|
541
|
+
/**
|
|
542
|
+
* Creates a builder for proving an existing session (no action, has session_id)
|
|
543
|
+
*
|
|
544
|
+
* Use this when a returning user needs to prove they own an existing session.
|
|
545
|
+
* The `sessionId` should be a value previously returned from `createSession()`.
|
|
412
546
|
*
|
|
413
|
-
*
|
|
547
|
+
* @param sessionId - The session ID from a previous session creation
|
|
548
|
+
* @param config - Session configuration (no action field)
|
|
549
|
+
* @returns IDKitBuilder - A builder instance
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* ```typescript
|
|
553
|
+
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
554
|
+
*
|
|
555
|
+
* // Prove an existing session (user returns)
|
|
556
|
+
* const request = await IDKit.proveSession(savedSessionId, {
|
|
557
|
+
* app_id: 'app_staging_xxxxx',
|
|
558
|
+
* rp_context: { ... },
|
|
559
|
+
* }).constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
560
|
+
*
|
|
561
|
+
* const result = await request.pollUntilCompletion();
|
|
562
|
+
* // result.session_id -> same session
|
|
563
|
+
* // result.responses[0].session_nullifier -> should match for same user
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
566
|
+
declare function proveSession(sessionId: string, config: IDKitSessionConfig): IDKitBuilder;
|
|
567
|
+
/**
|
|
568
|
+
* IDKit namespace providing the main API entry points
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* ```typescript
|
|
572
|
+
* import { IDKit, CredentialRequest, any, orbLegacy } from '@worldcoin/idkit-core'
|
|
573
|
+
*
|
|
574
|
+
* // Create a verification request
|
|
414
575
|
* const request = await IDKit.request({
|
|
415
576
|
* app_id: 'app_staging_xxxxx',
|
|
416
577
|
* action: 'my-action',
|
|
417
578
|
* rp_context: { ... },
|
|
418
|
-
*
|
|
579
|
+
* allow_legacy_proofs: true,
|
|
580
|
+
* }).preset(orbLegacy({ signal: 'user-123' }))
|
|
419
581
|
*
|
|
420
|
-
* //
|
|
582
|
+
* // In World App: result comes via postMessage (no QR needed)
|
|
583
|
+
* // On web: display QR code and wait for proof
|
|
421
584
|
* console.log(request.connectorURI)
|
|
422
|
-
* const proof = await request.
|
|
585
|
+
* const proof = await request.pollUntilCompletion()
|
|
423
586
|
* ```
|
|
424
587
|
*/
|
|
425
588
|
declare const IDKit: {
|
|
426
|
-
/** Initialize WASM for browser environments */
|
|
427
|
-
init: typeof initIDKit;
|
|
428
|
-
/** Initialize WASM for Node.js/server environments */
|
|
429
|
-
initServer: typeof initIDKitServer;
|
|
430
589
|
/** Create a new verification request */
|
|
431
590
|
request: typeof createRequest;
|
|
591
|
+
/** Create a new session (no action, no existing session_id) */
|
|
592
|
+
createSession: typeof createSession;
|
|
593
|
+
/** Prove an existing session (no action, has session_id) */
|
|
594
|
+
proveSession: typeof proveSession;
|
|
432
595
|
/** Create a CredentialRequest for a credential type */
|
|
433
596
|
CredentialRequest: typeof CredentialRequest;
|
|
434
597
|
/** Create an OR constraint - at least one child must be satisfied */
|
|
@@ -437,6 +600,10 @@ declare const IDKit: {
|
|
|
437
600
|
all: typeof all;
|
|
438
601
|
/** Create an OrbLegacy preset for World ID 3.0 legacy support */
|
|
439
602
|
orbLegacy: typeof orbLegacy;
|
|
603
|
+
/** Create a SecureDocumentLegacy preset for World ID 3.0 legacy support */
|
|
604
|
+
secureDocumentLegacy: typeof secureDocumentLegacy;
|
|
605
|
+
/** Create a DocumentLegacy preset for World ID 3.0 legacy support */
|
|
606
|
+
documentLegacy: typeof documentLegacy;
|
|
440
607
|
};
|
|
441
608
|
|
|
442
609
|
/**
|
|
@@ -461,30 +628,4 @@ declare const isWeb: () => boolean;
|
|
|
461
628
|
*/
|
|
462
629
|
declare const isNode: () => boolean;
|
|
463
630
|
|
|
464
|
-
|
|
465
|
-
* Signs an RP request for World ID proof verification
|
|
466
|
-
*
|
|
467
|
-
* **Backend-only**: This function should ONLY be used in Node.js/server environments.
|
|
468
|
-
* Never use this in browser/client-side code as it requires access to your signing key.
|
|
469
|
-
*
|
|
470
|
-
* This function generates a cryptographic signature that authenticates your proof request.
|
|
471
|
-
* The returned signature, nonce, and timestamps should be passed as `rp_context` to the client.
|
|
472
|
-
*
|
|
473
|
-
* @param action - The action tied to the proof request
|
|
474
|
-
* @param signingKeyHex - The ECDSA private key as hex (0x-prefixed or not, 32 bytes)
|
|
475
|
-
* @param ttlSeconds - Optional time-to-live in seconds (defaults to 300 = 5 minutes)
|
|
476
|
-
* @returns RpSignature object with sig, nonce, createdAt, expiresAt to use as rp_context
|
|
477
|
-
* @throws Error if called in non-Node.js environment or if parameters are invalid
|
|
478
|
-
*
|
|
479
|
-
* @example
|
|
480
|
-
* ```typescript
|
|
481
|
-
* import { signRequest } from '@worldcoin/idkit-core'
|
|
482
|
-
*
|
|
483
|
-
* const signingKey = process.env.RP_SIGNING_KEY // Load from secure env var
|
|
484
|
-
* const signature = signRequest('my-action', signingKey)
|
|
485
|
-
* console.log(signature.sig, signature.nonce, signature.createdAt, signature.expiresAt)
|
|
486
|
-
* ```
|
|
487
|
-
*/
|
|
488
|
-
declare function signRequest(action: string, signingKeyHex: string, ttlSeconds?: number): RpSignature;
|
|
489
|
-
|
|
490
|
-
export { type AbiEncodedValue, AppErrorCodes, type ConstraintNode, CredentialRequest, type CredentialRequestType, type CredentialType, IDKit, type IDKitRequest, type IDKitRequestConfig, type IDKitResult, type OrbLegacyPreset, type Preset, type ResponseItem, type ResponseItemV3, type ResponseItemV4, ResponseStatus, type RpContext, RpSignature, type Status$1 as Status, VerificationState, type WaitOptions, all, any, isNode, isReactNative, isWeb, orbLegacy, signRequest };
|
|
631
|
+
export { type AbiEncodedValue, type ConstraintNode, CredentialRequest, type CredentialRequestType, type CredentialType, type DocumentLegacyPreset, IDKit, type IDKitCompletionResult, type IDKitErrorCode, IDKitErrorCodes, type IDKitRequest, type IDKitRequestConfig, type IDKitResult, type IDKitResultSession, type IDKitSessionConfig, type OrbLegacyPreset, type Preset, type ResponseItemSession, type ResponseItemV3, type ResponseItemV4, type RpContext, type SecureDocumentLegacyPreset, type Status$1 as Status, type WaitOptions, all, any, documentLegacy, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy };
|