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