@arkade-os/sdk 0.4.67 → 0.5.0-rc.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.
Files changed (80) hide show
  1. package/README.md +40 -5
  2. package/dist/adapters/expo.cjs +5 -5
  3. package/dist/adapters/expo.d.cts +2 -2
  4. package/dist/adapters/expo.d.ts +2 -2
  5. package/dist/adapters/expo.js +3 -3
  6. package/dist/adapters/indexedDB.cjs +5 -5
  7. package/dist/adapters/indexedDB.js +4 -4
  8. package/dist/{asyncStorageTaskQueue-Za-e_zMk.d.ts → asyncStorageTaskQueue-BCzN3Y45.d.ts} +2 -2
  9. package/dist/{asyncStorageTaskQueue-LTpeXYaD.d.cts → asyncStorageTaskQueue-CdF_ELX8.d.cts} +2 -2
  10. package/dist/{chunk-MJUTO3PY.cjs → chunk-5MJHZHG7.cjs} +771 -477
  11. package/dist/chunk-5MJHZHG7.cjs.map +1 -0
  12. package/dist/{chunk-2JV4VQ7C.cjs → chunk-6AFUNKK7.cjs} +33 -7
  13. package/dist/chunk-6AFUNKK7.cjs.map +1 -0
  14. package/dist/{chunk-AEWJU6NZ.js → chunk-6F2Q32KA.js} +352 -59
  15. package/dist/chunk-6F2Q32KA.js.map +1 -0
  16. package/dist/{chunk-EALWOVHK.js → chunk-ABJPM4JF.js} +4 -4
  17. package/dist/{chunk-EALWOVHK.js.map → chunk-ABJPM4JF.js.map} +1 -1
  18. package/dist/{chunk-CO3KKSWM.cjs → chunk-CZ32XADN.cjs} +17 -17
  19. package/dist/{chunk-CO3KKSWM.cjs.map → chunk-CZ32XADN.cjs.map} +1 -1
  20. package/dist/{chunk-X3VEMUVV.js → chunk-FVTJJQNM.js} +3 -3
  21. package/dist/{chunk-X3VEMUVV.js.map → chunk-FVTJJQNM.js.map} +1 -1
  22. package/dist/{chunk-OIZ2V2VD.cjs → chunk-HL7EC2Z5.cjs} +121 -170
  23. package/dist/chunk-HL7EC2Z5.cjs.map +1 -0
  24. package/dist/{chunk-MZFUZUTQ.js → chunk-JYP7YXT2.js} +4 -4
  25. package/dist/{chunk-MZFUZUTQ.js.map → chunk-JYP7YXT2.js.map} +1 -1
  26. package/dist/{chunk-6TAQF6EV.js → chunk-KTU44AEH.js} +75 -124
  27. package/dist/chunk-KTU44AEH.js.map +1 -0
  28. package/dist/{chunk-YDRZDZPP.cjs → chunk-PB5KJI4U.cjs} +10 -10
  29. package/dist/{chunk-YDRZDZPP.cjs.map → chunk-PB5KJI4U.cjs.map} +1 -1
  30. package/dist/{chunk-3WIWNE4P.js → chunk-PPG6W34P.js} +30 -8
  31. package/dist/chunk-PPG6W34P.js.map +1 -0
  32. package/dist/{chunk-R2YAMONM.cjs → chunk-RXWKCEZP.cjs} +17 -17
  33. package/dist/{chunk-R2YAMONM.cjs.map → chunk-RXWKCEZP.cjs.map} +1 -1
  34. package/dist/contracts/handlers/index.cjs +9 -9
  35. package/dist/contracts/handlers/index.d.cts +3 -3
  36. package/dist/contracts/handlers/index.d.ts +3 -3
  37. package/dist/contracts/handlers/index.js +2 -2
  38. package/dist/{delegate-Bz2e2zXY.d.cts → delegate-DLIOBQ5x.d.cts} +1 -1
  39. package/dist/{delegate-cdmzb2f9.d.ts → delegate-Dyn5L80J.d.ts} +1 -1
  40. package/dist/{hdWalletCapable-BSjuUYOO.d.cts → hdWalletCapable-D9tooZ6F.d.ts} +102 -27
  41. package/dist/{hdWalletCapable-Hi12xjCJ.d.ts → hdWalletCapable-Dt3MUiGE.d.cts} +102 -27
  42. package/dist/{index-BiACuWaf.d.ts → index-D3hmsuKs.d.cts} +100 -123
  43. package/dist/{index-D2GjZxBr.d.cts → index-D9tXd-tN.d.ts} +100 -123
  44. package/dist/{index-DU5o_hz7.d.ts → index-Udm5V2xW.d.cts} +184 -19
  45. package/dist/{index-DU5o_hz7.d.cts → index-Udm5V2xW.d.ts} +184 -19
  46. package/dist/index.cjs +309 -289
  47. package/dist/index.d.cts +125 -29
  48. package/dist/index.d.ts +125 -29
  49. package/dist/index.js +4 -4
  50. package/dist/repositories/realm/index.cjs +19 -19
  51. package/dist/repositories/realm/index.d.cts +2 -2
  52. package/dist/repositories/realm/index.d.ts +2 -2
  53. package/dist/repositories/realm/index.js +5 -5
  54. package/dist/repositories/sqlite/index.cjs +18 -18
  55. package/dist/repositories/sqlite/index.d.cts +2 -2
  56. package/dist/repositories/sqlite/index.d.ts +2 -2
  57. package/dist/repositories/sqlite/index.js +5 -5
  58. package/dist/{taskRunner-BZJMLQ6g.d.cts → taskRunner-DxZciNaa.d.cts} +2 -2
  59. package/dist/{taskRunner-DATaRQus.d.ts → taskRunner-ZdS16Ypm.d.ts} +2 -2
  60. package/dist/wallet/expo/background.cjs +14 -14
  61. package/dist/wallet/expo/background.d.cts +3 -3
  62. package/dist/wallet/expo/background.d.ts +3 -3
  63. package/dist/wallet/expo/background.js +6 -6
  64. package/dist/wallet/expo/index.cjs +23 -14
  65. package/dist/wallet/expo/index.cjs.map +1 -1
  66. package/dist/wallet/expo/index.d.cts +7 -4
  67. package/dist/wallet/expo/index.d.ts +7 -4
  68. package/dist/wallet/expo/index.js +14 -5
  69. package/dist/wallet/expo/index.js.map +1 -1
  70. package/dist/worker/expo/index.cjs +9 -9
  71. package/dist/worker/expo/index.d.cts +4 -4
  72. package/dist/worker/expo/index.d.ts +4 -4
  73. package/dist/worker/expo/index.js +5 -5
  74. package/package.json +3 -2
  75. package/dist/chunk-2JV4VQ7C.cjs.map +0 -1
  76. package/dist/chunk-3WIWNE4P.js.map +0 -1
  77. package/dist/chunk-6TAQF6EV.js.map +0 -1
  78. package/dist/chunk-AEWJU6NZ.js.map +0 -1
  79. package/dist/chunk-MJUTO3PY.cjs.map +0 -1
  80. package/dist/chunk-OIZ2V2VD.cjs.map +0 -1
@@ -49,6 +49,18 @@ var Transaction = class extends btcSigner.Transaction {
49
49
  function withArkOpts(opts) {
50
50
  return { ...Transaction.ARK_TX_OPTS, ...opts };
51
51
  }
52
+ function formatSighash(type) {
53
+ return `0x${type.toString(16).padStart(2, "0")}`;
54
+ }
55
+ function assertAllowedSighashTypes(tx, allowedSighashTypes = [btcSigner.SigHash.DEFAULT]) {
56
+ for (let i = 0; i < tx.inputsLength; i++) {
57
+ const declared = tx.getInput(i).sighashType;
58
+ if (declared === void 0) continue;
59
+ if (!allowedSighashTypes.includes(declared)) {
60
+ throw new Error(`Unallowed sighash type ${formatSighash(declared)} for input ${i}.`);
61
+ }
62
+ }
63
+ }
52
64
  function timelockToSequence(timelock) {
53
65
  return bip68__namespace.encode(
54
66
  timelock.type === "blocks" ? { blocks: Number(timelock.value) } : { seconds: Number(timelock.value) }
@@ -202,6 +214,7 @@ var getNetwork = (network) => {
202
214
  if (!found) throw new Error(`Unsupported network: ${network}`);
203
215
  return found;
204
216
  };
217
+ var networkFromArkadeInfo = (info) => getNetwork(info.network);
205
218
  var networks = {
206
219
  bitcoin: withArkPrefix(utils_js.NETWORK, "ark", "bitcoin"),
207
220
  testnet: withArkPrefix(utils_js.TEST_NETWORK, "tark", "testnet"),
@@ -1032,7 +1045,7 @@ function resolveEventSource(override) {
1032
1045
  }
1033
1046
 
1034
1047
  // package.json
1035
- var version = "0.4.67";
1048
+ var version = "0.5.0-rc.0";
1036
1049
 
1037
1050
  // src/utils/fetch.ts
1038
1051
  var buildVersion = "0.9.9";
@@ -1630,8 +1643,9 @@ var RestArkProvider = class {
1630
1643
  /** Overrides {@link configureEventSource} for this provider's streams. */
1631
1644
  eventSource;
1632
1645
  /**
1633
- * Last server-info digest seen from {@link getInfo}. Sent as `X-Digest`
1634
- * so arkd can reject stale client configuration.
1646
+ * Last server-info digest seen (from {@link getInfo}). Sent as `X-Digest`
1647
+ * on outgoing requests so arkd can reject a client whose cached info is
1648
+ * stale. Empty until the first {@link getInfo}.
1635
1649
  */
1636
1650
  _digest = "";
1637
1651
  _hasServerInfo = false;
@@ -1709,7 +1723,10 @@ var RestArkProvider = class {
1709
1723
  }
1710
1724
  async getInfo() {
1711
1725
  const url = `${this.serverUrl}/v1/info`;
1712
- const response = await rateGate.runHttp(url, () => fetch(url));
1726
+ const response = await rateGate.runHttp(
1727
+ url,
1728
+ () => fetch(url, { signal: infoFetchSignal() })
1729
+ );
1713
1730
  if (!response.ok) {
1714
1731
  const errorText = await response.text();
1715
1732
  throwIfHttpUnavailable(response, "arkade", errorText);
@@ -2193,11 +2210,16 @@ function decodeMusig2Nonces(noncesObject) {
2193
2210
  })
2194
2211
  );
2195
2212
  }
2213
+ var INFO_FETCH_TIMEOUT_MS = 12e3;
2214
+ function infoFetchSignal() {
2215
+ return typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function" ? AbortSignal.timeout(INFO_FETCH_TIMEOUT_MS) : void 0;
2216
+ }
2196
2217
  function isFetchTimeoutError(err) {
2197
2218
  const checkError = (error) => {
2198
2219
  if (!(error instanceof Error)) return false;
2199
2220
  const isCloudflare524 = error.name === "TypeError" && error.message === "Failed to fetch";
2200
- return isCloudflare524 || error.name === "HeadersTimeoutError" || error.name === "BodyTimeoutError" || error.code === "UND_ERR_HEADERS_TIMEOUT" || error.code === "UND_ERR_BODY_TIMEOUT";
2221
+ return isCloudflare524 || // AbortSignal.timeout rejects with a DOMException named this
2222
+ error.name === "TimeoutError" || error.name === "HeadersTimeoutError" || error.name === "BodyTimeoutError" || error.code === "UND_ERR_HEADERS_TIMEOUT" || error.code === "UND_ERR_BODY_TIMEOUT";
2201
2223
  };
2202
2224
  return checkError(err) || checkError(err.cause);
2203
2225
  }
@@ -2449,6 +2471,7 @@ exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
2449
2471
  exports.DigestMismatchError = DigestMismatchError;
2450
2472
  exports.EventSourceUnavailableError = EventSourceUnavailableError;
2451
2473
  exports.FetchError = FetchError;
2474
+ exports.INFO_FETCH_TIMEOUT_MS = INFO_FETCH_TIMEOUT_MS;
2452
2475
  exports.MUTINYNET_EMULATOR_PUBKEY = MUTINYNET_EMULATOR_PUBKEY;
2453
2476
  exports.OP_RETURN_EMPTY_PKSCRIPT = OP_RETURN_EMPTY_PKSCRIPT;
2454
2477
  exports.PrevArkTxField = PrevArkTxField;
@@ -2465,6 +2488,7 @@ exports.VtxoScript = VtxoScript;
2465
2488
  exports.VtxoTaprootTree = VtxoTaprootTree;
2466
2489
  exports.VtxoTreeExpiry = VtxoTreeExpiry;
2467
2490
  exports.assembleBtcdTaprootTree = assembleBtcdTaprootTree;
2491
+ exports.assertAllowedSighashTypes = assertAllowedSighashTypes;
2468
2492
  exports.baseFetch = baseFetch;
2469
2493
  exports.buildVersion = buildVersion;
2470
2494
  exports.canRecoverOnchain = canRecoverOnchain;
@@ -2478,6 +2502,7 @@ exports.defaultEmulatorPubkey = defaultEmulatorPubkey;
2478
2502
  exports.eventSourceIterator = eventSourceIterator;
2479
2503
  exports.fetch = fetch;
2480
2504
  exports.fetchVtxoCreatedAtByTxid = fetchVtxoCreatedAtByTxid;
2505
+ exports.formatSighash = formatSighash;
2481
2506
  exports.getAllNormalizedVtxos = getAllNormalizedVtxos;
2482
2507
  exports.getArkPsbtFields = getArkPsbtFields;
2483
2508
  exports.getConfiguredEventSource = getConfiguredEventSource;
@@ -2496,6 +2521,7 @@ exports.isRetryableProviderError = isRetryableProviderError;
2496
2521
  exports.isSpendable = isSpendable;
2497
2522
  exports.isVirtualCoin = isVirtualCoin;
2498
2523
  exports.maybeArkError = maybeArkError;
2524
+ exports.networkFromArkadeInfo = networkFromArkadeInfo;
2499
2525
  exports.networks = networks;
2500
2526
  exports.normalizeVtxo = normalizeVtxo;
2501
2527
  exports.parseLegacyExpiry = parseLegacyExpiry;
@@ -2513,5 +2539,5 @@ exports.toBatchExpiry = toBatchExpiry;
2513
2539
  exports.toOffchainInputFeeParams = toOffchainInputFeeParams;
2514
2540
  exports.toProviderUnavailable = toProviderUnavailable;
2515
2541
  exports.toVirtualStatus = toVirtualStatus;
2516
- //# sourceMappingURL=chunk-2JV4VQ7C.cjs.map
2517
- //# sourceMappingURL=chunk-2JV4VQ7C.cjs.map
2542
+ //# sourceMappingURL=chunk-6AFUNKK7.cjs.map
2543
+ //# sourceMappingURL=chunk-6AFUNKK7.cjs.map