@buildonspark/spark-sdk 0.3.4 → 0.3.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @buildonspark/spark-sdk
2
2
 
3
+ ## 0.3.5
4
+
5
+ ### Patch Changes
6
+
7
+ - - Fix 0 amount invoice validation
8
+
3
9
  ## 0.3.4
4
10
 
5
11
  ### Patch Changes
@@ -19287,7 +19287,7 @@ var isWebExtension = (
19287
19287
  "chrome" in globalThis && globalThis.chrome.runtime?.id
19288
19288
  );
19289
19289
  var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
19290
- var packageVersion = true ? "0.3.4" : "unknown";
19290
+ var packageVersion = true ? "0.3.5" : "unknown";
19291
19291
  var baseEnvStr = "unknown";
19292
19292
  if (isBun) {
19293
19293
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -33740,7 +33740,14 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33740
33740
  expected: (0, import_utils23.bytesToHex)(paymentHash)
33741
33741
  });
33742
33742
  }
33743
- if (decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
33743
+ if (decodedInvoice.amountMSats === null && amountSats2 !== 0) {
33744
+ throw new ValidationError("Amount mismatch", {
33745
+ field: "amountMSats",
33746
+ value: "null",
33747
+ expected: amountSats2 * 1e3
33748
+ });
33749
+ }
33750
+ if (decodedInvoice.amountMSats !== null && decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
33744
33751
  throw new ValidationError("Amount mismatch", {
33745
33752
  field: "amountMSats",
33746
33753
  value: decodedInvoice.amountMSats,
@@ -17799,7 +17799,7 @@ var isWebExtension = (
17799
17799
  "chrome" in globalThis && globalThis.chrome.runtime?.id
17800
17800
  );
17801
17801
  var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
17802
- var packageVersion = true ? "0.3.4" : "unknown";
17802
+ var packageVersion = true ? "0.3.5" : "unknown";
17803
17803
  var baseEnvStr = "unknown";
17804
17804
  if (isBun) {
17805
17805
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -32270,7 +32270,14 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
32270
32270
  expected: bytesToHex11(paymentHash)
32271
32271
  });
32272
32272
  }
32273
- if (decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
32273
+ if (decodedInvoice.amountMSats === null && amountSats2 !== 0) {
32274
+ throw new ValidationError("Amount mismatch", {
32275
+ field: "amountMSats",
32276
+ value: "null",
32277
+ expected: amountSats2 * 1e3
32278
+ });
32279
+ }
32280
+ if (decodedInvoice.amountMSats !== null && decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
32274
32281
  throw new ValidationError("Amount mismatch", {
32275
32282
  field: "amountMSats",
32276
32283
  value: decodedInvoice.amountMSats,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SparkWallet,
3
3
  setCrypto
4
- } from "./chunk-KIQTO4FX.js";
4
+ } from "./chunk-JE73HB26.js";
5
5
 
6
6
  // src/spark-wallet/spark-wallet.browser.ts
7
7
  import { WebTracerProvider } from "@opentelemetry/sdk-trace-web";
@@ -584,7 +584,7 @@ var isWebExtension = (
584
584
  "chrome" in globalThis && globalThis.chrome.runtime?.id
585
585
  );
586
586
  var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
587
- var packageVersion = true ? "0.3.4" : "unknown";
587
+ var packageVersion = true ? "0.3.5" : "unknown";
588
588
  var baseEnvStr = "unknown";
589
589
  if (isBun) {
590
590
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -12956,7 +12956,14 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
12956
12956
  expected: bytesToHex10(paymentHash)
12957
12957
  });
12958
12958
  }
12959
- if (decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
12959
+ if (decodedInvoice.amountMSats === null && amountSats2 !== 0) {
12960
+ throw new ValidationError("Amount mismatch", {
12961
+ field: "amountMSats",
12962
+ value: "null",
12963
+ expected: amountSats2 * 1e3
12964
+ });
12965
+ }
12966
+ if (decodedInvoice.amountMSats !== null && decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
12960
12967
  throw new ValidationError("Amount mismatch", {
12961
12968
  field: "amountMSats",
12962
12969
  value: decodedInvoice.amountMSats,
package/dist/debug.cjs CHANGED
@@ -19278,7 +19278,7 @@ var isWebExtension = (
19278
19278
  "chrome" in globalThis && globalThis.chrome.runtime?.id
19279
19279
  );
19280
19280
  var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
19281
- var packageVersion = true ? "0.3.4" : "unknown";
19281
+ var packageVersion = true ? "0.3.5" : "unknown";
19282
19282
  var baseEnvStr = "unknown";
19283
19283
  if (isBun) {
19284
19284
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -33661,7 +33661,14 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
33661
33661
  expected: (0, import_utils23.bytesToHex)(paymentHash)
33662
33662
  });
33663
33663
  }
33664
- if (decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
33664
+ if (decodedInvoice.amountMSats === null && amountSats2 !== 0) {
33665
+ throw new ValidationError("Amount mismatch", {
33666
+ field: "amountMSats",
33667
+ value: "null",
33668
+ expected: amountSats2 * 1e3
33669
+ });
33670
+ }
33671
+ if (decodedInvoice.amountMSats !== null && decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
33665
33672
  throw new ValidationError("Amount mismatch", {
33666
33673
  field: "amountMSats",
33667
33674
  value: decodedInvoice.amountMSats,
package/dist/debug.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  SparkWallet,
3
3
  WalletConfig,
4
4
  utils_exports
5
- } from "./chunk-KIQTO4FX.js";
5
+ } from "./chunk-JE73HB26.js";
6
6
  import "./chunk-NX5KPN5F.js";
7
7
  import "./chunk-XWLR6G5C.js";
8
8
  import "./chunk-J2P3KTQP.js";
package/dist/index.cjs CHANGED
@@ -20918,7 +20918,7 @@ var isWebExtension = (
20918
20918
  "chrome" in globalThis && globalThis.chrome.runtime?.id
20919
20919
  );
20920
20920
  var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
20921
- var packageVersion = true ? "0.3.4" : "unknown";
20921
+ var packageVersion = true ? "0.3.5" : "unknown";
20922
20922
  var baseEnvStr = "unknown";
20923
20923
  if (isBun) {
20924
20924
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -34479,7 +34479,14 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34479
34479
  expected: (0, import_utils24.bytesToHex)(paymentHash)
34480
34480
  });
34481
34481
  }
34482
- if (decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
34482
+ if (decodedInvoice.amountMSats === null && amountSats2 !== 0) {
34483
+ throw new ValidationError("Amount mismatch", {
34484
+ field: "amountMSats",
34485
+ value: "null",
34486
+ expected: amountSats2 * 1e3
34487
+ });
34488
+ }
34489
+ if (decodedInvoice.amountMSats !== null && decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
34483
34490
  throw new ValidationError("Amount mismatch", {
34484
34491
  field: "amountMSats",
34485
34492
  value: decodedInvoice.amountMSats,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SparkWalletBrowser,
3
3
  initializeTracerEnvBrowser
4
- } from "./chunk-YH7MDVTT.js";
4
+ } from "./chunk-DIXXHATX.js";
5
5
  import {
6
6
  AuthenticationError,
7
7
  ConfigurationError,
@@ -117,7 +117,7 @@ import {
117
117
  validateShare,
118
118
  validateSparkInvoiceFields,
119
119
  validateSparkInvoiceSignature
120
- } from "./chunk-KIQTO4FX.js";
120
+ } from "./chunk-JE73HB26.js";
121
121
  import {
122
122
  LOGGER_NAMES,
123
123
  SparkSdkLogger
@@ -20919,7 +20919,7 @@ var isWebExtension = (
20919
20919
  "chrome" in globalThis && globalThis.chrome.runtime?.id
20920
20920
  );
20921
20921
  var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
20922
- var packageVersion = true ? "0.3.4" : "unknown";
20922
+ var packageVersion = true ? "0.3.5" : "unknown";
20923
20923
  var baseEnvStr = "unknown";
20924
20924
  if (isBun) {
20925
20925
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -34480,7 +34480,14 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34480
34480
  expected: (0, import_utils24.bytesToHex)(paymentHash)
34481
34481
  });
34482
34482
  }
34483
- if (decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
34483
+ if (decodedInvoice.amountMSats === null && amountSats2 !== 0) {
34484
+ throw new ValidationError("Amount mismatch", {
34485
+ field: "amountMSats",
34486
+ value: "null",
34487
+ expected: amountSats2 * 1e3
34488
+ });
34489
+ }
34490
+ if (decodedInvoice.amountMSats !== null && decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
34484
34491
  throw new ValidationError("Amount mismatch", {
34485
34492
  field: "amountMSats",
34486
34493
  value: decodedInvoice.amountMSats,
@@ -115,7 +115,7 @@ import {
115
115
  validateShare,
116
116
  validateSparkInvoiceFields,
117
117
  validateSparkInvoiceSignature
118
- } from "./chunk-KIQTO4FX.js";
118
+ } from "./chunk-JE73HB26.js";
119
119
  import {
120
120
  LOGGER_NAMES,
121
121
  SparkSdkLogger
@@ -21044,7 +21044,7 @@ var isWebExtension = (
21044
21044
  "chrome" in globalThis && globalThis.chrome.runtime?.id
21045
21045
  );
21046
21046
  var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
21047
- var packageVersion = true ? "0.3.4" : "unknown";
21047
+ var packageVersion = true ? "0.3.5" : "unknown";
21048
21048
  var baseEnvStr = "unknown";
21049
21049
  if (isBun) {
21050
21050
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -34535,7 +34535,14 @@ var SparkWallet = class _SparkWallet extends import_eventemitter3.EventEmitter {
34535
34535
  expected: (0, import_utils24.bytesToHex)(paymentHash)
34536
34536
  });
34537
34537
  }
34538
- if (decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
34538
+ if (decodedInvoice.amountMSats === null && amountSats2 !== 0) {
34539
+ throw new ValidationError("Amount mismatch", {
34540
+ field: "amountMSats",
34541
+ value: "null",
34542
+ expected: amountSats2 * 1e3
34543
+ });
34544
+ }
34545
+ if (decodedInvoice.amountMSats !== null && decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
34539
34546
  throw new ValidationError("Amount mismatch", {
34540
34547
  field: "amountMSats",
34541
34548
  value: decodedInvoice.amountMSats,
@@ -19427,7 +19427,7 @@ var isWebExtension = (
19427
19427
  "chrome" in globalThis && globalThis.chrome.runtime?.id
19428
19428
  );
19429
19429
  var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
19430
- var packageVersion = true ? "0.3.4" : "unknown";
19430
+ var packageVersion = true ? "0.3.5" : "unknown";
19431
19431
  var baseEnvStr = "unknown";
19432
19432
  if (isBun) {
19433
19433
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -32889,7 +32889,14 @@ var SparkWallet = class _SparkWallet extends EventEmitter {
32889
32889
  expected: bytesToHex12(paymentHash)
32890
32890
  });
32891
32891
  }
32892
- if (decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
32892
+ if (decodedInvoice.amountMSats === null && amountSats2 !== 0) {
32893
+ throw new ValidationError("Amount mismatch", {
32894
+ field: "amountMSats",
32895
+ value: "null",
32896
+ expected: amountSats2 * 1e3
32897
+ });
32898
+ }
32899
+ if (decodedInvoice.amountMSats !== null && decodedInvoice.amountMSats !== BigInt(amountSats2 * 1e3)) {
32893
32900
  throw new ValidationError("Amount mismatch", {
32894
32901
  field: "amountMSats",
32895
32902
  value: decodedInvoice.amountMSats,
@@ -17988,7 +17988,7 @@ var isWebExtension = (
17988
17988
  "chrome" in globalThis && globalThis.chrome.runtime?.id
17989
17989
  );
17990
17990
  var userAgent = "navigator" in globalThis ? globalThis.navigator.userAgent || "unknown-user-agent" : void 0;
17991
- var packageVersion = true ? "0.3.4" : "unknown";
17991
+ var packageVersion = true ? "0.3.5" : "unknown";
17992
17992
  var baseEnvStr = "unknown";
17993
17993
  if (isBun) {
17994
17994
  const bunVersion = "version" in globalThis.Bun ? globalThis.Bun.version : "unknown-version";
@@ -1,4 +1,4 @@
1
- import "../chunk-YH7MDVTT.js";
1
+ import "../chunk-DIXXHATX.js";
2
2
  import {
3
3
  BitcoinFaucet,
4
4
  ConnectionManager,
@@ -10,7 +10,7 @@ import {
10
10
  WalletConfigService,
11
11
  getNetwork,
12
12
  getP2TRAddressFromPublicKey
13
- } from "../chunk-KIQTO4FX.js";
13
+ } from "../chunk-JE73HB26.js";
14
14
  import "../chunk-NX5KPN5F.js";
15
15
  import "../chunk-XWLR6G5C.js";
16
16
  import "../chunk-J2P3KTQP.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildonspark/spark-sdk",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "author": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -3289,7 +3289,18 @@ export class SparkWallet extends EventEmitter<SparkWalletEvents> {
3289
3289
  });
3290
3290
  }
3291
3291
 
3292
- if (decodedInvoice.amountMSats !== BigInt(amountSats * 1000)) {
3292
+ if (decodedInvoice.amountMSats === null && amountSats !== 0) {
3293
+ throw new ValidationError("Amount mismatch", {
3294
+ field: "amountMSats",
3295
+ value: "null",
3296
+ expected: amountSats * 1000,
3297
+ });
3298
+ }
3299
+
3300
+ if (
3301
+ decodedInvoice.amountMSats !== null &&
3302
+ decodedInvoice.amountMSats !== BigInt(amountSats * 1000)
3303
+ ) {
3293
3304
  throw new ValidationError("Amount mismatch", {
3294
3305
  field: "amountMSats",
3295
3306
  value: decodedInvoice.amountMSats,