@worldcoin/idkit-core 4.0.1-dev.eebacb1 → 4.0.1
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 +64 -149
- package/dist/idkit_wasm_bg.wasm +0 -0
- package/dist/index.cjs +395 -268
- package/dist/index.d.cts +418 -92
- package/dist/index.d.ts +418 -92
- package/dist/index.js +391 -265
- 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,12 @@ 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 request(app_id, action, rp_context, action_description, bridge_url) {
|
|
248
|
+
function request(app_id, action, rp_context, action_description, bridge_url, allow_legacy_proofs, override_connect_base_url, environment) {
|
|
302
249
|
const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
303
250
|
const len0 = WASM_VECTOR_LEN;
|
|
304
251
|
const ptr1 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -309,28 +256,75 @@ function request(app_id, action, rp_context, action_description, bridge_url) {
|
|
|
309
256
|
var len3 = WASM_VECTOR_LEN;
|
|
310
257
|
var ptr4 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
311
258
|
var len4 = WASM_VECTOR_LEN;
|
|
312
|
-
|
|
313
|
-
|
|
259
|
+
var ptr5 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
260
|
+
var len5 = WASM_VECTOR_LEN;
|
|
261
|
+
var ptr6 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
262
|
+
var len6 = WASM_VECTOR_LEN;
|
|
263
|
+
const ret = wasm.idkitbuilder_new(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4, allow_legacy_proofs, ptr5, len5, ptr6, len6);
|
|
264
|
+
return IDKitBuilder.__wrap(ret);
|
|
314
265
|
}
|
|
315
|
-
function
|
|
266
|
+
function init_wasm() {
|
|
267
|
+
wasm.init_wasm();
|
|
268
|
+
}
|
|
269
|
+
function base64Decode(data) {
|
|
316
270
|
try {
|
|
317
271
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
wasm.
|
|
272
|
+
const ptr0 = passStringToWasm0(data, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
273
|
+
const len0 = WASM_VECTOR_LEN;
|
|
274
|
+
wasm.base64Decode(retptr, ptr0, len0);
|
|
321
275
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
322
276
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
323
277
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
324
|
-
|
|
325
|
-
|
|
278
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
279
|
+
if (r3) {
|
|
280
|
+
throw takeObject(r2);
|
|
326
281
|
}
|
|
327
|
-
|
|
282
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
283
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
284
|
+
return v2;
|
|
328
285
|
} finally {
|
|
329
286
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
330
287
|
}
|
|
331
288
|
}
|
|
332
|
-
function
|
|
333
|
-
wasm.
|
|
289
|
+
function proveSession(session_id, app_id, rp_context, action_description, bridge_url, override_connect_base_url, environment) {
|
|
290
|
+
const ptr0 = passStringToWasm0(session_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
291
|
+
const len0 = WASM_VECTOR_LEN;
|
|
292
|
+
const ptr1 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
293
|
+
const len1 = WASM_VECTOR_LEN;
|
|
294
|
+
_assertClass(rp_context, RpContextWasm);
|
|
295
|
+
var ptr2 = rp_context.__destroy_into_raw();
|
|
296
|
+
var ptr3 = isLikeNone(action_description) ? 0 : passStringToWasm0(action_description, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
297
|
+
var len3 = WASM_VECTOR_LEN;
|
|
298
|
+
var ptr4 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
299
|
+
var len4 = WASM_VECTOR_LEN;
|
|
300
|
+
var ptr5 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
301
|
+
var len5 = WASM_VECTOR_LEN;
|
|
302
|
+
var ptr6 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
303
|
+
var len6 = WASM_VECTOR_LEN;
|
|
304
|
+
const ret = wasm.idkitbuilder_forProveSession(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
|
|
305
|
+
return IDKitBuilder.__wrap(ret);
|
|
306
|
+
}
|
|
307
|
+
function createSession(app_id, rp_context, action_description, bridge_url, override_connect_base_url, environment) {
|
|
308
|
+
const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
309
|
+
const len0 = WASM_VECTOR_LEN;
|
|
310
|
+
_assertClass(rp_context, RpContextWasm);
|
|
311
|
+
var ptr1 = rp_context.__destroy_into_raw();
|
|
312
|
+
var ptr2 = isLikeNone(action_description) ? 0 : passStringToWasm0(action_description, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
313
|
+
var len2 = WASM_VECTOR_LEN;
|
|
314
|
+
var ptr3 = isLikeNone(bridge_url) ? 0 : passStringToWasm0(bridge_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
315
|
+
var len3 = WASM_VECTOR_LEN;
|
|
316
|
+
var ptr4 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
317
|
+
var len4 = WASM_VECTOR_LEN;
|
|
318
|
+
var ptr5 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
319
|
+
var len5 = WASM_VECTOR_LEN;
|
|
320
|
+
const ret = wasm.createSession(ptr0, len0, ptr1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5);
|
|
321
|
+
return IDKitBuilder.__wrap(ret);
|
|
322
|
+
}
|
|
323
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
324
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
325
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
326
|
+
WASM_VECTOR_LEN = arg.length;
|
|
327
|
+
return ptr;
|
|
334
328
|
}
|
|
335
329
|
function base64Encode(data) {
|
|
336
330
|
let deferred2_0;
|
|
@@ -350,24 +344,29 @@ function base64Encode(data) {
|
|
|
350
344
|
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
351
345
|
}
|
|
352
346
|
}
|
|
353
|
-
function
|
|
347
|
+
function hashSignal(signal) {
|
|
348
|
+
let deferred2_0;
|
|
349
|
+
let deferred2_1;
|
|
354
350
|
try {
|
|
355
351
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
356
|
-
|
|
357
|
-
const len0 = WASM_VECTOR_LEN;
|
|
358
|
-
wasm.base64Decode(retptr, ptr0, len0);
|
|
352
|
+
wasm.hashSignal(retptr, addHeapObject(signal));
|
|
359
353
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
360
354
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
361
355
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
362
356
|
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
357
|
+
var ptr1 = r0;
|
|
358
|
+
var len1 = r1;
|
|
363
359
|
if (r3) {
|
|
360
|
+
ptr1 = 0;
|
|
361
|
+
len1 = 0;
|
|
364
362
|
throw takeObject(r2);
|
|
365
363
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return
|
|
364
|
+
deferred2_0 = ptr1;
|
|
365
|
+
deferred2_1 = len1;
|
|
366
|
+
return getStringFromWasm0(ptr1, len1);
|
|
369
367
|
} finally {
|
|
370
368
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
369
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
371
370
|
}
|
|
372
371
|
}
|
|
373
372
|
function signRequest(action, signing_key_hex, ttl_seconds) {
|
|
@@ -389,14 +388,14 @@ function signRequest(action, signing_key_hex, ttl_seconds) {
|
|
|
389
388
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
390
389
|
}
|
|
391
390
|
}
|
|
392
|
-
function
|
|
393
|
-
wasm.
|
|
391
|
+
function __wasm_bindgen_func_elem_960(arg0, arg1, arg2) {
|
|
392
|
+
wasm.__wasm_bindgen_func_elem_960(arg0, arg1, addHeapObject(arg2));
|
|
394
393
|
}
|
|
395
|
-
function
|
|
396
|
-
wasm.
|
|
394
|
+
function __wasm_bindgen_func_elem_597(arg0, arg1) {
|
|
395
|
+
wasm.__wasm_bindgen_func_elem_597(arg0, arg1);
|
|
397
396
|
}
|
|
398
|
-
function
|
|
399
|
-
wasm.
|
|
397
|
+
function __wasm_bindgen_func_elem_1343(arg0, arg1, arg2, arg3) {
|
|
398
|
+
wasm.__wasm_bindgen_func_elem_1343(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_1343(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) {
|
|
@@ -1793,24 +1853,26 @@ var IDKitRequestImpl = class {
|
|
|
1793
1853
|
async pollOnce() {
|
|
1794
1854
|
return await this.wasmRequest.pollForStatus();
|
|
1795
1855
|
}
|
|
1796
|
-
async
|
|
1856
|
+
async pollUntilCompletion(options) {
|
|
1797
1857
|
const pollInterval = options?.pollInterval ?? 1e3;
|
|
1798
1858
|
const timeout = options?.timeout ?? 3e5;
|
|
1799
1859
|
const startTime = Date.now();
|
|
1800
1860
|
while (true) {
|
|
1801
1861
|
if (options?.signal?.aborted) {
|
|
1802
|
-
|
|
1862
|
+
return { success: false, error: "cancelled" /* Cancelled */ };
|
|
1803
1863
|
}
|
|
1804
1864
|
if (Date.now() - startTime > timeout) {
|
|
1805
|
-
|
|
1865
|
+
return { success: false, error: "timeout" /* Timeout */ };
|
|
1806
1866
|
}
|
|
1807
1867
|
const status = await this.pollOnce();
|
|
1808
|
-
if (status.type === "confirmed" && status.
|
|
1809
|
-
return status.
|
|
1868
|
+
if (status.type === "confirmed" && status.result) {
|
|
1869
|
+
return { success: true, result: status.result };
|
|
1810
1870
|
}
|
|
1811
1871
|
if (status.type === "failed") {
|
|
1812
|
-
|
|
1813
|
-
|
|
1872
|
+
return {
|
|
1873
|
+
success: false,
|
|
1874
|
+
error: status.error ?? "generic_error" /* GenericError */
|
|
1875
|
+
};
|
|
1814
1876
|
}
|
|
1815
1877
|
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
1816
1878
|
}
|
|
@@ -1820,7 +1882,8 @@ function CredentialRequest(credential_type, options) {
|
|
|
1820
1882
|
return {
|
|
1821
1883
|
type: credential_type,
|
|
1822
1884
|
signal: options?.signal,
|
|
1823
|
-
genesis_issued_at_min: options?.genesis_issued_at_min
|
|
1885
|
+
genesis_issued_at_min: options?.genesis_issued_at_min,
|
|
1886
|
+
expires_at_min: options?.expires_at_min
|
|
1824
1887
|
};
|
|
1825
1888
|
}
|
|
1826
1889
|
function any(...nodes) {
|
|
@@ -1829,12 +1892,18 @@ function any(...nodes) {
|
|
|
1829
1892
|
function all(...nodes) {
|
|
1830
1893
|
return { all: nodes };
|
|
1831
1894
|
}
|
|
1832
|
-
function
|
|
1833
|
-
return { type: "OrbLegacy",
|
|
1895
|
+
function orbLegacy(opts = {}) {
|
|
1896
|
+
return { type: "OrbLegacy", signal: opts.signal };
|
|
1834
1897
|
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1898
|
+
function secureDocumentLegacy(opts = {}) {
|
|
1899
|
+
return { type: "SecureDocumentLegacy", signal: opts.signal };
|
|
1900
|
+
}
|
|
1901
|
+
function documentLegacy(opts = {}) {
|
|
1902
|
+
return { type: "DocumentLegacy", signal: opts.signal };
|
|
1903
|
+
}
|
|
1904
|
+
var IDKitBuilder2 = class {
|
|
1905
|
+
constructor(wasmBuilder) {
|
|
1906
|
+
this.wasmBuilder = wasmBuilder;
|
|
1838
1907
|
}
|
|
1839
1908
|
/**
|
|
1840
1909
|
* Creates an IDKit request with the given constraints
|
|
@@ -1844,64 +1913,36 @@ var IDKitRequestBuilder = class {
|
|
|
1844
1913
|
*
|
|
1845
1914
|
* @example
|
|
1846
1915
|
* ```typescript
|
|
1847
|
-
* const
|
|
1848
|
-
*
|
|
1916
|
+
* const builder = await IDKit.request({ app_id, action, rp_context });
|
|
1917
|
+
* const request = await builder.constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
1849
1918
|
* ```
|
|
1850
1919
|
*/
|
|
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
|
-
}
|
|
1920
|
+
//TODO: re-enable once this is supported and World ID 4.0 is rolled out live
|
|
1921
|
+
// async constraints(constraints: ConstraintNode): Promise<IDKitRequest> {
|
|
1922
|
+
// await initIDKit();
|
|
1923
|
+
// const wasmRequest = (await this.wasmBuilder.constraints(
|
|
1924
|
+
// constraints,
|
|
1925
|
+
// )) as unknown as WasmModule.IDKitRequest;
|
|
1926
|
+
// return new IDKitRequestImpl(wasmRequest);
|
|
1927
|
+
// }
|
|
1872
1928
|
/**
|
|
1873
|
-
* Creates an IDKit request from a preset
|
|
1929
|
+
* Creates an IDKit request from a preset (works for all request types)
|
|
1874
1930
|
*
|
|
1875
1931
|
* 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.
|
|
1932
|
+
* credential configurations.
|
|
1878
1933
|
*
|
|
1879
1934
|
* @param preset - A preset object from orbLegacy()
|
|
1880
1935
|
* @returns A new IDKitRequest instance
|
|
1881
1936
|
*
|
|
1882
1937
|
* @example
|
|
1883
1938
|
* ```typescript
|
|
1884
|
-
* const
|
|
1885
|
-
*
|
|
1939
|
+
* const builder = await IDKit.request({ app_id, action, rp_context });
|
|
1940
|
+
* const request = await builder.preset(orbLegacy({ signal: 'user-123' }));
|
|
1886
1941
|
* ```
|
|
1887
1942
|
*/
|
|
1888
1943
|
async preset(preset) {
|
|
1889
1944
|
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(
|
|
1945
|
+
const wasmRequest = await this.wasmBuilder.preset(
|
|
1905
1946
|
preset
|
|
1906
1947
|
);
|
|
1907
1948
|
return new IDKitRequestImpl(wasmRequest);
|
|
@@ -1917,7 +1958,81 @@ function createRequest(config) {
|
|
|
1917
1958
|
if (!config.rp_context) {
|
|
1918
1959
|
throw new Error("rp_context is required");
|
|
1919
1960
|
}
|
|
1920
|
-
|
|
1961
|
+
if (typeof config.allow_legacy_proofs !== "boolean") {
|
|
1962
|
+
throw new Error(
|
|
1963
|
+
"allow_legacy_proofs is required. Set to true to accept v3 proofs during migration, or false to only accept v4 proofs."
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
const rpContext = new idkit_wasm_exports.RpContextWasm(
|
|
1967
|
+
config.rp_context.rp_id,
|
|
1968
|
+
config.rp_context.nonce,
|
|
1969
|
+
BigInt(config.rp_context.created_at),
|
|
1970
|
+
BigInt(config.rp_context.expires_at),
|
|
1971
|
+
config.rp_context.signature
|
|
1972
|
+
);
|
|
1973
|
+
const wasmBuilder = idkit_wasm_exports.request(
|
|
1974
|
+
config.app_id,
|
|
1975
|
+
String(config.action),
|
|
1976
|
+
rpContext,
|
|
1977
|
+
config.action_description ?? null,
|
|
1978
|
+
config.bridge_url ?? null,
|
|
1979
|
+
config.allow_legacy_proofs,
|
|
1980
|
+
config.override_connect_base_url ?? null,
|
|
1981
|
+
config.environment ?? null
|
|
1982
|
+
);
|
|
1983
|
+
return new IDKitBuilder2(wasmBuilder);
|
|
1984
|
+
}
|
|
1985
|
+
function createSession2(config) {
|
|
1986
|
+
if (!config.app_id) {
|
|
1987
|
+
throw new Error("app_id is required");
|
|
1988
|
+
}
|
|
1989
|
+
if (!config.rp_context) {
|
|
1990
|
+
throw new Error("rp_context is required");
|
|
1991
|
+
}
|
|
1992
|
+
const rpContext = new idkit_wasm_exports.RpContextWasm(
|
|
1993
|
+
config.rp_context.rp_id,
|
|
1994
|
+
config.rp_context.nonce,
|
|
1995
|
+
BigInt(config.rp_context.created_at),
|
|
1996
|
+
BigInt(config.rp_context.expires_at),
|
|
1997
|
+
config.rp_context.signature
|
|
1998
|
+
);
|
|
1999
|
+
const wasmBuilder = idkit_wasm_exports.createSession(
|
|
2000
|
+
config.app_id,
|
|
2001
|
+
rpContext,
|
|
2002
|
+
config.action_description ?? null,
|
|
2003
|
+
config.bridge_url ?? null,
|
|
2004
|
+
config.override_connect_base_url ?? null,
|
|
2005
|
+
config.environment ?? null
|
|
2006
|
+
);
|
|
2007
|
+
return new IDKitBuilder2(wasmBuilder);
|
|
2008
|
+
}
|
|
2009
|
+
function proveSession2(sessionId, config) {
|
|
2010
|
+
if (!sessionId) {
|
|
2011
|
+
throw new Error("session_id is required");
|
|
2012
|
+
}
|
|
2013
|
+
if (!config.app_id) {
|
|
2014
|
+
throw new Error("app_id is required");
|
|
2015
|
+
}
|
|
2016
|
+
if (!config.rp_context) {
|
|
2017
|
+
throw new Error("rp_context is required");
|
|
2018
|
+
}
|
|
2019
|
+
const rpContext = new idkit_wasm_exports.RpContextWasm(
|
|
2020
|
+
config.rp_context.rp_id,
|
|
2021
|
+
config.rp_context.nonce,
|
|
2022
|
+
BigInt(config.rp_context.created_at),
|
|
2023
|
+
BigInt(config.rp_context.expires_at),
|
|
2024
|
+
config.rp_context.signature
|
|
2025
|
+
);
|
|
2026
|
+
const wasmBuilder = idkit_wasm_exports.proveSession(
|
|
2027
|
+
sessionId,
|
|
2028
|
+
config.app_id,
|
|
2029
|
+
rpContext,
|
|
2030
|
+
config.action_description ?? null,
|
|
2031
|
+
config.bridge_url ?? null,
|
|
2032
|
+
config.override_connect_base_url ?? null,
|
|
2033
|
+
config.environment ?? null
|
|
2034
|
+
);
|
|
2035
|
+
return new IDKitBuilder2(wasmBuilder);
|
|
1921
2036
|
}
|
|
1922
2037
|
var IDKit = {
|
|
1923
2038
|
/** Initialize WASM for browser environments */
|
|
@@ -1926,6 +2041,10 @@ var IDKit = {
|
|
|
1926
2041
|
initServer: initIDKitServer,
|
|
1927
2042
|
/** Create a new verification request */
|
|
1928
2043
|
request: createRequest,
|
|
2044
|
+
/** Create a new session (no action, no existing session_id) */
|
|
2045
|
+
createSession: createSession2,
|
|
2046
|
+
/** Prove an existing session (no action, has session_id) */
|
|
2047
|
+
proveSession: proveSession2,
|
|
1929
2048
|
/** Create a CredentialRequest for a credential type */
|
|
1930
2049
|
CredentialRequest,
|
|
1931
2050
|
/** Create an OR constraint - at least one child must be satisfied */
|
|
@@ -1933,7 +2052,11 @@ var IDKit = {
|
|
|
1933
2052
|
/** Create an AND constraint - all children must be satisfied */
|
|
1934
2053
|
all,
|
|
1935
2054
|
/** Create an OrbLegacy preset for World ID 3.0 legacy support */
|
|
1936
|
-
orbLegacy
|
|
2055
|
+
orbLegacy,
|
|
2056
|
+
/** Create a SecureDocumentLegacy preset for World ID 3.0 legacy support */
|
|
2057
|
+
secureDocumentLegacy,
|
|
2058
|
+
/** Create a DocumentLegacy preset for World ID 3.0 legacy support */
|
|
2059
|
+
documentLegacy
|
|
1937
2060
|
};
|
|
1938
2061
|
|
|
1939
2062
|
// src/lib/platform.ts
|
|
@@ -1970,17 +2093,21 @@ function signRequest2(action, signingKeyHex, ttlSeconds) {
|
|
|
1970
2093
|
return idkit_wasm_exports.signRequest(action, signingKeyHex, ttlBigInt);
|
|
1971
2094
|
}
|
|
1972
2095
|
|
|
1973
|
-
|
|
2096
|
+
// src/lib/hashing.ts
|
|
2097
|
+
function hashSignal2(signal) {
|
|
2098
|
+
return idkit_wasm_exports.hashSignal(signal);
|
|
2099
|
+
}
|
|
2100
|
+
|
|
1974
2101
|
exports.CredentialRequest = CredentialRequest;
|
|
1975
2102
|
exports.IDKit = IDKit;
|
|
1976
|
-
exports.
|
|
1977
|
-
exports.VerificationState = VerificationState;
|
|
2103
|
+
exports.IDKitErrorCodes = IDKitErrorCodes;
|
|
1978
2104
|
exports.all = all;
|
|
1979
2105
|
exports.any = any;
|
|
2106
|
+
exports.documentLegacy = documentLegacy;
|
|
2107
|
+
exports.hashSignal = hashSignal2;
|
|
1980
2108
|
exports.isNode = isNode;
|
|
1981
2109
|
exports.isReactNative = isReactNative;
|
|
1982
2110
|
exports.isWeb = isWeb;
|
|
1983
|
-
exports.orbLegacy =
|
|
2111
|
+
exports.orbLegacy = orbLegacy;
|
|
2112
|
+
exports.secureDocumentLegacy = secureDocumentLegacy;
|
|
1984
2113
|
exports.signRequest = signRequest2;
|
|
1985
|
-
//# sourceMappingURL=index.cjs.map
|
|
1986
|
-
//# sourceMappingURL=index.cjs.map
|