@worldcoin/idkit-core 4.0.2-dev.a907be3 → 4.0.3-dev.20a22e3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/idkit_wasm_bg.wasm +0 -0
- package/dist/index.cjs +77 -170
- package/dist/index.d.cts +8 -119
- package/dist/index.d.ts +8 -119
- package/dist/index.js +74 -167
- package/dist/signing.cjs +9 -71
- package/dist/signing.d.cts +1 -36
- package/dist/signing.d.ts +1 -36
- package/dist/signing.js +1 -73
- package/package.json +2 -2
package/dist/idkit_wasm_bg.wasm
CHANGED
|
Binary file
|
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var idkitServer = require('@worldcoin/idkit-server');
|
|
3
4
|
var sha3 = require('@noble/hashes/sha3');
|
|
4
5
|
var utils = require('@noble/hashes/utils');
|
|
5
|
-
var hmac = require('@noble/hashes/hmac');
|
|
6
|
-
var sha2 = require('@noble/hashes/sha2');
|
|
7
|
-
var secp256k1 = require('@noble/secp256k1');
|
|
8
6
|
|
|
9
7
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
8
|
var __defProp = Object.defineProperty;
|
|
11
|
-
var __export = (target,
|
|
12
|
-
for (var name in
|
|
13
|
-
__defProp(target, name, { get:
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
12
|
};
|
|
15
13
|
|
|
16
14
|
// src/types/result.ts
|
|
@@ -394,14 +392,14 @@ function hashSignal(signal) {
|
|
|
394
392
|
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
395
393
|
}
|
|
396
394
|
}
|
|
397
|
-
function
|
|
398
|
-
wasm.
|
|
395
|
+
function __wasm_bindgen_func_elem_962(arg0, arg1, arg2) {
|
|
396
|
+
wasm.__wasm_bindgen_func_elem_962(arg0, arg1, addHeapObject(arg2));
|
|
399
397
|
}
|
|
400
|
-
function
|
|
401
|
-
wasm.
|
|
398
|
+
function __wasm_bindgen_func_elem_599(arg0, arg1) {
|
|
399
|
+
wasm.__wasm_bindgen_func_elem_599(arg0, arg1);
|
|
402
400
|
}
|
|
403
|
-
function
|
|
404
|
-
wasm.
|
|
401
|
+
function __wasm_bindgen_func_elem_1347(arg0, arg1, arg2, arg3) {
|
|
402
|
+
wasm.__wasm_bindgen_func_elem_1347(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
405
403
|
}
|
|
406
404
|
var __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
|
|
407
405
|
var __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
|
|
@@ -1564,7 +1562,7 @@ function __wbg_get_imports() {
|
|
|
1564
1562
|
const a = state0.a;
|
|
1565
1563
|
state0.a = 0;
|
|
1566
1564
|
try {
|
|
1567
|
-
return
|
|
1565
|
+
return __wasm_bindgen_func_elem_1347(a, state0.b, arg02, arg12);
|
|
1568
1566
|
} finally {
|
|
1569
1567
|
state0.a = a;
|
|
1570
1568
|
}
|
|
@@ -1777,20 +1775,20 @@ function __wbg_get_imports() {
|
|
|
1777
1775
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
1778
1776
|
return addHeapObject(ret);
|
|
1779
1777
|
};
|
|
1780
|
-
imports.wbg.
|
|
1781
|
-
const ret =
|
|
1778
|
+
imports.wbg.__wbindgen_cast_2d12912bac8cf5ca = function(arg0, arg1) {
|
|
1779
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_961, __wasm_bindgen_func_elem_962);
|
|
1782
1780
|
return addHeapObject(ret);
|
|
1783
1781
|
};
|
|
1784
|
-
imports.wbg.
|
|
1785
|
-
const ret =
|
|
1782
|
+
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
1783
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
1786
1784
|
return addHeapObject(ret);
|
|
1787
1785
|
};
|
|
1788
1786
|
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
1789
1787
|
const ret = arg0;
|
|
1790
1788
|
return addHeapObject(ret);
|
|
1791
1789
|
};
|
|
1792
|
-
imports.wbg.
|
|
1793
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1790
|
+
imports.wbg.__wbindgen_cast_b8b1061c2d0ea705 = function(arg0, arg1) {
|
|
1791
|
+
const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_598, __wasm_bindgen_func_elem_599);
|
|
1794
1792
|
return addHeapObject(ret);
|
|
1795
1793
|
};
|
|
1796
1794
|
imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
|
|
@@ -1884,19 +1882,19 @@ function isInWorldApp() {
|
|
|
1884
1882
|
}
|
|
1885
1883
|
var _requestCounter = 0;
|
|
1886
1884
|
var _activeNativeRequest = null;
|
|
1887
|
-
function createNativeRequest(wasmPayload, config) {
|
|
1885
|
+
function createNativeRequest(wasmPayload, config, signalHashes = {}) {
|
|
1888
1886
|
if (_activeNativeRequest?.isPending()) {
|
|
1889
1887
|
console.warn(
|
|
1890
1888
|
"IDKit native request already in flight. Reusing active request."
|
|
1891
1889
|
);
|
|
1892
1890
|
return _activeNativeRequest;
|
|
1893
1891
|
}
|
|
1894
|
-
const request2 = new NativeIDKitRequest(wasmPayload, config);
|
|
1892
|
+
const request2 = new NativeIDKitRequest(wasmPayload, config, signalHashes);
|
|
1895
1893
|
_activeNativeRequest = request2;
|
|
1896
1894
|
return request2;
|
|
1897
1895
|
}
|
|
1898
1896
|
var NativeIDKitRequest = class {
|
|
1899
|
-
constructor(wasmPayload, config) {
|
|
1897
|
+
constructor(wasmPayload, config, signalHashes = {}) {
|
|
1900
1898
|
this.connectorURI = "";
|
|
1901
1899
|
this.resolved = false;
|
|
1902
1900
|
this.cancelled = false;
|
|
@@ -1920,7 +1918,11 @@ var NativeIDKitRequest = class {
|
|
|
1920
1918
|
return;
|
|
1921
1919
|
}
|
|
1922
1920
|
this.resolved = true;
|
|
1923
|
-
const result = nativeResultToIDKitResult(
|
|
1921
|
+
const result = nativeResultToIDKitResult(
|
|
1922
|
+
responsePayload,
|
|
1923
|
+
config,
|
|
1924
|
+
signalHashes
|
|
1925
|
+
);
|
|
1924
1926
|
this.resolvedResult = result;
|
|
1925
1927
|
this.cleanup();
|
|
1926
1928
|
resolve(result);
|
|
@@ -2057,26 +2059,32 @@ var NativeVerifyError = class extends Error {
|
|
|
2057
2059
|
this.code = code;
|
|
2058
2060
|
}
|
|
2059
2061
|
};
|
|
2060
|
-
function nativeResultToIDKitResult(payload, config) {
|
|
2062
|
+
function nativeResultToIDKitResult(payload, config, signalHashes) {
|
|
2061
2063
|
const rpNonce = config.rp_context?.nonce ?? "";
|
|
2062
|
-
if ("responses" in payload
|
|
2064
|
+
if ("responses" in payload) {
|
|
2065
|
+
const v4 = payload;
|
|
2063
2066
|
return {
|
|
2064
|
-
protocol_version:
|
|
2065
|
-
nonce:
|
|
2066
|
-
action:
|
|
2067
|
-
action_description:
|
|
2068
|
-
session_id:
|
|
2069
|
-
responses:
|
|
2070
|
-
|
|
2067
|
+
protocol_version: v4.protocol_version ?? "4.0",
|
|
2068
|
+
nonce: v4.nonce ?? rpNonce,
|
|
2069
|
+
action: v4.action ?? config.action ?? "",
|
|
2070
|
+
action_description: v4.action_description,
|
|
2071
|
+
session_id: v4.session_id,
|
|
2072
|
+
responses: v4.responses.map((item) => ({
|
|
2073
|
+
...item,
|
|
2074
|
+
signal_hash: signalHashes[item.identifier]
|
|
2075
|
+
})),
|
|
2076
|
+
environment: v4.environment ?? config.environment ?? "production"
|
|
2071
2077
|
};
|
|
2072
2078
|
}
|
|
2073
2079
|
if ("verifications" in payload) {
|
|
2080
|
+
const multi = payload;
|
|
2074
2081
|
return {
|
|
2075
2082
|
protocol_version: "4.0",
|
|
2076
2083
|
nonce: rpNonce,
|
|
2077
2084
|
action: config.action ?? "",
|
|
2078
|
-
responses:
|
|
2085
|
+
responses: multi.verifications.map((v) => ({
|
|
2079
2086
|
identifier: v.verification_level,
|
|
2087
|
+
signal_hash: v.signal_hash ?? signalHashes[v.verification_level],
|
|
2080
2088
|
proof: [v.proof],
|
|
2081
2089
|
nullifier: v.nullifier_hash,
|
|
2082
2090
|
merkle_root: v.merkle_root,
|
|
@@ -2086,16 +2094,18 @@ function nativeResultToIDKitResult(payload, config) {
|
|
|
2086
2094
|
environment: "production"
|
|
2087
2095
|
};
|
|
2088
2096
|
}
|
|
2097
|
+
const single = payload;
|
|
2089
2098
|
return {
|
|
2090
2099
|
protocol_version: "3.0",
|
|
2091
2100
|
nonce: rpNonce,
|
|
2092
2101
|
action: config.action ?? "",
|
|
2093
2102
|
responses: [
|
|
2094
2103
|
{
|
|
2095
|
-
identifier:
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2104
|
+
identifier: single.verification_level,
|
|
2105
|
+
signal_hash: single.signal_hash ?? signalHashes[single.verification_level],
|
|
2106
|
+
proof: single.proof,
|
|
2107
|
+
merkle_root: single.merkle_root,
|
|
2108
|
+
nullifier: single.nullifier_hash
|
|
2099
2109
|
}
|
|
2100
2110
|
],
|
|
2101
2111
|
environment: "production"
|
|
@@ -2143,20 +2153,6 @@ var IDKitRequestImpl = class {
|
|
|
2143
2153
|
}
|
|
2144
2154
|
}
|
|
2145
2155
|
};
|
|
2146
|
-
function CredentialRequest(credential_type, options) {
|
|
2147
|
-
return {
|
|
2148
|
-
type: credential_type,
|
|
2149
|
-
signal: options?.signal,
|
|
2150
|
-
genesis_issued_at_min: options?.genesis_issued_at_min,
|
|
2151
|
-
expires_at_min: options?.expires_at_min
|
|
2152
|
-
};
|
|
2153
|
-
}
|
|
2154
|
-
function any(...nodes) {
|
|
2155
|
-
return { any: nodes };
|
|
2156
|
-
}
|
|
2157
|
-
function all(...nodes) {
|
|
2158
|
-
return { all: nodes };
|
|
2159
|
-
}
|
|
2160
2156
|
function orbLegacy(opts = {}) {
|
|
2161
2157
|
return { type: "OrbLegacy", signal: opts.signal };
|
|
2162
2158
|
}
|
|
@@ -2216,7 +2212,7 @@ var IDKitBuilder2 = class {
|
|
|
2216
2212
|
/**
|
|
2217
2213
|
* Creates an IDKit request with the given constraints
|
|
2218
2214
|
*
|
|
2219
|
-
* @param constraints - Constraint tree (CredentialRequest or any/all combinators)
|
|
2215
|
+
* @param constraints - Constraint tree (CredentialRequest or any/all/enumerate combinators)
|
|
2220
2216
|
* @returns A new IDKitRequest instance
|
|
2221
2217
|
*
|
|
2222
2218
|
* @example
|
|
@@ -2229,8 +2225,12 @@ var IDKitBuilder2 = class {
|
|
|
2229
2225
|
await initIDKit();
|
|
2230
2226
|
const wasmBuilder = createWasmBuilderFromConfig(this.config);
|
|
2231
2227
|
if (isInWorldApp()) {
|
|
2232
|
-
const
|
|
2233
|
-
return createNativeRequest(
|
|
2228
|
+
const wasmResult = wasmBuilder.nativePayload(constraints);
|
|
2229
|
+
return createNativeRequest(
|
|
2230
|
+
wasmResult.payload,
|
|
2231
|
+
this.config,
|
|
2232
|
+
wasmResult.signal_hashes ?? {}
|
|
2233
|
+
);
|
|
2234
2234
|
}
|
|
2235
2235
|
const wasmRequest = await wasmBuilder.constraints(
|
|
2236
2236
|
constraints
|
|
@@ -2256,8 +2256,12 @@ var IDKitBuilder2 = class {
|
|
|
2256
2256
|
await initIDKit();
|
|
2257
2257
|
const wasmBuilder = createWasmBuilderFromConfig(this.config);
|
|
2258
2258
|
if (isInWorldApp()) {
|
|
2259
|
-
const
|
|
2260
|
-
return createNativeRequest(
|
|
2259
|
+
const wasmResult = wasmBuilder.nativePayloadFromPreset(preset);
|
|
2260
|
+
return createNativeRequest(
|
|
2261
|
+
wasmResult.payload,
|
|
2262
|
+
this.config,
|
|
2263
|
+
wasmResult.signal_hashes ?? {}
|
|
2264
|
+
);
|
|
2261
2265
|
}
|
|
2262
2266
|
const wasmRequest = await wasmBuilder.preset(
|
|
2263
2267
|
preset
|
|
@@ -2294,61 +2298,22 @@ function createRequest(config) {
|
|
|
2294
2298
|
environment: config.environment
|
|
2295
2299
|
});
|
|
2296
2300
|
}
|
|
2297
|
-
function createSession2(config) {
|
|
2298
|
-
if (!config.app_id) {
|
|
2299
|
-
throw new Error("app_id is required");
|
|
2300
|
-
}
|
|
2301
|
-
if (!config.rp_context) {
|
|
2302
|
-
throw new Error(
|
|
2303
|
-
"rp_context is required. Generate it on your backend using signRequest()."
|
|
2304
|
-
);
|
|
2305
|
-
}
|
|
2306
|
-
return new IDKitBuilder2({
|
|
2307
|
-
type: "session",
|
|
2308
|
-
app_id: config.app_id,
|
|
2309
|
-
rp_context: config.rp_context,
|
|
2310
|
-
action_description: config.action_description,
|
|
2311
|
-
bridge_url: config.bridge_url,
|
|
2312
|
-
override_connect_base_url: config.override_connect_base_url,
|
|
2313
|
-
environment: config.environment
|
|
2314
|
-
});
|
|
2315
|
-
}
|
|
2316
|
-
function proveSession2(sessionId, config) {
|
|
2317
|
-
if (!sessionId) {
|
|
2318
|
-
throw new Error("session_id is required");
|
|
2319
|
-
}
|
|
2320
|
-
if (!config.app_id) {
|
|
2321
|
-
throw new Error("app_id is required");
|
|
2322
|
-
}
|
|
2323
|
-
if (!config.rp_context) {
|
|
2324
|
-
throw new Error(
|
|
2325
|
-
"rp_context is required. Generate it on your backend using signRequest()."
|
|
2326
|
-
);
|
|
2327
|
-
}
|
|
2328
|
-
return new IDKitBuilder2({
|
|
2329
|
-
type: "proveSession",
|
|
2330
|
-
session_id: sessionId,
|
|
2331
|
-
app_id: config.app_id,
|
|
2332
|
-
rp_context: config.rp_context,
|
|
2333
|
-
action_description: config.action_description,
|
|
2334
|
-
bridge_url: config.bridge_url,
|
|
2335
|
-
override_connect_base_url: config.override_connect_base_url,
|
|
2336
|
-
environment: config.environment
|
|
2337
|
-
});
|
|
2338
|
-
}
|
|
2339
2301
|
var IDKit = {
|
|
2340
2302
|
/** Create a new verification request */
|
|
2341
2303
|
request: createRequest,
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
CredentialRequest
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
all
|
|
2304
|
+
// TODO: Re-enable when World ID 4.0 is live
|
|
2305
|
+
// /** Create a new session (no action, no existing session_id) */
|
|
2306
|
+
// createSession,
|
|
2307
|
+
// /** Prove an existing session (no action, has session_id) */
|
|
2308
|
+
// proveSession,
|
|
2309
|
+
// /** Create a CredentialRequest for a credential type */
|
|
2310
|
+
// CredentialRequest,
|
|
2311
|
+
// /** Create an OR constraint - at least one child must be satisfied */
|
|
2312
|
+
// any,
|
|
2313
|
+
// /** Create an AND constraint - all children must be satisfied */
|
|
2314
|
+
// all,
|
|
2315
|
+
// /** Create an enumerate constraint - all satisfiable children should be selected */
|
|
2316
|
+
// enumerate,
|
|
2352
2317
|
/** Create an OrbLegacy preset for World ID 3.0 legacy support */
|
|
2353
2318
|
orbLegacy,
|
|
2354
2319
|
/** Create a SecureDocumentLegacy preset for World ID 3.0 legacy support */
|
|
@@ -2367,18 +2332,6 @@ var isWeb = () => {
|
|
|
2367
2332
|
var isNode = () => {
|
|
2368
2333
|
return typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined";
|
|
2369
2334
|
};
|
|
2370
|
-
var isServerEnvironment = () => {
|
|
2371
|
-
if (typeof process !== "undefined" && process.versions?.node) {
|
|
2372
|
-
return true;
|
|
2373
|
-
}
|
|
2374
|
-
if (typeof globalThis.Deno !== "undefined") {
|
|
2375
|
-
return true;
|
|
2376
|
-
}
|
|
2377
|
-
if (typeof globalThis.Bun !== "undefined") {
|
|
2378
|
-
return true;
|
|
2379
|
-
}
|
|
2380
|
-
return false;
|
|
2381
|
-
};
|
|
2382
2335
|
function hashToField(input) {
|
|
2383
2336
|
const hash = BigInt("0x" + utils.bytesToHex(sha3.keccak_256(input))) >> 8n;
|
|
2384
2337
|
return utils.hexToBytes(hash.toString(16).padStart(64, "0"));
|
|
@@ -2400,57 +2353,12 @@ function isValidHex(s) {
|
|
|
2400
2353
|
return /^[0-9a-fA-F]+$/.test(s);
|
|
2401
2354
|
}
|
|
2402
2355
|
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
const message = new Uint8Array(48);
|
|
2408
|
-
message.set(nonceBytes, 0);
|
|
2409
|
-
const view = new DataView(message.buffer);
|
|
2410
|
-
view.setBigUint64(32, BigInt(createdAt), false);
|
|
2411
|
-
view.setBigUint64(40, BigInt(expiresAt), false);
|
|
2412
|
-
return message;
|
|
2413
|
-
}
|
|
2414
|
-
function signRequest2(_action, signingKeyHex, ttl = DEFAULT_TTL_SEC) {
|
|
2415
|
-
if (!isServerEnvironment()) {
|
|
2416
|
-
throw new Error(
|
|
2417
|
-
"signRequest can only be used in Node.js environments. This function requires access to signing keys and should never be called from browser/client-side code."
|
|
2418
|
-
);
|
|
2419
|
-
}
|
|
2420
|
-
const keyHex = signingKeyHex.startsWith("0x") ? signingKeyHex.slice(2) : signingKeyHex;
|
|
2421
|
-
if (!/^[0-9a-fA-F]+$/.test(keyHex)) {
|
|
2422
|
-
throw new Error("Invalid signing key: contains non-hex characters");
|
|
2423
|
-
}
|
|
2424
|
-
if (keyHex.length !== 64) {
|
|
2425
|
-
throw new Error(
|
|
2426
|
-
`Invalid signing key: expected 32 bytes (64 hex chars), got ${keyHex.length / 2} bytes`
|
|
2427
|
-
);
|
|
2428
|
-
}
|
|
2429
|
-
const privKey = secp256k1.etc.hexToBytes(keyHex);
|
|
2430
|
-
const randomBytes = crypto.getRandomValues(new Uint8Array(32));
|
|
2431
|
-
const nonceBytes = hashToField(randomBytes);
|
|
2432
|
-
const createdAt = Math.floor(Date.now() / 1e3);
|
|
2433
|
-
const expiresAt = createdAt + ttl;
|
|
2434
|
-
const message = computeRpSignatureMessage(nonceBytes, createdAt, expiresAt);
|
|
2435
|
-
const msgHash = sha3.keccak_256(message);
|
|
2436
|
-
const recSig = secp256k1.sign(msgHash, privKey);
|
|
2437
|
-
const compact = recSig.toCompactRawBytes();
|
|
2438
|
-
const sig65 = new Uint8Array(65);
|
|
2439
|
-
sig65.set(compact, 0);
|
|
2440
|
-
sig65[64] = recSig.recovery + 27;
|
|
2441
|
-
return {
|
|
2442
|
-
sig: "0x" + utils.bytesToHex(sig65),
|
|
2443
|
-
nonce: "0x" + utils.bytesToHex(nonceBytes),
|
|
2444
|
-
createdAt,
|
|
2445
|
-
expiresAt
|
|
2446
|
-
};
|
|
2447
|
-
}
|
|
2448
|
-
|
|
2449
|
-
exports.CredentialRequest = CredentialRequest;
|
|
2356
|
+
Object.defineProperty(exports, "signRequest", {
|
|
2357
|
+
enumerable: true,
|
|
2358
|
+
get: function () { return idkitServer.signRequest; }
|
|
2359
|
+
});
|
|
2450
2360
|
exports.IDKit = IDKit;
|
|
2451
2361
|
exports.IDKitErrorCodes = IDKitErrorCodes;
|
|
2452
|
-
exports.all = all;
|
|
2453
|
-
exports.any = any;
|
|
2454
2362
|
exports.documentLegacy = documentLegacy;
|
|
2455
2363
|
exports.hashSignal = hashSignal2;
|
|
2456
2364
|
exports.isNode = isNode;
|
|
@@ -2458,4 +2366,3 @@ exports.isReactNative = isReactNative;
|
|
|
2458
2366
|
exports.isWeb = isWeb;
|
|
2459
2367
|
exports.orbLegacy = orbLegacy;
|
|
2460
2368
|
exports.secureDocumentLegacy = secureDocumentLegacy;
|
|
2461
|
-
exports.signRequest = signRequest2;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { RpSignature, signRequest } from '
|
|
1
|
+
export { RpSignature, signRequest } from '@worldcoin/idkit-server';
|
|
2
2
|
export { hashSignal } from './hashing.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -241,7 +241,8 @@ interface CredentialRequestType {
|
|
|
241
241
|
type ConstraintNode =
|
|
242
242
|
| CredentialRequestType
|
|
243
243
|
| { any: ConstraintNode[] }
|
|
244
|
-
| { all: ConstraintNode[] }
|
|
244
|
+
| { all: ConstraintNode[] }
|
|
245
|
+
| { enumerate: ConstraintNode[] };
|
|
245
246
|
|
|
246
247
|
/**
|
|
247
248
|
* Result types - re-exported from WASM bindings
|
|
@@ -329,55 +330,6 @@ interface IDKitRequest {
|
|
|
329
330
|
/** Poll continuously until completion or timeout */
|
|
330
331
|
pollUntilCompletion(options?: WaitOptions): Promise<IDKitCompletionResult>;
|
|
331
332
|
}
|
|
332
|
-
/**
|
|
333
|
-
* Creates a CredentialRequest for a credential type
|
|
334
|
-
*
|
|
335
|
-
* @param credential_type - The type of credential to request (e.g., 'orb', 'face')
|
|
336
|
-
* @param options - Optional signal, genesis_issued_at_min, and expires_at_min
|
|
337
|
-
* @returns A CredentialRequest object
|
|
338
|
-
*
|
|
339
|
-
* @example
|
|
340
|
-
* ```typescript
|
|
341
|
-
* const orb = CredentialRequest('orb', { signal: 'user-123' })
|
|
342
|
-
* const face = CredentialRequest('face')
|
|
343
|
-
* // Require credential to be valid for at least one year
|
|
344
|
-
* const withExpiry = CredentialRequest('orb', { expires_at_min: Date.now() / 1000 + 60 * 60 * 60 * 24 * 365 })
|
|
345
|
-
* ```
|
|
346
|
-
*/
|
|
347
|
-
declare function CredentialRequest(credential_type: CredentialType, options?: {
|
|
348
|
-
signal?: string;
|
|
349
|
-
genesis_issued_at_min?: number;
|
|
350
|
-
expires_at_min?: number;
|
|
351
|
-
}): CredentialRequestType;
|
|
352
|
-
/**
|
|
353
|
-
* Creates an OR constraint - at least one child must be satisfied
|
|
354
|
-
*
|
|
355
|
-
* @param nodes - Constraint nodes (CredentialRequests or nested constraints)
|
|
356
|
-
* @returns An "any" constraint node
|
|
357
|
-
*
|
|
358
|
-
* @example
|
|
359
|
-
* ```typescript
|
|
360
|
-
* const constraint = any(CredentialRequest('orb'), CredentialRequest('face'))
|
|
361
|
-
* ```
|
|
362
|
-
*/
|
|
363
|
-
declare function any(...nodes: ConstraintNode[]): {
|
|
364
|
-
any: ConstraintNode[];
|
|
365
|
-
};
|
|
366
|
-
/**
|
|
367
|
-
* Creates an AND constraint - all children must be satisfied
|
|
368
|
-
*
|
|
369
|
-
* @param nodes - Constraint nodes (CredentialRequests or nested constraints)
|
|
370
|
-
* @returns An "all" constraint node
|
|
371
|
-
*
|
|
372
|
-
* @example
|
|
373
|
-
* ```typescript
|
|
374
|
-
* const constraint = all(CredentialRequest('orb'), any(CredentialRequest('document'), CredentialRequest('secure_document')))
|
|
375
|
-
* ```
|
|
376
|
-
*/
|
|
377
|
-
declare function all(...nodes: ConstraintNode[]): {
|
|
378
|
-
all: ConstraintNode[];
|
|
379
|
-
};
|
|
380
|
-
|
|
381
333
|
/**
|
|
382
334
|
* Creates an OrbLegacy preset for World ID 3.0 legacy support
|
|
383
335
|
*
|
|
@@ -445,7 +397,7 @@ declare class IDKitBuilder {
|
|
|
445
397
|
/**
|
|
446
398
|
* Creates an IDKit request with the given constraints
|
|
447
399
|
*
|
|
448
|
-
* @param constraints - Constraint tree (CredentialRequest or any/all combinators)
|
|
400
|
+
* @param constraints - Constraint tree (CredentialRequest or any/all/enumerate combinators)
|
|
449
401
|
* @returns A new IDKitRequest instance
|
|
450
402
|
*
|
|
451
403
|
* @example
|
|
@@ -484,7 +436,7 @@ declare class IDKitBuilder {
|
|
|
484
436
|
*
|
|
485
437
|
* @example
|
|
486
438
|
* ```typescript
|
|
487
|
-
* import { IDKit, CredentialRequest, any, orbLegacy } from '@worldcoin/idkit-core'
|
|
439
|
+
* import { IDKit, CredentialRequest, any, enumerate, orbLegacy } from '@worldcoin/idkit-core'
|
|
488
440
|
*
|
|
489
441
|
* // With preset (legacy support)
|
|
490
442
|
* const request = await IDKit.request({
|
|
@@ -500,7 +452,7 @@ declare class IDKitBuilder {
|
|
|
500
452
|
* action: 'my-action',
|
|
501
453
|
* rp_context: { ... },
|
|
502
454
|
* allow_legacy_proofs: false,
|
|
503
|
-
* }).constraints(
|
|
455
|
+
* }).constraints(enumerate(CredentialRequest('orb'), CredentialRequest('face')));
|
|
504
456
|
*
|
|
505
457
|
* // In World App: connectorURI is empty, result comes via postMessage
|
|
506
458
|
* // On web: connectorURI is the QR URL to display
|
|
@@ -511,65 +463,12 @@ declare class IDKitBuilder {
|
|
|
511
463
|
* ```
|
|
512
464
|
*/
|
|
513
465
|
declare function createRequest(config: IDKitRequestConfig): IDKitBuilder;
|
|
514
|
-
/**
|
|
515
|
-
* Creates a new session builder (no action, no existing session_id)
|
|
516
|
-
*
|
|
517
|
-
* Use this when creating a new session for a user who doesn't have one yet.
|
|
518
|
-
* The response will include a `session_id` that should be saved for future
|
|
519
|
-
* session proofs with `proveSession()`.
|
|
520
|
-
*
|
|
521
|
-
* @param config - Session configuration (no action field)
|
|
522
|
-
* @returns IDKitBuilder - A builder instance
|
|
523
|
-
*
|
|
524
|
-
* @example
|
|
525
|
-
* ```typescript
|
|
526
|
-
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
527
|
-
*
|
|
528
|
-
* // Create a new session (user doesn't have session_id yet)
|
|
529
|
-
* const request = await IDKit.createSession({
|
|
530
|
-
* app_id: 'app_staging_xxxxx',
|
|
531
|
-
* rp_context: { ... },
|
|
532
|
-
* }).constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
533
|
-
*
|
|
534
|
-
* // Display QR, wait for proof
|
|
535
|
-
* const result = await request.pollUntilCompletion();
|
|
536
|
-
* // result.session_id -> save this for future sessions
|
|
537
|
-
* // result.responses[0].session_nullifier -> for session tracking
|
|
538
|
-
* ```
|
|
539
|
-
*/
|
|
540
|
-
declare function createSession(config: IDKitSessionConfig): IDKitBuilder;
|
|
541
|
-
/**
|
|
542
|
-
* Creates a builder for proving an existing session (no action, has session_id)
|
|
543
|
-
*
|
|
544
|
-
* Use this when a returning user needs to prove they own an existing session.
|
|
545
|
-
* The `sessionId` should be a value previously returned from `createSession()`.
|
|
546
|
-
*
|
|
547
|
-
* @param sessionId - The session ID from a previous session creation
|
|
548
|
-
* @param config - Session configuration (no action field)
|
|
549
|
-
* @returns IDKitBuilder - A builder instance
|
|
550
|
-
*
|
|
551
|
-
* @example
|
|
552
|
-
* ```typescript
|
|
553
|
-
* import { IDKit, CredentialRequest, any } from '@worldcoin/idkit-core'
|
|
554
|
-
*
|
|
555
|
-
* // Prove an existing session (user returns)
|
|
556
|
-
* const request = await IDKit.proveSession(savedSessionId, {
|
|
557
|
-
* app_id: 'app_staging_xxxxx',
|
|
558
|
-
* rp_context: { ... },
|
|
559
|
-
* }).constraints(any(CredentialRequest('orb'), CredentialRequest('face')));
|
|
560
|
-
*
|
|
561
|
-
* const result = await request.pollUntilCompletion();
|
|
562
|
-
* // result.session_id -> same session
|
|
563
|
-
* // result.responses[0].session_nullifier -> should match for same user
|
|
564
|
-
* ```
|
|
565
|
-
*/
|
|
566
|
-
declare function proveSession(sessionId: string, config: IDKitSessionConfig): IDKitBuilder;
|
|
567
466
|
/**
|
|
568
467
|
* IDKit namespace providing the main API entry points
|
|
569
468
|
*
|
|
570
469
|
* @example
|
|
571
470
|
* ```typescript
|
|
572
|
-
* import { IDKit, CredentialRequest, any, orbLegacy } from '@worldcoin/idkit-core'
|
|
471
|
+
* import { IDKit, CredentialRequest, any, enumerate, orbLegacy } from '@worldcoin/idkit-core'
|
|
573
472
|
*
|
|
574
473
|
* // Create a verification request
|
|
575
474
|
* const request = await IDKit.request({
|
|
@@ -588,16 +487,6 @@ declare function proveSession(sessionId: string, config: IDKitSessionConfig): ID
|
|
|
588
487
|
declare const IDKit: {
|
|
589
488
|
/** Create a new verification request */
|
|
590
489
|
request: typeof createRequest;
|
|
591
|
-
/** Create a new session (no action, no existing session_id) */
|
|
592
|
-
createSession: typeof createSession;
|
|
593
|
-
/** Prove an existing session (no action, has session_id) */
|
|
594
|
-
proveSession: typeof proveSession;
|
|
595
|
-
/** Create a CredentialRequest for a credential type */
|
|
596
|
-
CredentialRequest: typeof CredentialRequest;
|
|
597
|
-
/** Create an OR constraint - at least one child must be satisfied */
|
|
598
|
-
any: typeof any;
|
|
599
|
-
/** Create an AND constraint - all children must be satisfied */
|
|
600
|
-
all: typeof all;
|
|
601
490
|
/** Create an OrbLegacy preset for World ID 3.0 legacy support */
|
|
602
491
|
orbLegacy: typeof orbLegacy;
|
|
603
492
|
/** Create a SecureDocumentLegacy preset for World ID 3.0 legacy support */
|
|
@@ -628,4 +517,4 @@ declare const isWeb: () => boolean;
|
|
|
628
517
|
*/
|
|
629
518
|
declare const isNode: () => boolean;
|
|
630
519
|
|
|
631
|
-
export { type AbiEncodedValue, type ConstraintNode,
|
|
520
|
+
export { type AbiEncodedValue, type ConstraintNode, type CredentialRequestType, type CredentialType, type DocumentLegacyPreset, IDKit, type IDKitCompletionResult, type IDKitErrorCode, IDKitErrorCodes, type IDKitRequest, type IDKitRequestConfig, type IDKitResult, type IDKitResultSession, type IDKitSessionConfig, type OrbLegacyPreset, type Preset, type ResponseItemSession, type ResponseItemV3, type ResponseItemV4, type RpContext, type SecureDocumentLegacyPreset, type Status$1 as Status, type WaitOptions, documentLegacy, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy };
|