@worldcoin/idkit-core 4.0.8 → 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.
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_968(arg0, arg1, arg2) {
396
- wasm.__wasm_bindgen_func_elem_968(arg0, arg1, addHeapObject(arg2));
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_605(arg0, arg1) {
399
- wasm.__wasm_bindgen_func_elem_605(arg0, arg1);
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;
@@ -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
  );
@@ -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
  );
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_968(arg0, arg1, arg2) {
393
- wasm.__wasm_bindgen_func_elem_968(arg0, arg1, addHeapObject(arg2));
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_605(arg0, arg1) {
396
- wasm.__wasm_bindgen_func_elem_605(arg0, arg1);
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;
@@ -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
  );
@@ -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
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldcoin/idkit-core",
3
- "version": "4.0.8",
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",