@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/dist/index.js CHANGED
@@ -4,54 +4,43 @@ var __export = (target, all2) => {
4
4
  __defProp(target, name, { get: all2[name], enumerable: true });
5
5
  };
6
6
 
7
- // src/types/bridge.ts
8
- var AppErrorCodes = /* @__PURE__ */ ((AppErrorCodes2) => {
9
- AppErrorCodes2["ConnectionFailed"] = "connection_failed";
10
- AppErrorCodes2["VerificationRejected"] = "verification_rejected";
11
- AppErrorCodes2["MaxVerificationsReached"] = "max_verifications_reached";
12
- AppErrorCodes2["CredentialUnavailable"] = "credential_unavailable";
13
- AppErrorCodes2["MalformedRequest"] = "malformed_request";
14
- AppErrorCodes2["InvalidNetwork"] = "invalid_network";
15
- AppErrorCodes2["InclusionProofFailed"] = "inclusion_proof_failed";
16
- AppErrorCodes2["InclusionProofPending"] = "inclusion_proof_pending";
17
- AppErrorCodes2["UnexpectedResponse"] = "unexpected_response";
18
- AppErrorCodes2["FailedByHostApp"] = "failed_by_host_app";
19
- AppErrorCodes2["GenericError"] = "generic_error";
20
- return AppErrorCodes2;
21
- })(AppErrorCodes || {});
22
- var VerificationState = /* @__PURE__ */ ((VerificationState2) => {
23
- VerificationState2["PreparingClient"] = "loading_widget";
24
- VerificationState2["WaitingForConnection"] = "awaiting_connection";
25
- VerificationState2["WaitingForApp"] = "awaiting_app";
26
- VerificationState2["Confirmed"] = "confirmed";
27
- VerificationState2["Failed"] = "failed";
28
- return VerificationState2;
29
- })(VerificationState || {});
30
- var ResponseStatus = /* @__PURE__ */ ((ResponseStatus2) => {
31
- ResponseStatus2["Retrieved"] = "retrieved";
32
- ResponseStatus2["Completed"] = "completed";
33
- ResponseStatus2["Initialized"] = "initialized";
34
- return ResponseStatus2;
35
- })(ResponseStatus || {});
7
+ // src/types/result.ts
8
+ var IDKitErrorCodes = /* @__PURE__ */ ((IDKitErrorCodes2) => {
9
+ IDKitErrorCodes2["UserRejected"] = "user_rejected";
10
+ IDKitErrorCodes2["VerificationRejected"] = "verification_rejected";
11
+ IDKitErrorCodes2["CredentialUnavailable"] = "credential_unavailable";
12
+ IDKitErrorCodes2["MalformedRequest"] = "malformed_request";
13
+ IDKitErrorCodes2["InvalidNetwork"] = "invalid_network";
14
+ IDKitErrorCodes2["InclusionProofPending"] = "inclusion_proof_pending";
15
+ IDKitErrorCodes2["InclusionProofFailed"] = "inclusion_proof_failed";
16
+ IDKitErrorCodes2["UnexpectedResponse"] = "unexpected_response";
17
+ IDKitErrorCodes2["ConnectionFailed"] = "connection_failed";
18
+ IDKitErrorCodes2["MaxVerificationsReached"] = "max_verifications_reached";
19
+ IDKitErrorCodes2["FailedByHostApp"] = "failed_by_host_app";
20
+ IDKitErrorCodes2["GenericError"] = "generic_error";
21
+ IDKitErrorCodes2["Timeout"] = "timeout";
22
+ IDKitErrorCodes2["Cancelled"] = "cancelled";
23
+ return IDKitErrorCodes2;
24
+ })(IDKitErrorCodes || {});
36
25
 
37
26
  // wasm/idkit_wasm.js
38
27
  var idkit_wasm_exports = {};
39
28
  __export(idkit_wasm_exports, {
40
29
  BridgeEncryption: () => BridgeEncryption,
41
30
  CredentialRequestWasm: () => CredentialRequestWasm,
31
+ IDKitBuilder: () => IDKitBuilder,
42
32
  IDKitProof: () => IDKitProof,
43
33
  IDKitRequest: () => IDKitRequest,
44
- IDKitRequestBuilderWasm: () => IDKitRequestBuilderWasm,
45
34
  RpContextWasm: () => RpContextWasm,
46
35
  RpSignature: () => RpSignature,
47
36
  base64Decode: () => base64Decode,
48
37
  base64Encode: () => base64Encode,
38
+ createSession: () => createSession,
49
39
  default: () => idkit_wasm_default,
50
40
  hashSignal: () => hashSignal,
51
- hashSignalBytes: () => hashSignalBytes,
52
41
  initSync: () => initSync,
53
42
  init_wasm: () => init_wasm,
54
- orbLegacy: () => orbLegacy,
43
+ proveSession: () => proveSession,
55
44
  request: () => request,
56
45
  signRequest: () => signRequest
57
46
  });
@@ -248,54 +237,28 @@ function makeMutClosure(arg0, arg1, dtor, f) {
248
237
  CLOSURE_DTORS.register(real, state, state);
249
238
  return real;
250
239
  }
251
- function hashSignal(signal) {
252
- let deferred2_0;
253
- let deferred2_1;
254
- try {
255
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
256
- const ptr0 = passStringToWasm0(signal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
257
- const len0 = WASM_VECTOR_LEN;
258
- wasm.hashSignal(retptr, ptr0, len0);
259
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
260
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
261
- deferred2_0 = r0;
262
- deferred2_1 = r1;
263
- return getStringFromWasm0(r0, r1);
264
- } finally {
265
- wasm.__wbindgen_add_to_stack_pointer(16);
266
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
267
- }
268
- }
269
- function passArray8ToWasm0(arg, malloc) {
270
- const ptr = malloc(arg.length * 1, 1) >>> 0;
271
- getUint8ArrayMemory0().set(arg, ptr / 1);
272
- WASM_VECTOR_LEN = arg.length;
273
- return ptr;
274
- }
275
- function hashSignalBytes(bytes) {
276
- let deferred2_0;
277
- let deferred2_1;
278
- try {
279
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
280
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
281
- const len0 = WASM_VECTOR_LEN;
282
- wasm.hashSignal(retptr, ptr0, len0);
283
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
284
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
285
- deferred2_0 = r0;
286
- deferred2_1 = r1;
287
- return getStringFromWasm0(r0, r1);
288
- } finally {
289
- wasm.__wbindgen_add_to_stack_pointer(16);
290
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
291
- }
292
- }
293
240
  function _assertClass(instance, klass) {
294
241
  if (!(instance instanceof klass)) {
295
242
  throw new Error(`expected instance of ${klass.name}`);
296
243
  }
297
244
  }
298
- function request(app_id, action, rp_context, action_description, bridge_url) {
245
+ function createSession(app_id, rp_context, action_description, bridge_url, override_connect_base_url, environment) {
246
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
247
+ const len0 = WASM_VECTOR_LEN;
248
+ _assertClass(rp_context, RpContextWasm);
249
+ var ptr1 = rp_context.__destroy_into_raw();
250
+ var ptr2 = isLikeNone(action_description) ? 0 : passStringToWasm0(action_description, wasm.__wbindgen_export, wasm.__wbindgen_export2);
251
+ var len2 = WASM_VECTOR_LEN;
252
+ var ptr3 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
253
+ var len3 = WASM_VECTOR_LEN;
254
+ var ptr4 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
255
+ var len4 = WASM_VECTOR_LEN;
256
+ var ptr5 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
257
+ var len5 = WASM_VECTOR_LEN;
258
+ const ret = wasm.createSession(ptr0, len0, ptr1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
259
+ return IDKitBuilder.__wrap(ret);
260
+ }
261
+ function request(app_id, action, rp_context, action_description, bridge_url, allow_legacy_proofs, override_connect_base_url, environment) {
299
262
  const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
300
263
  const len0 = WASM_VECTOR_LEN;
301
264
  const ptr1 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
@@ -306,28 +269,56 @@ function request(app_id, action, rp_context, action_description, bridge_url) {
306
269
  var len3 = WASM_VECTOR_LEN;
307
270
  var ptr4 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
308
271
  var len4 = WASM_VECTOR_LEN;
309
- const ret = wasm.idkitrequestbuilderwasm_new(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4);
310
- return IDKitRequestBuilderWasm.__wrap(ret);
272
+ var ptr5 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
273
+ var len5 = WASM_VECTOR_LEN;
274
+ var ptr6 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
275
+ var len6 = WASM_VECTOR_LEN;
276
+ const ret = wasm.idkitbuilder_new(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4, allow_legacy_proofs, ptr5, len5, ptr6, len6);
277
+ return IDKitBuilder.__wrap(ret);
311
278
  }
312
- function orbLegacy(signal) {
279
+ function base64Decode(data) {
313
280
  try {
314
281
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
315
- var ptr0 = isLikeNone(signal) ? 0 : passStringToWasm0(signal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
316
- var len0 = WASM_VECTOR_LEN;
317
- wasm.orbLegacy(retptr, ptr0, len0);
282
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_export, wasm.__wbindgen_export2);
283
+ const len0 = WASM_VECTOR_LEN;
284
+ wasm.base64Decode(retptr, ptr0, len0);
318
285
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
319
286
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
320
287
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
321
- if (r2) {
322
- throw takeObject(r1);
288
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
289
+ if (r3) {
290
+ throw takeObject(r2);
323
291
  }
324
- return takeObject(r0);
292
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
293
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
294
+ return v2;
325
295
  } finally {
326
296
  wasm.__wbindgen_add_to_stack_pointer(16);
327
297
  }
328
298
  }
329
- function init_wasm() {
330
- wasm.init_wasm();
299
+ function proveSession(session_id, app_id, rp_context, action_description, bridge_url, override_connect_base_url, environment) {
300
+ const ptr0 = passStringToWasm0(session_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
301
+ const len0 = WASM_VECTOR_LEN;
302
+ const ptr1 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
303
+ const len1 = WASM_VECTOR_LEN;
304
+ _assertClass(rp_context, RpContextWasm);
305
+ var ptr2 = rp_context.__destroy_into_raw();
306
+ var ptr3 = isLikeNone(action_description) ? 0 : passStringToWasm0(action_description, wasm.__wbindgen_export, wasm.__wbindgen_export2);
307
+ var len3 = WASM_VECTOR_LEN;
308
+ var ptr4 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
309
+ var len4 = WASM_VECTOR_LEN;
310
+ var ptr5 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
311
+ var len5 = WASM_VECTOR_LEN;
312
+ var ptr6 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
313
+ var len6 = WASM_VECTOR_LEN;
314
+ const ret = wasm.idkitbuilder_forProveSession(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
315
+ return IDKitBuilder.__wrap(ret);
316
+ }
317
+ function passArray8ToWasm0(arg, malloc) {
318
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
319
+ getUint8ArrayMemory0().set(arg, ptr / 1);
320
+ WASM_VECTOR_LEN = arg.length;
321
+ return ptr;
331
322
  }
332
323
  function base64Encode(data) {
333
324
  let deferred2_0;
@@ -347,53 +338,61 @@ function base64Encode(data) {
347
338
  wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
348
339
  }
349
340
  }
350
- function base64Decode(data) {
341
+ function init_wasm() {
342
+ wasm.init_wasm();
343
+ }
344
+ function signRequest(action, signing_key_hex, ttl_seconds) {
351
345
  try {
352
346
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
353
- const ptr0 = passStringToWasm0(data, wasm.__wbindgen_export, wasm.__wbindgen_export2);
347
+ const ptr0 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
354
348
  const len0 = WASM_VECTOR_LEN;
355
- wasm.base64Decode(retptr, ptr0, len0);
349
+ const ptr1 = passStringToWasm0(signing_key_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
350
+ const len1 = WASM_VECTOR_LEN;
351
+ wasm.signRequest(retptr, ptr0, len0, ptr1, len1, !isLikeNone(ttl_seconds), isLikeNone(ttl_seconds) ? BigInt(0) : ttl_seconds);
356
352
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
357
353
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
358
354
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
359
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
360
- if (r3) {
361
- throw takeObject(r2);
355
+ if (r2) {
356
+ throw takeObject(r1);
362
357
  }
363
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
364
- wasm.__wbindgen_export4(r0, r1 * 1, 1);
365
- return v2;
358
+ return RpSignature.__wrap(r0);
366
359
  } finally {
367
360
  wasm.__wbindgen_add_to_stack_pointer(16);
368
361
  }
369
362
  }
370
- function signRequest(action, signing_key_hex, ttl_seconds) {
363
+ function hashSignal(signal) {
364
+ let deferred2_0;
365
+ let deferred2_1;
371
366
  try {
372
367
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
373
- const ptr0 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
374
- const len0 = WASM_VECTOR_LEN;
375
- const ptr1 = passStringToWasm0(signing_key_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
376
- const len1 = WASM_VECTOR_LEN;
377
- wasm.signRequest(retptr, ptr0, len0, ptr1, len1, !isLikeNone(ttl_seconds), isLikeNone(ttl_seconds) ? BigInt(0) : ttl_seconds);
368
+ wasm.hashSignal(retptr, addHeapObject(signal));
378
369
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
379
370
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
380
371
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
381
- if (r2) {
382
- throw takeObject(r1);
372
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
373
+ var ptr1 = r0;
374
+ var len1 = r1;
375
+ if (r3) {
376
+ ptr1 = 0;
377
+ len1 = 0;
378
+ throw takeObject(r2);
383
379
  }
384
- return RpSignature.__wrap(r0);
380
+ deferred2_0 = ptr1;
381
+ deferred2_1 = len1;
382
+ return getStringFromWasm0(ptr1, len1);
385
383
  } finally {
386
384
  wasm.__wbindgen_add_to_stack_pointer(16);
385
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
387
386
  }
388
387
  }
389
- function __wasm_bindgen_func_elem_510(arg0, arg1) {
390
- wasm.__wasm_bindgen_func_elem_510(arg0, arg1);
388
+ function __wasm_bindgen_func_elem_597(arg0, arg1) {
389
+ wasm.__wasm_bindgen_func_elem_597(arg0, arg1);
391
390
  }
392
- function __wasm_bindgen_func_elem_873(arg0, arg1, arg2) {
393
- wasm.__wasm_bindgen_func_elem_873(arg0, arg1, addHeapObject(arg2));
391
+ function __wasm_bindgen_func_elem_960(arg0, arg1, arg2) {
392
+ wasm.__wasm_bindgen_func_elem_960(arg0, arg1, addHeapObject(arg2));
394
393
  }
395
- function __wasm_bindgen_func_elem_1238(arg0, arg1, arg2, arg3) {
396
- wasm.__wasm_bindgen_func_elem_1238(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
394
+ function __wasm_bindgen_func_elem_1345(arg0, arg1, arg2, arg3) {
395
+ wasm.__wasm_bindgen_func_elem_1345(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
397
396
  }
398
397
  var __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
399
398
  var __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -572,7 +571,7 @@ var CredentialRequestWasm = class _CredentialRequestWasm {
572
571
  wasm.__wbg_credentialrequestwasm_free(ptr, 0);
573
572
  }
574
573
  /**
575
- * Creates a new request item with ABI-encoded bytes for the signal
574
+ * Creates a new request item with raw bytes for the signal
576
575
  *
577
576
  * # Errors
578
577
  *
@@ -654,6 +653,34 @@ var CredentialRequestWasm = class _CredentialRequestWasm {
654
653
  wasm.__wbindgen_add_to_stack_pointer(16);
655
654
  }
656
655
  }
656
+ /**
657
+ * Creates a new request item with expiration minimum timestamp
658
+ *
659
+ * # Errors
660
+ *
661
+ * Returns an error if the credential type is invalid
662
+ * @param {any} credential_type
663
+ * @param {string | null | undefined} signal
664
+ * @param {bigint} expires_at_min
665
+ * @returns {CredentialRequestWasm}
666
+ */
667
+ static withExpiresAtMin(credential_type, signal, expires_at_min) {
668
+ try {
669
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
670
+ var ptr0 = isLikeNone(signal) ? 0 : passStringToWasm0(signal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
671
+ var len0 = WASM_VECTOR_LEN;
672
+ wasm.credentialrequestwasm_withExpiresAtMin(retptr, addHeapObject(credential_type), ptr0, len0, expires_at_min);
673
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
674
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
675
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
676
+ if (r2) {
677
+ throw takeObject(r1);
678
+ }
679
+ return _CredentialRequestWasm.__wrap(r0);
680
+ } finally {
681
+ wasm.__wbindgen_add_to_stack_pointer(16);
682
+ }
683
+ }
657
684
  /**
658
685
  * Creates a new request item
659
686
  *
@@ -711,6 +738,135 @@ var CredentialRequestWasm = class _CredentialRequestWasm {
711
738
  }
712
739
  };
713
740
  if (Symbol.dispose) CredentialRequestWasm.prototype[Symbol.dispose] = CredentialRequestWasm.prototype.free;
741
+ var IDKitBuilderFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
742
+ }, unregister: () => {
743
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_idkitbuilder_free(ptr >>> 0, 1));
744
+ var IDKitBuilder = class _IDKitBuilder {
745
+ static __wrap(ptr) {
746
+ ptr = ptr >>> 0;
747
+ const obj = Object.create(_IDKitBuilder.prototype);
748
+ obj.__wbg_ptr = ptr;
749
+ IDKitBuilderFinalization.register(obj, obj.__wbg_ptr, obj);
750
+ return obj;
751
+ }
752
+ __destroy_into_raw() {
753
+ const ptr = this.__wbg_ptr;
754
+ this.__wbg_ptr = 0;
755
+ IDKitBuilderFinalization.unregister(this);
756
+ return ptr;
757
+ }
758
+ free() {
759
+ const ptr = this.__destroy_into_raw();
760
+ wasm.__wbg_idkitbuilder_free(ptr, 0);
761
+ }
762
+ /**
763
+ * Creates a `BridgeConnection` with the given constraints
764
+ * @param {any} constraints_json
765
+ * @returns {Promise<any>}
766
+ */
767
+ constraints(constraints_json) {
768
+ const ptr = this.__destroy_into_raw();
769
+ const ret = wasm.idkitbuilder_constraints(ptr, addHeapObject(constraints_json));
770
+ return takeObject(ret);
771
+ }
772
+ /**
773
+ * Creates a new builder for proving an existing session
774
+ * @param {string} session_id
775
+ * @param {string} app_id
776
+ * @param {RpContextWasm} rp_context
777
+ * @param {string | null} [action_description]
778
+ * @param {string | null} [bridge_url]
779
+ * @param {string | null} [override_connect_base_url]
780
+ * @param {string | null} [environment]
781
+ * @returns {IDKitBuilder}
782
+ */
783
+ static forProveSession(session_id, app_id, rp_context, action_description, bridge_url, override_connect_base_url, environment) {
784
+ const ptr0 = passStringToWasm0(session_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
785
+ const len0 = WASM_VECTOR_LEN;
786
+ const ptr1 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
787
+ const len1 = WASM_VECTOR_LEN;
788
+ _assertClass(rp_context, RpContextWasm);
789
+ var ptr2 = rp_context.__destroy_into_raw();
790
+ var ptr3 = isLikeNone(action_description) ? 0 : passStringToWasm0(action_description, wasm.__wbindgen_export, wasm.__wbindgen_export2);
791
+ var len3 = WASM_VECTOR_LEN;
792
+ var ptr4 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
793
+ var len4 = WASM_VECTOR_LEN;
794
+ var ptr5 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
795
+ var len5 = WASM_VECTOR_LEN;
796
+ var ptr6 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
797
+ var len6 = WASM_VECTOR_LEN;
798
+ const ret = wasm.idkitbuilder_forProveSession(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
799
+ return _IDKitBuilder.__wrap(ret);
800
+ }
801
+ /**
802
+ * Creates a new builder for creating a new session
803
+ * @param {string} app_id
804
+ * @param {RpContextWasm} rp_context
805
+ * @param {string | null} [action_description]
806
+ * @param {string | null} [bridge_url]
807
+ * @param {string | null} [override_connect_base_url]
808
+ * @param {string | null} [environment]
809
+ * @returns {IDKitBuilder}
810
+ */
811
+ static forCreateSession(app_id, rp_context, action_description, bridge_url, override_connect_base_url, environment) {
812
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
813
+ const len0 = WASM_VECTOR_LEN;
814
+ _assertClass(rp_context, RpContextWasm);
815
+ var ptr1 = rp_context.__destroy_into_raw();
816
+ var ptr2 = isLikeNone(action_description) ? 0 : passStringToWasm0(action_description, wasm.__wbindgen_export, wasm.__wbindgen_export2);
817
+ var len2 = WASM_VECTOR_LEN;
818
+ var ptr3 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
819
+ var len3 = WASM_VECTOR_LEN;
820
+ var ptr4 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
821
+ var len4 = WASM_VECTOR_LEN;
822
+ var ptr5 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
823
+ var len5 = WASM_VECTOR_LEN;
824
+ const ret = wasm.createSession(ptr0, len0, ptr1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
825
+ return _IDKitBuilder.__wrap(ret);
826
+ }
827
+ /**
828
+ * Creates a new builder for uniqueness requests
829
+ * @param {string} app_id
830
+ * @param {string} action
831
+ * @param {RpContextWasm} rp_context
832
+ * @param {string | null | undefined} action_description
833
+ * @param {string | null | undefined} bridge_url
834
+ * @param {boolean} allow_legacy_proofs
835
+ * @param {string | null} [override_connect_base_url]
836
+ * @param {string | null} [environment]
837
+ */
838
+ constructor(app_id, action, rp_context, action_description, bridge_url, allow_legacy_proofs, override_connect_base_url, environment) {
839
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
840
+ const len0 = WASM_VECTOR_LEN;
841
+ const ptr1 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
842
+ const len1 = WASM_VECTOR_LEN;
843
+ _assertClass(rp_context, RpContextWasm);
844
+ var ptr2 = rp_context.__destroy_into_raw();
845
+ var ptr3 = isLikeNone(action_description) ? 0 : passStringToWasm0(action_description, wasm.__wbindgen_export, wasm.__wbindgen_export2);
846
+ var len3 = WASM_VECTOR_LEN;
847
+ var ptr4 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
848
+ var len4 = WASM_VECTOR_LEN;
849
+ var ptr5 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
850
+ var len5 = WASM_VECTOR_LEN;
851
+ var ptr6 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
852
+ var len6 = WASM_VECTOR_LEN;
853
+ const ret = wasm.idkitbuilder_new(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4, allow_legacy_proofs, ptr5, len5, ptr6, len6);
854
+ this.__wbg_ptr = ret >>> 0;
855
+ IDKitBuilderFinalization.register(this, this.__wbg_ptr, this);
856
+ return this;
857
+ }
858
+ /**
859
+ * Creates a `BridgeConnection` from a preset (works for all request types)
860
+ * @param {any} preset_json
861
+ * @returns {Promise<any>}
862
+ */
863
+ preset(preset_json) {
864
+ const ptr = this.__destroy_into_raw();
865
+ const ret = wasm.idkitbuilder_preset(ptr, addHeapObject(preset_json));
866
+ return takeObject(ret);
867
+ }
868
+ };
869
+ if (Symbol.dispose) IDKitBuilder.prototype[Symbol.dispose] = IDKitBuilder.prototype.free;
714
870
  var IDKitProofFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
715
871
  }, unregister: () => {
716
872
  } } : new FinalizationRegistry((ptr) => wasm.__wbg_idkitproof_free(ptr >>> 0, 1));
@@ -726,7 +882,7 @@ var IDKitProof = class {
726
882
  wasm.__wbg_idkitproof_free(ptr, 0);
727
883
  }
728
884
  /**
729
- * Creates a new proof
885
+ * Creates a new legacy proof (protocol v1 / World ID v3)
730
886
  *
731
887
  * # Errors
732
888
  *
@@ -893,98 +1049,6 @@ var IDKitRequest = class _IDKitRequest {
893
1049
  }
894
1050
  };
895
1051
  if (Symbol.dispose) IDKitRequest.prototype[Symbol.dispose] = IDKitRequest.prototype.free;
896
- var IDKitRequestBuilderWasmFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
897
- }, unregister: () => {
898
- } } : new FinalizationRegistry((ptr) => wasm.__wbg_idkitrequestbuilderwasm_free(ptr >>> 0, 1));
899
- var IDKitRequestBuilderWasm = class _IDKitRequestBuilderWasm {
900
- static __wrap(ptr) {
901
- ptr = ptr >>> 0;
902
- const obj = Object.create(_IDKitRequestBuilderWasm.prototype);
903
- obj.__wbg_ptr = ptr;
904
- IDKitRequestBuilderWasmFinalization.register(obj, obj.__wbg_ptr, obj);
905
- return obj;
906
- }
907
- __destroy_into_raw() {
908
- const ptr = this.__wbg_ptr;
909
- this.__wbg_ptr = 0;
910
- IDKitRequestBuilderWasmFinalization.unregister(this);
911
- return ptr;
912
- }
913
- free() {
914
- const ptr = this.__destroy_into_raw();
915
- wasm.__wbg_idkitrequestbuilderwasm_free(ptr, 0);
916
- }
917
- /**
918
- * Creates an `IDKit` request with the given constraints
919
- *
920
- * # Arguments
921
- * * `constraints_json` - Constraint tree as JSON (`CredentialRequest` or `{any: []}` or `{all: []}`)
922
- *
923
- * # Errors
924
- *
925
- * Returns an error if the request cannot be created
926
- * @param {any} constraints_json
927
- * @returns {Promise<any>}
928
- */
929
- constraints(constraints_json) {
930
- const ptr = this.__destroy_into_raw();
931
- const ret = wasm.idkitrequestbuilderwasm_constraints(ptr, addHeapObject(constraints_json));
932
- return takeObject(ret);
933
- }
934
- /**
935
- * Creates a new `IDKitRequestBuilder`
936
- *
937
- * # Arguments
938
- * * `app_id` - Application ID from the Developer Portal
939
- * * `action` - Action identifier
940
- * * `rp_context` - RP context for building protocol-level `ProofRequest`
941
- * * `action_description` - Optional action description shown to users
942
- * * `bridge_url` - Optional bridge URL (defaults to production)
943
- * @param {string} app_id
944
- * @param {string} action
945
- * @param {RpContextWasm} rp_context
946
- * @param {string | null} [action_description]
947
- * @param {string | null} [bridge_url]
948
- */
949
- constructor(app_id, action, rp_context, action_description, bridge_url) {
950
- const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
951
- const len0 = WASM_VECTOR_LEN;
952
- const ptr1 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
953
- const len1 = WASM_VECTOR_LEN;
954
- _assertClass(rp_context, RpContextWasm);
955
- var ptr2 = rp_context.__destroy_into_raw();
956
- var ptr3 = isLikeNone(action_description) ? 0 : passStringToWasm0(action_description, wasm.__wbindgen_export, wasm.__wbindgen_export2);
957
- var len3 = WASM_VECTOR_LEN;
958
- var ptr4 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
959
- var len4 = WASM_VECTOR_LEN;
960
- const ret = wasm.idkitrequestbuilderwasm_new(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4);
961
- this.__wbg_ptr = ret >>> 0;
962
- IDKitRequestBuilderWasmFinalization.register(this, this.__wbg_ptr, this);
963
- return this;
964
- }
965
- /**
966
- * Creates an `IDKit` request from a preset
967
- *
968
- * Presets provide a simplified way to create requests with predefined
969
- * credential configurations. The preset is converted to both World ID 4.0
970
- * constraints and World ID 3.0 legacy fields for backward compatibility.
971
- *
972
- * # Arguments
973
- * * `preset_json` - Preset object from `orbLegacy()`
974
- *
975
- * # Errors
976
- *
977
- * Returns an error if the request cannot be created
978
- * @param {any} preset_json
979
- * @returns {Promise<any>}
980
- */
981
- preset(preset_json) {
982
- const ptr = this.__destroy_into_raw();
983
- const ret = wasm.idkitrequestbuilderwasm_preset(ptr, addHeapObject(preset_json));
984
- return takeObject(ret);
985
- }
986
- };
987
- if (Symbol.dispose) IDKitRequestBuilderWasm.prototype[Symbol.dispose] = IDKitRequestBuilderWasm.prototype.free;
988
1052
  var RpContextWasmFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
989
1053
  }, unregister: () => {
990
1054
  } } : new FinalizationRegistry((ptr) => wasm.__wbg_rpcontextwasm_free(ptr >>> 0, 1));
@@ -1340,10 +1404,6 @@ function __wbg_get_imports() {
1340
1404
  return addHeapObject(ret);
1341
1405
  }, arguments);
1342
1406
  };
1343
- imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
1344
- const ret = getObject(arg0)[getObject(arg1)];
1345
- return addHeapObject(ret);
1346
- };
1347
1407
  imports.wbg.__wbg_has_787fafc980c3ccdb = function() {
1348
1408
  return handleError(function(arg0, arg1) {
1349
1409
  const ret = Reflect.has(getObject(arg0), getObject(arg1));
@@ -1439,7 +1499,7 @@ function __wbg_get_imports() {
1439
1499
  const a = state0.a;
1440
1500
  state0.a = 0;
1441
1501
  try {
1442
- return __wasm_bindgen_func_elem_1238(a, state0.b, arg02, arg12);
1502
+ return __wasm_bindgen_func_elem_1345(a, state0.b, arg02, arg12);
1443
1503
  } finally {
1444
1504
  state0.a = a;
1445
1505
  }
@@ -1648,10 +1708,6 @@ function __wbg_get_imports() {
1648
1708
  const ret = getObject(arg0).versions;
1649
1709
  return addHeapObject(ret);
1650
1710
  };
1651
- imports.wbg.__wbindgen_cast_20b7882efa3c21d9 = function(arg0, arg1) {
1652
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_872, __wasm_bindgen_func_elem_873);
1653
- return addHeapObject(ret);
1654
- };
1655
1711
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1656
1712
  const ret = getStringFromWasm0(arg0, arg1);
1657
1713
  return addHeapObject(ret);
@@ -1660,12 +1716,16 @@ function __wbg_get_imports() {
1660
1716
  const ret = BigInt.asUintN(64, arg0);
1661
1717
  return addHeapObject(ret);
1662
1718
  };
1719
+ imports.wbg.__wbindgen_cast_91c43ecf1f8dafb8 = function(arg0, arg1) {
1720
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_596, __wasm_bindgen_func_elem_597);
1721
+ return addHeapObject(ret);
1722
+ };
1663
1723
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
1664
1724
  const ret = arg0;
1665
1725
  return addHeapObject(ret);
1666
1726
  };
1667
- imports.wbg.__wbindgen_cast_c84362f2a853c6d7 = function(arg0, arg1) {
1668
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_509, __wasm_bindgen_func_elem_510);
1727
+ imports.wbg.__wbindgen_cast_ab10518eebecf9a3 = function(arg0, arg1) {
1728
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_959, __wasm_bindgen_func_elem_960);
1669
1729
  return addHeapObject(ret);
1670
1730
  };
1671
1731
  imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
@@ -1733,6 +1793,10 @@ var idkit_wasm_default = __wbg_init;
1733
1793
  // src/lib/wasm.ts
1734
1794
  var wasmInitialized = false;
1735
1795
  var wasmInitPromise = null;
1796
+ async function importNodeModule(specifier) {
1797
+ const dynamicImport = Function("moduleName", "return import(moduleName)");
1798
+ return dynamicImport(specifier);
1799
+ }
1736
1800
  async function initIDKit() {
1737
1801
  if (wasmInitialized) {
1738
1802
  return;
@@ -1760,10 +1824,18 @@ async function initIDKitServer() {
1760
1824
  }
1761
1825
  wasmInitPromise = (async () => {
1762
1826
  try {
1763
- const { readFile } = await import('fs/promises');
1764
- const { fileURLToPath } = await import('url');
1765
- const wasmUrl = new URL("idkit_wasm_bg.wasm", import.meta.url);
1766
- const wasmBuffer = await readFile(fileURLToPath(wasmUrl));
1827
+ const { readFile } = await importNodeModule(
1828
+ "node:fs/promises"
1829
+ );
1830
+ const { fileURLToPath } = await importNodeModule(
1831
+ "node:url"
1832
+ );
1833
+ const { dirname, join } = await importNodeModule(
1834
+ "node:path"
1835
+ );
1836
+ const modulePath = fileURLToPath(import.meta.url);
1837
+ const wasmPath = join(dirname(modulePath), "idkit_wasm_bg.wasm");
1838
+ const wasmBuffer = await readFile(wasmPath);
1767
1839
  await idkit_wasm_default({ module_or_path: wasmBuffer });
1768
1840
  wasmInitialized = true;
1769
1841
  } catch (error) {
@@ -1790,24 +1862,26 @@ var IDKitRequestImpl = class {
1790
1862
  async pollOnce() {
1791
1863
  return await this.wasmRequest.pollForStatus();
1792
1864
  }
1793
- async pollForUpdates(options) {
1865
+ async pollUntilCompletion(options) {
1794
1866
  const pollInterval = options?.pollInterval ?? 1e3;
1795
1867
  const timeout = options?.timeout ?? 3e5;
1796
1868
  const startTime = Date.now();
1797
1869
  while (true) {
1798
1870
  if (options?.signal?.aborted) {
1799
- throw new Error("Verification cancelled");
1871
+ return { success: false, error: "cancelled" /* Cancelled */ };
1800
1872
  }
1801
1873
  if (Date.now() - startTime > timeout) {
1802
- throw new Error(`Timeout waiting for proof after ${timeout}ms`);
1874
+ return { success: false, error: "timeout" /* Timeout */ };
1803
1875
  }
1804
1876
  const status = await this.pollOnce();
1805
- if (status.type === "confirmed" && status.proof) {
1806
- return status.proof;
1877
+ if (status.type === "confirmed" && status.result) {
1878
+ return { success: true, result: status.result };
1807
1879
  }
1808
1880
  if (status.type === "failed") {
1809
- const errorCode = status.error ?? "generic_error" /* GenericError */;
1810
- throw new Error(`Verification failed: ${errorCode}`);
1881
+ return {
1882
+ success: false,
1883
+ error: status.error ?? "generic_error" /* GenericError */
1884
+ };
1811
1885
  }
1812
1886
  await new Promise((resolve) => setTimeout(resolve, pollInterval));
1813
1887
  }
@@ -1817,7 +1891,8 @@ function CredentialRequest(credential_type, options) {
1817
1891
  return {
1818
1892
  type: credential_type,
1819
1893
  signal: options?.signal,
1820
- genesis_issued_at_min: options?.genesis_issued_at_min
1894
+ genesis_issued_at_min: options?.genesis_issued_at_min,
1895
+ expires_at_min: options?.expires_at_min
1821
1896
  };
1822
1897
  }
1823
1898
  function any(...nodes) {
@@ -1826,12 +1901,18 @@ function any(...nodes) {
1826
1901
  function all(...nodes) {
1827
1902
  return { all: nodes };
1828
1903
  }
1829
- function orbLegacy2(opts = {}) {
1830
- return { type: "OrbLegacy", data: { signal: opts.signal } };
1904
+ function orbLegacy(opts = {}) {
1905
+ return { type: "OrbLegacy", signal: opts.signal };
1906
+ }
1907
+ function secureDocumentLegacy(opts = {}) {
1908
+ return { type: "SecureDocumentLegacy", signal: opts.signal };
1909
+ }
1910
+ function documentLegacy(opts = {}) {
1911
+ return { type: "DocumentLegacy", signal: opts.signal };
1831
1912
  }
1832
- var IDKitRequestBuilder = class {
1833
- constructor(config) {
1834
- this.config = config;
1913
+ var IDKitBuilder2 = class {
1914
+ constructor(wasmBuilder) {
1915
+ this.wasmBuilder = wasmBuilder;
1835
1916
  }
1836
1917
  /**
1837
1918
  * Creates an IDKit request with the given constraints
@@ -1841,64 +1922,36 @@ var IDKitRequestBuilder = class {
1841
1922
  *
1842
1923
  * @example
1843
1924
  * ```typescript
1844
- * const request = await IDKit.request({ app_id, action, rp_context })
1845
- * .constraints(any(CredentialRequest('orb'), CredentialRequest('face')))
1925
+ * const builder = await IDKit.request({ app_id, action, rp_context });
1926
+ * const request = await builder.constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
1846
1927
  * ```
1847
1928
  */
1848
- async constraints(constraints) {
1849
- await initIDKit();
1850
- const rpContext = new idkit_wasm_exports.RpContextWasm(
1851
- this.config.rp_context.rp_id,
1852
- this.config.rp_context.nonce,
1853
- BigInt(this.config.rp_context.created_at),
1854
- BigInt(this.config.rp_context.expires_at),
1855
- this.config.rp_context.signature
1856
- );
1857
- const wasmBuilder = idkit_wasm_exports.request(
1858
- this.config.app_id,
1859
- String(this.config.action),
1860
- rpContext,
1861
- this.config.action_description ?? null,
1862
- this.config.bridge_url ?? null
1863
- );
1864
- const wasmRequest = await wasmBuilder.constraints(
1865
- constraints
1866
- );
1867
- return new IDKitRequestImpl(wasmRequest);
1868
- }
1929
+ //TODO: re-enable once this is supported and World ID 4.0 is rolled out live
1930
+ // async constraints(constraints: ConstraintNode): Promise<IDKitRequest> {
1931
+ // await initIDKit();
1932
+ // const wasmRequest = (await this.wasmBuilder.constraints(
1933
+ // constraints,
1934
+ // )) as unknown as WasmModule.IDKitRequest;
1935
+ // return new IDKitRequestImpl(wasmRequest);
1936
+ // }
1869
1937
  /**
1870
- * Creates an IDKit request from a preset
1938
+ * Creates an IDKit request from a preset (works for all request types)
1871
1939
  *
1872
1940
  * Presets provide a simplified way to create requests with predefined
1873
- * credential configurations. The preset is converted to both World ID 4.0
1874
- * constraints and World ID 3.0 legacy fields for backward compatibility.
1941
+ * credential configurations.
1875
1942
  *
1876
1943
  * @param preset - A preset object from orbLegacy()
1877
1944
  * @returns A new IDKitRequest instance
1878
1945
  *
1879
1946
  * @example
1880
1947
  * ```typescript
1881
- * const request = await IDKit.request({ app_id, action, rp_context })
1882
- * .preset(orbLegacy({ signal: 'user-123' }))
1948
+ * const builder = await IDKit.request({ app_id, action, rp_context });
1949
+ * const request = await builder.preset(orbLegacy({ signal: 'user-123' }));
1883
1950
  * ```
1884
1951
  */
1885
1952
  async preset(preset) {
1886
1953
  await initIDKit();
1887
- const rpContext = new idkit_wasm_exports.RpContextWasm(
1888
- this.config.rp_context.rp_id,
1889
- this.config.rp_context.nonce,
1890
- BigInt(this.config.rp_context.created_at),
1891
- BigInt(this.config.rp_context.expires_at),
1892
- this.config.rp_context.signature
1893
- );
1894
- const wasmBuilder = idkit_wasm_exports.request(
1895
- this.config.app_id,
1896
- String(this.config.action),
1897
- rpContext,
1898
- this.config.action_description ?? null,
1899
- this.config.bridge_url ?? null
1900
- );
1901
- const wasmRequest = await wasmBuilder.preset(
1954
+ const wasmRequest = await this.wasmBuilder.preset(
1902
1955
  preset
1903
1956
  );
1904
1957
  return new IDKitRequestImpl(wasmRequest);
@@ -1914,7 +1967,81 @@ function createRequest(config) {
1914
1967
  if (!config.rp_context) {
1915
1968
  throw new Error("rp_context is required");
1916
1969
  }
1917
- return new IDKitRequestBuilder(config);
1970
+ if (typeof config.allow_legacy_proofs !== "boolean") {
1971
+ throw new Error(
1972
+ "allow_legacy_proofs is required. Set to true to accept v3 proofs during migration, or false to only accept v4 proofs."
1973
+ );
1974
+ }
1975
+ const rpContext = new idkit_wasm_exports.RpContextWasm(
1976
+ config.rp_context.rp_id,
1977
+ config.rp_context.nonce,
1978
+ BigInt(config.rp_context.created_at),
1979
+ BigInt(config.rp_context.expires_at),
1980
+ config.rp_context.signature
1981
+ );
1982
+ const wasmBuilder = idkit_wasm_exports.request(
1983
+ config.app_id,
1984
+ String(config.action),
1985
+ rpContext,
1986
+ config.action_description ?? null,
1987
+ config.bridge_url ?? null,
1988
+ config.allow_legacy_proofs,
1989
+ config.override_connect_base_url ?? null,
1990
+ config.environment ?? null
1991
+ );
1992
+ return new IDKitBuilder2(wasmBuilder);
1993
+ }
1994
+ function createSession2(config) {
1995
+ if (!config.app_id) {
1996
+ throw new Error("app_id is required");
1997
+ }
1998
+ if (!config.rp_context) {
1999
+ throw new Error("rp_context is required");
2000
+ }
2001
+ const rpContext = new idkit_wasm_exports.RpContextWasm(
2002
+ config.rp_context.rp_id,
2003
+ config.rp_context.nonce,
2004
+ BigInt(config.rp_context.created_at),
2005
+ BigInt(config.rp_context.expires_at),
2006
+ config.rp_context.signature
2007
+ );
2008
+ const wasmBuilder = idkit_wasm_exports.createSession(
2009
+ config.app_id,
2010
+ rpContext,
2011
+ config.action_description ?? null,
2012
+ config.bridge_url ?? null,
2013
+ config.override_connect_base_url ?? null,
2014
+ config.environment ?? null
2015
+ );
2016
+ return new IDKitBuilder2(wasmBuilder);
2017
+ }
2018
+ function proveSession2(sessionId, config) {
2019
+ if (!sessionId) {
2020
+ throw new Error("session_id is required");
2021
+ }
2022
+ if (!config.app_id) {
2023
+ throw new Error("app_id is required");
2024
+ }
2025
+ if (!config.rp_context) {
2026
+ throw new Error("rp_context is required");
2027
+ }
2028
+ const rpContext = new idkit_wasm_exports.RpContextWasm(
2029
+ config.rp_context.rp_id,
2030
+ config.rp_context.nonce,
2031
+ BigInt(config.rp_context.created_at),
2032
+ BigInt(config.rp_context.expires_at),
2033
+ config.rp_context.signature
2034
+ );
2035
+ const wasmBuilder = idkit_wasm_exports.proveSession(
2036
+ sessionId,
2037
+ config.app_id,
2038
+ rpContext,
2039
+ config.action_description ?? null,
2040
+ config.bridge_url ?? null,
2041
+ config.override_connect_base_url ?? null,
2042
+ config.environment ?? null
2043
+ );
2044
+ return new IDKitBuilder2(wasmBuilder);
1918
2045
  }
1919
2046
  var IDKit = {
1920
2047
  /** Initialize WASM for browser environments */
@@ -1923,6 +2050,10 @@ var IDKit = {
1923
2050
  initServer: initIDKitServer,
1924
2051
  /** Create a new verification request */
1925
2052
  request: createRequest,
2053
+ /** Create a new session (no action, no existing session_id) */
2054
+ createSession: createSession2,
2055
+ /** Prove an existing session (no action, has session_id) */
2056
+ proveSession: proveSession2,
1926
2057
  /** Create a CredentialRequest for a credential type */
1927
2058
  CredentialRequest,
1928
2059
  /** Create an OR constraint - at least one child must be satisfied */
@@ -1930,7 +2061,11 @@ var IDKit = {
1930
2061
  /** Create an AND constraint - all children must be satisfied */
1931
2062
  all,
1932
2063
  /** Create an OrbLegacy preset for World ID 3.0 legacy support */
1933
- orbLegacy: orbLegacy2
2064
+ orbLegacy,
2065
+ /** Create a SecureDocumentLegacy preset for World ID 3.0 legacy support */
2066
+ secureDocumentLegacy,
2067
+ /** Create a DocumentLegacy preset for World ID 3.0 legacy support */
2068
+ documentLegacy
1934
2069
  };
1935
2070
 
1936
2071
  // src/lib/platform.ts
@@ -1967,6 +2102,9 @@ function signRequest2(action, signingKeyHex, ttlSeconds) {
1967
2102
  return idkit_wasm_exports.signRequest(action, signingKeyHex, ttlBigInt);
1968
2103
  }
1969
2104
 
1970
- export { AppErrorCodes, CredentialRequest, IDKit, ResponseStatus, VerificationState, all, any, isNode, isReactNative, isWeb, orbLegacy2 as orbLegacy, signRequest2 as signRequest };
1971
- //# sourceMappingURL=index.js.map
1972
- //# sourceMappingURL=index.js.map
2105
+ // src/lib/hashing.ts
2106
+ function hashSignal2(signal) {
2107
+ return idkit_wasm_exports.hashSignal(signal);
2108
+ }
2109
+
2110
+ export { CredentialRequest, IDKit, IDKitErrorCodes, all, any, documentLegacy, hashSignal2 as hashSignal, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy, signRequest2 as signRequest };