@worldcoin/idkit-core 4.0.15 → 4.1.0
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 +9 -5
- package/dist/idkit_wasm_bg.wasm +0 -0
- package/dist/index.cjs +210 -71
- package/dist/index.d.cts +149 -7
- package/dist/index.d.ts +149 -7
- package/dist/index.js +205 -72
- package/dist/session.cjs +10 -0
- package/dist/session.d.cts +1 -0
- package/dist/session.d.ts +1 -0
- package/dist/session.js +1 -0
- package/dist/signing.d.cts +1 -1
- package/dist/signing.d.ts +1 -1
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -3,9 +3,9 @@ import { keccak_256 } from '@noble/hashes/sha3';
|
|
|
3
3
|
import { hexToBytes, bytesToHex } from '@noble/hashes/utils';
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
|
-
var __export = (target,
|
|
7
|
-
for (var name in
|
|
8
|
-
__defProp(target, name, { get:
|
|
6
|
+
var __export = (target, all2) => {
|
|
7
|
+
for (var name in all2)
|
|
8
|
+
__defProp(target, name, { get: all2[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
// src/types/result.ts
|
|
@@ -419,10 +419,11 @@ var IDKitBuilder = class _IDKitBuilder {
|
|
|
419
419
|
* @param {string | null} [action_description]
|
|
420
420
|
* @param {string | null} [bridge_url]
|
|
421
421
|
* @param {string | null} [override_connect_base_url]
|
|
422
|
+
* @param {string | null} [return_to]
|
|
422
423
|
* @param {string | null} [environment]
|
|
423
424
|
* @returns {IDKitBuilder}
|
|
424
425
|
*/
|
|
425
|
-
static forCreateSession(app_id, rp_context, action_description, bridge_url, override_connect_base_url, environment) {
|
|
426
|
+
static forCreateSession(app_id, rp_context, action_description, bridge_url, override_connect_base_url, return_to, environment) {
|
|
426
427
|
const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
427
428
|
const len0 = WASM_VECTOR_LEN;
|
|
428
429
|
_assertClass(rp_context, RpContextWasm);
|
|
@@ -433,9 +434,11 @@ var IDKitBuilder = class _IDKitBuilder {
|
|
|
433
434
|
var len3 = WASM_VECTOR_LEN;
|
|
434
435
|
var ptr4 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
435
436
|
var len4 = WASM_VECTOR_LEN;
|
|
436
|
-
var ptr5 = isLikeNone(
|
|
437
|
+
var ptr5 = isLikeNone(return_to) ? 0 : passStringToWasm0(return_to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
437
438
|
var len5 = WASM_VECTOR_LEN;
|
|
438
|
-
|
|
439
|
+
var ptr6 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
440
|
+
var len6 = WASM_VECTOR_LEN;
|
|
441
|
+
const ret = wasm.idkitbuilder_forCreateSession(ptr0, len0, ptr1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
|
|
439
442
|
return _IDKitBuilder.__wrap(ret);
|
|
440
443
|
}
|
|
441
444
|
/**
|
|
@@ -446,10 +449,11 @@ var IDKitBuilder = class _IDKitBuilder {
|
|
|
446
449
|
* @param {string | null} [action_description]
|
|
447
450
|
* @param {string | null} [bridge_url]
|
|
448
451
|
* @param {string | null} [override_connect_base_url]
|
|
452
|
+
* @param {string | null} [return_to]
|
|
449
453
|
* @param {string | null} [environment]
|
|
450
454
|
* @returns {IDKitBuilder}
|
|
451
455
|
*/
|
|
452
|
-
static forProveSession(session_id, app_id, rp_context, action_description, bridge_url, override_connect_base_url, environment) {
|
|
456
|
+
static forProveSession(session_id, app_id, rp_context, action_description, bridge_url, override_connect_base_url, return_to, environment) {
|
|
453
457
|
const ptr0 = passStringToWasm0(session_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
454
458
|
const len0 = WASM_VECTOR_LEN;
|
|
455
459
|
const ptr1 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -462,9 +466,11 @@ var IDKitBuilder = class _IDKitBuilder {
|
|
|
462
466
|
var len4 = WASM_VECTOR_LEN;
|
|
463
467
|
var ptr5 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
464
468
|
var len5 = WASM_VECTOR_LEN;
|
|
465
|
-
var ptr6 = isLikeNone(
|
|
469
|
+
var ptr6 = isLikeNone(return_to) ? 0 : passStringToWasm0(return_to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
466
470
|
var len6 = WASM_VECTOR_LEN;
|
|
467
|
-
|
|
471
|
+
var ptr7 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
472
|
+
var len7 = WASM_VECTOR_LEN;
|
|
473
|
+
const ret = wasm.idkitbuilder_forProveSession(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
|
|
468
474
|
return _IDKitBuilder.__wrap(ret);
|
|
469
475
|
}
|
|
470
476
|
/**
|
|
@@ -527,8 +533,8 @@ var IDKitBuilder = class _IDKitBuilder {
|
|
|
527
533
|
* Builds a v1 (legacy) native payload from a preset (synchronous, no bridge connection).
|
|
528
534
|
*
|
|
529
535
|
* Used by the native transport when the World App only supports verify v1.
|
|
530
|
-
* Only legacy presets produce valid v1 payloads (
|
|
531
|
-
* `
|
|
536
|
+
* Only legacy presets produce valid v1 payloads (constraint-based requests
|
|
537
|
+
* default to `Device` level and may not carry the correct action).
|
|
532
538
|
*
|
|
533
539
|
* # Errors
|
|
534
540
|
*
|
|
@@ -561,9 +567,10 @@ var IDKitBuilder = class _IDKitBuilder {
|
|
|
561
567
|
* @param {string | null | undefined} bridge_url
|
|
562
568
|
* @param {boolean} allow_legacy_proofs
|
|
563
569
|
* @param {string | null} [override_connect_base_url]
|
|
570
|
+
* @param {string | null} [return_to]
|
|
564
571
|
* @param {string | null} [environment]
|
|
565
572
|
*/
|
|
566
|
-
constructor(app_id, action, rp_context, action_description, bridge_url, allow_legacy_proofs, override_connect_base_url, environment) {
|
|
573
|
+
constructor(app_id, action, rp_context, action_description, bridge_url, allow_legacy_proofs, override_connect_base_url, return_to, environment) {
|
|
567
574
|
const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
568
575
|
const len0 = WASM_VECTOR_LEN;
|
|
569
576
|
const ptr1 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -576,9 +583,11 @@ var IDKitBuilder = class _IDKitBuilder {
|
|
|
576
583
|
var len4 = WASM_VECTOR_LEN;
|
|
577
584
|
var ptr5 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
578
585
|
var len5 = WASM_VECTOR_LEN;
|
|
579
|
-
var ptr6 = isLikeNone(
|
|
586
|
+
var ptr6 = isLikeNone(return_to) ? 0 : passStringToWasm0(return_to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
580
587
|
var len6 = WASM_VECTOR_LEN;
|
|
581
|
-
|
|
588
|
+
var ptr7 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
589
|
+
var len7 = WASM_VECTOR_LEN;
|
|
590
|
+
const ret = wasm.idkitbuilder_new(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4, allow_legacy_proofs, ptr5, len5, ptr6, len6, ptr7, len7);
|
|
582
591
|
this.__wbg_ptr = ret >>> 0;
|
|
583
592
|
IDKitBuilderFinalization.register(this, this.__wbg_ptr, this);
|
|
584
593
|
return this;
|
|
@@ -963,12 +972,14 @@ function base64Encode(data) {
|
|
|
963
972
|
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
964
973
|
}
|
|
965
974
|
}
|
|
966
|
-
function computeRpSignatureMessage(nonce, created_at, expires_at) {
|
|
975
|
+
function computeRpSignatureMessage(nonce, created_at, expires_at, action) {
|
|
967
976
|
try {
|
|
968
977
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
969
978
|
const ptr0 = passStringToWasm0(nonce, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
970
979
|
const len0 = WASM_VECTOR_LEN;
|
|
971
|
-
|
|
980
|
+
var ptr1 = isLikeNone(action) ? 0 : passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
981
|
+
var len1 = WASM_VECTOR_LEN;
|
|
982
|
+
wasm.computeRpSignatureMessage(retptr, ptr0, len0, created_at, expires_at, ptr1, len1);
|
|
972
983
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
973
984
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
974
985
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -976,14 +987,14 @@ function computeRpSignatureMessage(nonce, created_at, expires_at) {
|
|
|
976
987
|
if (r3) {
|
|
977
988
|
throw takeObject(r2);
|
|
978
989
|
}
|
|
979
|
-
var
|
|
990
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
980
991
|
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
981
|
-
return
|
|
992
|
+
return v3;
|
|
982
993
|
} finally {
|
|
983
994
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
984
995
|
}
|
|
985
996
|
}
|
|
986
|
-
function createSession(app_id, rp_context, action_description, bridge_url, override_connect_base_url, environment) {
|
|
997
|
+
function createSession(app_id, rp_context, action_description, bridge_url, override_connect_base_url, return_to, environment) {
|
|
987
998
|
const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
988
999
|
const len0 = WASM_VECTOR_LEN;
|
|
989
1000
|
_assertClass(rp_context, RpContextWasm);
|
|
@@ -994,9 +1005,11 @@ function createSession(app_id, rp_context, action_description, bridge_url, overr
|
|
|
994
1005
|
var len3 = WASM_VECTOR_LEN;
|
|
995
1006
|
var ptr4 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
996
1007
|
var len4 = WASM_VECTOR_LEN;
|
|
997
|
-
var ptr5 = isLikeNone(
|
|
1008
|
+
var ptr5 = isLikeNone(return_to) ? 0 : passStringToWasm0(return_to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
998
1009
|
var len5 = WASM_VECTOR_LEN;
|
|
999
|
-
|
|
1010
|
+
var ptr6 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1011
|
+
var len6 = WASM_VECTOR_LEN;
|
|
1012
|
+
const ret = wasm.createSession(ptr0, len0, ptr1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
|
|
1000
1013
|
return IDKitBuilder.__wrap(ret);
|
|
1001
1014
|
}
|
|
1002
1015
|
function hashSignal(signal) {
|
|
@@ -1027,7 +1040,7 @@ function hashSignal(signal) {
|
|
|
1027
1040
|
function init_wasm() {
|
|
1028
1041
|
wasm.init_wasm();
|
|
1029
1042
|
}
|
|
1030
|
-
function proveSession(session_id, app_id, rp_context, action_description, bridge_url, override_connect_base_url, environment) {
|
|
1043
|
+
function proveSession(session_id, app_id, rp_context, action_description, bridge_url, override_connect_base_url, return_to, environment) {
|
|
1031
1044
|
const ptr0 = passStringToWasm0(session_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1032
1045
|
const len0 = WASM_VECTOR_LEN;
|
|
1033
1046
|
const ptr1 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -1040,12 +1053,14 @@ function proveSession(session_id, app_id, rp_context, action_description, bridge
|
|
|
1040
1053
|
var len4 = WASM_VECTOR_LEN;
|
|
1041
1054
|
var ptr5 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1042
1055
|
var len5 = WASM_VECTOR_LEN;
|
|
1043
|
-
var ptr6 = isLikeNone(
|
|
1056
|
+
var ptr6 = isLikeNone(return_to) ? 0 : passStringToWasm0(return_to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1044
1057
|
var len6 = WASM_VECTOR_LEN;
|
|
1045
|
-
|
|
1058
|
+
var ptr7 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1059
|
+
var len7 = WASM_VECTOR_LEN;
|
|
1060
|
+
const ret = wasm.proveSession(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
|
|
1046
1061
|
return IDKitBuilder.__wrap(ret);
|
|
1047
1062
|
}
|
|
1048
|
-
function request(app_id, action, rp_context, action_description, bridge_url, allow_legacy_proofs, override_connect_base_url, environment) {
|
|
1063
|
+
function request(app_id, action, rp_context, action_description, bridge_url, allow_legacy_proofs, override_connect_base_url, return_to, environment) {
|
|
1049
1064
|
const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1050
1065
|
const len0 = WASM_VECTOR_LEN;
|
|
1051
1066
|
const ptr1 = passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -1058,17 +1073,21 @@ function request(app_id, action, rp_context, action_description, bridge_url, all
|
|
|
1058
1073
|
var len4 = WASM_VECTOR_LEN;
|
|
1059
1074
|
var ptr5 = isLikeNone(override_connect_base_url) ? 0 : passStringToWasm0(override_connect_base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1060
1075
|
var len5 = WASM_VECTOR_LEN;
|
|
1061
|
-
var ptr6 = isLikeNone(
|
|
1076
|
+
var ptr6 = isLikeNone(return_to) ? 0 : passStringToWasm0(return_to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1062
1077
|
var len6 = WASM_VECTOR_LEN;
|
|
1063
|
-
|
|
1078
|
+
var ptr7 = isLikeNone(environment) ? 0 : passStringToWasm0(environment, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1079
|
+
var len7 = WASM_VECTOR_LEN;
|
|
1080
|
+
const ret = wasm.request(ptr0, len0, ptr1, len1, ptr2, ptr3, len3, ptr4, len4, allow_legacy_proofs, ptr5, len5, ptr6, len6, ptr7, len7);
|
|
1064
1081
|
return IDKitBuilder.__wrap(ret);
|
|
1065
1082
|
}
|
|
1066
|
-
function signRequest(signing_key_hex, ttl_seconds) {
|
|
1083
|
+
function signRequest(signing_key_hex, ttl_seconds, action) {
|
|
1067
1084
|
try {
|
|
1068
1085
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1069
1086
|
const ptr0 = passStringToWasm0(signing_key_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1070
1087
|
const len0 = WASM_VECTOR_LEN;
|
|
1071
|
-
|
|
1088
|
+
var ptr1 = isLikeNone(action) ? 0 : passStringToWasm0(action, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1089
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1090
|
+
wasm.signRequest(retptr, ptr0, len0, !isLikeNone(ttl_seconds), isLikeNone(ttl_seconds) ? BigInt(0) : ttl_seconds, ptr1, len1);
|
|
1072
1091
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1073
1092
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1074
1093
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -1374,7 +1393,7 @@ function __wbg_get_imports() {
|
|
|
1374
1393
|
const a = state0.a;
|
|
1375
1394
|
state0.a = 0;
|
|
1376
1395
|
try {
|
|
1377
|
-
return
|
|
1396
|
+
return __wasm_bindgen_func_elem_1423(a, state0.b, arg02, arg12);
|
|
1378
1397
|
} finally {
|
|
1379
1398
|
state0.a = a;
|
|
1380
1399
|
}
|
|
@@ -1554,11 +1573,11 @@ function __wbg_get_imports() {
|
|
|
1554
1573
|
return addHeapObject(ret);
|
|
1555
1574
|
},
|
|
1556
1575
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1557
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1576
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_645, __wasm_bindgen_func_elem_646);
|
|
1558
1577
|
return addHeapObject(ret);
|
|
1559
1578
|
},
|
|
1560
1579
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1561
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1580
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_975, __wasm_bindgen_func_elem_976);
|
|
1562
1581
|
return addHeapObject(ret);
|
|
1563
1582
|
},
|
|
1564
1583
|
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
@@ -1594,13 +1613,13 @@ function __wbg_get_imports() {
|
|
|
1594
1613
|
"./idkit_wasm_bg.js": import0
|
|
1595
1614
|
};
|
|
1596
1615
|
}
|
|
1597
|
-
function
|
|
1598
|
-
wasm.
|
|
1616
|
+
function __wasm_bindgen_func_elem_646(arg0, arg1) {
|
|
1617
|
+
wasm.__wasm_bindgen_func_elem_646(arg0, arg1);
|
|
1599
1618
|
}
|
|
1600
|
-
function
|
|
1619
|
+
function __wasm_bindgen_func_elem_976(arg0, arg1, arg2) {
|
|
1601
1620
|
try {
|
|
1602
1621
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1603
|
-
wasm.
|
|
1622
|
+
wasm.__wasm_bindgen_func_elem_976(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1604
1623
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1605
1624
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1606
1625
|
if (r1) {
|
|
@@ -1610,8 +1629,8 @@ function __wasm_bindgen_func_elem_963(arg0, arg1, arg2) {
|
|
|
1610
1629
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1611
1630
|
}
|
|
1612
1631
|
}
|
|
1613
|
-
function
|
|
1614
|
-
wasm.
|
|
1632
|
+
function __wasm_bindgen_func_elem_1423(arg0, arg1, arg2, arg3) {
|
|
1633
|
+
wasm.__wasm_bindgen_func_elem_1423(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
1615
1634
|
}
|
|
1616
1635
|
var __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
|
|
1617
1636
|
var __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
|
|
@@ -1940,6 +1959,16 @@ async function initIDKit() {
|
|
|
1940
1959
|
return wasmInitPromise;
|
|
1941
1960
|
}
|
|
1942
1961
|
|
|
1962
|
+
// src/lib/debug.ts
|
|
1963
|
+
var _debug = false;
|
|
1964
|
+
function isDebug() {
|
|
1965
|
+
if (_debug) return true;
|
|
1966
|
+
return typeof window !== "undefined" && Boolean(window.IDKIT_DEBUG);
|
|
1967
|
+
}
|
|
1968
|
+
function setDebug(enabled) {
|
|
1969
|
+
_debug = enabled;
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1943
1972
|
// src/transports/native.ts
|
|
1944
1973
|
var MINIAPP_VERIFY_ACTION = "miniapp-verify-action";
|
|
1945
1974
|
function isInWorldApp() {
|
|
@@ -1955,9 +1984,10 @@ var _requestCounter = 0;
|
|
|
1955
1984
|
var _activeNativeRequest = null;
|
|
1956
1985
|
function createNativeRequest(wasmPayload, config, signalHashes = {}, legacySignalHash, version = 2) {
|
|
1957
1986
|
if (_activeNativeRequest?.isPending()) {
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1987
|
+
if (isDebug())
|
|
1988
|
+
console.warn(
|
|
1989
|
+
"[IDKit] Native: request already in flight, reusing active request"
|
|
1990
|
+
);
|
|
1961
1991
|
return _activeNativeRequest;
|
|
1962
1992
|
}
|
|
1963
1993
|
const request2 = new NativeIDKitRequest(
|
|
@@ -1984,6 +2014,11 @@ var NativeIDKitRequest = class {
|
|
|
1984
2014
|
const handleIncomingPayload = (responsePayload) => {
|
|
1985
2015
|
if (this.completionResult) return;
|
|
1986
2016
|
if (responsePayload?.status === "error") {
|
|
2017
|
+
if (isDebug())
|
|
2018
|
+
console.warn(
|
|
2019
|
+
"[IDKit] Native: received error response",
|
|
2020
|
+
responsePayload.error_code
|
|
2021
|
+
);
|
|
1987
2022
|
this.complete({
|
|
1988
2023
|
success: false,
|
|
1989
2024
|
error: responsePayload.error_code ?? "generic_error" /* GenericError */
|
|
@@ -2017,7 +2052,9 @@ var NativeIDKitRequest = class {
|
|
|
2017
2052
|
this.miniKitHandler = miniKitHandler;
|
|
2018
2053
|
miniKit.subscribe(MINIAPP_VERIFY_ACTION, miniKitHandler);
|
|
2019
2054
|
}
|
|
2020
|
-
} catch {
|
|
2055
|
+
} catch (err) {
|
|
2056
|
+
if (isDebug())
|
|
2057
|
+
console.warn("[IDKit] Native: MiniKit subscribe failed", err);
|
|
2021
2058
|
}
|
|
2022
2059
|
const sendPayload = {
|
|
2023
2060
|
command: "verify",
|
|
@@ -2027,16 +2064,29 @@ var NativeIDKitRequest = class {
|
|
|
2027
2064
|
try {
|
|
2028
2065
|
const w = window;
|
|
2029
2066
|
if (w.webkit?.messageHandlers?.minikit) {
|
|
2067
|
+
if (isDebug())
|
|
2068
|
+
console.debug(
|
|
2069
|
+
`[IDKit] Native: sending verify command (version=${version}, platform=ios)`
|
|
2070
|
+
);
|
|
2030
2071
|
w.webkit.messageHandlers.minikit.postMessage(sendPayload);
|
|
2031
2072
|
} else if (w.Android) {
|
|
2073
|
+
if (isDebug())
|
|
2074
|
+
console.debug(
|
|
2075
|
+
`[IDKit] Native: sending verify command (version=${version}, platform=android)`
|
|
2076
|
+
);
|
|
2032
2077
|
w.Android.postMessage(JSON.stringify(sendPayload));
|
|
2033
2078
|
} else {
|
|
2079
|
+
if (isDebug())
|
|
2080
|
+
console.warn(
|
|
2081
|
+
"[IDKit] Native: no native bridge found (no webkit/Android)"
|
|
2082
|
+
);
|
|
2034
2083
|
this.complete({
|
|
2035
2084
|
success: false,
|
|
2036
2085
|
error: "generic_error" /* GenericError */
|
|
2037
2086
|
});
|
|
2038
2087
|
}
|
|
2039
|
-
} catch {
|
|
2088
|
+
} catch (err) {
|
|
2089
|
+
if (isDebug()) console.warn("[IDKit] Native: postMessage failed", err);
|
|
2040
2090
|
this.complete({
|
|
2041
2091
|
success: false,
|
|
2042
2092
|
error: "generic_error" /* GenericError */
|
|
@@ -2047,6 +2097,11 @@ var NativeIDKitRequest = class {
|
|
|
2047
2097
|
// Single entry point for finishing the request. Idempotent — first caller wins.
|
|
2048
2098
|
complete(result) {
|
|
2049
2099
|
if (this.completionResult) return;
|
|
2100
|
+
if (isDebug())
|
|
2101
|
+
console.debug(
|
|
2102
|
+
"[IDKit] Native: request completed",
|
|
2103
|
+
result.success ? "success" : `error=${result.error}`
|
|
2104
|
+
);
|
|
2050
2105
|
this.completionResult = result;
|
|
2051
2106
|
this.cleanup();
|
|
2052
2107
|
this.resolveFn?.(result);
|
|
@@ -2066,7 +2121,9 @@ var NativeIDKitRequest = class {
|
|
|
2066
2121
|
try {
|
|
2067
2122
|
const miniKit = window.MiniKit;
|
|
2068
2123
|
miniKit?.unsubscribe?.(MINIAPP_VERIFY_ACTION);
|
|
2069
|
-
} catch {
|
|
2124
|
+
} catch (err) {
|
|
2125
|
+
if (isDebug())
|
|
2126
|
+
console.warn("[IDKit] Native: MiniKit unsubscribe failed", err);
|
|
2070
2127
|
}
|
|
2071
2128
|
this.miniKitHandler = null;
|
|
2072
2129
|
}
|
|
@@ -2084,7 +2141,7 @@ var NativeIDKitRequest = class {
|
|
|
2084
2141
|
return { type: "failed", error: this.completionResult.error };
|
|
2085
2142
|
}
|
|
2086
2143
|
async pollUntilCompletion(options) {
|
|
2087
|
-
const timeout = options?.timeout ??
|
|
2144
|
+
const timeout = options?.timeout ?? 9e5;
|
|
2088
2145
|
const timeoutId = setTimeout(() => {
|
|
2089
2146
|
this.complete({ success: false, error: "timeout" /* Timeout */ });
|
|
2090
2147
|
}, timeout);
|
|
@@ -2117,14 +2174,15 @@ var NativeIDKitRequest = class {
|
|
|
2117
2174
|
function nativeResultToIDKitResult(payload, config, signalHashes, legacySignalHash) {
|
|
2118
2175
|
const p = payload;
|
|
2119
2176
|
const rpNonce = config.rp_context?.nonce ?? "";
|
|
2120
|
-
if ("
|
|
2121
|
-
const
|
|
2122
|
-
|
|
2177
|
+
if ("proof_response" in p && p.proof_response != null) {
|
|
2178
|
+
const proof_response = p.proof_response;
|
|
2179
|
+
const items = proof_response.responses ?? [];
|
|
2180
|
+
if (proof_response.session_id) {
|
|
2123
2181
|
return {
|
|
2124
2182
|
protocol_version: "4.0",
|
|
2125
|
-
nonce:
|
|
2126
|
-
action_description:
|
|
2127
|
-
session_id:
|
|
2183
|
+
nonce: proof_response.nonce ?? rpNonce,
|
|
2184
|
+
action_description: proof_response.action_description,
|
|
2185
|
+
session_id: proof_response.session_id,
|
|
2128
2186
|
responses: items.map((item) => ({
|
|
2129
2187
|
identifier: item.identifier,
|
|
2130
2188
|
signal_hash: signalHashes[item.identifier],
|
|
@@ -2138,9 +2196,9 @@ function nativeResultToIDKitResult(payload, config, signalHashes, legacySignalHa
|
|
|
2138
2196
|
}
|
|
2139
2197
|
return {
|
|
2140
2198
|
protocol_version: "4.0",
|
|
2141
|
-
nonce:
|
|
2142
|
-
action:
|
|
2143
|
-
action_description:
|
|
2199
|
+
nonce: proof_response.nonce ?? rpNonce,
|
|
2200
|
+
action: proof_response.action ?? config.action ?? "",
|
|
2201
|
+
action_description: proof_response.action_description,
|
|
2144
2202
|
responses: items.map((item) => ({
|
|
2145
2203
|
identifier: item.identifier,
|
|
2146
2204
|
signal_hash: signalHashes[item.identifier],
|
|
@@ -2186,6 +2244,7 @@ function nativeResultToIDKitResult(payload, config, signalHashes, legacySignalHa
|
|
|
2186
2244
|
}
|
|
2187
2245
|
|
|
2188
2246
|
// src/request.ts
|
|
2247
|
+
var SESSION_ID_PATTERN = /^session_[0-9a-fA-F]{128}$/;
|
|
2189
2248
|
var IDKitRequestImpl = class {
|
|
2190
2249
|
constructor(wasmRequest) {
|
|
2191
2250
|
this.wasmRequest = wasmRequest;
|
|
@@ -2203,7 +2262,7 @@ var IDKitRequestImpl = class {
|
|
|
2203
2262
|
}
|
|
2204
2263
|
async pollUntilCompletion(options) {
|
|
2205
2264
|
const pollInterval = options?.pollInterval ?? 1e3;
|
|
2206
|
-
const timeout = options?.timeout ??
|
|
2265
|
+
const timeout = options?.timeout ?? 9e5;
|
|
2207
2266
|
const startTime = Date.now();
|
|
2208
2267
|
while (true) {
|
|
2209
2268
|
if (options?.signal?.aborted) {
|
|
@@ -2226,6 +2285,23 @@ var IDKitRequestImpl = class {
|
|
|
2226
2285
|
}
|
|
2227
2286
|
}
|
|
2228
2287
|
};
|
|
2288
|
+
function CredentialRequest(credential_type, options) {
|
|
2289
|
+
return {
|
|
2290
|
+
type: credential_type,
|
|
2291
|
+
signal: options?.signal,
|
|
2292
|
+
genesis_issued_at_min: options?.genesis_issued_at_min,
|
|
2293
|
+
expires_at_min: options?.expires_at_min
|
|
2294
|
+
};
|
|
2295
|
+
}
|
|
2296
|
+
function any(...nodes) {
|
|
2297
|
+
return { any: nodes };
|
|
2298
|
+
}
|
|
2299
|
+
function all(...nodes) {
|
|
2300
|
+
return { all: nodes };
|
|
2301
|
+
}
|
|
2302
|
+
function enumerate(...nodes) {
|
|
2303
|
+
return { enumerate: nodes };
|
|
2304
|
+
}
|
|
2229
2305
|
function orbLegacy(opts = {}) {
|
|
2230
2306
|
return { type: "OrbLegacy", signal: opts.signal };
|
|
2231
2307
|
}
|
|
@@ -2261,6 +2337,7 @@ function createWasmBuilderFromConfig(config) {
|
|
|
2261
2337
|
config.bridge_url ?? null,
|
|
2262
2338
|
config.allow_legacy_proofs ?? false,
|
|
2263
2339
|
config.override_connect_base_url ?? null,
|
|
2340
|
+
config.return_to ?? null,
|
|
2264
2341
|
config.environment ?? null
|
|
2265
2342
|
);
|
|
2266
2343
|
}
|
|
@@ -2272,6 +2349,7 @@ function createWasmBuilderFromConfig(config) {
|
|
|
2272
2349
|
config.action_description ?? null,
|
|
2273
2350
|
config.bridge_url ?? null,
|
|
2274
2351
|
config.override_connect_base_url ?? null,
|
|
2352
|
+
config.return_to ?? null,
|
|
2275
2353
|
config.environment ?? null
|
|
2276
2354
|
);
|
|
2277
2355
|
}
|
|
@@ -2281,6 +2359,7 @@ function createWasmBuilderFromConfig(config) {
|
|
|
2281
2359
|
config.action_description ?? null,
|
|
2282
2360
|
config.bridge_url ?? null,
|
|
2283
2361
|
config.override_connect_base_url ?? null,
|
|
2362
|
+
config.return_to ?? null,
|
|
2284
2363
|
config.environment ?? null
|
|
2285
2364
|
);
|
|
2286
2365
|
}
|
|
@@ -2315,7 +2394,7 @@ var IDKitBuilder2 = class {
|
|
|
2315
2394
|
wasmResult.payload,
|
|
2316
2395
|
this.config,
|
|
2317
2396
|
wasmResult.signal_hashes ?? {},
|
|
2318
|
-
wasmResult.legacy_signal_hash
|
|
2397
|
+
wasmResult.legacy_signal_hash,
|
|
2319
2398
|
2
|
|
2320
2399
|
);
|
|
2321
2400
|
}
|
|
@@ -2341,6 +2420,11 @@ var IDKitBuilder2 = class {
|
|
|
2341
2420
|
* ```
|
|
2342
2421
|
*/
|
|
2343
2422
|
async preset(preset) {
|
|
2423
|
+
if (this.config.type === "createSession" || this.config.type === "proveSession") {
|
|
2424
|
+
throw new Error(
|
|
2425
|
+
"Presets are not supported for session flows. Use .constraints() instead."
|
|
2426
|
+
);
|
|
2427
|
+
}
|
|
2344
2428
|
await initIDKit();
|
|
2345
2429
|
if (isInWorldApp()) {
|
|
2346
2430
|
const verifyVersion = getWorldAppVerifyVersion();
|
|
@@ -2351,7 +2435,7 @@ var IDKitBuilder2 = class {
|
|
|
2351
2435
|
wasmResult.payload,
|
|
2352
2436
|
this.config,
|
|
2353
2437
|
wasmResult.signal_hashes ?? {},
|
|
2354
|
-
wasmResult.legacy_signal_hash
|
|
2438
|
+
wasmResult.legacy_signal_hash,
|
|
2355
2439
|
2
|
|
2356
2440
|
);
|
|
2357
2441
|
}
|
|
@@ -2362,7 +2446,7 @@ var IDKitBuilder2 = class {
|
|
|
2362
2446
|
wasmResult.payload,
|
|
2363
2447
|
this.config,
|
|
2364
2448
|
wasmResult.signal_hashes ?? {},
|
|
2365
|
-
wasmResult.legacy_signal_hash
|
|
2449
|
+
wasmResult.legacy_signal_hash,
|
|
2366
2450
|
1
|
|
2367
2451
|
);
|
|
2368
2452
|
} catch (err) {
|
|
@@ -2405,27 +2489,76 @@ function createRequest(config) {
|
|
|
2405
2489
|
rp_context: config.rp_context,
|
|
2406
2490
|
action_description: config.action_description,
|
|
2407
2491
|
bridge_url: config.bridge_url,
|
|
2492
|
+
return_to: config.return_to,
|
|
2408
2493
|
allow_legacy_proofs: config.allow_legacy_proofs,
|
|
2409
2494
|
override_connect_base_url: config.override_connect_base_url,
|
|
2410
2495
|
environment: config.environment
|
|
2411
2496
|
});
|
|
2412
2497
|
}
|
|
2498
|
+
function createSession2(config) {
|
|
2499
|
+
if (!config.app_id) {
|
|
2500
|
+
throw new Error("app_id is required");
|
|
2501
|
+
}
|
|
2502
|
+
if (!config.rp_context) {
|
|
2503
|
+
throw new Error(
|
|
2504
|
+
"rp_context is required. Generate it on your backend using signRequest()."
|
|
2505
|
+
);
|
|
2506
|
+
}
|
|
2507
|
+
return new IDKitBuilder2({
|
|
2508
|
+
type: "createSession",
|
|
2509
|
+
app_id: config.app_id,
|
|
2510
|
+
rp_context: config.rp_context,
|
|
2511
|
+
action_description: config.action_description,
|
|
2512
|
+
bridge_url: config.bridge_url,
|
|
2513
|
+
return_to: config.return_to,
|
|
2514
|
+
override_connect_base_url: config.override_connect_base_url,
|
|
2515
|
+
environment: config.environment
|
|
2516
|
+
});
|
|
2517
|
+
}
|
|
2518
|
+
function proveSession2(sessionId, config) {
|
|
2519
|
+
if (!sessionId) {
|
|
2520
|
+
throw new Error("session_id is required");
|
|
2521
|
+
}
|
|
2522
|
+
if (!SESSION_ID_PATTERN.test(sessionId)) {
|
|
2523
|
+
throw new Error(
|
|
2524
|
+
"session_id must be in the format session_<128 hex characters>"
|
|
2525
|
+
);
|
|
2526
|
+
}
|
|
2527
|
+
if (!config.app_id) {
|
|
2528
|
+
throw new Error("app_id is required");
|
|
2529
|
+
}
|
|
2530
|
+
if (!config.rp_context) {
|
|
2531
|
+
throw new Error(
|
|
2532
|
+
"rp_context is required. Generate it on your backend using signRequest()."
|
|
2533
|
+
);
|
|
2534
|
+
}
|
|
2535
|
+
return new IDKitBuilder2({
|
|
2536
|
+
type: "proveSession",
|
|
2537
|
+
session_id: sessionId,
|
|
2538
|
+
app_id: config.app_id,
|
|
2539
|
+
rp_context: config.rp_context,
|
|
2540
|
+
action_description: config.action_description,
|
|
2541
|
+
bridge_url: config.bridge_url,
|
|
2542
|
+
return_to: config.return_to,
|
|
2543
|
+
override_connect_base_url: config.override_connect_base_url,
|
|
2544
|
+
environment: config.environment
|
|
2545
|
+
});
|
|
2546
|
+
}
|
|
2413
2547
|
var IDKit = {
|
|
2414
2548
|
/** Create a new verification request */
|
|
2415
2549
|
request: createRequest,
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
// enumerate,
|
|
2550
|
+
/** Create a new session (no action, no existing session_id) */
|
|
2551
|
+
createSession: createSession2,
|
|
2552
|
+
/** Prove an existing session (no action, has session_id) */
|
|
2553
|
+
proveSession: proveSession2,
|
|
2554
|
+
/** Create a CredentialRequest for a credential type */
|
|
2555
|
+
CredentialRequest,
|
|
2556
|
+
/** Create an OR constraint - at least one child must be satisfied */
|
|
2557
|
+
any,
|
|
2558
|
+
/** Create an AND constraint - all children must be satisfied */
|
|
2559
|
+
all,
|
|
2560
|
+
/** Create an enumerate constraint - all satisfiable children should be selected */
|
|
2561
|
+
enumerate,
|
|
2429
2562
|
/** Create an OrbLegacy preset for World ID 3.0 legacy support */
|
|
2430
2563
|
orbLegacy,
|
|
2431
2564
|
/** Create a SecureDocumentLegacy preset for World ID 3.0 legacy support */
|
|
@@ -2469,4 +2602,4 @@ function isValidHex(s) {
|
|
|
2469
2602
|
return /^[0-9a-fA-F]+$/.test(s);
|
|
2470
2603
|
}
|
|
2471
2604
|
|
|
2472
|
-
export { IDKit, IDKitErrorCodes, deviceLegacy, documentLegacy, hashSignal2 as hashSignal, isInWorldApp, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy, selfieCheckLegacy };
|
|
2605
|
+
export { CredentialRequest, IDKit, IDKitErrorCodes, all, any, deviceLegacy, documentLegacy, enumerate, hashSignal2 as hashSignal, isDebug, isInWorldApp, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy, selfieCheckLegacy, setDebug };
|
package/dist/session.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSessionCommitment } from '@worldcoin/idkit-server';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSessionCommitment } from '@worldcoin/idkit-server';
|
package/dist/session.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSessionCommitment } from '@worldcoin/idkit-server';
|
package/dist/signing.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { RpSignature, computeRpSignatureMessage, signRequest } from '@worldcoin/idkit-server';
|
|
1
|
+
export { RpSignature, SignRequestParams, computeRpSignatureMessage, signRequest } from '@worldcoin/idkit-server';
|
package/dist/signing.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { RpSignature, computeRpSignatureMessage, signRequest } from '@worldcoin/idkit-server';
|
|
1
|
+
export { RpSignature, SignRequestParams, computeRpSignatureMessage, signRequest } from '@worldcoin/idkit-server';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worldcoin/idkit-core",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Core IDKit SDK for World ID - Pure TypeScript, no dependencies",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"types": "./dist/hashing.d.ts",
|
|
22
22
|
"import": "./dist/hashing.js",
|
|
23
23
|
"require": "./dist/hashing.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./session": {
|
|
26
|
+
"types": "./dist/session.d.ts",
|
|
27
|
+
"import": "./dist/session.js",
|
|
28
|
+
"require": "./dist/session.cjs"
|
|
24
29
|
}
|
|
25
30
|
},
|
|
26
31
|
"files": [
|
|
@@ -52,7 +57,7 @@
|
|
|
52
57
|
},
|
|
53
58
|
"dependencies": {
|
|
54
59
|
"@noble/hashes": "^1.7.2",
|
|
55
|
-
"@worldcoin/idkit-server": "1.
|
|
60
|
+
"@worldcoin/idkit-server": "1.1.0"
|
|
56
61
|
},
|
|
57
62
|
"devDependencies": {
|
|
58
63
|
"@types/node": "^20.19.30",
|