@worldcoin/idkit-core 4.0.1-dev.eebacb1 → 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 +422 -283
- package/dist/index.d.cts +417 -91
- package/dist/index.d.ts +417 -91
- package/dist/index.js +418 -280
- 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 -456
- package/wasm/idkit_wasm.js +0 -1877
- 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,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for IDKit
|
|
3
|
+
*
|
|
4
|
+
* Note: CredentialType, CredentialRequestType, and ConstraintNode are now
|
|
5
|
+
* re-exported from WASM (source of truth: rust/core/src/wasm_bindings.rs)
|
|
6
|
+
*/
|
|
1
7
|
declare const brand: unique symbol;
|
|
2
8
|
type Brand<T, TBrand extends string> = T & {
|
|
3
9
|
[brand]: TBrand;
|
|
@@ -6,32 +12,11 @@ type AbiEncodedValue = Brand<{
|
|
|
6
12
|
types: string[];
|
|
7
13
|
values: unknown[];
|
|
8
14
|
}, "AbiEncodedValue">;
|
|
9
|
-
type CredentialType = "orb" | "face" | "secure_document" | "document" | "device";
|
|
10
|
-
/**
|
|
11
|
-
* A single credential request item
|
|
12
|
-
*/
|
|
13
|
-
interface CredentialRequestType {
|
|
14
|
-
/** The type of credential being requested */
|
|
15
|
-
type: CredentialType;
|
|
16
|
-
/** Optional signal string for cryptographic binding */
|
|
17
|
-
signal?: string;
|
|
18
|
-
/** Optional minimum genesis timestamp constraint */
|
|
19
|
-
genesis_issued_at_min?: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Constraint node - can be a CredentialRequest or a combinator (any/all)
|
|
23
|
-
*/
|
|
24
|
-
type ConstraintNode = CredentialRequestType | {
|
|
25
|
-
any: ConstraintNode[];
|
|
26
|
-
} | {
|
|
27
|
-
all: ConstraintNode[];
|
|
28
|
-
};
|
|
29
15
|
/**
|
|
30
|
-
* Relying Party context for
|
|
16
|
+
* Relying Party context for IDKit requests
|
|
31
17
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* 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.
|
|
35
20
|
*/
|
|
36
21
|
type RpContext = {
|
|
37
22
|
/** The registered RP ID (e.g., "rp_123456789abcdef0") */
|
|
@@ -59,46 +44,255 @@ type IDKitRequestConfig = {
|
|
|
59
44
|
action_description?: string;
|
|
60
45
|
/** URL to a third-party bridge to use when connecting to the World App. Optional. */
|
|
61
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";
|
|
62
81
|
};
|
|
63
82
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
MaxVerificationsReached = "max_verifications_reached",
|
|
68
|
-
CredentialUnavailable = "credential_unavailable",
|
|
69
|
-
MalformedRequest = "malformed_request",
|
|
70
|
-
InvalidNetwork = "invalid_network",
|
|
71
|
-
InclusionProofFailed = "inclusion_proof_failed",
|
|
72
|
-
InclusionProofPending = "inclusion_proof_pending",
|
|
73
|
-
UnexpectedResponse = "unexpected_response",
|
|
74
|
-
FailedByHostApp = "failed_by_host_app",
|
|
75
|
-
GenericError = "generic_error"
|
|
83
|
+
interface OrbLegacyPreset {
|
|
84
|
+
type: "OrbLegacy";
|
|
85
|
+
signal?: string;
|
|
76
86
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Confirmed = "confirmed",
|
|
82
|
-
Failed = "failed"
|
|
87
|
+
|
|
88
|
+
interface SecureDocumentLegacyPreset {
|
|
89
|
+
type: "SecureDocumentLegacy";
|
|
90
|
+
signal?: string;
|
|
83
91
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
|
|
93
|
+
interface DocumentLegacyPreset {
|
|
94
|
+
type: "DocumentLegacy";
|
|
95
|
+
signal?: string;
|
|
88
96
|
}
|
|
89
97
|
|
|
90
|
-
|
|
98
|
+
type Preset = OrbLegacyPreset | SecureDocumentLegacyPreset | DocumentLegacyPreset;
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
/** V4 response item for World ID v4 uniqueness proofs */
|
|
103
|
+
interface ResponseItemV4 {
|
|
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[];
|
|
110
|
+
/** RP-scoped nullifier (hex) */
|
|
111
|
+
nullifier: 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;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** V3 response item for World ID v3 (legacy format) */
|
|
119
|
+
interface ResponseItemV3 {
|
|
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;
|
|
124
|
+
/** ABI-encoded proof (hex) */
|
|
91
125
|
proof: string;
|
|
126
|
+
/** Merkle root (hex) */
|
|
92
127
|
merkle_root: string;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
128
|
+
/** Nullifier (hex) */
|
|
129
|
+
nullifier: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
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
|
+
}
|
|
147
|
+
|
|
148
|
+
/** V3 result (legacy format - no session support) */
|
|
149
|
+
interface IDKitResultV3 {
|
|
150
|
+
/** Protocol version 3.0 */
|
|
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;
|
|
158
|
+
/** Array of V3 credential responses */
|
|
159
|
+
responses: ResponseItemV3[];
|
|
160
|
+
/** The environment used for this request ("production" or "staging") */
|
|
161
|
+
environment: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** V4 result for uniqueness proofs */
|
|
165
|
+
interface IDKitResultV4 {
|
|
166
|
+
/** Protocol version 4.0 */
|
|
167
|
+
protocol_version: "4.0";
|
|
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;
|
|
174
|
+
/** Array of V4 credential responses */
|
|
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;
|
|
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";
|
|
218
|
+
|
|
219
|
+
/** Status returned from pollForStatus() */
|
|
220
|
+
type Status$1 =
|
|
221
|
+
| { type: "waiting_for_connection" }
|
|
222
|
+
| { type: "awaiting_confirmation" }
|
|
223
|
+
| { type: "confirmed"; result: IDKitResult }
|
|
224
|
+
| { type: "failed"; error: IDKitErrorCode };
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
type CredentialType = "orb" | "face" | "secure_document" | "document" | "device";
|
|
229
|
+
|
|
230
|
+
interface CredentialRequestType {
|
|
231
|
+
type: CredentialType;
|
|
232
|
+
/** Signal can be a string or raw bytes (Uint8Array) */
|
|
233
|
+
signal?: string | Uint8Array;
|
|
234
|
+
genesis_issued_at_min?: number;
|
|
235
|
+
expires_at_min?: number;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
type ConstraintNode =
|
|
239
|
+
| CredentialRequestType
|
|
240
|
+
| { any: ConstraintNode[] }
|
|
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>;
|
|
96
268
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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);
|
|
100
292
|
}
|
|
101
293
|
|
|
294
|
+
|
|
295
|
+
|
|
102
296
|
interface RpSignature {
|
|
103
297
|
sig: string;
|
|
104
298
|
nonce: string;
|
|
@@ -155,12 +349,40 @@ declare function initIDKit(): Promise<void>;
|
|
|
155
349
|
*/
|
|
156
350
|
declare function initIDKitServer(): Promise<void>;
|
|
157
351
|
|
|
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",
|
|
365
|
+
VerificationRejected = "verification_rejected",
|
|
366
|
+
CredentialUnavailable = "credential_unavailable",
|
|
367
|
+
MalformedRequest = "malformed_request",
|
|
368
|
+
InvalidNetwork = "invalid_network",
|
|
369
|
+
InclusionProofPending = "inclusion_proof_pending",
|
|
370
|
+
InclusionProofFailed = "inclusion_proof_failed",
|
|
371
|
+
UnexpectedResponse = "unexpected_response",
|
|
372
|
+
ConnectionFailed = "connection_failed",
|
|
373
|
+
MaxVerificationsReached = "max_verifications_reached",
|
|
374
|
+
FailedByHostApp = "failed_by_host_app",
|
|
375
|
+
GenericError = "generic_error",
|
|
376
|
+
Timeout = "timeout",
|
|
377
|
+
Cancelled = "cancelled"
|
|
378
|
+
}
|
|
379
|
+
|
|
158
380
|
/**
|
|
159
381
|
* IDKit Request
|
|
160
382
|
* Pure functional API for World ID verification - no dependencies
|
|
161
383
|
*/
|
|
162
384
|
|
|
163
|
-
/** Options for
|
|
385
|
+
/** Options for pollUntilCompletion() */
|
|
164
386
|
interface WaitOptions {
|
|
165
387
|
/** Milliseconds between polls (default: 1000) */
|
|
166
388
|
pollInterval?: number;
|
|
@@ -172,9 +394,17 @@ interface WaitOptions {
|
|
|
172
394
|
/** Status returned from pollOnce() */
|
|
173
395
|
interface Status {
|
|
174
396
|
type: "waiting_for_connection" | "awaiting_confirmation" | "confirmed" | "failed";
|
|
175
|
-
|
|
176
|
-
error?:
|
|
397
|
+
result?: IDKitResult;
|
|
398
|
+
error?: IDKitErrorCodes;
|
|
177
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
|
+
};
|
|
178
408
|
|
|
179
409
|
/**
|
|
180
410
|
* A World ID verification request
|
|
@@ -190,24 +420,27 @@ interface IDKitRequest {
|
|
|
190
420
|
/** Poll once for current status (for manual polling) */
|
|
191
421
|
pollOnce(): Promise<Status>;
|
|
192
422
|
/** Poll continuously until completion or timeout */
|
|
193
|
-
|
|
423
|
+
pollUntilCompletion(options?: WaitOptions): Promise<IDKitCompletionResult>;
|
|
194
424
|
}
|
|
195
425
|
/**
|
|
196
426
|
* Creates a CredentialRequest for a credential type
|
|
197
427
|
*
|
|
198
428
|
* @param credential_type - The type of credential to request (e.g., 'orb', 'face')
|
|
199
|
-
* @param options - Optional signal and
|
|
429
|
+
* @param options - Optional signal, genesis_issued_at_min, and expires_at_min
|
|
200
430
|
* @returns A CredentialRequest object
|
|
201
431
|
*
|
|
202
432
|
* @example
|
|
203
433
|
* ```typescript
|
|
204
434
|
* const orb = CredentialRequest('orb', { signal: 'user-123' })
|
|
205
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 })
|
|
206
438
|
* ```
|
|
207
439
|
*/
|
|
208
440
|
declare function CredentialRequest(credential_type: CredentialType, options?: {
|
|
209
441
|
signal?: string;
|
|
210
442
|
genesis_issued_at_min?: number;
|
|
443
|
+
expires_at_min?: number;
|
|
211
444
|
}): CredentialRequestType;
|
|
212
445
|
/**
|
|
213
446
|
* Creates an OR constraint - at least one child must be satisfied
|
|
@@ -237,23 +470,11 @@ declare function any(...nodes: ConstraintNode[]): {
|
|
|
237
470
|
declare function all(...nodes: ConstraintNode[]): {
|
|
238
471
|
all: ConstraintNode[];
|
|
239
472
|
};
|
|
240
|
-
|
|
241
|
-
* OrbLegacy preset configuration
|
|
242
|
-
*/
|
|
243
|
-
interface OrbLegacyPreset {
|
|
244
|
-
type: "OrbLegacy";
|
|
245
|
-
data: {
|
|
246
|
-
signal?: string;
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Preset types for simplified session creation
|
|
251
|
-
*/
|
|
252
|
-
type Preset = OrbLegacyPreset;
|
|
473
|
+
|
|
253
474
|
/**
|
|
254
475
|
* Creates an OrbLegacy preset for World ID 3.0 legacy support
|
|
255
476
|
*
|
|
256
|
-
* This preset creates
|
|
477
|
+
* This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
|
|
257
478
|
* Use this when you need backward compatibility with older World App versions.
|
|
258
479
|
*
|
|
259
480
|
* @param opts - Optional configuration with signal
|
|
@@ -261,7 +482,7 @@ type Preset = OrbLegacyPreset;
|
|
|
261
482
|
*
|
|
262
483
|
* @example
|
|
263
484
|
* ```typescript
|
|
264
|
-
* const
|
|
485
|
+
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
265
486
|
* .preset(orbLegacy({ signal: 'user-123' }))
|
|
266
487
|
* ```
|
|
267
488
|
*/
|
|
@@ -269,11 +490,47 @@ declare function orbLegacy(opts?: {
|
|
|
269
490
|
signal?: string;
|
|
270
491
|
}): OrbLegacyPreset;
|
|
271
492
|
/**
|
|
272
|
-
*
|
|
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
|
+
* ```
|
|
506
|
+
*/
|
|
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
|
|
273
530
|
*/
|
|
274
|
-
declare class
|
|
275
|
-
private
|
|
276
|
-
constructor(
|
|
531
|
+
declare class IDKitBuilder {
|
|
532
|
+
private wasmBuilder;
|
|
533
|
+
constructor(wasmBuilder: IDKitBuilder$1);
|
|
277
534
|
/**
|
|
278
535
|
* Creates an IDKit request with the given constraints
|
|
279
536
|
*
|
|
@@ -282,25 +539,23 @@ declare class IDKitRequestBuilder {
|
|
|
282
539
|
*
|
|
283
540
|
* @example
|
|
284
541
|
* ```typescript
|
|
285
|
-
* const
|
|
286
|
-
*
|
|
542
|
+
* const builder = await IDKit.request({ app_id, action, rp_context });
|
|
543
|
+
* const request = await builder.constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
287
544
|
* ```
|
|
288
545
|
*/
|
|
289
|
-
constraints(constraints: ConstraintNode): Promise<IDKitRequest>;
|
|
290
546
|
/**
|
|
291
|
-
* Creates an IDKit request from a preset
|
|
547
|
+
* Creates an IDKit request from a preset (works for all request types)
|
|
292
548
|
*
|
|
293
549
|
* Presets provide a simplified way to create requests with predefined
|
|
294
|
-
* credential configurations.
|
|
295
|
-
* constraints and World ID 3.0 legacy fields for backward compatibility.
|
|
550
|
+
* credential configurations.
|
|
296
551
|
*
|
|
297
552
|
* @param preset - A preset object from orbLegacy()
|
|
298
553
|
* @returns A new IDKitRequest instance
|
|
299
554
|
*
|
|
300
555
|
* @example
|
|
301
556
|
* ```typescript
|
|
302
|
-
* const
|
|
303
|
-
*
|
|
557
|
+
* const builder = await IDKit.request({ app_id, action, rp_context });
|
|
558
|
+
* const request = await builder.preset(orbLegacy({ signal: 'user-123' }));
|
|
304
559
|
* ```
|
|
305
560
|
*/
|
|
306
561
|
preset(preset: Preset): Promise<IDKitRequest>;
|
|
@@ -312,7 +567,7 @@ declare class IDKitRequestBuilder {
|
|
|
312
567
|
* Use the builder pattern with constraints to specify which credentials to accept.
|
|
313
568
|
*
|
|
314
569
|
* @param config - Request configuration
|
|
315
|
-
* @returns
|
|
570
|
+
* @returns IDKitBuilder - A builder instance
|
|
316
571
|
*
|
|
317
572
|
* @example
|
|
318
573
|
* ```typescript
|
|
@@ -336,17 +591,71 @@ declare class IDKitRequestBuilder {
|
|
|
336
591
|
* expires_at: Math.floor(Date.now() / 1000) + 3600,
|
|
337
592
|
* signature: 'ecdsa-signature-from-backend',
|
|
338
593
|
* },
|
|
339
|
-
*
|
|
594
|
+
* allow_legacy_proofs: false,
|
|
595
|
+
* }).constraints(any(orb, face));
|
|
340
596
|
*
|
|
341
597
|
* // Display QR code
|
|
342
598
|
* console.log('Scan this:', request.connectorURI)
|
|
343
599
|
*
|
|
344
600
|
* // Wait for proof
|
|
345
|
-
* const proof = await request.
|
|
601
|
+
* const proof = await request.pollUntilCompletion()
|
|
346
602
|
* console.log('Success:', proof)
|
|
347
603
|
* ```
|
|
348
604
|
*/
|
|
349
|
-
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;
|
|
350
659
|
/**
|
|
351
660
|
* IDKit namespace providing the main API entry points
|
|
352
661
|
*
|
|
@@ -366,7 +675,7 @@ declare function createRequest(config: IDKitRequestConfig): IDKitRequestBuilder;
|
|
|
366
675
|
*
|
|
367
676
|
* // Display QR and wait for proof
|
|
368
677
|
* console.log(request.connectorURI)
|
|
369
|
-
* const proof = await request.
|
|
678
|
+
* const proof = await request.pollUntilCompletion()
|
|
370
679
|
* ```
|
|
371
680
|
*/
|
|
372
681
|
declare const IDKit: {
|
|
@@ -376,6 +685,10 @@ declare const IDKit: {
|
|
|
376
685
|
initServer: typeof initIDKitServer;
|
|
377
686
|
/** Create a new verification request */
|
|
378
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;
|
|
379
692
|
/** Create a CredentialRequest for a credential type */
|
|
380
693
|
CredentialRequest: typeof CredentialRequest;
|
|
381
694
|
/** Create an OR constraint - at least one child must be satisfied */
|
|
@@ -384,6 +697,10 @@ declare const IDKit: {
|
|
|
384
697
|
all: typeof all;
|
|
385
698
|
/** Create an OrbLegacy preset for World ID 3.0 legacy support */
|
|
386
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;
|
|
387
704
|
};
|
|
388
705
|
|
|
389
706
|
/**
|
|
@@ -434,4 +751,13 @@ declare const isNode: () => boolean;
|
|
|
434
751
|
*/
|
|
435
752
|
declare function signRequest(action: string, signingKeyHex: string, ttlSeconds?: number): RpSignature;
|
|
436
753
|
|
|
437
|
-
|
|
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 };
|