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