@worldcoin/idkit-core 4.0.0-dev.777cdbe → 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 +1 -0
- package/dist/idkit_wasm_bg.wasm +0 -0
- package/dist/index.cjs +394 -116
- package/dist/index.d.cts +79 -117
- package/dist/index.d.ts +79 -117
- package/dist/index.js +394 -116
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -80,20 +80,22 @@ type IDKitSessionConfig = {
|
|
|
80
80
|
environment?: "production" | "staging";
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
interface OrbLegacyPreset {
|
|
84
|
+
type: "OrbLegacy";
|
|
85
|
+
signal?: string;
|
|
86
|
+
}
|
|
84
87
|
|
|
85
|
-
interface
|
|
86
|
-
type:
|
|
87
|
-
|
|
88
|
-
signal?: string | Uint8Array;
|
|
89
|
-
genesis_issued_at_min?: number;
|
|
90
|
-
expires_at_min?: number;
|
|
88
|
+
interface SecureDocumentLegacyPreset {
|
|
89
|
+
type: "SecureDocumentLegacy";
|
|
90
|
+
signal?: string;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
interface DocumentLegacyPreset {
|
|
94
|
+
type: "DocumentLegacy";
|
|
95
|
+
signal?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
type Preset = OrbLegacyPreset | SecureDocumentLegacyPreset | DocumentLegacyPreset;
|
|
97
99
|
|
|
98
100
|
|
|
99
101
|
|
|
@@ -223,73 +225,20 @@ type Status$1 =
|
|
|
223
225
|
|
|
224
226
|
|
|
225
227
|
|
|
226
|
-
|
|
227
|
-
type: "OrbLegacy";
|
|
228
|
-
signal?: string;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
interface SecureDocumentLegacyPreset {
|
|
232
|
-
type: "SecureDocumentLegacy";
|
|
233
|
-
signal?: string;
|
|
234
|
-
}
|
|
228
|
+
type CredentialType = "orb" | "face" | "secure_document" | "document" | "device";
|
|
235
229
|
|
|
236
|
-
interface
|
|
237
|
-
type:
|
|
238
|
-
|
|
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;
|
|
239
236
|
}
|
|
240
237
|
|
|
241
|
-
type
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
}
|
|
238
|
+
type ConstraintNode =
|
|
239
|
+
| CredentialRequestType
|
|
240
|
+
| { any: ConstraintNode[] }
|
|
241
|
+
| { all: ConstraintNode[] };
|
|
293
242
|
|
|
294
243
|
|
|
295
244
|
|
|
@@ -377,6 +326,19 @@ declare enum IDKitErrorCodes {
|
|
|
377
326
|
Cancelled = "cancelled"
|
|
378
327
|
}
|
|
379
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;
|
|
340
|
+
}
|
|
341
|
+
|
|
380
342
|
/**
|
|
381
343
|
* IDKit Request
|
|
382
344
|
* Pure functional API for World ID verification - no dependencies
|
|
@@ -482,7 +444,7 @@ declare function all(...nodes: ConstraintNode[]): {
|
|
|
482
444
|
*
|
|
483
445
|
* @example
|
|
484
446
|
* ```typescript
|
|
485
|
-
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
447
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
486
448
|
* .preset(orbLegacy({ signal: 'user-123' }))
|
|
487
449
|
* ```
|
|
488
450
|
*/
|
|
@@ -500,7 +462,7 @@ declare function orbLegacy(opts?: {
|
|
|
500
462
|
*
|
|
501
463
|
* @example
|
|
502
464
|
* ```typescript
|
|
503
|
-
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
465
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
504
466
|
* .preset(secureDocumentLegacy({ signal: 'user-123' }))
|
|
505
467
|
* ```
|
|
506
468
|
*/
|
|
@@ -518,7 +480,7 @@ declare function secureDocumentLegacy(opts?: {
|
|
|
518
480
|
*
|
|
519
481
|
* @example
|
|
520
482
|
* ```typescript
|
|
521
|
-
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
483
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
522
484
|
* .preset(documentLegacy({ signal: 'user-123' }))
|
|
523
485
|
* ```
|
|
524
486
|
*/
|
|
@@ -526,11 +488,15 @@ declare function documentLegacy(opts?: {
|
|
|
526
488
|
signal?: string;
|
|
527
489
|
}): DocumentLegacyPreset;
|
|
528
490
|
/**
|
|
529
|
-
*
|
|
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).
|
|
530
496
|
*/
|
|
531
497
|
declare class IDKitBuilder {
|
|
532
|
-
private
|
|
533
|
-
constructor(
|
|
498
|
+
private config;
|
|
499
|
+
constructor(config: BuilderConfig);
|
|
534
500
|
/**
|
|
535
501
|
* Creates an IDKit request with the given constraints
|
|
536
502
|
*
|
|
@@ -539,67 +505,64 @@ declare class IDKitBuilder {
|
|
|
539
505
|
*
|
|
540
506
|
* @example
|
|
541
507
|
* ```typescript
|
|
542
|
-
* const
|
|
543
|
-
*
|
|
508
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: false })
|
|
509
|
+
* .constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
544
510
|
* ```
|
|
545
511
|
*/
|
|
512
|
+
constraints(constraints: ConstraintNode): Promise<IDKitRequest>;
|
|
546
513
|
/**
|
|
547
514
|
* Creates an IDKit request from a preset (works for all request types)
|
|
548
515
|
*
|
|
549
516
|
* Presets provide a simplified way to create requests with predefined
|
|
550
517
|
* credential configurations.
|
|
551
518
|
*
|
|
552
|
-
* @param preset - A preset object from orbLegacy()
|
|
519
|
+
* @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), or documentLegacy()
|
|
553
520
|
* @returns A new IDKitRequest instance
|
|
554
521
|
*
|
|
555
522
|
* @example
|
|
556
523
|
* ```typescript
|
|
557
|
-
* const
|
|
558
|
-
*
|
|
524
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
525
|
+
* .preset(orbLegacy({ signal: 'user-123' }));
|
|
559
526
|
* ```
|
|
560
527
|
*/
|
|
561
528
|
preset(preset: Preset): Promise<IDKitRequest>;
|
|
562
529
|
}
|
|
563
530
|
/**
|
|
564
|
-
* Creates an IDKit request builder
|
|
531
|
+
* Creates an IDKit verification request builder
|
|
565
532
|
*
|
|
566
533
|
* This is the main entry point for creating World ID verification requests.
|
|
567
|
-
* Use the builder pattern with constraints to specify
|
|
534
|
+
* Use the builder pattern with `.preset()` or `.constraints()` to specify
|
|
535
|
+
* which credentials to accept.
|
|
568
536
|
*
|
|
569
537
|
* @param config - Request configuration
|
|
570
538
|
* @returns IDKitBuilder - A builder instance
|
|
571
539
|
*
|
|
572
540
|
* @example
|
|
573
541
|
* ```typescript
|
|
574
|
-
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
575
|
-
*
|
|
576
|
-
* // Initialize WASM (only needed once)
|
|
577
|
-
* await IDKit.init()
|
|
542
|
+
* import { IDKit, CredentialRequest, any, orbLegacy } from '@worldcoin/idkit-core'
|
|
578
543
|
*
|
|
579
|
-
* //
|
|
580
|
-
* const
|
|
581
|
-
*
|
|
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' }));
|
|
582
551
|
*
|
|
583
|
-
* //
|
|
552
|
+
* // With constraints (v4 only)
|
|
584
553
|
* const request = await IDKit.request({
|
|
585
554
|
* app_id: 'app_staging_xxxxx',
|
|
586
555
|
* action: 'my-action',
|
|
587
|
-
* rp_context: {
|
|
588
|
-
* rp_id: 'rp_123456789abcdef0',
|
|
589
|
-
* nonce: 'unique-nonce',
|
|
590
|
-
* created_at: Math.floor(Date.now() / 1000),
|
|
591
|
-
* expires_at: Math.floor(Date.now() / 1000) + 3600,
|
|
592
|
-
* signature: 'ecdsa-signature-from-backend',
|
|
593
|
-
* },
|
|
556
|
+
* rp_context: { ... },
|
|
594
557
|
* allow_legacy_proofs: false,
|
|
595
|
-
* }).constraints(any(orb, face));
|
|
558
|
+
* }).constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
596
559
|
*
|
|
597
|
-
* //
|
|
598
|
-
*
|
|
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);
|
|
599
563
|
*
|
|
600
|
-
* // Wait for
|
|
601
|
-
* const proof = await request.pollUntilCompletion()
|
|
602
|
-
* console.log('Success:', proof)
|
|
564
|
+
* // Wait for result — same interface in both environments
|
|
565
|
+
* const proof = await request.pollUntilCompletion();
|
|
603
566
|
* ```
|
|
604
567
|
*/
|
|
605
568
|
declare function createRequest(config: IDKitRequestConfig): IDKitBuilder;
|
|
@@ -661,25 +624,24 @@ declare function proveSession(sessionId: string, config: IDKitSessionConfig): ID
|
|
|
661
624
|
*
|
|
662
625
|
* @example
|
|
663
626
|
* ```typescript
|
|
664
|
-
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
665
|
-
*
|
|
666
|
-
* // Initialize (only needed once)
|
|
667
|
-
* await IDKit.init()
|
|
627
|
+
* import { IDKit, CredentialRequest, any, orbLegacy } from '@worldcoin/idkit-core'
|
|
668
628
|
*
|
|
669
|
-
* // Create a request
|
|
629
|
+
* // Create a verification request
|
|
670
630
|
* const request = await IDKit.request({
|
|
671
631
|
* app_id: 'app_staging_xxxxx',
|
|
672
632
|
* action: 'my-action',
|
|
673
633
|
* rp_context: { ... },
|
|
674
|
-
*
|
|
634
|
+
* allow_legacy_proofs: true,
|
|
635
|
+
* }).preset(orbLegacy({ signal: 'user-123' }))
|
|
675
636
|
*
|
|
676
|
-
* //
|
|
637
|
+
* // In World App: result comes via postMessage (no QR needed)
|
|
638
|
+
* // On web: display QR code and wait for proof
|
|
677
639
|
* console.log(request.connectorURI)
|
|
678
640
|
* const proof = await request.pollUntilCompletion()
|
|
679
641
|
* ```
|
|
680
642
|
*/
|
|
681
643
|
declare const IDKit: {
|
|
682
|
-
/** Initialize WASM for browser environments */
|
|
644
|
+
/** Initialize WASM for browser environments (not needed in World App) */
|
|
683
645
|
init: typeof initIDKit;
|
|
684
646
|
/** Initialize WASM for Node.js/server environments */
|
|
685
647
|
initServer: typeof initIDKitServer;
|
package/dist/index.d.ts
CHANGED
|
@@ -80,20 +80,22 @@ type IDKitSessionConfig = {
|
|
|
80
80
|
environment?: "production" | "staging";
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
interface OrbLegacyPreset {
|
|
84
|
+
type: "OrbLegacy";
|
|
85
|
+
signal?: string;
|
|
86
|
+
}
|
|
84
87
|
|
|
85
|
-
interface
|
|
86
|
-
type:
|
|
87
|
-
|
|
88
|
-
signal?: string | Uint8Array;
|
|
89
|
-
genesis_issued_at_min?: number;
|
|
90
|
-
expires_at_min?: number;
|
|
88
|
+
interface SecureDocumentLegacyPreset {
|
|
89
|
+
type: "SecureDocumentLegacy";
|
|
90
|
+
signal?: string;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
interface DocumentLegacyPreset {
|
|
94
|
+
type: "DocumentLegacy";
|
|
95
|
+
signal?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
type Preset = OrbLegacyPreset | SecureDocumentLegacyPreset | DocumentLegacyPreset;
|
|
97
99
|
|
|
98
100
|
|
|
99
101
|
|
|
@@ -223,73 +225,20 @@ type Status$1 =
|
|
|
223
225
|
|
|
224
226
|
|
|
225
227
|
|
|
226
|
-
|
|
227
|
-
type: "OrbLegacy";
|
|
228
|
-
signal?: string;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
interface SecureDocumentLegacyPreset {
|
|
232
|
-
type: "SecureDocumentLegacy";
|
|
233
|
-
signal?: string;
|
|
234
|
-
}
|
|
228
|
+
type CredentialType = "orb" | "face" | "secure_document" | "document" | "device";
|
|
235
229
|
|
|
236
|
-
interface
|
|
237
|
-
type:
|
|
238
|
-
|
|
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;
|
|
239
236
|
}
|
|
240
237
|
|
|
241
|
-
type
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
}
|
|
238
|
+
type ConstraintNode =
|
|
239
|
+
| CredentialRequestType
|
|
240
|
+
| { any: ConstraintNode[] }
|
|
241
|
+
| { all: ConstraintNode[] };
|
|
293
242
|
|
|
294
243
|
|
|
295
244
|
|
|
@@ -377,6 +326,19 @@ declare enum IDKitErrorCodes {
|
|
|
377
326
|
Cancelled = "cancelled"
|
|
378
327
|
}
|
|
379
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;
|
|
340
|
+
}
|
|
341
|
+
|
|
380
342
|
/**
|
|
381
343
|
* IDKit Request
|
|
382
344
|
* Pure functional API for World ID verification - no dependencies
|
|
@@ -482,7 +444,7 @@ declare function all(...nodes: ConstraintNode[]): {
|
|
|
482
444
|
*
|
|
483
445
|
* @example
|
|
484
446
|
* ```typescript
|
|
485
|
-
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
447
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
486
448
|
* .preset(orbLegacy({ signal: 'user-123' }))
|
|
487
449
|
* ```
|
|
488
450
|
*/
|
|
@@ -500,7 +462,7 @@ declare function orbLegacy(opts?: {
|
|
|
500
462
|
*
|
|
501
463
|
* @example
|
|
502
464
|
* ```typescript
|
|
503
|
-
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
465
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
504
466
|
* .preset(secureDocumentLegacy({ signal: 'user-123' }))
|
|
505
467
|
* ```
|
|
506
468
|
*/
|
|
@@ -518,7 +480,7 @@ declare function secureDocumentLegacy(opts?: {
|
|
|
518
480
|
*
|
|
519
481
|
* @example
|
|
520
482
|
* ```typescript
|
|
521
|
-
* const request = await IDKit.request({ app_id, action, rp_context })
|
|
483
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
522
484
|
* .preset(documentLegacy({ signal: 'user-123' }))
|
|
523
485
|
* ```
|
|
524
486
|
*/
|
|
@@ -526,11 +488,15 @@ declare function documentLegacy(opts?: {
|
|
|
526
488
|
signal?: string;
|
|
527
489
|
}): DocumentLegacyPreset;
|
|
528
490
|
/**
|
|
529
|
-
*
|
|
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).
|
|
530
496
|
*/
|
|
531
497
|
declare class IDKitBuilder {
|
|
532
|
-
private
|
|
533
|
-
constructor(
|
|
498
|
+
private config;
|
|
499
|
+
constructor(config: BuilderConfig);
|
|
534
500
|
/**
|
|
535
501
|
* Creates an IDKit request with the given constraints
|
|
536
502
|
*
|
|
@@ -539,67 +505,64 @@ declare class IDKitBuilder {
|
|
|
539
505
|
*
|
|
540
506
|
* @example
|
|
541
507
|
* ```typescript
|
|
542
|
-
* const
|
|
543
|
-
*
|
|
508
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: false })
|
|
509
|
+
* .constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
544
510
|
* ```
|
|
545
511
|
*/
|
|
512
|
+
constraints(constraints: ConstraintNode): Promise<IDKitRequest>;
|
|
546
513
|
/**
|
|
547
514
|
* Creates an IDKit request from a preset (works for all request types)
|
|
548
515
|
*
|
|
549
516
|
* Presets provide a simplified way to create requests with predefined
|
|
550
517
|
* credential configurations.
|
|
551
518
|
*
|
|
552
|
-
* @param preset - A preset object from orbLegacy()
|
|
519
|
+
* @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), or documentLegacy()
|
|
553
520
|
* @returns A new IDKitRequest instance
|
|
554
521
|
*
|
|
555
522
|
* @example
|
|
556
523
|
* ```typescript
|
|
557
|
-
* const
|
|
558
|
-
*
|
|
524
|
+
* const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: true })
|
|
525
|
+
* .preset(orbLegacy({ signal: 'user-123' }));
|
|
559
526
|
* ```
|
|
560
527
|
*/
|
|
561
528
|
preset(preset: Preset): Promise<IDKitRequest>;
|
|
562
529
|
}
|
|
563
530
|
/**
|
|
564
|
-
* Creates an IDKit request builder
|
|
531
|
+
* Creates an IDKit verification request builder
|
|
565
532
|
*
|
|
566
533
|
* This is the main entry point for creating World ID verification requests.
|
|
567
|
-
* Use the builder pattern with constraints to specify
|
|
534
|
+
* Use the builder pattern with `.preset()` or `.constraints()` to specify
|
|
535
|
+
* which credentials to accept.
|
|
568
536
|
*
|
|
569
537
|
* @param config - Request configuration
|
|
570
538
|
* @returns IDKitBuilder - A builder instance
|
|
571
539
|
*
|
|
572
540
|
* @example
|
|
573
541
|
* ```typescript
|
|
574
|
-
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
575
|
-
*
|
|
576
|
-
* // Initialize WASM (only needed once)
|
|
577
|
-
* await IDKit.init()
|
|
542
|
+
* import { IDKit, CredentialRequest, any, orbLegacy } from '@worldcoin/idkit-core'
|
|
578
543
|
*
|
|
579
|
-
* //
|
|
580
|
-
* const
|
|
581
|
-
*
|
|
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' }));
|
|
582
551
|
*
|
|
583
|
-
* //
|
|
552
|
+
* // With constraints (v4 only)
|
|
584
553
|
* const request = await IDKit.request({
|
|
585
554
|
* app_id: 'app_staging_xxxxx',
|
|
586
555
|
* action: 'my-action',
|
|
587
|
-
* rp_context: {
|
|
588
|
-
* rp_id: 'rp_123456789abcdef0',
|
|
589
|
-
* nonce: 'unique-nonce',
|
|
590
|
-
* created_at: Math.floor(Date.now() / 1000),
|
|
591
|
-
* expires_at: Math.floor(Date.now() / 1000) + 3600,
|
|
592
|
-
* signature: 'ecdsa-signature-from-backend',
|
|
593
|
-
* },
|
|
556
|
+
* rp_context: { ... },
|
|
594
557
|
* allow_legacy_proofs: false,
|
|
595
|
-
* }).constraints(any(orb, face));
|
|
558
|
+
* }).constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
596
559
|
*
|
|
597
|
-
* //
|
|
598
|
-
*
|
|
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);
|
|
599
563
|
*
|
|
600
|
-
* // Wait for
|
|
601
|
-
* const proof = await request.pollUntilCompletion()
|
|
602
|
-
* console.log('Success:', proof)
|
|
564
|
+
* // Wait for result — same interface in both environments
|
|
565
|
+
* const proof = await request.pollUntilCompletion();
|
|
603
566
|
* ```
|
|
604
567
|
*/
|
|
605
568
|
declare function createRequest(config: IDKitRequestConfig): IDKitBuilder;
|
|
@@ -661,25 +624,24 @@ declare function proveSession(sessionId: string, config: IDKitSessionConfig): ID
|
|
|
661
624
|
*
|
|
662
625
|
* @example
|
|
663
626
|
* ```typescript
|
|
664
|
-
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
665
|
-
*
|
|
666
|
-
* // Initialize (only needed once)
|
|
667
|
-
* await IDKit.init()
|
|
627
|
+
* import { IDKit, CredentialRequest, any, orbLegacy } from '@worldcoin/idkit-core'
|
|
668
628
|
*
|
|
669
|
-
* // Create a request
|
|
629
|
+
* // Create a verification request
|
|
670
630
|
* const request = await IDKit.request({
|
|
671
631
|
* app_id: 'app_staging_xxxxx',
|
|
672
632
|
* action: 'my-action',
|
|
673
633
|
* rp_context: { ... },
|
|
674
|
-
*
|
|
634
|
+
* allow_legacy_proofs: true,
|
|
635
|
+
* }).preset(orbLegacy({ signal: 'user-123' }))
|
|
675
636
|
*
|
|
676
|
-
* //
|
|
637
|
+
* // In World App: result comes via postMessage (no QR needed)
|
|
638
|
+
* // On web: display QR code and wait for proof
|
|
677
639
|
* console.log(request.connectorURI)
|
|
678
640
|
* const proof = await request.pollUntilCompletion()
|
|
679
641
|
* ```
|
|
680
642
|
*/
|
|
681
643
|
declare const IDKit: {
|
|
682
|
-
/** Initialize WASM for browser environments */
|
|
644
|
+
/** Initialize WASM for browser environments (not needed in World App) */
|
|
683
645
|
init: typeof initIDKit;
|
|
684
646
|
/** Initialize WASM for Node.js/server environments */
|
|
685
647
|
initServer: typeof initIDKitServer;
|