@worldcoin/idkit-core 4.0.7 → 4.0.9-dev.648eacc

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 CHANGED
@@ -56,19 +56,19 @@ const request = await IDKit.request({
56
56
  const qrUrl = request.connectorURI;
57
57
  ```
58
58
 
59
- **Available presets:** `orbLegacy`, `documentLegacy`, `secureDocumentLegacy`, `selfieCheck`
59
+ **Available presets:** `orbLegacy`, `documentLegacy`, `secureDocumentLegacy`, `selfieCheckLegacy`
60
60
 
61
61
  Selfie check preset example:
62
62
 
63
63
  ```typescript
64
- import { IDKit, selfieCheck } from "@worldcoin/idkit-core";
64
+ import { IDKit, selfieCheckLegacy } from "@worldcoin/idkit-core";
65
65
 
66
66
  const request = await IDKit.request({
67
67
  app_id: "app_xxxxx",
68
68
  action: "my-action",
69
69
  rp_context: rpContext,
70
70
  allow_legacy_proofs: false,
71
- }).preset(selfieCheck({ signal: "user-123" }));
71
+ }).preset(selfieCheckLegacy({ signal: "user-123" }));
72
72
  ```
73
73
 
74
74
  ## Handling the Result
Binary file
package/dist/index.cjs CHANGED
@@ -392,14 +392,14 @@ function hashSignal(signal) {
392
392
  wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
393
393
  }
394
394
  }
395
- function __wasm_bindgen_func_elem_605(arg0, arg1) {
396
- wasm.__wasm_bindgen_func_elem_605(arg0, arg1);
395
+ function __wasm_bindgen_func_elem_972(arg0, arg1, arg2) {
396
+ wasm.__wasm_bindgen_func_elem_972(arg0, arg1, addHeapObject(arg2));
397
397
  }
398
- function __wasm_bindgen_func_elem_968(arg0, arg1, arg2) {
399
- wasm.__wasm_bindgen_func_elem_968(arg0, arg1, addHeapObject(arg2));
398
+ function __wasm_bindgen_func_elem_609(arg0, arg1) {
399
+ wasm.__wasm_bindgen_func_elem_609(arg0, arg1);
400
400
  }
401
- function __wasm_bindgen_func_elem_1353(arg0, arg1, arg2, arg3) {
402
- wasm.__wasm_bindgen_func_elem_1353(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
401
+ function __wasm_bindgen_func_elem_1357(arg0, arg1, arg2, arg3) {
402
+ wasm.__wasm_bindgen_func_elem_1357(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
403
403
  }
404
404
  var __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
405
405
  var __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -887,6 +887,35 @@ var IDKitBuilder = class _IDKitBuilder {
887
887
  wasm.__wbindgen_add_to_stack_pointer(16);
888
888
  }
889
889
  }
890
+ /**
891
+ * Builds a v1 (legacy) native payload from a preset (synchronous, no bridge connection).
892
+ *
893
+ * Used by the native transport when the World App only supports verify v1.
894
+ * Only legacy presets produce valid v1 payloads (constraints always have
895
+ * `Deprecated` verification level and will fail).
896
+ *
897
+ * # Errors
898
+ *
899
+ * Returns an error if the preset is invalid or v1 payload construction fails.
900
+ * @param {any} preset_json
901
+ * @returns {any}
902
+ */
903
+ nativePayloadV1FromPreset(preset_json) {
904
+ try {
905
+ const ptr = this.__destroy_into_raw();
906
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
907
+ wasm.idkitbuilder_nativePayloadV1FromPreset(retptr, ptr, addHeapObject(preset_json));
908
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
909
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
910
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
911
+ if (r2) {
912
+ throw takeObject(r1);
913
+ }
914
+ return takeObject(r0);
915
+ } finally {
916
+ wasm.__wbindgen_add_to_stack_pointer(16);
917
+ }
918
+ }
890
919
  /**
891
920
  * Creates a new builder for uniqueness requests
892
921
  * @param {string} app_id
@@ -1562,7 +1591,7 @@ function __wbg_get_imports() {
1562
1591
  const a = state0.a;
1563
1592
  state0.a = 0;
1564
1593
  try {
1565
- return __wasm_bindgen_func_elem_1353(a, state0.b, arg02, arg12);
1594
+ return __wasm_bindgen_func_elem_1357(a, state0.b, arg02, arg12);
1566
1595
  } finally {
1567
1596
  state0.a = a;
1568
1597
  }
@@ -1772,7 +1801,7 @@ function __wbg_get_imports() {
1772
1801
  return addHeapObject(ret);
1773
1802
  };
1774
1803
  imports.wbg.__wbindgen_cast_02740531cfdb05fe = function(arg0, arg1) {
1775
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_604, __wasm_bindgen_func_elem_605);
1804
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_608, __wasm_bindgen_func_elem_609);
1776
1805
  return addHeapObject(ret);
1777
1806
  };
1778
1807
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
@@ -1796,7 +1825,7 @@ function __wbg_get_imports() {
1796
1825
  return addHeapObject(ret);
1797
1826
  };
1798
1827
  imports.wbg.__wbindgen_cast_f23235b6472d5cf3 = function(arg0, arg1) {
1799
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_967, __wasm_bindgen_func_elem_968);
1828
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_971, __wasm_bindgen_func_elem_972);
1800
1829
  return addHeapObject(ret);
1801
1830
  };
1802
1831
  imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
@@ -1880,21 +1909,32 @@ var MINIAPP_VERIFY_ACTION = "miniapp-verify-action";
1880
1909
  function isInWorldApp() {
1881
1910
  return typeof window !== "undefined" && Boolean(window.WorldApp);
1882
1911
  }
1912
+ function getWorldAppVerifyVersion() {
1913
+ const cmds = window.WorldApp?.supported_commands;
1914
+ if (!Array.isArray(cmds)) return 1;
1915
+ const verify = cmds.find((c) => c.name === "verify");
1916
+ return verify?.supported_versions?.includes(2) ? 2 : 1;
1917
+ }
1883
1918
  var _requestCounter = 0;
1884
1919
  var _activeNativeRequest = null;
1885
- function createNativeRequest(wasmPayload, config, signalHashes = {}) {
1920
+ function createNativeRequest(wasmPayload, config, signalHashes = {}, version) {
1886
1921
  if (_activeNativeRequest?.isPending()) {
1887
1922
  console.warn(
1888
1923
  "IDKit native request already in flight. Reusing active request."
1889
1924
  );
1890
1925
  return _activeNativeRequest;
1891
1926
  }
1892
- const request2 = new NativeIDKitRequest(wasmPayload, config, signalHashes);
1927
+ const request2 = new NativeIDKitRequest(
1928
+ wasmPayload,
1929
+ config,
1930
+ signalHashes,
1931
+ version
1932
+ );
1893
1933
  _activeNativeRequest = request2;
1894
1934
  return request2;
1895
1935
  }
1896
1936
  var NativeIDKitRequest = class {
1897
- constructor(wasmPayload, config, signalHashes = {}) {
1937
+ constructor(wasmPayload, config, signalHashes = {}, version) {
1898
1938
  this.connectorURI = "";
1899
1939
  this.resolved = false;
1900
1940
  this.cancelled = false;
@@ -1948,7 +1988,7 @@ var NativeIDKitRequest = class {
1948
1988
  }
1949
1989
  const sendPayload = {
1950
1990
  command: "verify",
1951
- version: 2,
1991
+ version,
1952
1992
  payload: wasmPayload
1953
1993
  };
1954
1994
  const w = window;
@@ -2180,8 +2220,8 @@ function secureDocumentLegacy(opts = {}) {
2180
2220
  function documentLegacy(opts = {}) {
2181
2221
  return { type: "DocumentLegacy", signal: opts.signal };
2182
2222
  }
2183
- function selfieCheck(opts = {}) {
2184
- return { type: "SelfieCheck", signal: opts.signal };
2223
+ function selfieCheckLegacy(opts = {}) {
2224
+ return { type: "SelfieCheckLegacy", signal: opts.signal };
2185
2225
  }
2186
2226
  function createWasmBuilderFromConfig(config) {
2187
2227
  if (!config.rp_context) {
@@ -2244,15 +2284,23 @@ var IDKitBuilder2 = class {
2244
2284
  */
2245
2285
  async constraints(constraints) {
2246
2286
  await initIDKit();
2247
- const wasmBuilder = createWasmBuilderFromConfig(this.config);
2248
2287
  if (isInWorldApp()) {
2249
- const wasmResult = wasmBuilder.nativePayload(constraints);
2288
+ const verifyVersion = getWorldAppVerifyVersion();
2289
+ if (verifyVersion < 2) {
2290
+ throw new Error(
2291
+ "verify v2 is not supported by this World App version. Use a legacy preset (e.g. orbLegacy()) or update the World App."
2292
+ );
2293
+ }
2294
+ const wasmBuilder2 = createWasmBuilderFromConfig(this.config);
2295
+ const wasmResult = wasmBuilder2.nativePayload(constraints);
2250
2296
  return createNativeRequest(
2251
2297
  wasmResult.payload,
2252
2298
  this.config,
2253
- wasmResult.signal_hashes ?? {}
2299
+ wasmResult.signal_hashes ?? {},
2300
+ 2
2254
2301
  );
2255
2302
  }
2303
+ const wasmBuilder = createWasmBuilderFromConfig(this.config);
2256
2304
  const wasmRequest = await wasmBuilder.constraints(
2257
2305
  constraints
2258
2306
  );
@@ -2264,7 +2312,7 @@ var IDKitBuilder2 = class {
2264
2312
  * Presets provide a simplified way to create requests with predefined
2265
2313
  * credential configurations.
2266
2314
  *
2267
- * @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), documentLegacy(), or selfieCheck()
2315
+ * @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), documentLegacy(), or selfieCheckLegacy()
2268
2316
  * @returns A new IDKitRequest instance
2269
2317
  *
2270
2318
  * @example
@@ -2275,15 +2323,37 @@ var IDKitBuilder2 = class {
2275
2323
  */
2276
2324
  async preset(preset) {
2277
2325
  await initIDKit();
2278
- const wasmBuilder = createWasmBuilderFromConfig(this.config);
2279
2326
  if (isInWorldApp()) {
2280
- const wasmResult = wasmBuilder.nativePayloadFromPreset(preset);
2281
- return createNativeRequest(
2282
- wasmResult.payload,
2283
- this.config,
2284
- wasmResult.signal_hashes ?? {}
2285
- );
2327
+ const verifyVersion = getWorldAppVerifyVersion();
2328
+ if (verifyVersion === 2) {
2329
+ const wasmBuilder2 = createWasmBuilderFromConfig(this.config);
2330
+ const wasmResult = wasmBuilder2.nativePayloadFromPreset(preset);
2331
+ return createNativeRequest(
2332
+ wasmResult.payload,
2333
+ this.config,
2334
+ wasmResult.signal_hashes ?? {},
2335
+ 2
2336
+ );
2337
+ }
2338
+ try {
2339
+ const wasmBuilder2 = createWasmBuilderFromConfig(this.config);
2340
+ const wasmResult = wasmBuilder2.nativePayloadV1FromPreset(preset);
2341
+ return createNativeRequest(
2342
+ wasmResult.payload,
2343
+ this.config,
2344
+ wasmResult.signal_hashes ?? {},
2345
+ 1
2346
+ );
2347
+ } catch (err) {
2348
+ if (err instanceof Error && String(err.message).includes("v1 payload")) {
2349
+ throw new Error(
2350
+ "verify v2 is not supported by this World App version. Use a legacy preset (e.g. orbLegacy()) or update the World App."
2351
+ );
2352
+ }
2353
+ throw err;
2354
+ }
2286
2355
  }
2356
+ const wasmBuilder = createWasmBuilderFromConfig(this.config);
2287
2357
  const wasmRequest = await wasmBuilder.preset(
2288
2358
  preset
2289
2359
  );
@@ -2341,8 +2411,8 @@ var IDKit = {
2341
2411
  secureDocumentLegacy,
2342
2412
  /** Create a DocumentLegacy preset for World ID 3.0 legacy support */
2343
2413
  documentLegacy,
2344
- /** Create a SelfieCheck preset for face verification */
2345
- selfieCheck
2414
+ /** Create a SelfieCheckLegacy preset for face verification */
2415
+ selfieCheckLegacy
2346
2416
  };
2347
2417
 
2348
2418
  // src/lib/platform.ts
@@ -2389,4 +2459,4 @@ exports.isReactNative = isReactNative;
2389
2459
  exports.isWeb = isWeb;
2390
2460
  exports.orbLegacy = orbLegacy;
2391
2461
  exports.secureDocumentLegacy = secureDocumentLegacy;
2392
- exports.selfieCheck = selfieCheck;
2462
+ exports.selfieCheckLegacy = selfieCheckLegacy;
package/dist/index.d.cts CHANGED
@@ -84,27 +84,31 @@ type IDKitSessionConfig = {
84
84
  };
85
85
 
86
86
  interface OrbLegacyPreset {
87
+ /** This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions. */
87
88
  type: "OrbLegacy";
88
89
  signal?: string;
89
90
  }
90
91
 
91
92
  interface SecureDocumentLegacyPreset {
93
+ /** This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions. */
92
94
  type: "SecureDocumentLegacy";
93
95
  signal?: string;
94
96
  }
95
97
 
96
98
  interface DocumentLegacyPreset {
99
+ /** This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions. */
97
100
  type: "DocumentLegacy";
98
101
  signal?: string;
99
102
  }
100
103
 
101
- interface SelfieCheckPreset {
104
+ interface SelfieCheckLegacyPreset {
105
+ /** This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions. */
102
106
  /** Preview: Selfie Check is currently in preview. Contact us if you need it enabled. */
103
- type: "SelfieCheck";
107
+ type: "SelfieCheckLegacy";
104
108
  signal?: string;
105
109
  }
106
110
 
107
- type Preset = OrbLegacyPreset | SecureDocumentLegacyPreset | DocumentLegacyPreset | SelfieCheckPreset;
111
+ type Preset = OrbLegacyPreset | SecureDocumentLegacyPreset | DocumentLegacyPreset | SelfieCheckLegacyPreset;
108
112
 
109
113
 
110
114
 
@@ -339,8 +343,7 @@ interface IDKitRequest {
339
343
  /**
340
344
  * Creates an OrbLegacy preset for World ID 3.0 legacy support
341
345
  *
342
- * This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
343
- * Use this when you need backward compatibility with older World App versions.
346
+ * This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions.
344
347
  *
345
348
  * @param opts - Optional configuration with signal
346
349
  * @returns An OrbLegacy preset
@@ -357,8 +360,7 @@ declare function orbLegacy(opts?: {
357
360
  /**
358
361
  * Creates a SecureDocumentLegacy preset for World ID 3.0 legacy support
359
362
  *
360
- * This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
361
- * Use this when you need backward compatibility with older World App versions.
363
+ * This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions.
362
364
  *
363
365
  * @param opts - Optional configuration with signal
364
366
  * @returns A SecureDocumentLegacy preset
@@ -375,8 +377,7 @@ declare function secureDocumentLegacy(opts?: {
375
377
  /**
376
378
  * Creates a DocumentLegacy preset for World ID 3.0 legacy support
377
379
  *
378
- * This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
379
- * Use this when you need backward compatibility with older World App versions.
380
+ * This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions.
380
381
  *
381
382
  * @param opts - Optional configuration with signal
382
383
  * @returns A DocumentLegacy preset
@@ -391,26 +392,25 @@ declare function documentLegacy(opts?: {
391
392
  signal?: string;
392
393
  }): DocumentLegacyPreset;
393
394
  /**
394
- * Creates a SelfieCheck preset for face verification
395
+ * Creates a SelfieCheckLegacy preset for face verification
395
396
  *
396
397
  * Preview: Selfie Check is currently in preview.
397
398
  * Contact us if you need it enabled.
398
399
  *
399
- * This preset requests face credentials in v4 constraints.
400
- * In legacy compatibility fields, it maps to verification level "face".
400
+ * This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions.
401
401
  *
402
402
  * @param opts - Optional configuration with signal
403
- * @returns A SelfieCheck preset
403
+ * @returns A SelfieCheckLegacy preset
404
404
  *
405
405
  * @example
406
406
  * ```typescript
407
407
  * const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: false })
408
- * .preset(selfieCheck({ signal: 'user-123' }))
408
+ * .preset(selfieCheckLegacy({ signal: 'user-123' }))
409
409
  * ```
410
410
  */
411
- declare function selfieCheck(opts?: {
411
+ declare function selfieCheckLegacy(opts?: {
412
412
  signal?: string;
413
- }): SelfieCheckPreset;
413
+ }): SelfieCheckLegacyPreset;
414
414
  /**
415
415
  * Builder for IDKit requests
416
416
  *
@@ -440,7 +440,7 @@ declare class IDKitBuilder {
440
440
  * Presets provide a simplified way to create requests with predefined
441
441
  * credential configurations.
442
442
  *
443
- * @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), documentLegacy(), or selfieCheck()
443
+ * @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), documentLegacy(), or selfieCheckLegacy()
444
444
  * @returns A new IDKitRequest instance
445
445
  *
446
446
  * @example
@@ -520,8 +520,8 @@ declare const IDKit: {
520
520
  secureDocumentLegacy: typeof secureDocumentLegacy;
521
521
  /** Create a DocumentLegacy preset for World ID 3.0 legacy support */
522
522
  documentLegacy: typeof documentLegacy;
523
- /** Create a SelfieCheck preset for face verification */
524
- selfieCheck: typeof selfieCheck;
523
+ /** Create a SelfieCheckLegacy preset for face verification */
524
+ selfieCheckLegacy: typeof selfieCheckLegacy;
525
525
  };
526
526
 
527
527
  /**
@@ -546,4 +546,4 @@ declare const isWeb: () => boolean;
546
546
  */
547
547
  declare const isNode: () => boolean;
548
548
 
549
- 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 SelfieCheckPreset, type Status$1 as Status, type WaitOptions, documentLegacy, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy, selfieCheck };
549
+ 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 SelfieCheckLegacyPreset, type Status$1 as Status, type WaitOptions, documentLegacy, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy, selfieCheckLegacy };
package/dist/index.d.ts CHANGED
@@ -84,27 +84,31 @@ type IDKitSessionConfig = {
84
84
  };
85
85
 
86
86
  interface OrbLegacyPreset {
87
+ /** This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions. */
87
88
  type: "OrbLegacy";
88
89
  signal?: string;
89
90
  }
90
91
 
91
92
  interface SecureDocumentLegacyPreset {
93
+ /** This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions. */
92
94
  type: "SecureDocumentLegacy";
93
95
  signal?: string;
94
96
  }
95
97
 
96
98
  interface DocumentLegacyPreset {
99
+ /** This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions. */
97
100
  type: "DocumentLegacy";
98
101
  signal?: string;
99
102
  }
100
103
 
101
- interface SelfieCheckPreset {
104
+ interface SelfieCheckLegacyPreset {
105
+ /** This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions. */
102
106
  /** Preview: Selfie Check is currently in preview. Contact us if you need it enabled. */
103
- type: "SelfieCheck";
107
+ type: "SelfieCheckLegacy";
104
108
  signal?: string;
105
109
  }
106
110
 
107
- type Preset = OrbLegacyPreset | SecureDocumentLegacyPreset | DocumentLegacyPreset | SelfieCheckPreset;
111
+ type Preset = OrbLegacyPreset | SecureDocumentLegacyPreset | DocumentLegacyPreset | SelfieCheckLegacyPreset;
108
112
 
109
113
 
110
114
 
@@ -339,8 +343,7 @@ interface IDKitRequest {
339
343
  /**
340
344
  * Creates an OrbLegacy preset for World ID 3.0 legacy support
341
345
  *
342
- * This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
343
- * Use this when you need backward compatibility with older World App versions.
346
+ * This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions.
344
347
  *
345
348
  * @param opts - Optional configuration with signal
346
349
  * @returns An OrbLegacy preset
@@ -357,8 +360,7 @@ declare function orbLegacy(opts?: {
357
360
  /**
358
361
  * Creates a SecureDocumentLegacy preset for World ID 3.0 legacy support
359
362
  *
360
- * This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
361
- * Use this when you need backward compatibility with older World App versions.
363
+ * This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions.
362
364
  *
363
365
  * @param opts - Optional configuration with signal
364
366
  * @returns A SecureDocumentLegacy preset
@@ -375,8 +377,7 @@ declare function secureDocumentLegacy(opts?: {
375
377
  /**
376
378
  * Creates a DocumentLegacy preset for World ID 3.0 legacy support
377
379
  *
378
- * This preset creates an IDKit request compatible with both World ID 4.0 and 3.0 protocols.
379
- * Use this when you need backward compatibility with older World App versions.
380
+ * This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions.
380
381
  *
381
382
  * @param opts - Optional configuration with signal
382
383
  * @returns A DocumentLegacy preset
@@ -391,26 +392,25 @@ declare function documentLegacy(opts?: {
391
392
  signal?: string;
392
393
  }): DocumentLegacyPreset;
393
394
  /**
394
- * Creates a SelfieCheck preset for face verification
395
+ * Creates a SelfieCheckLegacy preset for face verification
395
396
  *
396
397
  * Preview: Selfie Check is currently in preview.
397
398
  * Contact us if you need it enabled.
398
399
  *
399
- * This preset requests face credentials in v4 constraints.
400
- * In legacy compatibility fields, it maps to verification level "face".
400
+ * This preset only returns World ID 3.0 proofs. Use it for compatibility with older IDKit versions.
401
401
  *
402
402
  * @param opts - Optional configuration with signal
403
- * @returns A SelfieCheck preset
403
+ * @returns A SelfieCheckLegacy preset
404
404
  *
405
405
  * @example
406
406
  * ```typescript
407
407
  * const request = await IDKit.request({ app_id, action, rp_context, allow_legacy_proofs: false })
408
- * .preset(selfieCheck({ signal: 'user-123' }))
408
+ * .preset(selfieCheckLegacy({ signal: 'user-123' }))
409
409
  * ```
410
410
  */
411
- declare function selfieCheck(opts?: {
411
+ declare function selfieCheckLegacy(opts?: {
412
412
  signal?: string;
413
- }): SelfieCheckPreset;
413
+ }): SelfieCheckLegacyPreset;
414
414
  /**
415
415
  * Builder for IDKit requests
416
416
  *
@@ -440,7 +440,7 @@ declare class IDKitBuilder {
440
440
  * Presets provide a simplified way to create requests with predefined
441
441
  * credential configurations.
442
442
  *
443
- * @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), documentLegacy(), or selfieCheck()
443
+ * @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), documentLegacy(), or selfieCheckLegacy()
444
444
  * @returns A new IDKitRequest instance
445
445
  *
446
446
  * @example
@@ -520,8 +520,8 @@ declare const IDKit: {
520
520
  secureDocumentLegacy: typeof secureDocumentLegacy;
521
521
  /** Create a DocumentLegacy preset for World ID 3.0 legacy support */
522
522
  documentLegacy: typeof documentLegacy;
523
- /** Create a SelfieCheck preset for face verification */
524
- selfieCheck: typeof selfieCheck;
523
+ /** Create a SelfieCheckLegacy preset for face verification */
524
+ selfieCheckLegacy: typeof selfieCheckLegacy;
525
525
  };
526
526
 
527
527
  /**
@@ -546,4 +546,4 @@ declare const isWeb: () => boolean;
546
546
  */
547
547
  declare const isNode: () => boolean;
548
548
 
549
- 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 SelfieCheckPreset, type Status$1 as Status, type WaitOptions, documentLegacy, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy, selfieCheck };
549
+ 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 SelfieCheckLegacyPreset, type Status$1 as Status, type WaitOptions, documentLegacy, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy, selfieCheckLegacy };
package/dist/index.js CHANGED
@@ -389,14 +389,14 @@ function hashSignal(signal) {
389
389
  wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
390
390
  }
391
391
  }
392
- function __wasm_bindgen_func_elem_605(arg0, arg1) {
393
- wasm.__wasm_bindgen_func_elem_605(arg0, arg1);
392
+ function __wasm_bindgen_func_elem_972(arg0, arg1, arg2) {
393
+ wasm.__wasm_bindgen_func_elem_972(arg0, arg1, addHeapObject(arg2));
394
394
  }
395
- function __wasm_bindgen_func_elem_968(arg0, arg1, arg2) {
396
- wasm.__wasm_bindgen_func_elem_968(arg0, arg1, addHeapObject(arg2));
395
+ function __wasm_bindgen_func_elem_609(arg0, arg1) {
396
+ wasm.__wasm_bindgen_func_elem_609(arg0, arg1);
397
397
  }
398
- function __wasm_bindgen_func_elem_1353(arg0, arg1, arg2, arg3) {
399
- wasm.__wasm_bindgen_func_elem_1353(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
398
+ function __wasm_bindgen_func_elem_1357(arg0, arg1, arg2, arg3) {
399
+ wasm.__wasm_bindgen_func_elem_1357(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
400
400
  }
401
401
  var __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
402
402
  var __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -884,6 +884,35 @@ var IDKitBuilder = class _IDKitBuilder {
884
884
  wasm.__wbindgen_add_to_stack_pointer(16);
885
885
  }
886
886
  }
887
+ /**
888
+ * Builds a v1 (legacy) native payload from a preset (synchronous, no bridge connection).
889
+ *
890
+ * Used by the native transport when the World App only supports verify v1.
891
+ * Only legacy presets produce valid v1 payloads (constraints always have
892
+ * `Deprecated` verification level and will fail).
893
+ *
894
+ * # Errors
895
+ *
896
+ * Returns an error if the preset is invalid or v1 payload construction fails.
897
+ * @param {any} preset_json
898
+ * @returns {any}
899
+ */
900
+ nativePayloadV1FromPreset(preset_json) {
901
+ try {
902
+ const ptr = this.__destroy_into_raw();
903
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
904
+ wasm.idkitbuilder_nativePayloadV1FromPreset(retptr, ptr, addHeapObject(preset_json));
905
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
906
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
907
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
908
+ if (r2) {
909
+ throw takeObject(r1);
910
+ }
911
+ return takeObject(r0);
912
+ } finally {
913
+ wasm.__wbindgen_add_to_stack_pointer(16);
914
+ }
915
+ }
887
916
  /**
888
917
  * Creates a new builder for uniqueness requests
889
918
  * @param {string} app_id
@@ -1559,7 +1588,7 @@ function __wbg_get_imports() {
1559
1588
  const a = state0.a;
1560
1589
  state0.a = 0;
1561
1590
  try {
1562
- return __wasm_bindgen_func_elem_1353(a, state0.b, arg02, arg12);
1591
+ return __wasm_bindgen_func_elem_1357(a, state0.b, arg02, arg12);
1563
1592
  } finally {
1564
1593
  state0.a = a;
1565
1594
  }
@@ -1769,7 +1798,7 @@ function __wbg_get_imports() {
1769
1798
  return addHeapObject(ret);
1770
1799
  };
1771
1800
  imports.wbg.__wbindgen_cast_02740531cfdb05fe = function(arg0, arg1) {
1772
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_604, __wasm_bindgen_func_elem_605);
1801
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_608, __wasm_bindgen_func_elem_609);
1773
1802
  return addHeapObject(ret);
1774
1803
  };
1775
1804
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
@@ -1793,7 +1822,7 @@ function __wbg_get_imports() {
1793
1822
  return addHeapObject(ret);
1794
1823
  };
1795
1824
  imports.wbg.__wbindgen_cast_f23235b6472d5cf3 = function(arg0, arg1) {
1796
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_967, __wasm_bindgen_func_elem_968);
1825
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_971, __wasm_bindgen_func_elem_972);
1797
1826
  return addHeapObject(ret);
1798
1827
  };
1799
1828
  imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
@@ -1877,21 +1906,32 @@ var MINIAPP_VERIFY_ACTION = "miniapp-verify-action";
1877
1906
  function isInWorldApp() {
1878
1907
  return typeof window !== "undefined" && Boolean(window.WorldApp);
1879
1908
  }
1909
+ function getWorldAppVerifyVersion() {
1910
+ const cmds = window.WorldApp?.supported_commands;
1911
+ if (!Array.isArray(cmds)) return 1;
1912
+ const verify = cmds.find((c) => c.name === "verify");
1913
+ return verify?.supported_versions?.includes(2) ? 2 : 1;
1914
+ }
1880
1915
  var _requestCounter = 0;
1881
1916
  var _activeNativeRequest = null;
1882
- function createNativeRequest(wasmPayload, config, signalHashes = {}) {
1917
+ function createNativeRequest(wasmPayload, config, signalHashes = {}, version) {
1883
1918
  if (_activeNativeRequest?.isPending()) {
1884
1919
  console.warn(
1885
1920
  "IDKit native request already in flight. Reusing active request."
1886
1921
  );
1887
1922
  return _activeNativeRequest;
1888
1923
  }
1889
- const request2 = new NativeIDKitRequest(wasmPayload, config, signalHashes);
1924
+ const request2 = new NativeIDKitRequest(
1925
+ wasmPayload,
1926
+ config,
1927
+ signalHashes,
1928
+ version
1929
+ );
1890
1930
  _activeNativeRequest = request2;
1891
1931
  return request2;
1892
1932
  }
1893
1933
  var NativeIDKitRequest = class {
1894
- constructor(wasmPayload, config, signalHashes = {}) {
1934
+ constructor(wasmPayload, config, signalHashes = {}, version) {
1895
1935
  this.connectorURI = "";
1896
1936
  this.resolved = false;
1897
1937
  this.cancelled = false;
@@ -1945,7 +1985,7 @@ var NativeIDKitRequest = class {
1945
1985
  }
1946
1986
  const sendPayload = {
1947
1987
  command: "verify",
1948
- version: 2,
1988
+ version,
1949
1989
  payload: wasmPayload
1950
1990
  };
1951
1991
  const w = window;
@@ -2177,8 +2217,8 @@ function secureDocumentLegacy(opts = {}) {
2177
2217
  function documentLegacy(opts = {}) {
2178
2218
  return { type: "DocumentLegacy", signal: opts.signal };
2179
2219
  }
2180
- function selfieCheck(opts = {}) {
2181
- return { type: "SelfieCheck", signal: opts.signal };
2220
+ function selfieCheckLegacy(opts = {}) {
2221
+ return { type: "SelfieCheckLegacy", signal: opts.signal };
2182
2222
  }
2183
2223
  function createWasmBuilderFromConfig(config) {
2184
2224
  if (!config.rp_context) {
@@ -2241,15 +2281,23 @@ var IDKitBuilder2 = class {
2241
2281
  */
2242
2282
  async constraints(constraints) {
2243
2283
  await initIDKit();
2244
- const wasmBuilder = createWasmBuilderFromConfig(this.config);
2245
2284
  if (isInWorldApp()) {
2246
- const wasmResult = wasmBuilder.nativePayload(constraints);
2285
+ const verifyVersion = getWorldAppVerifyVersion();
2286
+ if (verifyVersion < 2) {
2287
+ throw new Error(
2288
+ "verify v2 is not supported by this World App version. Use a legacy preset (e.g. orbLegacy()) or update the World App."
2289
+ );
2290
+ }
2291
+ const wasmBuilder2 = createWasmBuilderFromConfig(this.config);
2292
+ const wasmResult = wasmBuilder2.nativePayload(constraints);
2247
2293
  return createNativeRequest(
2248
2294
  wasmResult.payload,
2249
2295
  this.config,
2250
- wasmResult.signal_hashes ?? {}
2296
+ wasmResult.signal_hashes ?? {},
2297
+ 2
2251
2298
  );
2252
2299
  }
2300
+ const wasmBuilder = createWasmBuilderFromConfig(this.config);
2253
2301
  const wasmRequest = await wasmBuilder.constraints(
2254
2302
  constraints
2255
2303
  );
@@ -2261,7 +2309,7 @@ var IDKitBuilder2 = class {
2261
2309
  * Presets provide a simplified way to create requests with predefined
2262
2310
  * credential configurations.
2263
2311
  *
2264
- * @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), documentLegacy(), or selfieCheck()
2312
+ * @param preset - A preset object from orbLegacy(), secureDocumentLegacy(), documentLegacy(), or selfieCheckLegacy()
2265
2313
  * @returns A new IDKitRequest instance
2266
2314
  *
2267
2315
  * @example
@@ -2272,15 +2320,37 @@ var IDKitBuilder2 = class {
2272
2320
  */
2273
2321
  async preset(preset) {
2274
2322
  await initIDKit();
2275
- const wasmBuilder = createWasmBuilderFromConfig(this.config);
2276
2323
  if (isInWorldApp()) {
2277
- const wasmResult = wasmBuilder.nativePayloadFromPreset(preset);
2278
- return createNativeRequest(
2279
- wasmResult.payload,
2280
- this.config,
2281
- wasmResult.signal_hashes ?? {}
2282
- );
2324
+ const verifyVersion = getWorldAppVerifyVersion();
2325
+ if (verifyVersion === 2) {
2326
+ const wasmBuilder2 = createWasmBuilderFromConfig(this.config);
2327
+ const wasmResult = wasmBuilder2.nativePayloadFromPreset(preset);
2328
+ return createNativeRequest(
2329
+ wasmResult.payload,
2330
+ this.config,
2331
+ wasmResult.signal_hashes ?? {},
2332
+ 2
2333
+ );
2334
+ }
2335
+ try {
2336
+ const wasmBuilder2 = createWasmBuilderFromConfig(this.config);
2337
+ const wasmResult = wasmBuilder2.nativePayloadV1FromPreset(preset);
2338
+ return createNativeRequest(
2339
+ wasmResult.payload,
2340
+ this.config,
2341
+ wasmResult.signal_hashes ?? {},
2342
+ 1
2343
+ );
2344
+ } catch (err) {
2345
+ if (err instanceof Error && String(err.message).includes("v1 payload")) {
2346
+ throw new Error(
2347
+ "verify v2 is not supported by this World App version. Use a legacy preset (e.g. orbLegacy()) or update the World App."
2348
+ );
2349
+ }
2350
+ throw err;
2351
+ }
2283
2352
  }
2353
+ const wasmBuilder = createWasmBuilderFromConfig(this.config);
2284
2354
  const wasmRequest = await wasmBuilder.preset(
2285
2355
  preset
2286
2356
  );
@@ -2338,8 +2408,8 @@ var IDKit = {
2338
2408
  secureDocumentLegacy,
2339
2409
  /** Create a DocumentLegacy preset for World ID 3.0 legacy support */
2340
2410
  documentLegacy,
2341
- /** Create a SelfieCheck preset for face verification */
2342
- selfieCheck
2411
+ /** Create a SelfieCheckLegacy preset for face verification */
2412
+ selfieCheckLegacy
2343
2413
  };
2344
2414
 
2345
2415
  // src/lib/platform.ts
@@ -2373,4 +2443,4 @@ function isValidHex(s) {
2373
2443
  return /^[0-9a-fA-F]+$/.test(s);
2374
2444
  }
2375
2445
 
2376
- export { IDKit, IDKitErrorCodes, documentLegacy, hashSignal2 as hashSignal, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy, selfieCheck };
2446
+ export { IDKit, IDKitErrorCodes, documentLegacy, hashSignal2 as hashSignal, isNode, isReactNative, isWeb, orbLegacy, secureDocumentLegacy, selfieCheckLegacy };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldcoin/idkit-core",
3
- "version": "4.0.7",
3
+ "version": "4.0.9-dev.648eacc",
4
4
  "description": "Core IDKit SDK for World ID - Pure TypeScript, no dependencies",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",