@breeztech/breez-sdk-spark 0.19.0 → 0.20.0-dev1

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.
@@ -35,6 +35,16 @@ export class BitcoinChainServiceHandle {
35
35
  const ret = wasm.bitcoinchainservicehandle_broadcastTransaction(this.__wbg_ptr, ptr0, len0);
36
36
  return ret;
37
37
  }
38
+ /**
39
+ * @param {string} address
40
+ * @returns {Promise<any>}
41
+ */
42
+ getAddressTxos(address) {
43
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
44
+ const len0 = WASM_VECTOR_LEN;
45
+ const ret = wasm.bitcoinchainservicehandle_getAddressTxos(this.__wbg_ptr, ptr0, len0);
46
+ return ret;
47
+ }
38
48
  /**
39
49
  * @param {string} address
40
50
  * @returns {Promise<any>}
@@ -45,6 +55,17 @@ export class BitcoinChainServiceHandle {
45
55
  const ret = wasm.bitcoinchainservicehandle_getAddressUtxos(this.__wbg_ptr, ptr0, len0);
46
56
  return ret;
47
57
  }
58
+ /**
59
+ * @param {string} txid
60
+ * @param {number} vout
61
+ * @returns {Promise<any>}
62
+ */
63
+ getOutspend(txid, vout) {
64
+ const ptr0 = passStringToWasm0(txid, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
65
+ const len0 = WASM_VECTOR_LEN;
66
+ const ret = wasm.bitcoinchainservicehandle_getOutspend(this.__wbg_ptr, ptr0, len0, vout);
67
+ return ret;
68
+ }
48
69
  /**
49
70
  * @param {string} txid
50
71
  * @returns {Promise<any>}
@@ -368,6 +389,14 @@ export class BreezSdk {
368
389
  const ret = wasm.breezsdk_prepareSendPayment(this.__wbg_ptr, request);
369
390
  return ret;
370
391
  }
392
+ /**
393
+ * @param {PrepareUnilateralExitRequest} request
394
+ * @returns {Promise<PrepareUnilateralExitResponse>}
395
+ */
396
+ prepareUnilateralExit(request) {
397
+ const ret = wasm.breezsdk_prepareUnilateralExit(this.__wbg_ptr, request);
398
+ return ret;
399
+ }
371
400
  /**
372
401
  * @param {PublishSignedLnurlPayPackageRequest} request
373
402
  * @returns {Promise<PublishSignedLnurlPayResponse>}
@@ -408,7 +437,7 @@ export class BreezSdk {
408
437
  return ret;
409
438
  }
410
439
  /**
411
- * @returns {Promise<void>}
440
+ * @returns {Promise<RefundPendingConversionsResponse>}
412
441
  */
413
442
  refundPendingConversions() {
414
443
  const ret = wasm.breezsdk_refundPendingConversions(this.__wbg_ptr);
@@ -464,6 +493,15 @@ export class BreezSdk {
464
493
  const ret = wasm.breezsdk_syncWallet(this.__wbg_ptr, request);
465
494
  return ret;
466
495
  }
496
+ /**
497
+ * @param {UnilateralExitRequest} request
498
+ * @param {CpfpSigner} signer
499
+ * @returns {Promise<UnilateralExitResponse>}
500
+ */
501
+ unilateralExit(request, signer) {
502
+ const ret = wasm.breezsdk_unilateralExit(this.__wbg_ptr, request, signer);
503
+ return ret;
504
+ }
467
505
  /**
468
506
  * @param {UnregisterWebhookRequest} request
469
507
  * @returns {Promise<void>}
@@ -491,6 +529,39 @@ export class BreezSdk {
491
529
  }
492
530
  if (Symbol.dispose) BreezSdk.prototype[Symbol.dispose] = BreezSdk.prototype.free;
493
531
 
532
+ /**
533
+ * A CPFP signer matching the `CpfpSigner` TypeScript interface.
534
+ */
535
+ export class DefaultCpfpSigner {
536
+ static __wrap(ptr) {
537
+ const obj = Object.create(DefaultCpfpSigner.prototype);
538
+ obj.__wbg_ptr = ptr;
539
+ DefaultCpfpSignerFinalization.register(obj, obj.__wbg_ptr, obj);
540
+ return obj;
541
+ }
542
+ __destroy_into_raw() {
543
+ const ptr = this.__wbg_ptr;
544
+ this.__wbg_ptr = 0;
545
+ DefaultCpfpSignerFinalization.unregister(this);
546
+ return ptr;
547
+ }
548
+ free() {
549
+ const ptr = this.__destroy_into_raw();
550
+ wasm.__wbg_defaultcpfpsigner_free(ptr, 0);
551
+ }
552
+ /**
553
+ * @param {Uint8Array} psbt_bytes
554
+ * @returns {Promise<Uint8Array>}
555
+ */
556
+ signPsbt(psbt_bytes) {
557
+ const ptr0 = passArray8ToWasm0(psbt_bytes, wasm.__wbindgen_malloc);
558
+ const len0 = WASM_VECTOR_LEN;
559
+ const ret = wasm.defaultcpfpsigner_signPsbt(this.__wbg_ptr, ptr0, len0);
560
+ return ret;
561
+ }
562
+ }
563
+ if (Symbol.dispose) DefaultCpfpSigner.prototype[Symbol.dispose] = DefaultCpfpSigner.prototype.free;
564
+
494
565
  /**
495
566
  * A JS handle to a backend's own session store (from `defaultSessionStore`),
496
567
  * exposing the same `getSession` / `setSession` interface. Wrap it in a JS
@@ -880,6 +951,17 @@ export class ExternalSparkSignerHandle {
880
951
  const ret = wasm.externalsparksignerhandle_signFrost(this.__wbg_ptr, ptr0, len0);
881
952
  return ret;
882
953
  }
954
+ /**
955
+ * @param {ExternalTreeNodeId} leaf_id
956
+ * @param {Uint8Array} sighash
957
+ * @returns {Promise<SchnorrSignatureBytes>}
958
+ */
959
+ signLeafRefundSpend(leaf_id, sighash) {
960
+ const ptr0 = passArray8ToWasm0(sighash, wasm.__wbindgen_malloc);
961
+ const len0 = WASM_VECTOR_LEN;
962
+ const ret = wasm.externalsparksignerhandle_signLeafRefundSpend(this.__wbg_ptr, leaf_id, ptr0, len0);
963
+ return ret;
964
+ }
883
965
  /**
884
966
  * @param {Uint8Array} message
885
967
  * @returns {Promise<EcdsaSignatureBytes>}
@@ -1053,6 +1135,23 @@ export class PasskeyClient {
1053
1135
  const ret = wasm.passkeyclient_checkAvailability(this.__wbg_ptr);
1054
1136
  return ret;
1055
1137
  }
1138
+ /**
1139
+ * Single-CTA onboarding: silent sign-in that falls through to
1140
+ * registration when no credential exists on the device. Pins
1141
+ * immediate mediation, so on web only use it where the browser
1142
+ * advertises it (`supportsImmediateMediation`); otherwise the silent
1143
+ * probe degrades to the standard picker and a dismiss does not fall
1144
+ * through to register, so
1145
+ * present an explicit create / sign-in choice instead. Called without
1146
+ * a `label`, the response `labels` lists a returning user's wallets
1147
+ * for a picker.
1148
+ * @param {ConnectWithPasskeyRequest} request
1149
+ * @returns {Promise<ConnectWithPasskeyResponse>}
1150
+ */
1151
+ connectWithPasskey(request) {
1152
+ const ret = wasm.passkeyclient_connectWithPasskey(this.__wbg_ptr, request);
1153
+ return ret;
1154
+ }
1056
1155
  /**
1057
1156
  * Label sub-object. List / publish labels for this passkey's identity.
1058
1157
  * @returns {PasskeyLabels}
@@ -1101,6 +1200,18 @@ export class PasskeyClient {
1101
1200
  const ret = wasm.passkeyclient_signIn(this.__wbg_ptr, request);
1102
1201
  return ret;
1103
1202
  }
1203
+ /**
1204
+ * Whether this browser advertises WebAuthn immediate mediation: the
1205
+ * silent single-CTA probe (a no-credential sign-in fast-fails with no
1206
+ * UI) works here, so a web host can pick single- vs two-button
1207
+ * onboarding. Web-only and WASM-only: native does the silent probe
1208
+ * inherently, so there is nothing to query off-web.
1209
+ * @returns {Promise<boolean>}
1210
+ */
1211
+ supportsImmediateMediation() {
1212
+ const ret = wasm.passkeyclient_supportsImmediateMediation(this.__wbg_ptr);
1213
+ return ret;
1214
+ }
1104
1215
  }
1105
1216
  if (Symbol.dispose) PasskeyClient.prototype[Symbol.dispose] = PasskeyClient.prototype.free;
1106
1217
 
@@ -1765,6 +1876,21 @@ export function postgresStorage(config) {
1765
1876
  return WasmStorageConfig.__wrap(ret);
1766
1877
  }
1767
1878
 
1879
+ /**
1880
+ * Creates a default CPFP signer backed by a single private key.
1881
+ * @param {Uint8Array} secret_key_bytes
1882
+ * @returns {DefaultCpfpSigner}
1883
+ */
1884
+ export function singleKeyCpfpSigner(secret_key_bytes) {
1885
+ const ptr0 = passArray8ToWasm0(secret_key_bytes, wasm.__wbindgen_malloc);
1886
+ const len0 = WASM_VECTOR_LEN;
1887
+ const ret = wasm.singleKeyCpfpSigner(ptr0, len0);
1888
+ if (ret[2]) {
1889
+ throw takeFromExternrefTable0(ret[1]);
1890
+ }
1891
+ return DefaultCpfpSigner.__wrap(ret[0]);
1892
+ }
1893
+
1768
1894
  /**
1769
1895
  * Runs automatically when the wasm module is instantiated. Installs the
1770
1896
  * panic hook so Rust panics surface as readable `console.error` output
@@ -2300,6 +2426,18 @@ function __wbg_get_imports() {
2300
2426
  const ret = Array.from(arg0);
2301
2427
  return ret;
2302
2428
  },
2429
+ __wbg_getAddressTxos_3ca1c4b39dd84911: function() { return handleError(function (arg0, arg1, arg2) {
2430
+ let deferred0_0;
2431
+ let deferred0_1;
2432
+ try {
2433
+ deferred0_0 = arg1;
2434
+ deferred0_1 = arg2;
2435
+ const ret = arg0.getAddressTxos(getStringFromWasm0(arg1, arg2));
2436
+ return ret;
2437
+ } finally {
2438
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2439
+ }
2440
+ }, arguments); },
2303
2441
  __wbg_getAddressUtxos_9526b6d8078b867e: function() { return handleError(function (arg0, arg1, arg2) {
2304
2442
  let deferred0_0;
2305
2443
  let deferred0_1;
@@ -2365,6 +2503,18 @@ function __wbg_get_imports() {
2365
2503
  const ret = arg0.getLeaves();
2366
2504
  return ret;
2367
2505
  }, arguments); },
2506
+ __wbg_getOutspend_4b3c117972515790: function() { return handleError(function (arg0, arg1, arg2, arg3) {
2507
+ let deferred0_0;
2508
+ let deferred0_1;
2509
+ try {
2510
+ deferred0_0 = arg1;
2511
+ deferred0_1 = arg2;
2512
+ const ret = arg0.getOutspend(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
2513
+ return ret;
2514
+ } finally {
2515
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
2516
+ }
2517
+ }, arguments); },
2368
2518
  __wbg_getPaymentById_6d677ada5879df99: function() { return handleError(function (arg0, arg1, arg2) {
2369
2519
  let deferred0_0;
2370
2520
  let deferred0_1;
@@ -3194,12 +3344,24 @@ function __wbg_get_imports() {
3194
3344
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3195
3345
  }
3196
3346
  }, arguments); },
3347
+ __wbg_signLeafRefundSpend_dc0eea305a0dde9c: function() { return handleError(function (arg0, arg1, arg2, arg3) {
3348
+ var v0 = getArrayU8FromWasm0(arg2, arg3).slice();
3349
+ wasm.__wbindgen_free(arg2, arg3 * 1, 1);
3350
+ const ret = arg0.signLeafRefundSpend(arg1, v0);
3351
+ return ret;
3352
+ }, arguments); },
3197
3353
  __wbg_signMessage_80ec0b0dfc7f00ee: function() { return handleError(function (arg0, arg1, arg2) {
3198
3354
  var v0 = getArrayU8FromWasm0(arg1, arg2).slice();
3199
3355
  wasm.__wbindgen_free(arg1, arg2 * 1, 1);
3200
3356
  const ret = arg0.signMessage(v0);
3201
3357
  return ret;
3202
3358
  }, arguments); },
3359
+ __wbg_signPsbt_625c8cbdec488cc6: function() { return handleError(function (arg0, arg1, arg2) {
3360
+ var v0 = getArrayU8FromWasm0(arg1, arg2).slice();
3361
+ wasm.__wbindgen_free(arg1, arg2 * 1, 1);
3362
+ const ret = arg0.signPsbt(v0);
3363
+ return ret;
3364
+ }, arguments); },
3203
3365
  __wbg_signSparkInvoice_cca6c7f35b5e85d2: function() { return handleError(function (arg0, arg1) {
3204
3366
  const ret = arg0.signSparkInvoice(arg1);
3205
3367
  return ret;
@@ -3255,6 +3417,10 @@ function __wbg_get_imports() {
3255
3417
  const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
3256
3418
  return ret;
3257
3419
  },
3420
+ __wbg_supportsImmediateMediation_a50b46b1cdfacd3d: function() { return handleError(function (arg0) {
3421
+ const ret = arg0.supportsImmediateMediation();
3422
+ return ret;
3423
+ }, arguments); },
3258
3424
  __wbg_syncAddOutgoingChange_69db2a1430cbd55a: function() { return handleError(function (arg0, arg1) {
3259
3425
  const ret = arg0.syncAddOutgoingChange(arg1);
3260
3426
  return ret;
@@ -3407,62 +3573,62 @@ function __wbg_get_imports() {
3407
3573
  return ret;
3408
3574
  },
3409
3575
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
3410
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 17, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3576
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3411
3577
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h21f6855640435575);
3412
3578
  return ret;
3413
3579
  },
3414
3580
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
3415
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 230, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3581
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 389, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3416
3582
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h3120db8c4a8a92b2);
3417
3583
  return ret;
3418
3584
  },
3419
3585
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
3420
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 230, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3586
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 389, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3421
3587
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h3120db8c4a8a92b2_2);
3422
3588
  return ret;
3423
3589
  },
3424
3590
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
3425
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 230, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3591
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("ErrorEvent")], shim_idx: 389, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3426
3592
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h3120db8c4a8a92b2_3);
3427
3593
  return ret;
3428
3594
  },
3429
3595
  __wbindgen_cast_0000000000000005: function(arg0, arg1) {
3430
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 230, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3596
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 389, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3431
3597
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h3120db8c4a8a92b2_4);
3432
3598
  return ret;
3433
3599
  },
3434
3600
  __wbindgen_cast_0000000000000006: function(arg0, arg1) {
3435
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 230, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3601
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 389, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3436
3602
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h3120db8c4a8a92b2_5);
3437
3603
  return ret;
3438
3604
  },
3439
3605
  __wbindgen_cast_0000000000000007: function(arg0, arg1) {
3440
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("SessionStore")], shim_idx: 17, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3606
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("SessionStore")], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3441
3607
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h21f6855640435575_6);
3442
3608
  return ret;
3443
3609
  },
3444
3610
  __wbindgen_cast_0000000000000008: function(arg0, arg1) {
3445
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Storage")], shim_idx: 17, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3611
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Storage")], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3446
3612
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h21f6855640435575_7);
3447
3613
  return ret;
3448
3614
  },
3449
3615
  __wbindgen_cast_0000000000000009: function(arg0, arg1) {
3450
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("TokenStore")], shim_idx: 17, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3616
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("TokenStore")], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3451
3617
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h21f6855640435575_8);
3452
3618
  return ret;
3453
3619
  },
3454
3620
  __wbindgen_cast_000000000000000a: function(arg0, arg1) {
3455
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("TreeStore")], shim_idx: 17, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3621
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("TreeStore")], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
3456
3622
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h21f6855640435575_9);
3457
3623
  return ret;
3458
3624
  },
3459
3625
  __wbindgen_cast_000000000000000b: function(arg0, arg1) {
3460
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 392, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3626
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 394, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3461
3627
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h1d6669a7b693932a);
3462
3628
  return ret;
3463
3629
  },
3464
3630
  __wbindgen_cast_000000000000000c: function(arg0, arg1) {
3465
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 421, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
3631
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 425, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
3466
3632
  const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0fa3f876e31d2a3e);
3467
3633
  return ret;
3468
3634
  },
@@ -3647,6 +3813,9 @@ const BitcoinChainServiceHandleFinalization = (typeof FinalizationRegistry === '
3647
3813
  const BreezSdkFinalization = (typeof FinalizationRegistry === 'undefined')
3648
3814
  ? { register: () => {}, unregister: () => {} }
3649
3815
  : new FinalizationRegistry(ptr => wasm.__wbg_breezsdk_free(ptr, 1));
3816
+ const DefaultCpfpSignerFinalization = (typeof FinalizationRegistry === 'undefined')
3817
+ ? { register: () => {}, unregister: () => {} }
3818
+ : new FinalizationRegistry(ptr => wasm.__wbg_defaultcpfpsigner_free(ptr, 1));
3650
3819
  const DefaultSessionStoreFinalization = (typeof FinalizationRegistry === 'undefined')
3651
3820
  ? { register: () => {}, unregister: () => {} }
3652
3821
  : new FinalizationRegistry(ptr => wasm.__wbg_defaultsessionstore_free(ptr, 1));
Binary file
@@ -3,6 +3,7 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_bitcoinchainservicehandle_free: (a: number, b: number) => void;
5
5
  export const __wbg_breezsdk_free: (a: number, b: number) => void;
6
+ export const __wbg_defaultcpfpsigner_free: (a: number, b: number) => void;
6
7
  export const __wbg_externalsigners_free: (a: number, b: number) => void;
7
8
  export const __wbg_passkeyclient_free: (a: number, b: number) => void;
8
9
  export const __wbg_passkeylabels_free: (a: number, b: number) => void;
@@ -11,7 +12,9 @@ export const __wbg_tokenissuer_free: (a: number, b: number) => void;
11
12
  export const __wbg_wasmsdkcontext_free: (a: number, b: number) => void;
12
13
  export const __wbg_wasmstorageconfig_free: (a: number, b: number) => void;
13
14
  export const bitcoinchainservicehandle_broadcastTransaction: (a: number, b: number, c: number) => any;
15
+ export const bitcoinchainservicehandle_getAddressTxos: (a: number, b: number, c: number) => any;
14
16
  export const bitcoinchainservicehandle_getAddressUtxos: (a: number, b: number, c: number) => any;
17
+ export const bitcoinchainservicehandle_getOutspend: (a: number, b: number, c: number, d: number) => any;
15
18
  export const bitcoinchainservicehandle_getTransactionHex: (a: number, b: number, c: number) => any;
16
19
  export const bitcoinchainservicehandle_getTransactionStatus: (a: number, b: number, c: number) => any;
17
20
  export const bitcoinchainservicehandle_recommendedFees: (a: number) => any;
@@ -50,6 +53,7 @@ export const breezsdk_optimizeLeaves: (a: number, b: any) => any;
50
53
  export const breezsdk_parse: (a: number, b: number, c: number) => any;
51
54
  export const breezsdk_prepareLnurlPay: (a: number, b: any) => any;
52
55
  export const breezsdk_prepareSendPayment: (a: number, b: any) => any;
56
+ export const breezsdk_prepareUnilateralExit: (a: number, b: any) => any;
53
57
  export const breezsdk_publishSignedLnurlPayPackage: (a: number, b: any) => any;
54
58
  export const breezsdk_publishSignedTransferPackage: (a: number, b: any) => any;
55
59
  export const breezsdk_receivePayment: (a: number, b: any) => any;
@@ -62,6 +66,7 @@ export const breezsdk_removeEventListener: (a: number, b: number, c: number) =>
62
66
  export const breezsdk_sendPayment: (a: number, b: any) => any;
63
67
  export const breezsdk_signMessage: (a: number, b: any) => any;
64
68
  export const breezsdk_syncWallet: (a: number, b: any) => any;
69
+ export const breezsdk_unilateralExit: (a: number, b: any, c: any) => any;
65
70
  export const breezsdk_unregisterWebhook: (a: number, b: any) => any;
66
71
  export const breezsdk_updateContact: (a: number, b: any) => any;
67
72
  export const breezsdk_updateUserSettings: (a: number, b: any) => any;
@@ -77,6 +82,7 @@ export const defaultPostgresStorageConfig: (a: number, b: number) => any;
77
82
  export const defaultServerConfig: (a: any) => any;
78
83
  export const defaultSessionStore: (a: number, b: any, c: number, d: number) => any;
79
84
  export const defaultStorage: (a: number, b: number) => number;
85
+ export const defaultcpfpsigner_signPsbt: (a: number, b: number, c: number) => any;
80
86
  export const defaultsessionstore_getSession: (a: number, b: number, c: number) => any;
81
87
  export const defaultsessionstore_setSession: (a: number, b: number, c: number, d: any) => any;
82
88
  export const externalbreezsignerhandle_decryptEcies: (a: number, b: number, c: number, d: number, e: number) => any;
@@ -103,6 +109,7 @@ export const externalsparksignerhandle_prepareTokenTransaction: (a: number, b: a
103
109
  export const externalsparksignerhandle_prepareTransfer: (a: number, b: any) => any;
104
110
  export const externalsparksignerhandle_signAuthenticationChallenge: (a: number, b: number, c: number) => any;
105
111
  export const externalsparksignerhandle_signFrost: (a: number, b: number, c: number) => any;
112
+ export const externalsparksignerhandle_signLeafRefundSpend: (a: number, b: any, c: number, d: number) => any;
106
113
  export const externalsparksignerhandle_signMessage: (a: number, b: number, c: number) => any;
107
114
  export const externalsparksignerhandle_signSparkInvoice: (a: number, b: any) => any;
108
115
  export const externalsparksignerhandle_signStaticDepositRefund: (a: number, b: any) => any;
@@ -113,10 +120,12 @@ export const mysqlStorage: (a: any) => number;
113
120
  export const newRestChainService: (a: number, b: number, c: any, d: any, e: number) => any;
114
121
  export const newSharedSdkContext: (a: any) => any;
115
122
  export const passkeyclient_checkAvailability: (a: number) => any;
123
+ export const passkeyclient_connectWithPasskey: (a: number, b: any) => any;
116
124
  export const passkeyclient_labels: (a: number) => number;
117
125
  export const passkeyclient_new: (a: any, b: number, c: number, d: number) => number;
118
126
  export const passkeyclient_register: (a: number, b: any) => any;
119
127
  export const passkeyclient_signIn: (a: number, b: any) => any;
128
+ export const passkeyclient_supportsImmediateMediation: (a: number) => any;
120
129
  export const passkeylabels_list: (a: number) => any;
121
130
  export const passkeylabels_store: (a: number, b: number, c: number) => any;
122
131
  export const postgresStorage: (a: any) => number;
@@ -137,6 +146,7 @@ export const sdkbuilder_withSessionStore: (a: number, b: any) => number;
137
146
  export const sdkbuilder_withSharedContext: (a: number, b: number) => number;
138
147
  export const sdkbuilder_withStorage: (a: number, b: any) => number;
139
148
  export const sdkbuilder_withStorageBackend: (a: number, b: number) => number;
149
+ export const singleKeyCpfpSigner: (a: number, b: number) => [number, number, number];
140
150
  export const start: () => void;
141
151
  export const tokenissuer_burnIssuerToken: (a: number, b: any) => any;
142
152
  export const tokenissuer_createIssuerToken: (a: number, b: any) => any;
@@ -0,0 +1,2 @@
1
+ node_modules/
2
+ .env
@@ -0,0 +1,70 @@
1
+ 'use strict'
2
+
3
+ // Pure tests for the tolerant JSON evaluator; no network. Mirrors the unit
4
+ // tests in crates/breez-sdk/cli/tests/harness/assert.rs.
5
+
6
+ const assert = require('node:assert/strict')
7
+ const test = require('node:test')
8
+
9
+ const { checkMatcher, extractJsonDocs, interpolate, lookupPath } = require('./scenario')
10
+
11
+ test('extracts pretty and inline docs and skips noise', () => {
12
+ const chunk = 'Breez SDK: noise\n{\n "a": 1\n}\nError: nope\n{"b": 2}\nEvent: {"c": 3}\n'
13
+ assert.deepEqual(extractJsonDocs(chunk), [{ a: 1 }, { b: 2 }])
14
+ })
15
+
16
+ test('path matches across casings', () => {
17
+ const rust = { payment_request: { amount_msat: 5 } }
18
+ const wasm = { paymentRequest: { amountMsat: 5 } }
19
+ for (const doc of [rust, wasm]) {
20
+ assert.equal(lookupPath(doc, 'payment_request.amount_msat'), 5)
21
+ }
22
+ })
23
+
24
+ test('path bridges enum tags', () => {
25
+ const rust = { Bolt11Invoice: { amount_msat: 7 } }
26
+ const wasm = { type: 'bolt11Invoice', amountMsat: 7 }
27
+ for (const doc of [rust, wasm]) {
28
+ assert.equal(lookupPath(doc, 'bolt11_invoice.amount_msat'), 7)
29
+ }
30
+ })
31
+
32
+ test('empty path addresses the document', () => {
33
+ assert.deepEqual(lookupPath({}, ''), {})
34
+ checkMatcher({}, lookupPath({}, ''))
35
+ })
36
+
37
+ test('path indexes arrays', () => {
38
+ const doc = { payments: [{ id: 'x' }, { id: 'y' }] }
39
+ assert.equal(lookupPath(doc, 'payments.1.id'), 'y')
40
+ assert.equal(lookupPath(doc, 'payments.2.id'), undefined)
41
+ })
42
+
43
+ test('equality tolerates case and bigint strings', () => {
44
+ checkMatcher('completed', 'Completed')
45
+ checkMatcher('1000', 1000)
46
+ checkMatcher(1000, '1000')
47
+ assert.throws(() => checkMatcher('completed', 'failed'))
48
+ assert.throws(() => checkMatcher('completed', undefined))
49
+ })
50
+
51
+ test('gte accepts numbers and numeric strings', () => {
52
+ checkMatcher({ gte: 10 }, 11)
53
+ checkMatcher({ gte: 10 }, '10')
54
+ assert.throws(() => checkMatcher({ gte: 10 }, 9))
55
+ assert.throws(() => checkMatcher({ gte: 10 }, 'abc'))
56
+ assert.throws(() => checkMatcher({ gte: 10 }, undefined))
57
+ })
58
+
59
+ test('exists checks presence and null', () => {
60
+ checkMatcher({ exists: true }, 'x')
61
+ checkMatcher({ exists: false }, undefined)
62
+ checkMatcher({ exists: false }, null)
63
+ assert.throws(() => checkMatcher({ exists: true }, null))
64
+ assert.throws(() => checkMatcher({ exists: true }, undefined))
65
+ })
66
+
67
+ test('interpolation substitutes known vars and rejects unknown', () => {
68
+ assert.equal(interpolate('pay -r ${addr} -a 5', { addr: 'spark1x' }), 'pay -r spark1x -a 5')
69
+ assert.throws(() => interpolate('${missing}', {}))
70
+ })
@@ -0,0 +1,68 @@
1
+ 'use strict'
2
+
3
+ // Minimal client for the Lightspark regtest faucet, mirroring the Rust
4
+ // harness (crates/breez-sdk/cli/tests/harness/faucet.rs).
5
+
6
+ const DEFAULT_URL = 'https://api.lightspark.com/graphql/spark/rc'
7
+ const MAX_RETRIES = 3
8
+
9
+ /**
10
+ * Fund a regtest bitcoin address, returning the funding txid. Retries with
11
+ * exponential backoff. Reads FAUCET_URL, FAUCET_USERNAME, and
12
+ * FAUCET_PASSWORD from the environment.
13
+ *
14
+ * @param {string} address
15
+ * @param {number} amountSats
16
+ * @returns {Promise<string>}
17
+ */
18
+ async function fundAddress(address, amountSats) {
19
+ let lastError
20
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
21
+ if (attempt > 0) {
22
+ await new Promise((resolve) => setTimeout(resolve, 2 ** attempt * 1000))
23
+ }
24
+ try {
25
+ return await tryFundAddress(address, amountSats)
26
+ } catch (e) {
27
+ lastError = e
28
+ }
29
+ }
30
+ throw lastError
31
+ }
32
+
33
+ async function tryFundAddress(address, amountSats) {
34
+ const url = process.env.FAUCET_URL || DEFAULT_URL
35
+ const headers = { 'Content-Type': 'application/json' }
36
+ const { FAUCET_USERNAME, FAUCET_PASSWORD } = process.env
37
+ if (FAUCET_USERNAME && FAUCET_PASSWORD) {
38
+ const credentials = Buffer.from(`${FAUCET_USERNAME}:${FAUCET_PASSWORD}`).toString('base64')
39
+ headers.Authorization = `Basic ${credentials}`
40
+ }
41
+
42
+ const response = await fetch(url, {
43
+ method: 'POST',
44
+ headers,
45
+ body: JSON.stringify({
46
+ operationName: 'RequestRegtestFunds',
47
+ variables: { amount_sats: amountSats, address },
48
+ query:
49
+ 'mutation RequestRegtestFunds($address: String!, $amount_sats: Long!) { ' +
50
+ 'request_regtest_funds(input: {address: $address, amount_sats: $amount_sats}) ' +
51
+ '{ transaction_hash}}'
52
+ })
53
+ })
54
+ const body = await response.text()
55
+ if (!response.ok) {
56
+ throw new Error(`faucet request failed with status ${response.status}: ${body}`)
57
+ }
58
+ const parsed = JSON.parse(body)
59
+ if (parsed.errors && parsed.errors.length > 0) {
60
+ throw new Error(`faucet returned errors: ${parsed.errors.map((e) => e.message).join(', ')}`)
61
+ }
62
+ if (!parsed.data) {
63
+ throw new Error(`faucet response has no data: ${body}`)
64
+ }
65
+ return parsed.data.request_regtest_funds.transaction_hash
66
+ }
67
+
68
+ module.exports = { fundAddress }