@worldcoin/idkit-core 4.0.1-dev.123c6a8 → 4.0.1-dev.fe98789
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 +416 -277
- package/dist/index.d.cts +359 -86
- package/dist/index.d.ts +359 -86
- package/dist/index.js +412 -274
- 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";
|
|
48
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";
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
interface OrbLegacyPreset {
|
|
84
|
+
type: "OrbLegacy";
|
|
85
|
+
signal?: string;
|
|
86
|
+
}
|
|
49
87
|
|
|
50
|
-
|
|
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;
|
|
100
178
|
}
|
|
101
179
|
|
|
102
|
-
/**
|
|
103
|
-
|
|
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;
|
|
194
|
+
}
|
|
195
|
+
|
|
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,14 +229,67 @@ 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 =
|
|
123
239
|
| CredentialRequestType
|
|
124
240
|
| { any: ConstraintNode[] }
|
|
125
241
|
| { all: ConstraintNode[] };
|
|
242
|
+
/**
|
|
243
|
+
* Unified builder for creating `IDKit` requests and sessions (WASM)
|
|
244
|
+
*/
|
|
245
|
+
declare class IDKitBuilder$1 {
|
|
246
|
+
free(): void;
|
|
247
|
+
[Symbol.dispose](): void;
|
|
248
|
+
/**
|
|
249
|
+
* Creates a `BridgeConnection` with the given constraints
|
|
250
|
+
*/
|
|
251
|
+
constraints(constraints_json: any): Promise<any>;
|
|
252
|
+
/**
|
|
253
|
+
* Creates a new builder for proving an existing session
|
|
254
|
+
*/
|
|
255
|
+
static forProveSession(session_id: string, app_id: string, rp_context: RpContextWasm, action_description?: string | null, bridge_url?: string | null, override_connect_base_url?: string | null, environment?: string | null): IDKitBuilder$1;
|
|
256
|
+
/**
|
|
257
|
+
* Creates a new builder for creating a new session
|
|
258
|
+
*/
|
|
259
|
+
static forCreateSession(app_id: string, rp_context: RpContextWasm, action_description?: string | null, bridge_url?: string | null, override_connect_base_url?: string | null, environment?: string | null): IDKitBuilder$1;
|
|
260
|
+
/**
|
|
261
|
+
* Creates a new builder for uniqueness requests
|
|
262
|
+
*/
|
|
263
|
+
constructor(app_id: string, action: string, rp_context: RpContextWasm, action_description: string | null | undefined, bridge_url: string | null | undefined, allow_legacy_proofs: boolean, override_connect_base_url?: string | null, environment?: string | null);
|
|
264
|
+
/**
|
|
265
|
+
* Creates a `BridgeConnection` from a preset (works for all request types)
|
|
266
|
+
*/
|
|
267
|
+
preset(preset_json: any): Promise<any>;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* RP Context for protocol-level proof requests (WASM binding)
|
|
271
|
+
*
|
|
272
|
+
* Contains RP-specific data needed to construct a `ProofRequest`.
|
|
273
|
+
*/
|
|
274
|
+
declare class RpContextWasm {
|
|
275
|
+
free(): void;
|
|
276
|
+
[Symbol.dispose](): void;
|
|
277
|
+
/**
|
|
278
|
+
* Creates a new RP context
|
|
279
|
+
*
|
|
280
|
+
* # Arguments
|
|
281
|
+
* * `rp_id` - The registered RP ID (e.g., `"rp_123456789abcdef0"`)
|
|
282
|
+
* * `nonce` - Unique nonce for this proof request
|
|
283
|
+
* * `created_at` - Unix timestamp (seconds since epoch) when created
|
|
284
|
+
* * `expires_at` - Unix timestamp (seconds since epoch) when expires
|
|
285
|
+
* * `signature` - The RP's ECDSA signature of the `nonce` and `created_at` timestamp
|
|
286
|
+
*
|
|
287
|
+
* # Errors
|
|
288
|
+
*
|
|
289
|
+
* Returns an error if `rp_id` is not a valid RP ID (must start with `rp_`)
|
|
290
|
+
*/
|
|
291
|
+
constructor(rp_id: string, nonce: string, created_at: bigint, expires_at: bigint, signature: string);
|
|
292
|
+
}
|
|
126
293
|
|
|
127
294
|
|
|
128
295
|
|
|
@@ -182,30 +349,32 @@ declare function initIDKit(): Promise<void>;
|
|
|
182
349
|
*/
|
|
183
350
|
declare function initIDKitServer(): Promise<void>;
|
|
184
351
|
|
|
185
|
-
|
|
186
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Result types - re-exported from WASM bindings
|
|
354
|
+
*
|
|
355
|
+
* Source of truth: rust/core/src/wasm_bindings.rs (typescript_custom_section)
|
|
356
|
+
*/
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* IDKit error codes enum — runtime values for matching against errors.
|
|
360
|
+
* Values mirror Rust's AppError enum (snake_case via serde rename_all).
|
|
361
|
+
* Includes client-side codes (timeout, cancelled) not from World App.
|
|
362
|
+
*/
|
|
363
|
+
declare enum IDKitErrorCodes {
|
|
364
|
+
UserRejected = "user_rejected",
|
|
187
365
|
VerificationRejected = "verification_rejected",
|
|
188
|
-
MaxVerificationsReached = "max_verifications_reached",
|
|
189
366
|
CredentialUnavailable = "credential_unavailable",
|
|
190
367
|
MalformedRequest = "malformed_request",
|
|
191
368
|
InvalidNetwork = "invalid_network",
|
|
192
|
-
InclusionProofFailed = "inclusion_proof_failed",
|
|
193
369
|
InclusionProofPending = "inclusion_proof_pending",
|
|
370
|
+
InclusionProofFailed = "inclusion_proof_failed",
|
|
194
371
|
UnexpectedResponse = "unexpected_response",
|
|
372
|
+
ConnectionFailed = "connection_failed",
|
|
373
|
+
MaxVerificationsReached = "max_verifications_reached",
|
|
195
374
|
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"
|
|
204
|
-
}
|
|
205
|
-
declare enum ResponseStatus {
|
|
206
|
-
Retrieved = "retrieved",
|
|
207
|
-
Completed = "completed",
|
|
208
|
-
Initialized = "initialized"
|
|
375
|
+
GenericError = "generic_error",
|
|
376
|
+
Timeout = "timeout",
|
|
377
|
+
Cancelled = "cancelled"
|
|
209
378
|
}
|
|
210
379
|
|
|
211
380
|
/**
|
|
@@ -213,7 +382,7 @@ declare enum ResponseStatus {
|
|
|
213
382
|
* Pure functional API for World ID verification - no dependencies
|
|
214
383
|
*/
|
|
215
384
|
|
|
216
|
-
/** Options for
|
|
385
|
+
/** Options for pollUntilCompletion() */
|
|
217
386
|
interface WaitOptions {
|
|
218
387
|
/** Milliseconds between polls (default: 1000) */
|
|
219
388
|
pollInterval?: number;
|
|
@@ -226,8 +395,16 @@ interface WaitOptions {
|
|
|
226
395
|
interface Status {
|
|
227
396
|
type: "waiting_for_connection" | "awaiting_confirmation" | "confirmed" | "failed";
|
|
228
397
|
result?: IDKitResult;
|
|
229
|
-
error?:
|
|
398
|
+
error?: IDKitErrorCodes;
|
|
230
399
|
}
|
|
400
|
+
/** Result from pollUntilCompletion() — discriminated union, never throws */
|
|
401
|
+
type IDKitCompletionResult = {
|
|
402
|
+
success: true;
|
|
403
|
+
result: IDKitResult;
|
|
404
|
+
} | {
|
|
405
|
+
success: false;
|
|
406
|
+
error: IDKitErrorCodes;
|
|
407
|
+
};
|
|
231
408
|
|
|
232
409
|
/**
|
|
233
410
|
* A World ID verification request
|
|
@@ -243,24 +420,27 @@ interface IDKitRequest {
|
|
|
243
420
|
/** Poll once for current status (for manual polling) */
|
|
244
421
|
pollOnce(): Promise<Status>;
|
|
245
422
|
/** Poll continuously until completion or timeout */
|
|
246
|
-
|
|
423
|
+
pollUntilCompletion(options?: WaitOptions): Promise<IDKitCompletionResult>;
|
|
247
424
|
}
|
|
248
425
|
/**
|
|
249
426
|
* Creates a CredentialRequest for a credential type
|
|
250
427
|
*
|
|
251
428
|
* @param credential_type - The type of credential to request (e.g., 'orb', 'face')
|
|
252
|
-
* @param options - Optional signal and
|
|
429
|
+
* @param options - Optional signal, genesis_issued_at_min, and expires_at_min
|
|
253
430
|
* @returns A CredentialRequest object
|
|
254
431
|
*
|
|
255
432
|
* @example
|
|
256
433
|
* ```typescript
|
|
257
434
|
* const orb = CredentialRequest('orb', { signal: 'user-123' })
|
|
258
435
|
* const face = CredentialRequest('face')
|
|
436
|
+
* // Require credential to be valid for at least one year
|
|
437
|
+
* const withExpiry = CredentialRequest('orb', { expires_at_min: Date.now() / 1000 + 60 * 60 * 60 * 24 * 365 })
|
|
259
438
|
* ```
|
|
260
439
|
*/
|
|
261
440
|
declare function CredentialRequest(credential_type: CredentialType, options?: {
|
|
262
441
|
signal?: string;
|
|
263
442
|
genesis_issued_at_min?: number;
|
|
443
|
+
expires_at_min?: number;
|
|
264
444
|
}): CredentialRequestType;
|
|
265
445
|
/**
|
|
266
446
|
* Creates an OR constraint - at least one child must be satisfied
|
|
@@ -290,23 +470,11 @@ declare function any(...nodes: ConstraintNode[]): {
|
|
|
290
470
|
declare function all(...nodes: ConstraintNode[]): {
|
|
291
471
|
all: ConstraintNode[];
|
|
292
472
|
};
|
|
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;
|
|
473
|
+
|
|
306
474
|
/**
|
|
307
475
|
* Creates an OrbLegacy preset for World ID 3.0 legacy support
|
|
308
476
|
*
|
|
309
|
-
* This preset creates
|
|
477
|
+
* This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
|
|
310
478
|
* Use this when you need backward compatibility with older World App versions.
|
|
311
479
|
*
|
|
312
480
|
* @param opts - Optional configuration with signal
|
|
@@ -314,7 +482,7 @@ type Preset = OrbLegacyPreset;
|
|
|
314
482
|
*
|
|
315
483
|
* @example
|
|
316
484
|
* ```typescript
|
|
317
|
-
* const
|
|
485
|
+
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
318
486
|
* .preset(orbLegacy({ signal: 'user-123' }))
|
|
319
487
|
* ```
|
|
320
488
|
*/
|
|
@@ -322,11 +490,47 @@ declare function orbLegacy(opts?: {
|
|
|
322
490
|
signal?: string;
|
|
323
491
|
}): OrbLegacyPreset;
|
|
324
492
|
/**
|
|
325
|
-
*
|
|
493
|
+
* Creates a SecureDocumentLegacy preset for World ID 3.0 legacy support
|
|
494
|
+
*
|
|
495
|
+
* This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
|
|
496
|
+
* Use this when you need backward compatibility with older World App versions.
|
|
497
|
+
*
|
|
498
|
+
* @param opts - Optional configuration with signal
|
|
499
|
+
* @returns A SecureDocumentLegacy preset
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```typescript
|
|
503
|
+
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
504
|
+
* .preset(secureDocumentLegacy({ signal: 'user-123' }))
|
|
505
|
+
* ```
|
|
326
506
|
*/
|
|
327
|
-
declare
|
|
328
|
-
|
|
329
|
-
|
|
507
|
+
declare function secureDocumentLegacy(opts?: {
|
|
508
|
+
signal?: string;
|
|
509
|
+
}): SecureDocumentLegacyPreset;
|
|
510
|
+
/**
|
|
511
|
+
* Creates a DocumentLegacy preset for World ID 3.0 legacy support
|
|
512
|
+
*
|
|
513
|
+
* This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
|
|
514
|
+
* Use this when you need backward compatibility with older World App versions.
|
|
515
|
+
*
|
|
516
|
+
* @param opts - Optional configuration with signal
|
|
517
|
+
* @returns A DocumentLegacy preset
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```typescript
|
|
521
|
+
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
522
|
+
* .preset(documentLegacy({ signal: 'user-123' }))
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
declare function documentLegacy(opts?: {
|
|
526
|
+
signal?: string;
|
|
527
|
+
}): DocumentLegacyPreset;
|
|
528
|
+
/**
|
|
529
|
+
* Merged builder for IDKit requests
|
|
530
|
+
*/
|
|
531
|
+
declare class IDKitBuilder {
|
|
532
|
+
private wasmBuilder;
|
|
533
|
+
constructor(wasmBuilder: IDKitBuilder$1);
|
|
330
534
|
/**
|
|
331
535
|
* Creates an IDKit request with the given constraints
|
|
332
536
|
*
|
|
@@ -335,25 +539,23 @@ declare class IDKitRequestBuilder {
|
|
|
335
539
|
*
|
|
336
540
|
* @example
|
|
337
541
|
* ```typescript
|
|
338
|
-
* const
|
|
339
|
-
*
|
|
542
|
+
* const builder = await IDKit.request({ app_id, action, rp_context });
|
|
543
|
+
* const request = await builder.constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
340
544
|
* ```
|
|
341
545
|
*/
|
|
342
|
-
constraints(constraints: ConstraintNode): Promise<IDKitRequest>;
|
|
343
546
|
/**
|
|
344
|
-
* Creates an IDKit request from a preset
|
|
547
|
+
* Creates an IDKit request from a preset (works for all request types)
|
|
345
548
|
*
|
|
346
549
|
* 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.
|
|
550
|
+
* credential configurations.
|
|
349
551
|
*
|
|
350
552
|
* @param preset - A preset object from orbLegacy()
|
|
351
553
|
* @returns A new IDKitRequest instance
|
|
352
554
|
*
|
|
353
555
|
* @example
|
|
354
556
|
* ```typescript
|
|
355
|
-
* const
|
|
356
|
-
*
|
|
557
|
+
* const builder = await IDKit.request({ app_id, action, rp_context });
|
|
558
|
+
* const request = await builder.preset(orbLegacy({ signal: 'user-123' }));
|
|
357
559
|
* ```
|
|
358
560
|
*/
|
|
359
561
|
preset(preset: Preset): Promise<IDKitRequest>;
|
|
@@ -365,7 +567,7 @@ declare class IDKitRequestBuilder {
|
|
|
365
567
|
* Use the builder pattern with constraints to specify which credentials to accept.
|
|
366
568
|
*
|
|
367
569
|
* @param config - Request configuration
|
|
368
|
-
* @returns
|
|
570
|
+
* @returns IDKitBuilder - A builder instance
|
|
369
571
|
*
|
|
370
572
|
* @example
|
|
371
573
|
* ```typescript
|
|
@@ -389,17 +591,71 @@ declare class IDKitRequestBuilder {
|
|
|
389
591
|
* expires_at: Math.floor(Date.now() / 1000) + 3600,
|
|
390
592
|
* signature: 'ecdsa-signature-from-backend',
|
|
391
593
|
* },
|
|
392
|
-
*
|
|
594
|
+
* allow_legacy_proofs: false,
|
|
595
|
+
* }).constraints(any(orb, face));
|
|
393
596
|
*
|
|
394
597
|
* // Display QR code
|
|
395
598
|
* console.log('Scan this:', request.connectorURI)
|
|
396
599
|
*
|
|
397
600
|
* // Wait for proof
|
|
398
|
-
* const proof = await request.
|
|
601
|
+
* const proof = await request.pollUntilCompletion()
|
|
399
602
|
* console.log('Success:', proof)
|
|
400
603
|
* ```
|
|
401
604
|
*/
|
|
402
|
-
declare function createRequest(config: IDKitRequestConfig):
|
|
605
|
+
declare function createRequest(config: IDKitRequestConfig): IDKitBuilder;
|
|
606
|
+
/**
|
|
607
|
+
* Creates a new session builder (no action, no existing session_id)
|
|
608
|
+
*
|
|
609
|
+
* Use this when creating a new session for a user who doesn't have one yet.
|
|
610
|
+
* The response will include a `session_id` that should be saved for future
|
|
611
|
+
* session proofs with `proveSession()`.
|
|
612
|
+
*
|
|
613
|
+
* @param config - Session configuration (no action field)
|
|
614
|
+
* @returns IDKitBuilder - A builder instance
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```typescript
|
|
618
|
+
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
619
|
+
*
|
|
620
|
+
* // Create a new session (user doesn't have session_id yet)
|
|
621
|
+
* const request = await IDKit.createSession({
|
|
622
|
+
* app_id: 'app_staging_xxxxx',
|
|
623
|
+
* rp_context: { ... },
|
|
624
|
+
* }).constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
625
|
+
*
|
|
626
|
+
* // Display QR, wait for proof
|
|
627
|
+
* const result = await request.pollUntilCompletion();
|
|
628
|
+
* // result.session_id -> save this for future sessions
|
|
629
|
+
* // result.responses[0].session_nullifier -> for session tracking
|
|
630
|
+
* ```
|
|
631
|
+
*/
|
|
632
|
+
declare function createSession(config: IDKitSessionConfig): IDKitBuilder;
|
|
633
|
+
/**
|
|
634
|
+
* Creates a builder for proving an existing session (no action, has session_id)
|
|
635
|
+
*
|
|
636
|
+
* Use this when a returning user needs to prove they own an existing session.
|
|
637
|
+
* The `sessionId` should be a value previously returned from `createSession()`.
|
|
638
|
+
*
|
|
639
|
+
* @param sessionId - The session ID from a previous session creation
|
|
640
|
+
* @param config - Session configuration (no action field)
|
|
641
|
+
* @returns IDKitBuilder - A builder instance
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* ```typescript
|
|
645
|
+
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
646
|
+
*
|
|
647
|
+
* // Prove an existing session (user returns)
|
|
648
|
+
* const request = await IDKit.proveSession(savedSessionId, {
|
|
649
|
+
* app_id: 'app_staging_xxxxx',
|
|
650
|
+
* rp_context: { ... },
|
|
651
|
+
* }).constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
652
|
+
*
|
|
653
|
+
* const result = await request.pollUntilCompletion();
|
|
654
|
+
* // result.session_id -> same session
|
|
655
|
+
* // result.responses[0].session_nullifier -> should match for same user
|
|
656
|
+
* ```
|
|
657
|
+
*/
|
|
658
|
+
declare function proveSession(sessionId: string, config: IDKitSessionConfig): IDKitBuilder;
|
|
403
659
|
/**
|
|
404
660
|
* IDKit namespace providing the main API entry points
|
|
405
661
|
*
|
|
@@ -419,7 +675,7 @@ declare function createRequest(config: IDKitRequestConfig): IDKitRequestBuilder;
|
|
|
419
675
|
*
|
|
420
676
|
* // Display QR and wait for proof
|
|
421
677
|
* console.log(request.connectorURI)
|
|
422
|
-
* const proof = await request.
|
|
678
|
+
* const proof = await request.pollUntilCompletion()
|
|
423
679
|
* ```
|
|
424
680
|
*/
|
|
425
681
|
declare const IDKit: {
|
|
@@ -429,6 +685,10 @@ declare const IDKit: {
|
|
|
429
685
|
initServer: typeof initIDKitServer;
|
|
430
686
|
/** Create a new verification request */
|
|
431
687
|
request: typeof createRequest;
|
|
688
|
+
/** Create a new session (no action, no existing session_id) */
|
|
689
|
+
createSession: typeof createSession;
|
|
690
|
+
/** Prove an existing session (no action, has session_id) */
|
|
691
|
+
proveSession: typeof proveSession;
|
|
432
692
|
/** Create a CredentialRequest for a credential type */
|
|
433
693
|
CredentialRequest: typeof CredentialRequest;
|
|
434
694
|
/** Create an OR constraint - at least one child must be satisfied */
|
|
@@ -437,6 +697,10 @@ declare const IDKit: {
|
|
|
437
697
|
all: typeof all;
|
|
438
698
|
/** Create an OrbLegacy preset for World ID 3.0 legacy support */
|
|
439
699
|
orbLegacy: typeof orbLegacy;
|
|
700
|
+
/** Create a SecureDocumentLegacy preset for World ID 3.0 legacy support */
|
|
701
|
+
secureDocumentLegacy: typeof secureDocumentLegacy;
|
|
702
|
+
/** Create a DocumentLegacy preset for World ID 3.0 legacy support */
|
|
703
|
+
documentLegacy: typeof documentLegacy;
|
|
440
704
|
};
|
|
441
705
|
|
|
442
706
|
/**
|
|
@@ -487,4 +751,13 @@ declare const isNode: () => boolean;
|
|
|
487
751
|
*/
|
|
488
752
|
declare function signRequest(action: string, signingKeyHex: string, ttlSeconds?: number): RpSignature;
|
|
489
753
|
|
|
490
|
-
|
|
754
|
+
/**
|
|
755
|
+
* Hashes a Signal (string or Uint8Array) to its hash representation.
|
|
756
|
+
* This is the same hashing used internally when constructing proof requests.
|
|
757
|
+
*
|
|
758
|
+
* @param signal - The signal to hash (string or Uint8Array)
|
|
759
|
+
* @returns 0x-prefixed hex string representing the signal hash
|
|
760
|
+
*/
|
|
761
|
+
declare function hashSignal(signal: string | Uint8Array): string;
|
|
762
|
+
|
|
763
|
+
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 };
|