@worldcoin/idkit-core 2.1.0 → 4.0.1-dev.eebacb1

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.
@@ -0,0 +1,1877 @@
1
+ let wasm;
2
+
3
+ let cachedUint8ArrayMemory0 = null;
4
+
5
+ function getUint8ArrayMemory0() {
6
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
8
+ }
9
+ return cachedUint8ArrayMemory0;
10
+ }
11
+
12
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
+
14
+ cachedTextDecoder.decode();
15
+
16
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
+ let numBytesDecoded = 0;
18
+ function decodeText(ptr, len) {
19
+ numBytesDecoded += len;
20
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
+ cachedTextDecoder.decode();
23
+ numBytesDecoded = len;
24
+ }
25
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
+ }
27
+
28
+ function getStringFromWasm0(ptr, len) {
29
+ ptr = ptr >>> 0;
30
+ return decodeText(ptr, len);
31
+ }
32
+
33
+ let heap = new Array(128).fill(undefined);
34
+
35
+ heap.push(undefined, null, true, false);
36
+
37
+ let heap_next = heap.length;
38
+
39
+ function addHeapObject(obj) {
40
+ if (heap_next === heap.length) heap.push(heap.length + 1);
41
+ const idx = heap_next;
42
+ heap_next = heap[idx];
43
+
44
+ heap[idx] = obj;
45
+ return idx;
46
+ }
47
+
48
+ function getObject(idx) { return heap[idx]; }
49
+
50
+ let WASM_VECTOR_LEN = 0;
51
+
52
+ const cachedTextEncoder = new TextEncoder();
53
+
54
+ if (!('encodeInto' in cachedTextEncoder)) {
55
+ cachedTextEncoder.encodeInto = function (arg, view) {
56
+ const buf = cachedTextEncoder.encode(arg);
57
+ view.set(buf);
58
+ return {
59
+ read: arg.length,
60
+ written: buf.length
61
+ };
62
+ }
63
+ }
64
+
65
+ function passStringToWasm0(arg, malloc, realloc) {
66
+
67
+ if (realloc === undefined) {
68
+ const buf = cachedTextEncoder.encode(arg);
69
+ const ptr = malloc(buf.length, 1) >>> 0;
70
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
71
+ WASM_VECTOR_LEN = buf.length;
72
+ return ptr;
73
+ }
74
+
75
+ let len = arg.length;
76
+ let ptr = malloc(len, 1) >>> 0;
77
+
78
+ const mem = getUint8ArrayMemory0();
79
+
80
+ let offset = 0;
81
+
82
+ for (; offset < len; offset++) {
83
+ const code = arg.charCodeAt(offset);
84
+ if (code > 0x7F) break;
85
+ mem[ptr + offset] = code;
86
+ }
87
+
88
+ if (offset !== len) {
89
+ if (offset !== 0) {
90
+ arg = arg.slice(offset);
91
+ }
92
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
93
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
94
+ const ret = cachedTextEncoder.encodeInto(arg, view);
95
+
96
+ offset += ret.written;
97
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
98
+ }
99
+
100
+ WASM_VECTOR_LEN = offset;
101
+ return ptr;
102
+ }
103
+
104
+ let cachedDataViewMemory0 = null;
105
+
106
+ function getDataViewMemory0() {
107
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
108
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
109
+ }
110
+ return cachedDataViewMemory0;
111
+ }
112
+
113
+ function isLikeNone(x) {
114
+ return x === undefined || x === null;
115
+ }
116
+
117
+ function debugString(val) {
118
+ // primitive types
119
+ const type = typeof val;
120
+ if (type == 'number' || type == 'boolean' || val == null) {
121
+ return `${val}`;
122
+ }
123
+ if (type == 'string') {
124
+ return `"${val}"`;
125
+ }
126
+ if (type == 'symbol') {
127
+ const description = val.description;
128
+ if (description == null) {
129
+ return 'Symbol';
130
+ } else {
131
+ return `Symbol(${description})`;
132
+ }
133
+ }
134
+ if (type == 'function') {
135
+ const name = val.name;
136
+ if (typeof name == 'string' && name.length > 0) {
137
+ return `Function(${name})`;
138
+ } else {
139
+ return 'Function';
140
+ }
141
+ }
142
+ // objects
143
+ if (Array.isArray(val)) {
144
+ const length = val.length;
145
+ let debug = '[';
146
+ if (length > 0) {
147
+ debug += debugString(val[0]);
148
+ }
149
+ for(let i = 1; i < length; i++) {
150
+ debug += ', ' + debugString(val[i]);
151
+ }
152
+ debug += ']';
153
+ return debug;
154
+ }
155
+ // Test for built-in
156
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
157
+ let className;
158
+ if (builtInMatches && builtInMatches.length > 1) {
159
+ className = builtInMatches[1];
160
+ } else {
161
+ // Failed to match the standard '[object ClassName]'
162
+ return toString.call(val);
163
+ }
164
+ if (className == 'Object') {
165
+ // we're a user defined class or Object
166
+ // JSON.stringify avoids problems with cycles, and is generally much
167
+ // easier than looping through ownProperties of `val`.
168
+ try {
169
+ return 'Object(' + JSON.stringify(val) + ')';
170
+ } catch (_) {
171
+ return 'Object';
172
+ }
173
+ }
174
+ // errors
175
+ if (val instanceof Error) {
176
+ return `${val.name}: ${val.message}\n${val.stack}`;
177
+ }
178
+ // TODO we could test for more things here, like `Set`s and `Map`s.
179
+ return className;
180
+ }
181
+
182
+ function handleError(f, args) {
183
+ try {
184
+ return f.apply(this, args);
185
+ } catch (e) {
186
+ wasm.__wbindgen_export3(addHeapObject(e));
187
+ }
188
+ }
189
+
190
+ function dropObject(idx) {
191
+ if (idx < 132) return;
192
+ heap[idx] = heap_next;
193
+ heap_next = idx;
194
+ }
195
+
196
+ function takeObject(idx) {
197
+ const ret = getObject(idx);
198
+ dropObject(idx);
199
+ return ret;
200
+ }
201
+
202
+ function getArrayU8FromWasm0(ptr, len) {
203
+ ptr = ptr >>> 0;
204
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
205
+ }
206
+
207
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
208
+ ? { register: () => {}, unregister: () => {} }
209
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
210
+
211
+ function makeMutClosure(arg0, arg1, dtor, f) {
212
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
213
+ const real = (...args) => {
214
+
215
+ // First up with a closure we increment the internal reference
216
+ // count. This ensures that the Rust closure environment won't
217
+ // be deallocated while we're invoking it.
218
+ state.cnt++;
219
+ const a = state.a;
220
+ state.a = 0;
221
+ try {
222
+ return f(a, state.b, ...args);
223
+ } finally {
224
+ state.a = a;
225
+ real._wbg_cb_unref();
226
+ }
227
+ };
228
+ real._wbg_cb_unref = () => {
229
+ if (--state.cnt === 0) {
230
+ state.dtor(state.a, state.b);
231
+ state.a = 0;
232
+ CLOSURE_DTORS.unregister(state);
233
+ }
234
+ };
235
+ CLOSURE_DTORS.register(real, state, state);
236
+ return real;
237
+ }
238
+ /**
239
+ * Hashes a signal string using Keccak256
240
+ * @param {string} signal
241
+ * @returns {string}
242
+ */
243
+ export function hashSignal(signal) {
244
+ let deferred2_0;
245
+ let deferred2_1;
246
+ try {
247
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
248
+ const ptr0 = passStringToWasm0(signal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
249
+ const len0 = WASM_VECTOR_LEN;
250
+ wasm.hashSignal(retptr, ptr0, len0);
251
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
252
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
253
+ deferred2_0 = r0;
254
+ deferred2_1 = r1;
255
+ return getStringFromWasm0(r0, r1);
256
+ } finally {
257
+ wasm.__wbindgen_add_to_stack_pointer(16);
258
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
259
+ }
260
+ }
261
+
262
+ function passArray8ToWasm0(arg, malloc) {
263
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
264
+ getUint8ArrayMemory0().set(arg, ptr / 1);
265
+ WASM_VECTOR_LEN = arg.length;
266
+ return ptr;
267
+ }
268
+ /**
269
+ * Hashes raw bytes using Keccak256
270
+ * @param {Uint8Array} bytes
271
+ * @returns {string}
272
+ */
273
+ export function hashSignalBytes(bytes) {
274
+ let deferred2_0;
275
+ let deferred2_1;
276
+ try {
277
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
278
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
279
+ const len0 = WASM_VECTOR_LEN;
280
+ wasm.hashSignal(retptr, ptr0, len0);
281
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
282
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
283
+ deferred2_0 = r0;
284
+ deferred2_1 = r1;
285
+ return getStringFromWasm0(r0, r1);
286
+ } finally {
287
+ wasm.__wbindgen_add_to_stack_pointer(16);
288
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
289
+ }
290
+ }
291
+
292
+ function _assertClass(instance, klass) {
293
+ if (!(instance instanceof klass)) {
294
+ throw new Error(`expected instance of ${klass.name}`);
295
+ }
296
+ }
297
+ /**
298
+ * Entry point for creating `IDKit` requests (WASM)
299
+ *
300
+ * # Arguments
301
+ * * `app_id` - Application ID from the Developer Portal
302
+ * * `action` - Action identifier
303
+ * * `rp_context` - RP context for building protocol-level `ProofRequest`
304
+ * * `action_description` - Optional action description shown to users
305
+ * * `bridge_url` - Optional bridge URL (defaults to production)
306
+ * @param {string} app_id
307
+ * @param {string} action
308
+ * @param {RpContextWasm} rp_context
309
+ * @param {string | null} [action_description]
310
+ * @param {string | null} [bridge_url]
311
+ * @returns {IDKitRequestBuilderWasm}
312
+ */
313
+ export function request(app_id, action, rp_context, action_description, bridge_url) {
314
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
315
+ const len0 = WASM_VECTOR_LEN;
316
+ const ptr1 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
317
+ const len1 = WASM_VECTOR_LEN;
318
+ _assertClass(rp_context, RpContextWasm);
319
+ var ptr2 = rp_context.__destroy_into_raw();
320
+ var ptr3 = isLikeNone(action_description) ? 0 : passStringToWasm0(action_description, wasm.__wbindgen_export, wasm.__wbindgen_export2);
321
+ var len3 = WASM_VECTOR_LEN;
322
+ var ptr4 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
323
+ var len4 = WASM_VECTOR_LEN;
324
+ const ret = wasm.idkitrequestbuilderwasm_new(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4);
325
+ return IDKitRequestBuilderWasm.__wrap(ret);
326
+ }
327
+
328
+ /**
329
+ * Creates an `OrbLegacy` preset for World ID 3.0 legacy support
330
+ *
331
+ * Returns a preset object that can be passed to `request().preset()`.
332
+ *
333
+ * # Arguments
334
+ * * `signal` - Optional signal string
335
+ *
336
+ * # Errors
337
+ *
338
+ * Returns an error if serialization fails
339
+ * @param {string | null} [signal]
340
+ * @returns {any}
341
+ */
342
+ export function orbLegacy(signal) {
343
+ try {
344
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
345
+ var ptr0 = isLikeNone(signal) ? 0 : passStringToWasm0(signal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
346
+ var len0 = WASM_VECTOR_LEN;
347
+ wasm.orbLegacy(retptr, ptr0, len0);
348
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
349
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
350
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
351
+ if (r2) {
352
+ throw takeObject(r1);
353
+ }
354
+ return takeObject(r0);
355
+ } finally {
356
+ wasm.__wbindgen_add_to_stack_pointer(16);
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Initialize the WASM module.
362
+ * This sets up panic hooks for better error messages in the browser console.
363
+ * Safe to call multiple times - initialization only happens once.
364
+ */
365
+ export function init_wasm() {
366
+ wasm.init_wasm();
367
+ }
368
+
369
+ /**
370
+ * Encodes data to base64
371
+ * @param {Uint8Array} data
372
+ * @returns {string}
373
+ */
374
+ export function base64Encode(data) {
375
+ let deferred2_0;
376
+ let deferred2_1;
377
+ try {
378
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
379
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
380
+ const len0 = WASM_VECTOR_LEN;
381
+ wasm.base64Encode(retptr, ptr0, len0);
382
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
383
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
384
+ deferred2_0 = r0;
385
+ deferred2_1 = r1;
386
+ return getStringFromWasm0(r0, r1);
387
+ } finally {
388
+ wasm.__wbindgen_add_to_stack_pointer(16);
389
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
390
+ }
391
+ }
392
+
393
+ /**
394
+ * Decodes base64 data
395
+ *
396
+ * # Errors
397
+ *
398
+ * Returns an error if decoding fails
399
+ * @param {string} data
400
+ * @returns {Uint8Array}
401
+ */
402
+ export function base64Decode(data) {
403
+ try {
404
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
405
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_export, wasm.__wbindgen_export2);
406
+ const len0 = WASM_VECTOR_LEN;
407
+ wasm.base64Decode(retptr, ptr0, len0);
408
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
409
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
410
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
411
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
412
+ if (r3) {
413
+ throw takeObject(r2);
414
+ }
415
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
416
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
417
+ return v2;
418
+ } finally {
419
+ wasm.__wbindgen_add_to_stack_pointer(16);
420
+ }
421
+ }
422
+
423
+ /**
424
+ * Signs an RP request for World ID proof verification
425
+ *
426
+ * **Backend-only**: This function should only be used in server-side environments.
427
+ * Never expose your signing key to client-side code.
428
+ *
429
+ * This function generates a cryptographic signature that RPs use to authenticate
430
+ * proof requests. It:
431
+ * 1. Generates a random nonce
432
+ * 2. Gets the current timestamp
433
+ * 3. Computes: keccak256(nonce || action || timestamp || `expires_at`)
434
+ * 4. Signs the hash with ECDSA secp256k1
435
+ *
436
+ * # Arguments
437
+ * * `action` - The action identifier string (e.g., "verify-human")
438
+ * * `signing_key_hex` - The ECDSA private key as hex (0x-prefixed or not, 32 bytes)
439
+ * * `ttl_seconds` - Optional time-to-live in seconds (defaults to 300 = 5 minutes)
440
+ *
441
+ * # Returns
442
+ * An `RpSignature` object containing the signature, nonce, and timestamps
443
+ * to be passed as `rp_context` in the proof request
444
+ *
445
+ * # Errors
446
+ * Returns an error if:
447
+ * - The signing key is invalid hex or wrong length
448
+ * - Random generation fails
449
+ * - Signing fails
450
+ *
451
+ * # Example
452
+ * ```javascript
453
+ * import { signRequest } from '@worldcoin/idkit-core'
454
+ *
455
+ * const signingKey = process.env.RP_SIGNING_KEY // Load from secure env var
456
+ * const signature = signRequest('my-action', signingKey) // default 5 min TTL
457
+ * const customTtl = signRequest('my-action', signingKey, 600) // 10 min TTL
458
+ * console.log(signature.sig, signature.nonce, signature.createdAt, signature.expiresAt)
459
+ * ```
460
+ * @param {string} action
461
+ * @param {string} signing_key_hex
462
+ * @param {bigint | null} [ttl_seconds]
463
+ * @returns {RpSignature}
464
+ */
465
+ export function signRequest(action, signing_key_hex, ttl_seconds) {
466
+ try {
467
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
468
+ const ptr0 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
469
+ const len0 = WASM_VECTOR_LEN;
470
+ const ptr1 = passStringToWasm0(signing_key_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
471
+ const len1 = WASM_VECTOR_LEN;
472
+ wasm.signRequest(retptr, ptr0, len0, ptr1, len1, !isLikeNone(ttl_seconds), isLikeNone(ttl_seconds) ? BigInt(0) : ttl_seconds);
473
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
474
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
475
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
476
+ if (r2) {
477
+ throw takeObject(r1);
478
+ }
479
+ return RpSignature.__wrap(r0);
480
+ } finally {
481
+ wasm.__wbindgen_add_to_stack_pointer(16);
482
+ }
483
+ }
484
+
485
+ function __wasm_bindgen_func_elem_510(arg0, arg1) {
486
+ wasm.__wasm_bindgen_func_elem_510(arg0, arg1);
487
+ }
488
+
489
+ function __wasm_bindgen_func_elem_873(arg0, arg1, arg2) {
490
+ wasm.__wasm_bindgen_func_elem_873(arg0, arg1, addHeapObject(arg2));
491
+ }
492
+
493
+ function __wasm_bindgen_func_elem_1238(arg0, arg1, arg2, arg3) {
494
+ wasm.__wasm_bindgen_func_elem_1238(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
495
+ }
496
+
497
+ const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
498
+
499
+ const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
500
+
501
+ const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
502
+
503
+ const BridgeEncryptionFinalization = (typeof FinalizationRegistry === 'undefined')
504
+ ? { register: () => {}, unregister: () => {} }
505
+ : new FinalizationRegistry(ptr => wasm.__wbg_bridgeencryption_free(ptr >>> 0, 1));
506
+ /**
507
+ * Bridge encryption for secure communication between client and bridge
508
+ */
509
+ export class BridgeEncryption {
510
+
511
+ __destroy_into_raw() {
512
+ const ptr = this.__wbg_ptr;
513
+ this.__wbg_ptr = 0;
514
+ BridgeEncryptionFinalization.unregister(this);
515
+ return ptr;
516
+ }
517
+
518
+ free() {
519
+ const ptr = this.__destroy_into_raw();
520
+ wasm.__wbg_bridgeencryption_free(ptr, 0);
521
+ }
522
+ /**
523
+ * Returns the key as a base64-encoded string
524
+ * @returns {string}
525
+ */
526
+ keyBase64() {
527
+ let deferred1_0;
528
+ let deferred1_1;
529
+ try {
530
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
531
+ wasm.bridgeencryption_keyBase64(retptr, this.__wbg_ptr);
532
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
533
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
534
+ deferred1_0 = r0;
535
+ deferred1_1 = r1;
536
+ return getStringFromWasm0(r0, r1);
537
+ } finally {
538
+ wasm.__wbindgen_add_to_stack_pointer(16);
539
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
540
+ }
541
+ }
542
+ /**
543
+ * Returns the nonce as a base64-encoded string
544
+ * @returns {string}
545
+ */
546
+ nonceBase64() {
547
+ let deferred1_0;
548
+ let deferred1_1;
549
+ try {
550
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
551
+ wasm.bridgeencryption_nonceBase64(retptr, this.__wbg_ptr);
552
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
553
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
554
+ deferred1_0 = r0;
555
+ deferred1_1 = r1;
556
+ return getStringFromWasm0(r0, r1);
557
+ } finally {
558
+ wasm.__wbindgen_add_to_stack_pointer(16);
559
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
560
+ }
561
+ }
562
+ /**
563
+ * Creates a new `BridgeEncryption` instance with randomly generated key and nonce
564
+ *
565
+ * # Errors
566
+ *
567
+ * Returns an error if key generation fails
568
+ */
569
+ constructor() {
570
+ try {
571
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
572
+ wasm.bridgeencryption_new(retptr);
573
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
574
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
575
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
576
+ if (r2) {
577
+ throw takeObject(r1);
578
+ }
579
+ this.__wbg_ptr = r0 >>> 0;
580
+ BridgeEncryptionFinalization.register(this, this.__wbg_ptr, this);
581
+ return this;
582
+ } finally {
583
+ wasm.__wbindgen_add_to_stack_pointer(16);
584
+ }
585
+ }
586
+ /**
587
+ * Decrypts a base64-encoded ciphertext using AES-256-GCM
588
+ *
589
+ * # Errors
590
+ *
591
+ * Returns an error if decryption fails or the output is not valid UTF-8
592
+ * @param {string} ciphertext_base64
593
+ * @returns {string}
594
+ */
595
+ decrypt(ciphertext_base64) {
596
+ let deferred3_0;
597
+ let deferred3_1;
598
+ try {
599
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
600
+ const ptr0 = passStringToWasm0(ciphertext_base64, wasm.__wbindgen_export, wasm.__wbindgen_export2);
601
+ const len0 = WASM_VECTOR_LEN;
602
+ wasm.bridgeencryption_decrypt(retptr, this.__wbg_ptr, ptr0, len0);
603
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
604
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
605
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
606
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
607
+ var ptr2 = r0;
608
+ var len2 = r1;
609
+ if (r3) {
610
+ ptr2 = 0; len2 = 0;
611
+ throw takeObject(r2);
612
+ }
613
+ deferred3_0 = ptr2;
614
+ deferred3_1 = len2;
615
+ return getStringFromWasm0(ptr2, len2);
616
+ } finally {
617
+ wasm.__wbindgen_add_to_stack_pointer(16);
618
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
619
+ }
620
+ }
621
+ /**
622
+ * Encrypts a plaintext string using AES-256-GCM and returns base64
623
+ *
624
+ * # Errors
625
+ *
626
+ * Returns an error if encryption fails
627
+ * @param {string} plaintext
628
+ * @returns {string}
629
+ */
630
+ encrypt(plaintext) {
631
+ let deferred3_0;
632
+ let deferred3_1;
633
+ try {
634
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
635
+ const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_export, wasm.__wbindgen_export2);
636
+ const len0 = WASM_VECTOR_LEN;
637
+ wasm.bridgeencryption_encrypt(retptr, this.__wbg_ptr, ptr0, len0);
638
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
639
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
640
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
641
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
642
+ var ptr2 = r0;
643
+ var len2 = r1;
644
+ if (r3) {
645
+ ptr2 = 0; len2 = 0;
646
+ throw takeObject(r2);
647
+ }
648
+ deferred3_0 = ptr2;
649
+ deferred3_1 = len2;
650
+ return getStringFromWasm0(ptr2, len2);
651
+ } finally {
652
+ wasm.__wbindgen_add_to_stack_pointer(16);
653
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
654
+ }
655
+ }
656
+ }
657
+ if (Symbol.dispose) BridgeEncryption.prototype[Symbol.dispose] = BridgeEncryption.prototype.free;
658
+
659
+ const CredentialRequestWasmFinalization = (typeof FinalizationRegistry === 'undefined')
660
+ ? { register: () => {}, unregister: () => {} }
661
+ : new FinalizationRegistry(ptr => wasm.__wbg_credentialrequestwasm_free(ptr >>> 0, 1));
662
+ /**
663
+ * WASM wrapper for `CredentialRequest`
664
+ */
665
+ export class CredentialRequestWasm {
666
+
667
+ static __wrap(ptr) {
668
+ ptr = ptr >>> 0;
669
+ const obj = Object.create(CredentialRequestWasm.prototype);
670
+ obj.__wbg_ptr = ptr;
671
+ CredentialRequestWasmFinalization.register(obj, obj.__wbg_ptr, obj);
672
+ return obj;
673
+ }
674
+
675
+ __destroy_into_raw() {
676
+ const ptr = this.__wbg_ptr;
677
+ this.__wbg_ptr = 0;
678
+ CredentialRequestWasmFinalization.unregister(this);
679
+ return ptr;
680
+ }
681
+
682
+ free() {
683
+ const ptr = this.__destroy_into_raw();
684
+ wasm.__wbg_credentialrequestwasm_free(ptr, 0);
685
+ }
686
+ /**
687
+ * Creates a new request item with ABI-encoded bytes for the signal
688
+ *
689
+ * # Errors
690
+ *
691
+ * Returns an error if the credential type is invalid
692
+ * @param {any} credential_type
693
+ * @param {Uint8Array} signal_bytes
694
+ * @returns {CredentialRequestWasm}
695
+ */
696
+ static withBytes(credential_type, signal_bytes) {
697
+ try {
698
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
699
+ const ptr0 = passArray8ToWasm0(signal_bytes, wasm.__wbindgen_export);
700
+ const len0 = WASM_VECTOR_LEN;
701
+ wasm.credentialrequestwasm_withBytes(retptr, addHeapObject(credential_type), ptr0, len0);
702
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
703
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
704
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
705
+ if (r2) {
706
+ throw takeObject(r1);
707
+ }
708
+ return CredentialRequestWasm.__wrap(r0);
709
+ } finally {
710
+ wasm.__wbindgen_add_to_stack_pointer(16);
711
+ }
712
+ }
713
+ /**
714
+ * Gets the credential type
715
+ * @returns {any}
716
+ */
717
+ credentialType() {
718
+ const ret = wasm.credentialrequestwasm_credentialType(this.__wbg_ptr);
719
+ return takeObject(ret);
720
+ }
721
+ /**
722
+ * Gets the signal as raw bytes
723
+ * @returns {Uint8Array | undefined}
724
+ */
725
+ getSignalBytes() {
726
+ try {
727
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
728
+ wasm.credentialrequestwasm_getSignalBytes(retptr, this.__wbg_ptr);
729
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
730
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
731
+ let v1;
732
+ if (r0 !== 0) {
733
+ v1 = getArrayU8FromWasm0(r0, r1).slice();
734
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
735
+ }
736
+ return v1;
737
+ } finally {
738
+ wasm.__wbindgen_add_to_stack_pointer(16);
739
+ }
740
+ }
741
+ /**
742
+ * Creates a new request item with genesis minimum timestamp
743
+ *
744
+ * # Errors
745
+ *
746
+ * Returns an error if the credential type is invalid
747
+ * @param {any} credential_type
748
+ * @param {string | null | undefined} signal
749
+ * @param {bigint} genesis_min
750
+ * @returns {CredentialRequestWasm}
751
+ */
752
+ static withGenesisMin(credential_type, signal, genesis_min) {
753
+ try {
754
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
755
+ var ptr0 = isLikeNone(signal) ? 0 : passStringToWasm0(signal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
756
+ var len0 = WASM_VECTOR_LEN;
757
+ wasm.credentialrequestwasm_withGenesisMin(retptr, addHeapObject(credential_type), ptr0, len0, genesis_min);
758
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
759
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
760
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
761
+ if (r2) {
762
+ throw takeObject(r1);
763
+ }
764
+ return CredentialRequestWasm.__wrap(r0);
765
+ } finally {
766
+ wasm.__wbindgen_add_to_stack_pointer(16);
767
+ }
768
+ }
769
+ /**
770
+ * Creates a new request item
771
+ *
772
+ * # Arguments
773
+ * * `credential_type` - The type of credential to request (e.g., "orb", "face")
774
+ * * `signal` - Optional signal string
775
+ *
776
+ * # Errors
777
+ *
778
+ * Returns an error if the credential type is invalid
779
+ * @param {any} credential_type
780
+ * @param {string | null} [signal]
781
+ */
782
+ constructor(credential_type, signal) {
783
+ try {
784
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
785
+ var ptr0 = isLikeNone(signal) ? 0 : passStringToWasm0(signal, wasm.__wbindgen_export, wasm.__wbindgen_export2);
786
+ var len0 = WASM_VECTOR_LEN;
787
+ wasm.credentialrequestwasm_new(retptr, addHeapObject(credential_type), ptr0, len0);
788
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
789
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
790
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
791
+ if (r2) {
792
+ throw takeObject(r1);
793
+ }
794
+ this.__wbg_ptr = r0 >>> 0;
795
+ CredentialRequestWasmFinalization.register(this, this.__wbg_ptr, this);
796
+ return this;
797
+ } finally {
798
+ wasm.__wbindgen_add_to_stack_pointer(16);
799
+ }
800
+ }
801
+ /**
802
+ * Converts the request item to JSON
803
+ *
804
+ * # Errors
805
+ *
806
+ * Returns an error if serialization fails
807
+ * @returns {any}
808
+ */
809
+ toJSON() {
810
+ try {
811
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
812
+ wasm.credentialrequestwasm_toJSON(retptr, this.__wbg_ptr);
813
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
814
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
815
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
816
+ if (r2) {
817
+ throw takeObject(r1);
818
+ }
819
+ return takeObject(r0);
820
+ } finally {
821
+ wasm.__wbindgen_add_to_stack_pointer(16);
822
+ }
823
+ }
824
+ }
825
+ if (Symbol.dispose) CredentialRequestWasm.prototype[Symbol.dispose] = CredentialRequestWasm.prototype.free;
826
+
827
+ const IDKitProofFinalization = (typeof FinalizationRegistry === 'undefined')
828
+ ? { register: () => {}, unregister: () => {} }
829
+ : new FinalizationRegistry(ptr => wasm.__wbg_idkitproof_free(ptr >>> 0, 1));
830
+
831
+ export class IDKitProof {
832
+
833
+ __destroy_into_raw() {
834
+ const ptr = this.__wbg_ptr;
835
+ this.__wbg_ptr = 0;
836
+ IDKitProofFinalization.unregister(this);
837
+ return ptr;
838
+ }
839
+
840
+ free() {
841
+ const ptr = this.__destroy_into_raw();
842
+ wasm.__wbg_idkitproof_free(ptr, 0);
843
+ }
844
+ /**
845
+ * Creates a new proof
846
+ *
847
+ * # Errors
848
+ *
849
+ * Returns an error if the verification level cannot be deserialized
850
+ * @param {string} proof
851
+ * @param {string} merkle_root
852
+ * @param {string} nullifier_hash
853
+ * @param {any} verification_level
854
+ */
855
+ constructor(proof, merkle_root, nullifier_hash, verification_level) {
856
+ try {
857
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
858
+ const ptr0 = passStringToWasm0(proof, wasm.__wbindgen_export, wasm.__wbindgen_export2);
859
+ const len0 = WASM_VECTOR_LEN;
860
+ const ptr1 = passStringToWasm0(merkle_root, wasm.__wbindgen_export, wasm.__wbindgen_export2);
861
+ const len1 = WASM_VECTOR_LEN;
862
+ const ptr2 = passStringToWasm0(nullifier_hash, wasm.__wbindgen_export, wasm.__wbindgen_export2);
863
+ const len2 = WASM_VECTOR_LEN;
864
+ wasm.idkitproof_new(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addHeapObject(verification_level));
865
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
866
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
867
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
868
+ if (r2) {
869
+ throw takeObject(r1);
870
+ }
871
+ this.__wbg_ptr = r0 >>> 0;
872
+ IDKitProofFinalization.register(this, this.__wbg_ptr, this);
873
+ return this;
874
+ } finally {
875
+ wasm.__wbindgen_add_to_stack_pointer(16);
876
+ }
877
+ }
878
+ /**
879
+ * Converts the proof to JSON
880
+ *
881
+ * # Errors
882
+ *
883
+ * Returns an error if serialization fails
884
+ * @returns {any}
885
+ */
886
+ toJSON() {
887
+ try {
888
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
889
+ wasm.idkitproof_toJSON(retptr, this.__wbg_ptr);
890
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
891
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
892
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
893
+ if (r2) {
894
+ throw takeObject(r1);
895
+ }
896
+ return takeObject(r0);
897
+ } finally {
898
+ wasm.__wbindgen_add_to_stack_pointer(16);
899
+ }
900
+ }
901
+ }
902
+ if (Symbol.dispose) IDKitProof.prototype[Symbol.dispose] = IDKitProof.prototype.free;
903
+
904
+ const IDKitRequestFinalization = (typeof FinalizationRegistry === 'undefined')
905
+ ? { register: () => {}, unregister: () => {} }
906
+ : new FinalizationRegistry(ptr => wasm.__wbg_idkitrequest_free(ptr >>> 0, 1));
907
+ /**
908
+ * World ID verification request
909
+ *
910
+ * Manages the verification flow with World App via the bridge.
911
+ */
912
+ export class IDKitRequest {
913
+
914
+ static __wrap(ptr) {
915
+ ptr = ptr >>> 0;
916
+ const obj = Object.create(IDKitRequest.prototype);
917
+ obj.__wbg_ptr = ptr;
918
+ IDKitRequestFinalization.register(obj, obj.__wbg_ptr, obj);
919
+ return obj;
920
+ }
921
+
922
+ __destroy_into_raw() {
923
+ const ptr = this.__wbg_ptr;
924
+ this.__wbg_ptr = 0;
925
+ IDKitRequestFinalization.unregister(this);
926
+ return ptr;
927
+ }
928
+
929
+ free() {
930
+ const ptr = this.__destroy_into_raw();
931
+ wasm.__wbg_idkitrequest_free(ptr, 0);
932
+ }
933
+ /**
934
+ * Returns the request ID for this request
935
+ *
936
+ * # Errors
937
+ *
938
+ * Returns an error if the request has been closed
939
+ * @returns {string}
940
+ */
941
+ requestId() {
942
+ let deferred2_0;
943
+ let deferred2_1;
944
+ try {
945
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
946
+ wasm.idkitrequest_requestId(retptr, this.__wbg_ptr);
947
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
948
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
949
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
950
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
951
+ var ptr1 = r0;
952
+ var len1 = r1;
953
+ if (r3) {
954
+ ptr1 = 0; len1 = 0;
955
+ throw takeObject(r2);
956
+ }
957
+ deferred2_0 = ptr1;
958
+ deferred2_1 = len1;
959
+ return getStringFromWasm0(ptr1, len1);
960
+ } finally {
961
+ wasm.__wbindgen_add_to_stack_pointer(16);
962
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
963
+ }
964
+ }
965
+ /**
966
+ * Returns the connect URL for World App
967
+ *
968
+ * This URL should be displayed as a QR code for users to scan with World App.
969
+ *
970
+ * # Errors
971
+ *
972
+ * Returns an error if the request has been closed
973
+ * @returns {string}
974
+ */
975
+ connectUrl() {
976
+ let deferred2_0;
977
+ let deferred2_1;
978
+ try {
979
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
980
+ wasm.idkitrequest_connectUrl(retptr, this.__wbg_ptr);
981
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
982
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
983
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
984
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
985
+ var ptr1 = r0;
986
+ var len1 = r1;
987
+ if (r3) {
988
+ ptr1 = 0; len1 = 0;
989
+ throw takeObject(r2);
990
+ }
991
+ deferred2_0 = ptr1;
992
+ deferred2_1 = len1;
993
+ return getStringFromWasm0(ptr1, len1);
994
+ } finally {
995
+ wasm.__wbindgen_add_to_stack_pointer(16);
996
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
997
+ }
998
+ }
999
+ /**
1000
+ * Polls the bridge for the current status (non-blocking)
1001
+ *
1002
+ * Returns a status object with type:
1003
+ * - `"waiting_for_connection"` - Waiting for World App to retrieve the request
1004
+ * - `"awaiting_confirmation"` - World App has retrieved the request, waiting for user
1005
+ * - `"confirmed"` - User confirmed and provided a proof
1006
+ * - `"failed"` - Request has failed
1007
+ *
1008
+ * # Errors
1009
+ *
1010
+ * Returns an error if the request fails or the response is invalid
1011
+ * @returns {Promise<any>}
1012
+ */
1013
+ pollForStatus() {
1014
+ const ret = wasm.idkitrequest_pollForStatus(this.__wbg_ptr);
1015
+ return takeObject(ret);
1016
+ }
1017
+ }
1018
+ if (Symbol.dispose) IDKitRequest.prototype[Symbol.dispose] = IDKitRequest.prototype.free;
1019
+
1020
+ const IDKitRequestBuilderWasmFinalization = (typeof FinalizationRegistry === 'undefined')
1021
+ ? { register: () => {}, unregister: () => {} }
1022
+ : new FinalizationRegistry(ptr => wasm.__wbg_idkitrequestbuilderwasm_free(ptr >>> 0, 1));
1023
+ /**
1024
+ * Builder for creating `IDKit` requests (WASM)
1025
+ */
1026
+ export class IDKitRequestBuilderWasm {
1027
+
1028
+ static __wrap(ptr) {
1029
+ ptr = ptr >>> 0;
1030
+ const obj = Object.create(IDKitRequestBuilderWasm.prototype);
1031
+ obj.__wbg_ptr = ptr;
1032
+ IDKitRequestBuilderWasmFinalization.register(obj, obj.__wbg_ptr, obj);
1033
+ return obj;
1034
+ }
1035
+
1036
+ __destroy_into_raw() {
1037
+ const ptr = this.__wbg_ptr;
1038
+ this.__wbg_ptr = 0;
1039
+ IDKitRequestBuilderWasmFinalization.unregister(this);
1040
+ return ptr;
1041
+ }
1042
+
1043
+ free() {
1044
+ const ptr = this.__destroy_into_raw();
1045
+ wasm.__wbg_idkitrequestbuilderwasm_free(ptr, 0);
1046
+ }
1047
+ /**
1048
+ * Creates an `IDKit` request with the given constraints
1049
+ *
1050
+ * # Arguments
1051
+ * * `constraints_json` - Constraint tree as JSON (`CredentialRequest` or `{any: []}` or `{all: []}`)
1052
+ *
1053
+ * # Errors
1054
+ *
1055
+ * Returns an error if the request cannot be created
1056
+ * @param {any} constraints_json
1057
+ * @returns {Promise<any>}
1058
+ */
1059
+ constraints(constraints_json) {
1060
+ const ptr = this.__destroy_into_raw();
1061
+ const ret = wasm.idkitrequestbuilderwasm_constraints(ptr, addHeapObject(constraints_json));
1062
+ return takeObject(ret);
1063
+ }
1064
+ /**
1065
+ * Creates a new `IDKitRequestBuilder`
1066
+ *
1067
+ * # Arguments
1068
+ * * `app_id` - Application ID from the Developer Portal
1069
+ * * `action` - Action identifier
1070
+ * * `rp_context` - RP context for building protocol-level `ProofRequest`
1071
+ * * `action_description` - Optional action description shown to users
1072
+ * * `bridge_url` - Optional bridge URL (defaults to production)
1073
+ * @param {string} app_id
1074
+ * @param {string} action
1075
+ * @param {RpContextWasm} rp_context
1076
+ * @param {string | null} [action_description]
1077
+ * @param {string | null} [bridge_url]
1078
+ */
1079
+ constructor(app_id, action, rp_context, action_description, bridge_url) {
1080
+ const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1081
+ const len0 = WASM_VECTOR_LEN;
1082
+ const ptr1 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1083
+ const len1 = WASM_VECTOR_LEN;
1084
+ _assertClass(rp_context, RpContextWasm);
1085
+ var ptr2 = rp_context.__destroy_into_raw();
1086
+ var ptr3 = isLikeNone(action_description) ? 0 : passStringToWasm0(action_description, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1087
+ var len3 = WASM_VECTOR_LEN;
1088
+ var ptr4 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1089
+ var len4 = WASM_VECTOR_LEN;
1090
+ const ret = wasm.idkitrequestbuilderwasm_new(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4);
1091
+ this.__wbg_ptr = ret >>> 0;
1092
+ IDKitRequestBuilderWasmFinalization.register(this, this.__wbg_ptr, this);
1093
+ return this;
1094
+ }
1095
+ /**
1096
+ * Creates an `IDKit` request from a preset
1097
+ *
1098
+ * Presets provide a simplified way to create requests with predefined
1099
+ * credential configurations. The preset is converted to both World ID 4.0
1100
+ * constraints and World ID 3.0 legacy fields for backward compatibility.
1101
+ *
1102
+ * # Arguments
1103
+ * * `preset_json` - Preset object from `orbLegacy()`
1104
+ *
1105
+ * # Errors
1106
+ *
1107
+ * Returns an error if the request cannot be created
1108
+ * @param {any} preset_json
1109
+ * @returns {Promise<any>}
1110
+ */
1111
+ preset(preset_json) {
1112
+ const ptr = this.__destroy_into_raw();
1113
+ const ret = wasm.idkitrequestbuilderwasm_preset(ptr, addHeapObject(preset_json));
1114
+ return takeObject(ret);
1115
+ }
1116
+ }
1117
+ if (Symbol.dispose) IDKitRequestBuilderWasm.prototype[Symbol.dispose] = IDKitRequestBuilderWasm.prototype.free;
1118
+
1119
+ const RpContextWasmFinalization = (typeof FinalizationRegistry === 'undefined')
1120
+ ? { register: () => {}, unregister: () => {} }
1121
+ : new FinalizationRegistry(ptr => wasm.__wbg_rpcontextwasm_free(ptr >>> 0, 1));
1122
+ /**
1123
+ * RP Context for protocol-level proof requests (WASM binding)
1124
+ *
1125
+ * Contains RP-specific data needed to construct a `ProofRequest`.
1126
+ */
1127
+ export class RpContextWasm {
1128
+
1129
+ __destroy_into_raw() {
1130
+ const ptr = this.__wbg_ptr;
1131
+ this.__wbg_ptr = 0;
1132
+ RpContextWasmFinalization.unregister(this);
1133
+ return ptr;
1134
+ }
1135
+
1136
+ free() {
1137
+ const ptr = this.__destroy_into_raw();
1138
+ wasm.__wbg_rpcontextwasm_free(ptr, 0);
1139
+ }
1140
+ /**
1141
+ * Creates a new RP context
1142
+ *
1143
+ * # Arguments
1144
+ * * `rp_id` - The registered RP ID (e.g., `"rp_123456789abcdef0"`)
1145
+ * * `nonce` - Unique nonce for this proof request
1146
+ * * `created_at` - Unix timestamp (seconds since epoch) when created
1147
+ * * `expires_at` - Unix timestamp (seconds since epoch) when expires
1148
+ * * `signature` - The RP's ECDSA signature of the `nonce` and `created_at` timestamp
1149
+ *
1150
+ * # Errors
1151
+ *
1152
+ * Returns an error if `rp_id` is not a valid RP ID (must start with `rp_`)
1153
+ * @param {string} rp_id
1154
+ * @param {string} nonce
1155
+ * @param {bigint} created_at
1156
+ * @param {bigint} expires_at
1157
+ * @param {string} signature
1158
+ */
1159
+ constructor(rp_id, nonce, created_at, expires_at, signature) {
1160
+ try {
1161
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1162
+ const ptr0 = passStringToWasm0(rp_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1163
+ const len0 = WASM_VECTOR_LEN;
1164
+ const ptr1 = passStringToWasm0(nonce, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1165
+ const len1 = WASM_VECTOR_LEN;
1166
+ const ptr2 = passStringToWasm0(signature, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1167
+ const len2 = WASM_VECTOR_LEN;
1168
+ wasm.rpcontextwasm_new(retptr, ptr0, len0, ptr1, len1, created_at, expires_at, ptr2, len2);
1169
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1170
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1171
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1172
+ if (r2) {
1173
+ throw takeObject(r1);
1174
+ }
1175
+ this.__wbg_ptr = r0 >>> 0;
1176
+ RpContextWasmFinalization.register(this, this.__wbg_ptr, this);
1177
+ return this;
1178
+ } finally {
1179
+ wasm.__wbindgen_add_to_stack_pointer(16);
1180
+ }
1181
+ }
1182
+ }
1183
+ if (Symbol.dispose) RpContextWasm.prototype[Symbol.dispose] = RpContextWasm.prototype.free;
1184
+
1185
+ const RpSignatureFinalization = (typeof FinalizationRegistry === 'undefined')
1186
+ ? { register: () => {}, unregister: () => {} }
1187
+ : new FinalizationRegistry(ptr => wasm.__wbg_rpsignature_free(ptr >>> 0, 1));
1188
+
1189
+ export class RpSignature {
1190
+
1191
+ static __wrap(ptr) {
1192
+ ptr = ptr >>> 0;
1193
+ const obj = Object.create(RpSignature.prototype);
1194
+ obj.__wbg_ptr = ptr;
1195
+ RpSignatureFinalization.register(obj, obj.__wbg_ptr, obj);
1196
+ return obj;
1197
+ }
1198
+
1199
+ __destroy_into_raw() {
1200
+ const ptr = this.__wbg_ptr;
1201
+ this.__wbg_ptr = 0;
1202
+ RpSignatureFinalization.unregister(this);
1203
+ return ptr;
1204
+ }
1205
+
1206
+ free() {
1207
+ const ptr = this.__destroy_into_raw();
1208
+ wasm.__wbg_rpsignature_free(ptr, 0);
1209
+ }
1210
+ /**
1211
+ * Gets the creation timestamp
1212
+ * @returns {bigint}
1213
+ */
1214
+ get createdAt() {
1215
+ const ret = wasm.rpsignature_createdAt(this.__wbg_ptr);
1216
+ return BigInt.asUintN(64, ret);
1217
+ }
1218
+ /**
1219
+ * Gets the expiration timestamp
1220
+ * @returns {bigint}
1221
+ */
1222
+ get expiresAt() {
1223
+ const ret = wasm.rpsignature_expiresAt(this.__wbg_ptr);
1224
+ return BigInt.asUintN(64, ret);
1225
+ }
1226
+ /**
1227
+ * Gets the signature as hex string (0x-prefixed, 65 bytes)
1228
+ * @returns {string}
1229
+ */
1230
+ get sig() {
1231
+ let deferred1_0;
1232
+ let deferred1_1;
1233
+ try {
1234
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1235
+ wasm.rpsignature_sig(retptr, this.__wbg_ptr);
1236
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1237
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1238
+ deferred1_0 = r0;
1239
+ deferred1_1 = r1;
1240
+ return getStringFromWasm0(r0, r1);
1241
+ } finally {
1242
+ wasm.__wbindgen_add_to_stack_pointer(16);
1243
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1244
+ }
1245
+ }
1246
+ /**
1247
+ * Gets the nonce as hex string (0x-prefixed field element)
1248
+ * @returns {string}
1249
+ */
1250
+ get nonce() {
1251
+ let deferred1_0;
1252
+ let deferred1_1;
1253
+ try {
1254
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1255
+ wasm.rpsignature_nonce(retptr, this.__wbg_ptr);
1256
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1257
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1258
+ deferred1_0 = r0;
1259
+ deferred1_1 = r1;
1260
+ return getStringFromWasm0(r0, r1);
1261
+ } finally {
1262
+ wasm.__wbindgen_add_to_stack_pointer(16);
1263
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
1264
+ }
1265
+ }
1266
+ /**
1267
+ * Converts to JSON
1268
+ *
1269
+ * # Errors
1270
+ *
1271
+ * Returns an error if setting object properties fails
1272
+ * @returns {any}
1273
+ */
1274
+ toJSON() {
1275
+ try {
1276
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1277
+ wasm.rpsignature_toJSON(retptr, this.__wbg_ptr);
1278
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1279
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1280
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1281
+ if (r2) {
1282
+ throw takeObject(r1);
1283
+ }
1284
+ return takeObject(r0);
1285
+ } finally {
1286
+ wasm.__wbindgen_add_to_stack_pointer(16);
1287
+ }
1288
+ }
1289
+ }
1290
+ if (Symbol.dispose) RpSignature.prototype[Symbol.dispose] = RpSignature.prototype.free;
1291
+
1292
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
1293
+
1294
+ async function __wbg_load(module, imports) {
1295
+ if (typeof Response === 'function' && module instanceof Response) {
1296
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1297
+ try {
1298
+ return await WebAssembly.instantiateStreaming(module, imports);
1299
+
1300
+ } catch (e) {
1301
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
1302
+
1303
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1304
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1305
+
1306
+ } else {
1307
+ throw e;
1308
+ }
1309
+ }
1310
+ }
1311
+
1312
+ const bytes = await module.arrayBuffer();
1313
+ return await WebAssembly.instantiate(bytes, imports);
1314
+
1315
+ } else {
1316
+ const instance = await WebAssembly.instantiate(module, imports);
1317
+
1318
+ if (instance instanceof WebAssembly.Instance) {
1319
+ return { instance, module };
1320
+
1321
+ } else {
1322
+ return instance;
1323
+ }
1324
+ }
1325
+ }
1326
+
1327
+ function __wbg_get_imports() {
1328
+ const imports = {};
1329
+ imports.wbg = {};
1330
+ imports.wbg.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
1331
+ const ret = Error(getStringFromWasm0(arg0, arg1));
1332
+ return addHeapObject(ret);
1333
+ };
1334
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
1335
+ const ret = String(getObject(arg1));
1336
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1337
+ const len1 = WASM_VECTOR_LEN;
1338
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1339
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1340
+ };
1341
+ imports.wbg.__wbg___wbindgen_bigint_get_as_i64_f3ebc5a755000afd = function(arg0, arg1) {
1342
+ const v = getObject(arg1);
1343
+ const ret = typeof(v) === 'bigint' ? v : undefined;
1344
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
1345
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1346
+ };
1347
+ imports.wbg.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68 = function(arg0) {
1348
+ const v = getObject(arg0);
1349
+ const ret = typeof(v) === 'boolean' ? v : undefined;
1350
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1351
+ };
1352
+ imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
1353
+ const ret = debugString(getObject(arg1));
1354
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1355
+ const len1 = WASM_VECTOR_LEN;
1356
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1357
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1358
+ };
1359
+ imports.wbg.__wbg___wbindgen_in_bb933bd9e1b3bc0f = function(arg0, arg1) {
1360
+ const ret = getObject(arg0) in getObject(arg1);
1361
+ return ret;
1362
+ };
1363
+ imports.wbg.__wbg___wbindgen_is_bigint_cb320707dcd35f0b = function(arg0) {
1364
+ const ret = typeof(getObject(arg0)) === 'bigint';
1365
+ return ret;
1366
+ };
1367
+ imports.wbg.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
1368
+ const ret = typeof(getObject(arg0)) === 'function';
1369
+ return ret;
1370
+ };
1371
+ imports.wbg.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
1372
+ const val = getObject(arg0);
1373
+ const ret = typeof(val) === 'object' && val !== null;
1374
+ return ret;
1375
+ };
1376
+ imports.wbg.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
1377
+ const ret = typeof(getObject(arg0)) === 'string';
1378
+ return ret;
1379
+ };
1380
+ imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
1381
+ const ret = getObject(arg0) === undefined;
1382
+ return ret;
1383
+ };
1384
+ imports.wbg.__wbg___wbindgen_jsval_eq_6b13ab83478b1c50 = function(arg0, arg1) {
1385
+ const ret = getObject(arg0) === getObject(arg1);
1386
+ return ret;
1387
+ };
1388
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_b664b38a2f582147 = function(arg0, arg1) {
1389
+ const ret = getObject(arg0) == getObject(arg1);
1390
+ return ret;
1391
+ };
1392
+ imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
1393
+ const obj = getObject(arg1);
1394
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1395
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
1396
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
1397
+ };
1398
+ imports.wbg.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) {
1399
+ const obj = getObject(arg1);
1400
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1401
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1402
+ var len1 = WASM_VECTOR_LEN;
1403
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1404
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1405
+ };
1406
+ imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
1407
+ throw new Error(getStringFromWasm0(arg0, arg1));
1408
+ };
1409
+ imports.wbg.__wbg__wbg_cb_unref_2454a539ea5790d9 = function(arg0) {
1410
+ getObject(arg0)._wbg_cb_unref();
1411
+ };
1412
+ imports.wbg.__wbg_abort_28ad55c5825b004d = function(arg0, arg1) {
1413
+ getObject(arg0).abort(getObject(arg1));
1414
+ };
1415
+ imports.wbg.__wbg_abort_e7eb059f72f9ed0c = function(arg0) {
1416
+ getObject(arg0).abort();
1417
+ };
1418
+ imports.wbg.__wbg_append_b577eb3a177bc0fa = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1419
+ getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
1420
+ }, arguments) };
1421
+ imports.wbg.__wbg_arrayBuffer_b375eccb84b4ddf3 = function() { return handleError(function (arg0) {
1422
+ const ret = getObject(arg0).arrayBuffer();
1423
+ return addHeapObject(ret);
1424
+ }, arguments) };
1425
+ imports.wbg.__wbg_call_525440f72fbfc0ea = function() { return handleError(function (arg0, arg1, arg2) {
1426
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1427
+ return addHeapObject(ret);
1428
+ }, arguments) };
1429
+ imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
1430
+ const ret = getObject(arg0).call(getObject(arg1));
1431
+ return addHeapObject(ret);
1432
+ }, arguments) };
1433
+ imports.wbg.__wbg_clearTimeout_7a42b49784aea641 = function(arg0) {
1434
+ const ret = clearTimeout(takeObject(arg0));
1435
+ return addHeapObject(ret);
1436
+ };
1437
+ imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
1438
+ const ret = getObject(arg0).crypto;
1439
+ return addHeapObject(ret);
1440
+ };
1441
+ imports.wbg.__wbg_done_2042aa2670fb1db1 = function(arg0) {
1442
+ const ret = getObject(arg0).done;
1443
+ return ret;
1444
+ };
1445
+ imports.wbg.__wbg_entries_e171b586f8f6bdbf = function(arg0) {
1446
+ const ret = Object.entries(getObject(arg0));
1447
+ return addHeapObject(ret);
1448
+ };
1449
+ imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
1450
+ let deferred0_0;
1451
+ let deferred0_1;
1452
+ try {
1453
+ deferred0_0 = arg0;
1454
+ deferred0_1 = arg1;
1455
+ console.error(getStringFromWasm0(arg0, arg1));
1456
+ } finally {
1457
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
1458
+ }
1459
+ };
1460
+ imports.wbg.__wbg_fetch_74a3e84ebd2c9a0e = function(arg0) {
1461
+ const ret = fetch(getObject(arg0));
1462
+ return addHeapObject(ret);
1463
+ };
1464
+ imports.wbg.__wbg_fetch_f8ba0e29a9d6de0d = function(arg0, arg1) {
1465
+ const ret = getObject(arg0).fetch(getObject(arg1));
1466
+ return addHeapObject(ret);
1467
+ };
1468
+ imports.wbg.__wbg_getRandomValues_38a1ff1ea09f6cc7 = function() { return handleError(function (arg0, arg1) {
1469
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
1470
+ }, arguments) };
1471
+ imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
1472
+ getObject(arg0).getRandomValues(getObject(arg1));
1473
+ }, arguments) };
1474
+ imports.wbg.__wbg_get_7bed016f185add81 = function(arg0, arg1) {
1475
+ const ret = getObject(arg0)[arg1 >>> 0];
1476
+ return addHeapObject(ret);
1477
+ };
1478
+ imports.wbg.__wbg_get_efcb449f58ec27c2 = function() { return handleError(function (arg0, arg1) {
1479
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
1480
+ return addHeapObject(ret);
1481
+ }, arguments) };
1482
+ imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
1483
+ const ret = getObject(arg0)[getObject(arg1)];
1484
+ return addHeapObject(ret);
1485
+ };
1486
+ imports.wbg.__wbg_has_787fafc980c3ccdb = function() { return handleError(function (arg0, arg1) {
1487
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
1488
+ return ret;
1489
+ }, arguments) };
1490
+ imports.wbg.__wbg_headers_b87d7eaba61c3278 = function(arg0) {
1491
+ const ret = getObject(arg0).headers;
1492
+ return addHeapObject(ret);
1493
+ };
1494
+ imports.wbg.__wbg_idkitrequest_new = function(arg0) {
1495
+ const ret = IDKitRequest.__wrap(arg0);
1496
+ return addHeapObject(ret);
1497
+ };
1498
+ imports.wbg.__wbg_instanceof_ArrayBuffer_70beb1189ca63b38 = function(arg0) {
1499
+ let result;
1500
+ try {
1501
+ result = getObject(arg0) instanceof ArrayBuffer;
1502
+ } catch (_) {
1503
+ result = false;
1504
+ }
1505
+ const ret = result;
1506
+ return ret;
1507
+ };
1508
+ imports.wbg.__wbg_instanceof_Map_8579b5e2ab5437c7 = function(arg0) {
1509
+ let result;
1510
+ try {
1511
+ result = getObject(arg0) instanceof Map;
1512
+ } catch (_) {
1513
+ result = false;
1514
+ }
1515
+ const ret = result;
1516
+ return ret;
1517
+ };
1518
+ imports.wbg.__wbg_instanceof_Response_f4f3e87e07f3135c = function(arg0) {
1519
+ let result;
1520
+ try {
1521
+ result = getObject(arg0) instanceof Response;
1522
+ } catch (_) {
1523
+ result = false;
1524
+ }
1525
+ const ret = result;
1526
+ return ret;
1527
+ };
1528
+ imports.wbg.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
1529
+ let result;
1530
+ try {
1531
+ result = getObject(arg0) instanceof Uint8Array;
1532
+ } catch (_) {
1533
+ result = false;
1534
+ }
1535
+ const ret = result;
1536
+ return ret;
1537
+ };
1538
+ imports.wbg.__wbg_isArray_96e0af9891d0945d = function(arg0) {
1539
+ const ret = Array.isArray(getObject(arg0));
1540
+ return ret;
1541
+ };
1542
+ imports.wbg.__wbg_isSafeInteger_d216eda7911dde36 = function(arg0) {
1543
+ const ret = Number.isSafeInteger(getObject(arg0));
1544
+ return ret;
1545
+ };
1546
+ imports.wbg.__wbg_iterator_e5822695327a3c39 = function() {
1547
+ const ret = Symbol.iterator;
1548
+ return addHeapObject(ret);
1549
+ };
1550
+ imports.wbg.__wbg_length_69bca3cb64fc8748 = function(arg0) {
1551
+ const ret = getObject(arg0).length;
1552
+ return ret;
1553
+ };
1554
+ imports.wbg.__wbg_length_cdd215e10d9dd507 = function(arg0) {
1555
+ const ret = getObject(arg0).length;
1556
+ return ret;
1557
+ };
1558
+ imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
1559
+ const ret = getObject(arg0).msCrypto;
1560
+ return addHeapObject(ret);
1561
+ };
1562
+ imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
1563
+ const ret = new Object();
1564
+ return addHeapObject(ret);
1565
+ };
1566
+ imports.wbg.__wbg_new_2531773dac38ebb3 = function() { return handleError(function () {
1567
+ const ret = new AbortController();
1568
+ return addHeapObject(ret);
1569
+ }, arguments) };
1570
+ imports.wbg.__wbg_new_3c3d849046688a66 = function(arg0, arg1) {
1571
+ try {
1572
+ var state0 = {a: arg0, b: arg1};
1573
+ var cb0 = (arg0, arg1) => {
1574
+ const a = state0.a;
1575
+ state0.a = 0;
1576
+ try {
1577
+ return __wasm_bindgen_func_elem_1238(a, state0.b, arg0, arg1);
1578
+ } finally {
1579
+ state0.a = a;
1580
+ }
1581
+ };
1582
+ const ret = new Promise(cb0);
1583
+ return addHeapObject(ret);
1584
+ } finally {
1585
+ state0.a = state0.b = 0;
1586
+ }
1587
+ };
1588
+ imports.wbg.__wbg_new_5a79be3ab53b8aa5 = function(arg0) {
1589
+ const ret = new Uint8Array(getObject(arg0));
1590
+ return addHeapObject(ret);
1591
+ };
1592
+ imports.wbg.__wbg_new_68651c719dcda04e = function() {
1593
+ const ret = new Map();
1594
+ return addHeapObject(ret);
1595
+ };
1596
+ imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
1597
+ const ret = new Error();
1598
+ return addHeapObject(ret);
1599
+ };
1600
+ imports.wbg.__wbg_new_9edf9838a2def39c = function() { return handleError(function () {
1601
+ const ret = new Headers();
1602
+ return addHeapObject(ret);
1603
+ }, arguments) };
1604
+ imports.wbg.__wbg_new_e17d9f43105b08be = function() {
1605
+ const ret = new Array();
1606
+ return addHeapObject(ret);
1607
+ };
1608
+ imports.wbg.__wbg_new_from_slice_92f4d78ca282a2d2 = function(arg0, arg1) {
1609
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1610
+ return addHeapObject(ret);
1611
+ };
1612
+ imports.wbg.__wbg_new_no_args_ee98eee5275000a4 = function(arg0, arg1) {
1613
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
1614
+ return addHeapObject(ret);
1615
+ };
1616
+ imports.wbg.__wbg_new_with_length_01aa0dc35aa13543 = function(arg0) {
1617
+ const ret = new Uint8Array(arg0 >>> 0);
1618
+ return addHeapObject(ret);
1619
+ };
1620
+ imports.wbg.__wbg_new_with_str_and_init_0ae7728b6ec367b1 = function() { return handleError(function (arg0, arg1, arg2) {
1621
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
1622
+ return addHeapObject(ret);
1623
+ }, arguments) };
1624
+ imports.wbg.__wbg_next_020810e0ae8ebcb0 = function() { return handleError(function (arg0) {
1625
+ const ret = getObject(arg0).next();
1626
+ return addHeapObject(ret);
1627
+ }, arguments) };
1628
+ imports.wbg.__wbg_next_2c826fe5dfec6b6a = function(arg0) {
1629
+ const ret = getObject(arg0).next;
1630
+ return addHeapObject(ret);
1631
+ };
1632
+ imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) {
1633
+ const ret = getObject(arg0).node;
1634
+ return addHeapObject(ret);
1635
+ };
1636
+ imports.wbg.__wbg_now_793306c526e2e3b6 = function() {
1637
+ const ret = Date.now();
1638
+ return ret;
1639
+ };
1640
+ imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
1641
+ const ret = getObject(arg0).process;
1642
+ return addHeapObject(ret);
1643
+ };
1644
+ imports.wbg.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
1645
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1646
+ };
1647
+ imports.wbg.__wbg_queueMicrotask_34d692c25c47d05b = function(arg0) {
1648
+ const ret = getObject(arg0).queueMicrotask;
1649
+ return addHeapObject(ret);
1650
+ };
1651
+ imports.wbg.__wbg_queueMicrotask_9d76cacb20c84d58 = function(arg0) {
1652
+ queueMicrotask(getObject(arg0));
1653
+ };
1654
+ imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
1655
+ getObject(arg0).randomFillSync(takeObject(arg1));
1656
+ }, arguments) };
1657
+ imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
1658
+ const ret = module.require;
1659
+ return addHeapObject(ret);
1660
+ }, arguments) };
1661
+ imports.wbg.__wbg_resolve_caf97c30b83f7053 = function(arg0) {
1662
+ const ret = Promise.resolve(getObject(arg0));
1663
+ return addHeapObject(ret);
1664
+ };
1665
+ imports.wbg.__wbg_setTimeout_7bb3429662ab1e70 = function(arg0, arg1) {
1666
+ const ret = setTimeout(getObject(arg0), arg1);
1667
+ return addHeapObject(ret);
1668
+ };
1669
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
1670
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1671
+ };
1672
+ imports.wbg.__wbg_set_907fb406c34a251d = function(arg0, arg1, arg2) {
1673
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
1674
+ return addHeapObject(ret);
1675
+ };
1676
+ imports.wbg.__wbg_set_body_3c365989753d61f4 = function(arg0, arg1) {
1677
+ getObject(arg0).body = getObject(arg1);
1678
+ };
1679
+ imports.wbg.__wbg_set_c213c871859d6500 = function(arg0, arg1, arg2) {
1680
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1681
+ };
1682
+ imports.wbg.__wbg_set_c2abbebe8b9ebee1 = function() { return handleError(function (arg0, arg1, arg2) {
1683
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1684
+ return ret;
1685
+ }, arguments) };
1686
+ imports.wbg.__wbg_set_cache_2f9deb19b92b81e3 = function(arg0, arg1) {
1687
+ getObject(arg0).cache = __wbindgen_enum_RequestCache[arg1];
1688
+ };
1689
+ imports.wbg.__wbg_set_credentials_f621cd2d85c0c228 = function(arg0, arg1) {
1690
+ getObject(arg0).credentials = __wbindgen_enum_RequestCredentials[arg1];
1691
+ };
1692
+ imports.wbg.__wbg_set_headers_6926da238cd32ee4 = function(arg0, arg1) {
1693
+ getObject(arg0).headers = getObject(arg1);
1694
+ };
1695
+ imports.wbg.__wbg_set_method_c02d8cbbe204ac2d = function(arg0, arg1, arg2) {
1696
+ getObject(arg0).method = getStringFromWasm0(arg1, arg2);
1697
+ };
1698
+ imports.wbg.__wbg_set_mode_52ef73cfa79639cb = function(arg0, arg1) {
1699
+ getObject(arg0).mode = __wbindgen_enum_RequestMode[arg1];
1700
+ };
1701
+ imports.wbg.__wbg_set_signal_dda2cf7ccb6bee0f = function(arg0, arg1) {
1702
+ getObject(arg0).signal = getObject(arg1);
1703
+ };
1704
+ imports.wbg.__wbg_signal_4db5aa055bf9eb9a = function(arg0) {
1705
+ const ret = getObject(arg0).signal;
1706
+ return addHeapObject(ret);
1707
+ };
1708
+ imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
1709
+ const ret = getObject(arg1).stack;
1710
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1711
+ const len1 = WASM_VECTOR_LEN;
1712
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1713
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1714
+ };
1715
+ imports.wbg.__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e = function() {
1716
+ const ret = typeof global === 'undefined' ? null : global;
1717
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1718
+ };
1719
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac = function() {
1720
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
1721
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1722
+ };
1723
+ imports.wbg.__wbg_static_accessor_SELF_6fdf4b64710cc91b = function() {
1724
+ const ret = typeof self === 'undefined' ? null : self;
1725
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1726
+ };
1727
+ imports.wbg.__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2 = function() {
1728
+ const ret = typeof window === 'undefined' ? null : window;
1729
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1730
+ };
1731
+ imports.wbg.__wbg_status_de7eed5a7a5bfd5d = function(arg0) {
1732
+ const ret = getObject(arg0).status;
1733
+ return ret;
1734
+ };
1735
+ imports.wbg.__wbg_stringify_b5fb28f6465d9c3e = function() { return handleError(function (arg0) {
1736
+ const ret = JSON.stringify(getObject(arg0));
1737
+ return addHeapObject(ret);
1738
+ }, arguments) };
1739
+ imports.wbg.__wbg_subarray_480600f3d6a9f26c = function(arg0, arg1, arg2) {
1740
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
1741
+ return addHeapObject(ret);
1742
+ };
1743
+ imports.wbg.__wbg_text_dc33c15c17bdfb52 = function() { return handleError(function (arg0) {
1744
+ const ret = getObject(arg0).text();
1745
+ return addHeapObject(ret);
1746
+ }, arguments) };
1747
+ imports.wbg.__wbg_then_4f46f6544e6b4a28 = function(arg0, arg1) {
1748
+ const ret = getObject(arg0).then(getObject(arg1));
1749
+ return addHeapObject(ret);
1750
+ };
1751
+ imports.wbg.__wbg_then_70d05cf780a18d77 = function(arg0, arg1, arg2) {
1752
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
1753
+ return addHeapObject(ret);
1754
+ };
1755
+ imports.wbg.__wbg_url_b36d2a5008eb056f = function(arg0, arg1) {
1756
+ const ret = getObject(arg1).url;
1757
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1758
+ const len1 = WASM_VECTOR_LEN;
1759
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1760
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1761
+ };
1762
+ imports.wbg.__wbg_value_692627309814bb8c = function(arg0) {
1763
+ const ret = getObject(arg0).value;
1764
+ return addHeapObject(ret);
1765
+ };
1766
+ imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) {
1767
+ const ret = getObject(arg0).versions;
1768
+ return addHeapObject(ret);
1769
+ };
1770
+ imports.wbg.__wbindgen_cast_20b7882efa3c21d9 = function(arg0, arg1) {
1771
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 190, function: Function { arguments: [Externref], shim_idx: 191, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1772
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_872, __wasm_bindgen_func_elem_873);
1773
+ return addHeapObject(ret);
1774
+ };
1775
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
1776
+ // Cast intrinsic for `Ref(String) -> Externref`.
1777
+ const ret = getStringFromWasm0(arg0, arg1);
1778
+ return addHeapObject(ret);
1779
+ };
1780
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
1781
+ // Cast intrinsic for `U64 -> Externref`.
1782
+ const ret = BigInt.asUintN(64, arg0);
1783
+ return addHeapObject(ret);
1784
+ };
1785
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
1786
+ // Cast intrinsic for `I64 -> Externref`.
1787
+ const ret = arg0;
1788
+ return addHeapObject(ret);
1789
+ };
1790
+ imports.wbg.__wbindgen_cast_c84362f2a853c6d7 = function(arg0, arg1) {
1791
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 131, function: Function { arguments: [], shim_idx: 132, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1792
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_509, __wasm_bindgen_func_elem_510);
1793
+ return addHeapObject(ret);
1794
+ };
1795
+ imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
1796
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1797
+ const ret = getArrayU8FromWasm0(arg0, arg1);
1798
+ return addHeapObject(ret);
1799
+ };
1800
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1801
+ // Cast intrinsic for `F64 -> Externref`.
1802
+ const ret = arg0;
1803
+ return addHeapObject(ret);
1804
+ };
1805
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
1806
+ const ret = getObject(arg0);
1807
+ return addHeapObject(ret);
1808
+ };
1809
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1810
+ takeObject(arg0);
1811
+ };
1812
+
1813
+ return imports;
1814
+ }
1815
+
1816
+ function __wbg_finalize_init(instance, module) {
1817
+ wasm = instance.exports;
1818
+ __wbg_init.__wbindgen_wasm_module = module;
1819
+ cachedDataViewMemory0 = null;
1820
+ cachedUint8ArrayMemory0 = null;
1821
+
1822
+
1823
+ wasm.__wbindgen_start();
1824
+ return wasm;
1825
+ }
1826
+
1827
+ function initSync(module) {
1828
+ if (wasm !== undefined) return wasm;
1829
+
1830
+
1831
+ if (typeof module !== 'undefined') {
1832
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1833
+ ({module} = module)
1834
+ } else {
1835
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1836
+ }
1837
+ }
1838
+
1839
+ const imports = __wbg_get_imports();
1840
+
1841
+ if (!(module instanceof WebAssembly.Module)) {
1842
+ module = new WebAssembly.Module(module);
1843
+ }
1844
+
1845
+ const instance = new WebAssembly.Instance(module, imports);
1846
+
1847
+ return __wbg_finalize_init(instance, module);
1848
+ }
1849
+
1850
+ async function __wbg_init(module_or_path) {
1851
+ if (wasm !== undefined) return wasm;
1852
+
1853
+
1854
+ if (typeof module_or_path !== 'undefined') {
1855
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1856
+ ({module_or_path} = module_or_path)
1857
+ } else {
1858
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1859
+ }
1860
+ }
1861
+
1862
+ if (typeof module_or_path === 'undefined') {
1863
+ module_or_path = new URL('idkit_wasm_bg.wasm', import.meta.url);
1864
+ }
1865
+ const imports = __wbg_get_imports();
1866
+
1867
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1868
+ module_or_path = fetch(module_or_path);
1869
+ }
1870
+
1871
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1872
+
1873
+ return __wbg_finalize_init(instance, module);
1874
+ }
1875
+
1876
+ export { initSync };
1877
+ export default __wbg_init;