@buildonspark/spark-sdk 0.2.9 → 0.2.11

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 (55) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/bare/chunk-P6AVV7VD.js +34 -0
  3. package/dist/bare/index.cjs +341 -279
  4. package/dist/bare/index.d.cts +15 -2
  5. package/dist/bare/index.d.ts +15 -2
  6. package/dist/bare/index.js +55 -50
  7. package/dist/bare/{wasm-OPXXYRN5.js → wasm-F5QFVBNZ.js} +26 -0
  8. package/dist/bare/{xhr-transport-6GYJAFWU.js → xhr-transport-EEEC7FYA.js} +2 -2
  9. package/dist/{chunk-23BBEC25.js → chunk-3WBPICWC.js} +1 -1
  10. package/dist/chunk-NX5KPN5F.js +34 -0
  11. package/dist/{chunk-5Y7YILMA.js → chunk-QNYJGFPD.js} +53 -49
  12. package/dist/debug.cjs +337 -276
  13. package/dist/debug.d.cts +5 -2
  14. package/dist/debug.d.ts +5 -2
  15. package/dist/debug.js +2 -1
  16. package/dist/index.cjs +390 -327
  17. package/dist/index.d.cts +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +8 -2
  20. package/dist/index.node.cjs +390 -327
  21. package/dist/index.node.d.cts +1 -1
  22. package/dist/index.node.d.ts +1 -1
  23. package/dist/index.node.js +7 -1
  24. package/dist/{xchain-address-CNQEwLjR.d.cts → logging-BOAzMqpM.d.cts} +15 -1
  25. package/dist/{xchain-address-BPwpnmuY.d.ts → logging-Bt_WdZbu.d.ts} +15 -1
  26. package/dist/native/chunk-D3SZRO65.js +36 -0
  27. package/dist/native/index.cjs +387 -324
  28. package/dist/native/index.d.cts +15 -2
  29. package/dist/native/index.d.ts +15 -2
  30. package/dist/native/index.js +147 -143
  31. package/dist/native/{wasm-2KV6XFEP.js → wasm-3YAXKQ7F.js} +25 -0
  32. package/dist/native/{xhr-transport-WHMS3FGG.js → xhr-transport-TNCG4HTW.js} +2 -2
  33. package/dist/spark_bindings/wasm/index.cjs +51 -0
  34. package/dist/spark_bindings/wasm/index.js +25 -0
  35. package/dist/tests/test-utils.cjs +229 -166
  36. package/dist/tests/test-utils.js +3 -2
  37. package/dist/{xhr-transport-RH6LDRXS.js → xhr-transport-IWJPYF7F.js} +2 -2
  38. package/package.json +1 -1
  39. package/src/services/deposit.ts +5 -1
  40. package/src/services/xhr-transport.ts +2 -2
  41. package/src/spark-wallet/spark-wallet.ts +4 -9
  42. package/src/spark_bindings/wasm/index.ts +21 -0
  43. package/src/tests/integration/lightning.test.ts +2 -2
  44. package/src/tests/integration/ssp/coop-exit-validation.test.ts +2 -2
  45. package/src/tests/integration/ssp/static_deposit.test.ts +0 -32
  46. package/src/tests/integration/swap.test.ts +2 -2
  47. package/src/tests/integration/transfer.test.ts +20 -16
  48. package/src/tests/integration/watchtower.test.ts +2 -2
  49. package/src/utils/adaptor-signature.ts +11 -12
  50. package/src/utils/address.ts +10 -10
  51. package/src/utils/bitcoin.ts +6 -6
  52. package/src/utils/index.ts +1 -0
  53. package/src/utils/keys.ts +9 -9
  54. package/src/utils/logging.ts +40 -0
  55. package/src/utils/secret-sharing.ts +9 -11
@@ -42,6 +42,9 @@ if (typeof window !== "undefined") {
42
42
  }
43
43
  }
44
44
 
45
+ // src/spark_bindings/wasm/index.ts
46
+ var import_utils = require("@noble/curves/utils");
47
+
45
48
  // src/wasm/spark_bindings.js
46
49
  var imports = {};
47
50
  imports["__wbindgen_placeholder__"] = imports;
@@ -1029,6 +1032,36 @@ wasm = wasmInstance.exports;
1029
1032
  var __wasm = imports.__wasm = wasm;
1030
1033
  wasm.__wbindgen_start();
1031
1034
 
1035
+ // src/utils/logging.ts
1036
+ var import_core = require("@lightsparkdev/core");
1037
+ var LOGGER_NAMES = {
1038
+ wasm: "wasm"
1039
+ };
1040
+ var SparkSdkLogger = class {
1041
+ static loggers = /* @__PURE__ */ new Map();
1042
+ static get(name) {
1043
+ if (!this.loggers.has(name)) {
1044
+ this.loggers.set(name, new import_core.Logger(name));
1045
+ }
1046
+ return this.loggers.get(name);
1047
+ }
1048
+ static setLevel(name, level) {
1049
+ this.get(name).setLevel(level);
1050
+ }
1051
+ static setAllLevels(level) {
1052
+ this.loggers.forEach((logger) => logger.setLevel(level));
1053
+ }
1054
+ static setEnabled(name, enabled) {
1055
+ this.get(name).setEnabled(enabled);
1056
+ }
1057
+ static setAllEnabled(enabled) {
1058
+ this.loggers.forEach((logger) => logger.setEnabled(enabled));
1059
+ }
1060
+ static {
1061
+ Object.values(LOGGER_NAMES).forEach((name) => this.get(name));
1062
+ }
1063
+ };
1064
+
1032
1065
  // src/spark_bindings/wasm/index.ts
1033
1066
  function createKeyPackage(params) {
1034
1067
  return new KeyPackage(
@@ -1051,6 +1084,13 @@ function signFrost({
1051
1084
  statechainCommitments,
1052
1085
  adaptorPubKey
1053
1086
  }) {
1087
+ SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("signFrost", {
1088
+ message: (0, import_utils.bytesToHex)(message),
1089
+ keyPackage,
1090
+ nonce,
1091
+ selfCommitment,
1092
+ statechainCommitments
1093
+ });
1054
1094
  return wasm_sign_frost(
1055
1095
  message,
1056
1096
  createKeyPackage(keyPackage),
@@ -1071,6 +1111,17 @@ function aggregateFrost({
1071
1111
  verifyingKey,
1072
1112
  adaptorPubKey
1073
1113
  }) {
1114
+ SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("aggregateFrost", {
1115
+ message: (0, import_utils.bytesToHex)(message),
1116
+ statechainCommitments,
1117
+ selfCommitment,
1118
+ statechainSignatures,
1119
+ selfSignature: (0, import_utils.bytesToHex)(selfSignature),
1120
+ statechainPublicKeys,
1121
+ selfPublicKey: (0, import_utils.bytesToHex)(selfPublicKey),
1122
+ verifyingKey: (0, import_utils.bytesToHex)(verifyingKey),
1123
+ adaptorPubKey: adaptorPubKey ? (0, import_utils.bytesToHex)(adaptorPubKey) : void 0
1124
+ });
1074
1125
  return wasm_aggregate_frost(
1075
1126
  message,
1076
1127
  statechainCommitments,
@@ -1,5 +1,12 @@
1
+ import {
2
+ LOGGER_NAMES,
3
+ SparkSdkLogger
4
+ } from "../../chunk-NX5KPN5F.js";
1
5
  import "../../chunk-MVRQ5US7.js";
2
6
 
7
+ // src/spark_bindings/wasm/index.ts
8
+ import { bytesToHex } from "@noble/curves/utils";
9
+
3
10
  // src/wasm/spark_bindings.js
4
11
  var imports = {};
5
12
  imports["__wbindgen_placeholder__"] = imports;
@@ -1009,6 +1016,13 @@ function signFrost({
1009
1016
  statechainCommitments,
1010
1017
  adaptorPubKey
1011
1018
  }) {
1019
+ SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("signFrost", {
1020
+ message: bytesToHex(message),
1021
+ keyPackage,
1022
+ nonce,
1023
+ selfCommitment,
1024
+ statechainCommitments
1025
+ });
1012
1026
  return wasm_sign_frost(
1013
1027
  message,
1014
1028
  createKeyPackage(keyPackage),
@@ -1029,6 +1043,17 @@ function aggregateFrost({
1029
1043
  verifyingKey,
1030
1044
  adaptorPubKey
1031
1045
  }) {
1046
+ SparkSdkLogger.get(LOGGER_NAMES.wasm).trace("aggregateFrost", {
1047
+ message: bytesToHex(message),
1048
+ statechainCommitments,
1049
+ selfCommitment,
1050
+ statechainSignatures,
1051
+ selfSignature: bytesToHex(selfSignature),
1052
+ statechainPublicKeys,
1053
+ selfPublicKey: bytesToHex(selfPublicKey),
1054
+ verifyingKey: bytesToHex(verifyingKey),
1055
+ adaptorPubKey: adaptorPubKey ? bytesToHex(adaptorPubKey) : void 0
1056
+ });
1032
1057
  return wasm_aggregate_frost(
1033
1058
  message,
1034
1059
  statechainCommitments,