@lightsparkdev/lightspark-sdk 1.2.0 → 1.2.1

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 (35) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/{chunk-5RDIWPBE.js → chunk-D32EWIPX.js} +3 -1
  3. package/dist/env.cjs +3 -1
  4. package/dist/env.d.cts +17 -0
  5. package/dist/env.js +2 -2
  6. package/dist/{index-f040db9f.d.ts → index-5acc6526.d.ts} +717 -14
  7. package/dist/index.cjs +29 -19
  8. package/dist/index.d.cts +41 -0
  9. package/dist/index.d.ts +3 -3
  10. package/dist/index.js +26 -21
  11. package/dist/objects/index.d.cts +4 -0
  12. package/dist/objects/index.d.ts +1 -1
  13. package/dist/objects/index.js +1 -1
  14. package/dist/{text-encoding-MDIPJAHL.js → text-encoding-26SMKBAQ.js} +3 -1
  15. package/package.json +4 -4
  16. package/src/auth/AccountTokenAuthProvider.ts +15 -11
  17. package/src/client.ts +7 -6
  18. package/src/helpers.ts +3 -1
  19. package/src/objects/Account.ts +8 -0
  20. package/src/objects/AccountToChannelsConnection.ts +5 -0
  21. package/src/objects/Channel.ts +31 -0
  22. package/src/objects/GraphNode.ts +28 -0
  23. package/src/objects/IncomingPayment.ts +17 -0
  24. package/src/objects/LightsparkNodeWithOSK.ts +61 -0
  25. package/src/objects/LightsparkNodeWithRemoteSigning.ts +60 -0
  26. package/src/objects/OutgoingPayment.ts +19 -0
  27. package/src/objects/OutgoingPaymentAttempt.ts +26 -0
  28. package/src/objects/Wallet.ts +12 -0
  29. package/src/objects/WithdrawalRequest.ts +17 -0
  30. package/src/tests/integration/constants.ts +13 -0
  31. package/src/tests/integration/general-regtest.test.ts +652 -0
  32. package/src/tests/serialization.test.ts +5 -2
  33. package/src/webhooks.ts +1 -1
  34. package/src/tests/integration/client.test.ts +0 -207
  35. /package/dist/{chunk-NIMBE7W3.js → chunk-BMTV3EA2.js} +0 -0
package/dist/index.cjs CHANGED
@@ -33,6 +33,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
33
33
  // ../../node_modules/text-encoding/lib/encoding-indexes.js
34
34
  var require_encoding_indexes = __commonJS({
35
35
  "../../node_modules/text-encoding/lib/encoding-indexes.js"(exports, module2) {
36
+ "use strict";
36
37
  (function(global) {
37
38
  "use strict";
38
39
  if (typeof module2 !== "undefined" && module2.exports) {
@@ -80,6 +81,7 @@ var require_encoding_indexes = __commonJS({
80
81
  // ../../node_modules/text-encoding/lib/encoding.js
81
82
  var require_encoding = __commonJS({
82
83
  "../../node_modules/text-encoding/lib/encoding.js"(exports, module2) {
84
+ "use strict";
83
85
  (function(global) {
84
86
  "use strict";
85
87
  if (typeof module2 !== "undefined" && module2.exports && !global["encoding-indexes"]) {
@@ -1826,6 +1828,7 @@ var require_encoding = __commonJS({
1826
1828
  // ../../node_modules/text-encoding/index.js
1827
1829
  var require_text_encoding = __commonJS({
1828
1830
  "../../node_modules/text-encoding/index.js"(exports, module2) {
1831
+ "use strict";
1829
1832
  var encoding = require_encoding();
1830
1833
  module2.exports = {
1831
1834
  TextEncoder: encoding.TextEncoder,
@@ -1914,19 +1917,23 @@ var AccountTokenAuthProvider = class {
1914
1917
  (0, import_auto_bind.default)(this);
1915
1918
  }
1916
1919
  utf8AuthBytes;
1917
- async addWsConnectionParams(params) {
1918
- return Object.assign({}, params, {
1919
- client_id: this.apiTokenClientId,
1920
- client_secret: this.apiTokenClientSecret
1921
- });
1920
+ addWsConnectionParams(params) {
1921
+ return Promise.resolve(
1922
+ Object.assign({}, params, {
1923
+ client_id: this.apiTokenClientId,
1924
+ client_secret: this.apiTokenClientSecret
1925
+ })
1926
+ );
1922
1927
  }
1923
- async addAuthHeaders(headers) {
1924
- return Object.assign({}, headers, {
1925
- authorization: `Basic ${(0, import_core.b64encode)(this.utf8AuthBytes)}`
1926
- });
1928
+ addAuthHeaders(headers) {
1929
+ return Promise.resolve(
1930
+ Object.assign({}, headers, {
1931
+ authorization: `Basic ${(0, import_core.b64encode)(this.utf8AuthBytes)}`
1932
+ })
1933
+ );
1927
1934
  }
1928
- async isAuthorized() {
1929
- return true;
1935
+ isAuthorized() {
1936
+ return Promise.resolve(true);
1930
1937
  }
1931
1938
  };
1932
1939
  var AccountTokenAuthProvider_default = AccountTokenAuthProvider;
@@ -1938,7 +1945,7 @@ var import_core9 = require("@lightsparkdev/core");
1938
1945
  // package.json
1939
1946
  var package_default = {
1940
1947
  name: "@lightsparkdev/lightspark-sdk",
1941
- version: "1.2.0",
1948
+ version: "1.2.1",
1942
1949
  description: "Lightspark JS SDK",
1943
1950
  author: "Lightspark Inc.",
1944
1951
  keywords: [
@@ -2026,7 +2033,7 @@ var package_default = {
2026
2033
  },
2027
2034
  license: "Apache-2.0",
2028
2035
  dependencies: {
2029
- "@lightsparkdev/core": "1.0.9",
2036
+ "@lightsparkdev/core": "1.0.10",
2030
2037
  "@lightsparkdev/crypto-wasm": "0.1.2",
2031
2038
  "auto-bind": "^5.0.1",
2032
2039
  "crypto-browserify": "^3.12.0",
@@ -2048,10 +2055,10 @@ var package_default = {
2048
2055
  "eslint-watch": "^8.0.0",
2049
2056
  jest: "^29.6.2",
2050
2057
  prettier: "3.0.3",
2051
- "prettier-plugin-organize-imports": "^3.2.2",
2058
+ "prettier-plugin-organize-imports": "^3.2.4",
2052
2059
  "ts-jest": "^29.1.1",
2053
2060
  "tsc-absolute": "^1.0.1",
2054
- tsup: "^6.7.0",
2061
+ tsup: "^7.2.0",
2055
2062
  typedoc: "^0.24.7",
2056
2063
  typescript: "^4.9.5"
2057
2064
  }
@@ -11440,7 +11447,8 @@ var LightsparkClient = class {
11440
11447
  /**
11441
11448
  * Constructs a new LightsparkClient.
11442
11449
  *
11443
- * @param authProvider The auth provider to use for authentication. Defaults to a stub auth provider. For server-side
11450
+ * @param authProvider The auth provider to use for authentication. Defaults to a stub auth provider.
11451
+ * For server-side
11444
11452
  * use, you should use the `AccountTokenAuthProvider`.
11445
11453
  * @param serverUrl The base URL of the server to connect to. Defaults to lightspark production.
11446
11454
  * @param cryptoImpl The crypto implementation to use. Defaults to web and node compatible crypto.
@@ -11497,7 +11505,7 @@ var LightsparkClient = class {
11497
11505
  *
11498
11506
  * @param authProvider
11499
11507
  */
11500
- async setAuthProvider(authProvider) {
11508
+ setAuthProvider(authProvider) {
11501
11509
  this.requester = new import_core9.Requester(
11502
11510
  this.nodeKeyCache,
11503
11511
  this.LIGHTSPARK_SDK_ENDPOINT,
@@ -12235,7 +12243,9 @@ var isBitcoinNetwork = (bitcoinNetwork) => {
12235
12243
  var assertValidBitcoinNetwork = (bitcoinNetwork) => {
12236
12244
  if (!isBitcoinNetwork(bitcoinNetwork)) {
12237
12245
  throw new Error(
12238
- `Invalid bitcoin network ${bitcoinNetwork}. Valid networks: ${BITCOIN_NETWORKS}`
12246
+ `Invalid bitcoin network ${bitcoinNetwork}. Valid networks: ${BITCOIN_NETWORKS.join(
12247
+ ", "
12248
+ )}`
12239
12249
  );
12240
12250
  }
12241
12251
  };
@@ -13505,7 +13515,7 @@ var RemoteSigningWebhookHandler = class {
13505
13515
  this.validator
13506
13516
  );
13507
13517
  const variables = JSON.parse(response.variables);
13508
- this.client.executeRawQuery({
13518
+ return this.client.executeRawQuery({
13509
13519
  queryPayload: response.query,
13510
13520
  variables,
13511
13521
  constructObject: (rawData) => rawData
@@ -0,0 +1,41 @@
1
+ import { AuthProvider } from '@lightsparkdev/core';
2
+ import { W as WebhookEventType, L as LightsparkClient } from './index-5acc6526.js';
3
+ export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelSnapshot, p as ChannelStatus, q as ChannelToTransactionsConnection, r as ComplianceProvider, s as Connection, t as CreateApiTokenInput, u as CreateApiTokenOutput, v as CreateInvoiceInput, w as CreateInvoiceOutput, x as CreateLnurlInvoiceInput, y as CreateNodeWalletAddressInput, z as CreateNodeWalletAddressOutput, D as CreateTestModeInvoiceInput, E as CreateTestModeInvoiceOutput, F as CreateTestModePaymentInput, G as CreateTestModePaymentoutput, H as CreateUmaInvoiceInput, I as CurrencyAmount, J as CurrencyUnit, K as DeclineToSignMessagesInput, M as DeclineToSignMessagesOutput, N as DeleteApiTokenInput, O as DeleteApiTokenOutput, P as Deposit, R as Entity, S as FeeEstimate, T as FundNodeInput, U as FundNodeOutput, V as GraphNode, X as Hop, Z as HtlcAttemptFailureCode, _ as IdAndSignature, $ as IncomingPayment, a0 as IncomingPaymentAttempt, a2 as IncomingPaymentAttemptStatus, a3 as IncomingPaymentToAttemptsConnection, a4 as Invoice, a6 as InvoiceData, a7 as InvoiceType, a8 as LightningFeeEstimateForInvoiceInput, a9 as LightningFeeEstimateForNodeInput, aa as LightningFeeEstimateOutput, ab as LightningTransaction, ad as LightsparkNode, af as LightsparkNodeOwner, ah as LightsparkNodeStatus, ai as LightsparkNodeToChannelsConnection, aj as LightsparkNodeWithOSK, ak as LightsparkNodeWithRemoteSigning, al as Node, an as NodeAddress, ao as NodeAddressType, ap as NodeToAddressesConnection, aq as OnChainTransaction, as as OutgoingPayment, at as OutgoingPaymentAttempt, au as OutgoingPaymentAttemptStatus, av as OutgoingPaymentAttemptToHopsConnection, ay as OutgoingPaymentToAttemptsConnection, aw as OutgoingPaymentsForInvoiceQueryInput, ax as OutgoingPaymentsForInvoiceQueryOutput, az as PageInfo, aA as PayInvoiceInput, aB as PayInvoiceOutput, aI as PayUmaInvoiceInput, aC as PaymentDirection, aD as PaymentFailureReason, aE as PaymentRequest, aG as PaymentRequestData, aH as PaymentRequestStatus, aJ as Permission, aK as PostTransactionData, aL as RegisterPaymentInput, aM as RegisterPaymentOutput, aN as ReleaseChannelPerCommitmentSecretInput, aO as ReleaseChannelPerCommitmentSecretOutput, aP as ReleasePaymentPreimageInput, aQ as ReleasePaymentPreimageOutput, aR as RemoteSigningSubEventType, aS as RequestWithdrawalInput, aT as RequestWithdrawalOutput, aU as RichText, aV as RiskRating, aW as RoutingTransaction, aY as RoutingTransactionFailureReason, aZ as ScreenNodeInput, a_ as ScreenNodeOutput, a$ as Secret, b0 as SendPaymentInput, b1 as SendPaymentOutput, b2 as SetInvoicePaymentHashInput, b3 as SetInvoicePaymentHashOutput, b9 as SignInvoiceInput, ba as SignInvoiceOutput, bb as SignMessagesInput, bc as SignMessagesOutput, b4 as Signable, b6 as SignablePayload, b8 as SignablePayloadStatus, bd as SingleNodeDashboard, be as Transaction, bg as TransactionFailures, bh as TransactionStatus, bi as TransactionType, bj as TransactionUpdate, bk as UpdateChannelPerCommitmentPointInput, bl as UpdateChannelPerCommitmentPointOutput, bm as UpdateNodeSharedSecretInput, bn as UpdateNodeSharedSecretOutput, bo as Wallet, bp as WalletStatus, bq as WalletToPaymentRequestsConnection, br as WalletToTransactionsConnection, bs as Withdrawal, bu as WithdrawalMode, bv as WithdrawalRequest, bw as WithdrawalRequestStatus, bx as WithdrawalRequestToChannelClosingTransactionsConnection, by as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, Q as getDepositQuery, Y as getHopQuery, a1 as getIncomingPaymentAttemptQuery, a5 as getInvoiceQuery, ac as getLightningTransactionQuery, ag as getLightsparkNodeOwnerQuery, ae as getLightsparkNodeQuery, am as getNodeQuery, ar as getOnChainTransactionQuery, aF as getPaymentRequestQuery, aX as getRoutingTransactionQuery, b7 as getSignablePayloadQuery, b5 as getSignableQuery, bf as getTransactionQuery, bt as getWithdrawalQuery } from './index-5acc6526.js';
4
+ import { B as BitcoinNetwork } from './BitcoinNetwork-a816c0be.js';
5
+ import 'zen-observable';
6
+
7
+ declare class AccountTokenAuthProvider implements AuthProvider {
8
+ private readonly apiTokenClientId;
9
+ private readonly apiTokenClientSecret;
10
+ private readonly utf8AuthBytes;
11
+ constructor(apiTokenClientId: string, apiTokenClientSecret: string);
12
+ addWsConnectionParams(params: Record<string, string>): Promise<Record<string, string>>;
13
+ addAuthHeaders(headers: Record<string, string>): Promise<Record<string, string>>;
14
+ isAuthorized(): Promise<boolean>;
15
+ }
16
+
17
+ declare const isBitcoinNetwork: (bitcoinNetwork: BitcoinNetwork) => boolean;
18
+ declare const assertValidBitcoinNetwork: (bitcoinNetwork: BitcoinNetwork) => void;
19
+ declare const getBitcoinNetworkOrThrow: (bitcoinNetwork: BitcoinNetwork) => BitcoinNetwork;
20
+
21
+ declare const WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
22
+ interface WebhookEvent {
23
+ event_type: WebhookEventType;
24
+ event_id: string;
25
+ timestamp: Date;
26
+ entity_id: string;
27
+ wallet_id?: string;
28
+ }
29
+ declare const verifyAndParseWebhook: (data: Uint8Array, hexdigest: string, webhook_secret: string) => Promise<WebhookEvent>;
30
+ type Validator = {
31
+ should_sign: (event: WebhookEvent) => boolean;
32
+ };
33
+ declare class RemoteSigningWebhookHandler {
34
+ #private;
35
+ client: LightsparkClient;
36
+ validator: Validator;
37
+ constructor(client: LightsparkClient, masterSeed: Uint8Array, validator: Validator);
38
+ handleWebhookRequest(data: Uint8Array, webhookSignature: string, webhookSecret: string): Promise<unknown>;
39
+ }
40
+
41
+ export { AccountTokenAuthProvider, BitcoinNetwork, LightsparkClient, RemoteSigningWebhookHandler, WEBHOOKS_SIGNATURE_HEADER, WebhookEvent, WebhookEventType, assertValidBitcoinNetwork, getBitcoinNetworkOrThrow, isBitcoinNetwork, verifyAndParseWebhook };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AuthProvider } from '@lightsparkdev/core';
2
- import { W as WebhookEventType, L as LightsparkClient } from './index-f040db9f.js';
3
- export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelSnapshot, p as ChannelStatus, q as ChannelToTransactionsConnection, r as ComplianceProvider, s as Connection, t as CreateApiTokenInput, u as CreateApiTokenOutput, v as CreateInvoiceInput, w as CreateInvoiceOutput, x as CreateLnurlInvoiceInput, y as CreateNodeWalletAddressInput, z as CreateNodeWalletAddressOutput, D as CreateTestModeInvoiceInput, E as CreateTestModeInvoiceOutput, F as CreateTestModePaymentInput, G as CreateTestModePaymentoutput, H as CreateUmaInvoiceInput, I as CurrencyAmount, J as CurrencyUnit, K as DeclineToSignMessagesInput, M as DeclineToSignMessagesOutput, N as DeleteApiTokenInput, O as DeleteApiTokenOutput, P as Deposit, R as Entity, S as FeeEstimate, T as FundNodeInput, U as FundNodeOutput, V as GraphNode, X as Hop, Z as HtlcAttemptFailureCode, _ as IdAndSignature, $ as IncomingPayment, a0 as IncomingPaymentAttempt, a2 as IncomingPaymentAttemptStatus, a3 as IncomingPaymentToAttemptsConnection, a4 as Invoice, a6 as InvoiceData, a7 as InvoiceType, a8 as LightningFeeEstimateForInvoiceInput, a9 as LightningFeeEstimateForNodeInput, aa as LightningFeeEstimateOutput, ab as LightningTransaction, ad as LightsparkNode, af as LightsparkNodeOwner, ah as LightsparkNodeStatus, ai as LightsparkNodeToChannelsConnection, aj as LightsparkNodeWithOSK, ak as LightsparkNodeWithRemoteSigning, al as Node, an as NodeAddress, ao as NodeAddressType, ap as NodeToAddressesConnection, aq as OnChainTransaction, as as OutgoingPayment, at as OutgoingPaymentAttempt, au as OutgoingPaymentAttemptStatus, av as OutgoingPaymentAttemptToHopsConnection, ay as OutgoingPaymentToAttemptsConnection, aw as OutgoingPaymentsForInvoiceQueryInput, ax as OutgoingPaymentsForInvoiceQueryOutput, az as PageInfo, aA as PayInvoiceInput, aB as PayInvoiceOutput, aI as PayUmaInvoiceInput, aC as PaymentDirection, aD as PaymentFailureReason, aE as PaymentRequest, aG as PaymentRequestData, aH as PaymentRequestStatus, aJ as Permission, aK as PostTransactionData, aL as RegisterPaymentInput, aM as RegisterPaymentOutput, aN as ReleaseChannelPerCommitmentSecretInput, aO as ReleaseChannelPerCommitmentSecretOutput, aP as ReleasePaymentPreimageInput, aQ as ReleasePaymentPreimageOutput, aR as RemoteSigningSubEventType, aS as RequestWithdrawalInput, aT as RequestWithdrawalOutput, aU as RichText, aV as RiskRating, aW as RoutingTransaction, aY as RoutingTransactionFailureReason, aZ as ScreenNodeInput, a_ as ScreenNodeOutput, a$ as Secret, b0 as SendPaymentInput, b1 as SendPaymentOutput, b2 as SetInvoicePaymentHashInput, b3 as SetInvoicePaymentHashOutput, b9 as SignInvoiceInput, ba as SignInvoiceOutput, bb as SignMessagesInput, bc as SignMessagesOutput, b4 as Signable, b6 as SignablePayload, b8 as SignablePayloadStatus, bd as SingleNodeDashboard, be as Transaction, bg as TransactionFailures, bh as TransactionStatus, bi as TransactionType, bj as TransactionUpdate, bk as UpdateChannelPerCommitmentPointInput, bl as UpdateChannelPerCommitmentPointOutput, bm as UpdateNodeSharedSecretInput, bn as UpdateNodeSharedSecretOutput, bo as Wallet, bp as WalletStatus, bq as WalletToPaymentRequestsConnection, br as WalletToTransactionsConnection, bs as Withdrawal, bu as WithdrawalMode, bv as WithdrawalRequest, bw as WithdrawalRequestStatus, bx as WithdrawalRequestToChannelClosingTransactionsConnection, by as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, Q as getDepositQuery, Y as getHopQuery, a1 as getIncomingPaymentAttemptQuery, a5 as getInvoiceQuery, ac as getLightningTransactionQuery, ag as getLightsparkNodeOwnerQuery, ae as getLightsparkNodeQuery, am as getNodeQuery, ar as getOnChainTransactionQuery, aF as getPaymentRequestQuery, aX as getRoutingTransactionQuery, b7 as getSignablePayloadQuery, b5 as getSignableQuery, bf as getTransactionQuery, bt as getWithdrawalQuery } from './index-f040db9f.js';
2
+ import { W as WebhookEventType, L as LightsparkClient } from './index-5acc6526.js';
3
+ export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelSnapshot, p as ChannelStatus, q as ChannelToTransactionsConnection, r as ComplianceProvider, s as Connection, t as CreateApiTokenInput, u as CreateApiTokenOutput, v as CreateInvoiceInput, w as CreateInvoiceOutput, x as CreateLnurlInvoiceInput, y as CreateNodeWalletAddressInput, z as CreateNodeWalletAddressOutput, D as CreateTestModeInvoiceInput, E as CreateTestModeInvoiceOutput, F as CreateTestModePaymentInput, G as CreateTestModePaymentoutput, H as CreateUmaInvoiceInput, I as CurrencyAmount, J as CurrencyUnit, K as DeclineToSignMessagesInput, M as DeclineToSignMessagesOutput, N as DeleteApiTokenInput, O as DeleteApiTokenOutput, P as Deposit, R as Entity, S as FeeEstimate, T as FundNodeInput, U as FundNodeOutput, V as GraphNode, X as Hop, Z as HtlcAttemptFailureCode, _ as IdAndSignature, $ as IncomingPayment, a0 as IncomingPaymentAttempt, a2 as IncomingPaymentAttemptStatus, a3 as IncomingPaymentToAttemptsConnection, a4 as Invoice, a6 as InvoiceData, a7 as InvoiceType, a8 as LightningFeeEstimateForInvoiceInput, a9 as LightningFeeEstimateForNodeInput, aa as LightningFeeEstimateOutput, ab as LightningTransaction, ad as LightsparkNode, af as LightsparkNodeOwner, ah as LightsparkNodeStatus, ai as LightsparkNodeToChannelsConnection, aj as LightsparkNodeWithOSK, ak as LightsparkNodeWithRemoteSigning, al as Node, an as NodeAddress, ao as NodeAddressType, ap as NodeToAddressesConnection, aq as OnChainTransaction, as as OutgoingPayment, at as OutgoingPaymentAttempt, au as OutgoingPaymentAttemptStatus, av as OutgoingPaymentAttemptToHopsConnection, ay as OutgoingPaymentToAttemptsConnection, aw as OutgoingPaymentsForInvoiceQueryInput, ax as OutgoingPaymentsForInvoiceQueryOutput, az as PageInfo, aA as PayInvoiceInput, aB as PayInvoiceOutput, aI as PayUmaInvoiceInput, aC as PaymentDirection, aD as PaymentFailureReason, aE as PaymentRequest, aG as PaymentRequestData, aH as PaymentRequestStatus, aJ as Permission, aK as PostTransactionData, aL as RegisterPaymentInput, aM as RegisterPaymentOutput, aN as ReleaseChannelPerCommitmentSecretInput, aO as ReleaseChannelPerCommitmentSecretOutput, aP as ReleasePaymentPreimageInput, aQ as ReleasePaymentPreimageOutput, aR as RemoteSigningSubEventType, aS as RequestWithdrawalInput, aT as RequestWithdrawalOutput, aU as RichText, aV as RiskRating, aW as RoutingTransaction, aY as RoutingTransactionFailureReason, aZ as ScreenNodeInput, a_ as ScreenNodeOutput, a$ as Secret, b0 as SendPaymentInput, b1 as SendPaymentOutput, b2 as SetInvoicePaymentHashInput, b3 as SetInvoicePaymentHashOutput, b9 as SignInvoiceInput, ba as SignInvoiceOutput, bb as SignMessagesInput, bc as SignMessagesOutput, b4 as Signable, b6 as SignablePayload, b8 as SignablePayloadStatus, bd as SingleNodeDashboard, be as Transaction, bg as TransactionFailures, bh as TransactionStatus, bi as TransactionType, bj as TransactionUpdate, bk as UpdateChannelPerCommitmentPointInput, bl as UpdateChannelPerCommitmentPointOutput, bm as UpdateNodeSharedSecretInput, bn as UpdateNodeSharedSecretOutput, bo as Wallet, bp as WalletStatus, bq as WalletToPaymentRequestsConnection, br as WalletToTransactionsConnection, bs as Withdrawal, bu as WithdrawalMode, bv as WithdrawalRequest, bw as WithdrawalRequestStatus, bx as WithdrawalRequestToChannelClosingTransactionsConnection, by as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, Q as getDepositQuery, Y as getHopQuery, a1 as getIncomingPaymentAttemptQuery, a5 as getInvoiceQuery, ac as getLightningTransactionQuery, ag as getLightsparkNodeOwnerQuery, ae as getLightsparkNodeQuery, am as getNodeQuery, ar as getOnChainTransactionQuery, aF as getPaymentRequestQuery, aX as getRoutingTransactionQuery, b7 as getSignablePayloadQuery, b5 as getSignableQuery, bf as getTransactionQuery, bt as getWithdrawalQuery } from './index-5acc6526.js';
4
4
  import { B as BitcoinNetwork } from './BitcoinNetwork-a816c0be.js';
5
5
  import 'zen-observable';
6
6
 
@@ -35,7 +35,7 @@ declare class RemoteSigningWebhookHandler {
35
35
  client: LightsparkClient;
36
36
  validator: Validator;
37
37
  constructor(client: LightsparkClient, masterSeed: Uint8Array, validator: Validator);
38
- handleWebhookRequest(data: Uint8Array, webhookSignature: string, webhookSecret: string): void;
38
+ handleWebhookRequest(data: Uint8Array, webhookSignature: string, webhookSecret: string): Promise<unknown>;
39
39
  }
40
40
 
41
41
  export { AccountTokenAuthProvider, BitcoinNetwork, LightsparkClient, RemoteSigningWebhookHandler, WEBHOOKS_SIGNATURE_HEADER, WebhookEvent, WebhookEventType, assertValidBitcoinNetwork, getBitcoinNetworkOrThrow, isBitcoinNetwork, verifyAndParseWebhook };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  assertValidBitcoinNetwork,
3
3
  getBitcoinNetworkOrThrow,
4
4
  isBitcoinNetwork
5
- } from "./chunk-5RDIWPBE.js";
5
+ } from "./chunk-D32EWIPX.js";
6
6
  import {
7
7
  AccountToChannelsConnection_default,
8
8
  Account_default,
@@ -84,7 +84,7 @@ import {
84
84
  import {
85
85
  BitcoinNetwork_default
86
86
  } from "./chunk-K6SAUSAX.js";
87
- import "./chunk-NIMBE7W3.js";
87
+ import "./chunk-BMTV3EA2.js";
88
88
 
89
89
  // src/auth/AccountTokenAuthProvider.ts
90
90
  import { b64encode } from "@lightsparkdev/core";
@@ -99,19 +99,23 @@ var AccountTokenAuthProvider = class {
99
99
  autoBind(this);
100
100
  }
101
101
  utf8AuthBytes;
102
- async addWsConnectionParams(params) {
103
- return Object.assign({}, params, {
104
- client_id: this.apiTokenClientId,
105
- client_secret: this.apiTokenClientSecret
106
- });
102
+ addWsConnectionParams(params) {
103
+ return Promise.resolve(
104
+ Object.assign({}, params, {
105
+ client_id: this.apiTokenClientId,
106
+ client_secret: this.apiTokenClientSecret
107
+ })
108
+ );
107
109
  }
108
- async addAuthHeaders(headers) {
109
- return Object.assign({}, headers, {
110
- authorization: `Basic ${b64encode(this.utf8AuthBytes)}`
111
- });
110
+ addAuthHeaders(headers) {
111
+ return Promise.resolve(
112
+ Object.assign({}, headers, {
113
+ authorization: `Basic ${b64encode(this.utf8AuthBytes)}`
114
+ })
115
+ );
112
116
  }
113
- async isAuthorized() {
114
- return true;
117
+ isAuthorized() {
118
+ return Promise.resolve(true);
115
119
  }
116
120
  };
117
121
  var AccountTokenAuthProvider_default = AccountTokenAuthProvider;
@@ -134,7 +138,7 @@ import {
134
138
  // package.json
135
139
  var package_default = {
136
140
  name: "@lightsparkdev/lightspark-sdk",
137
- version: "1.2.0",
141
+ version: "1.2.1",
138
142
  description: "Lightspark JS SDK",
139
143
  author: "Lightspark Inc.",
140
144
  keywords: [
@@ -222,7 +226,7 @@ var package_default = {
222
226
  },
223
227
  license: "Apache-2.0",
224
228
  dependencies: {
225
- "@lightsparkdev/core": "1.0.9",
229
+ "@lightsparkdev/core": "1.0.10",
226
230
  "@lightsparkdev/crypto-wasm": "0.1.2",
227
231
  "auto-bind": "^5.0.1",
228
232
  "crypto-browserify": "^3.12.0",
@@ -244,10 +248,10 @@ var package_default = {
244
248
  "eslint-watch": "^8.0.0",
245
249
  jest: "^29.6.2",
246
250
  prettier: "3.0.3",
247
- "prettier-plugin-organize-imports": "^3.2.2",
251
+ "prettier-plugin-organize-imports": "^3.2.4",
248
252
  "ts-jest": "^29.1.1",
249
253
  "tsc-absolute": "^1.0.1",
250
- tsup: "^6.7.0",
254
+ tsup: "^7.2.0",
251
255
  typedoc: "^0.24.7",
252
256
  typescript: "^4.9.5"
253
257
  }
@@ -1046,7 +1050,8 @@ var LightsparkClient = class {
1046
1050
  /**
1047
1051
  * Constructs a new LightsparkClient.
1048
1052
  *
1049
- * @param authProvider The auth provider to use for authentication. Defaults to a stub auth provider. For server-side
1053
+ * @param authProvider The auth provider to use for authentication. Defaults to a stub auth provider.
1054
+ * For server-side
1050
1055
  * use, you should use the `AccountTokenAuthProvider`.
1051
1056
  * @param serverUrl The base URL of the server to connect to. Defaults to lightspark production.
1052
1057
  * @param cryptoImpl The crypto implementation to use. Defaults to web and node compatible crypto.
@@ -1103,7 +1108,7 @@ var LightsparkClient = class {
1103
1108
  *
1104
1109
  * @param authProvider
1105
1110
  */
1106
- async setAuthProvider(authProvider) {
1111
+ setAuthProvider(authProvider) {
1107
1112
  this.requester = new Requester(
1108
1113
  this.nodeKeyCache,
1109
1114
  this.LIGHTSPARK_SDK_ENDPOINT,
@@ -1842,7 +1847,7 @@ var verifyAndParseWebhook = async (data, hexdigest, webhook_secret) => {
1842
1847
  var parseWebhook = async (data) => {
1843
1848
  let td = TextDecoder;
1844
1849
  if (typeof td === "undefined") {
1845
- const tdModule = await import("./text-encoding-MDIPJAHL.js");
1850
+ const tdModule = await import("./text-encoding-26SMKBAQ.js");
1846
1851
  td = tdModule.TextDecoder;
1847
1852
  }
1848
1853
  const dataStr = new td().decode(data);
@@ -1873,7 +1878,7 @@ var RemoteSigningWebhookHandler = class {
1873
1878
  this.validator
1874
1879
  );
1875
1880
  const variables = JSON.parse(response.variables);
1876
- this.client.executeRawQuery({
1881
+ return this.client.executeRawQuery({
1877
1882
  queryPayload: response.query,
1878
1883
  variables,
1879
1884
  constructObject: (rawData) => rawData
@@ -0,0 +1,4 @@
1
+ export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelSnapshot, p as ChannelStatus, q as ChannelToTransactionsConnection, r as ComplianceProvider, s as Connection, t as CreateApiTokenInput, u as CreateApiTokenOutput, v as CreateInvoiceInput, w as CreateInvoiceOutput, x as CreateLnurlInvoiceInput, y as CreateNodeWalletAddressInput, z as CreateNodeWalletAddressOutput, D as CreateTestModeInvoiceInput, E as CreateTestModeInvoiceOutput, F as CreateTestModePaymentInput, G as CreateTestModePaymentoutput, H as CreateUmaInvoiceInput, I as CurrencyAmount, J as CurrencyUnit, K as DeclineToSignMessagesInput, M as DeclineToSignMessagesOutput, N as DeleteApiTokenInput, O as DeleteApiTokenOutput, P as Deposit, R as Entity, S as FeeEstimate, T as FundNodeInput, U as FundNodeOutput, V as GraphNode, X as Hop, Z as HtlcAttemptFailureCode, _ as IdAndSignature, $ as IncomingPayment, a0 as IncomingPaymentAttempt, a2 as IncomingPaymentAttemptStatus, a3 as IncomingPaymentToAttemptsConnection, a4 as Invoice, a6 as InvoiceData, a7 as InvoiceType, a8 as LightningFeeEstimateForInvoiceInput, a9 as LightningFeeEstimateForNodeInput, aa as LightningFeeEstimateOutput, ab as LightningTransaction, ad as LightsparkNode, af as LightsparkNodeOwner, ah as LightsparkNodeStatus, ai as LightsparkNodeToChannelsConnection, aj as LightsparkNodeWithOSK, ak as LightsparkNodeWithRemoteSigning, al as Node, an as NodeAddress, ao as NodeAddressType, ap as NodeToAddressesConnection, aq as OnChainTransaction, as as OutgoingPayment, at as OutgoingPaymentAttempt, au as OutgoingPaymentAttemptStatus, av as OutgoingPaymentAttemptToHopsConnection, ay as OutgoingPaymentToAttemptsConnection, aw as OutgoingPaymentsForInvoiceQueryInput, ax as OutgoingPaymentsForInvoiceQueryOutput, az as PageInfo, aA as PayInvoiceInput, aB as PayInvoiceOutput, aI as PayUmaInvoiceInput, aC as PaymentDirection, aD as PaymentFailureReason, aE as PaymentRequest, aG as PaymentRequestData, aH as PaymentRequestStatus, aJ as Permission, aK as PostTransactionData, aL as RegisterPaymentInput, aM as RegisterPaymentOutput, aN as ReleaseChannelPerCommitmentSecretInput, aO as ReleaseChannelPerCommitmentSecretOutput, aP as ReleasePaymentPreimageInput, aQ as ReleasePaymentPreimageOutput, aR as RemoteSigningSubEventType, aS as RequestWithdrawalInput, aT as RequestWithdrawalOutput, aU as RichText, aV as RiskRating, aW as RoutingTransaction, aY as RoutingTransactionFailureReason, aZ as ScreenNodeInput, a_ as ScreenNodeOutput, a$ as Secret, b0 as SendPaymentInput, b1 as SendPaymentOutput, b2 as SetInvoicePaymentHashInput, b3 as SetInvoicePaymentHashOutput, b9 as SignInvoiceInput, ba as SignInvoiceOutput, bb as SignMessagesInput, bc as SignMessagesOutput, b4 as Signable, b6 as SignablePayload, b8 as SignablePayloadStatus, bd as SingleNodeDashboard, be as Transaction, bg as TransactionFailures, bh as TransactionStatus, bi as TransactionType, bj as TransactionUpdate, bk as UpdateChannelPerCommitmentPointInput, bl as UpdateChannelPerCommitmentPointOutput, bm as UpdateNodeSharedSecretInput, bn as UpdateNodeSharedSecretOutput, bo as Wallet, bp as WalletStatus, bq as WalletToPaymentRequestsConnection, br as WalletToTransactionsConnection, W as WebhookEventType, bs as Withdrawal, bu as WithdrawalMode, bv as WithdrawalRequest, bw as WithdrawalRequestStatus, bx as WithdrawalRequestToChannelClosingTransactionsConnection, by as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, Q as getDepositQuery, Y as getHopQuery, a1 as getIncomingPaymentAttemptQuery, a5 as getInvoiceQuery, ac as getLightningTransactionQuery, ag as getLightsparkNodeOwnerQuery, ae as getLightsparkNodeQuery, am as getNodeQuery, ar as getOnChainTransactionQuery, aF as getPaymentRequestQuery, aX as getRoutingTransactionQuery, b7 as getSignablePayloadQuery, b5 as getSignableQuery, bf as getTransactionQuery, bt as getWithdrawalQuery } from '../index-5acc6526.js';
2
+ export { B as BitcoinNetwork } from '../BitcoinNetwork-a816c0be.js';
3
+ import '@lightsparkdev/core';
4
+ import 'zen-observable';
@@ -1,4 +1,4 @@
1
- export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelSnapshot, p as ChannelStatus, q as ChannelToTransactionsConnection, r as ComplianceProvider, s as Connection, t as CreateApiTokenInput, u as CreateApiTokenOutput, v as CreateInvoiceInput, w as CreateInvoiceOutput, x as CreateLnurlInvoiceInput, y as CreateNodeWalletAddressInput, z as CreateNodeWalletAddressOutput, D as CreateTestModeInvoiceInput, E as CreateTestModeInvoiceOutput, F as CreateTestModePaymentInput, G as CreateTestModePaymentoutput, H as CreateUmaInvoiceInput, I as CurrencyAmount, J as CurrencyUnit, K as DeclineToSignMessagesInput, M as DeclineToSignMessagesOutput, N as DeleteApiTokenInput, O as DeleteApiTokenOutput, P as Deposit, R as Entity, S as FeeEstimate, T as FundNodeInput, U as FundNodeOutput, V as GraphNode, X as Hop, Z as HtlcAttemptFailureCode, _ as IdAndSignature, $ as IncomingPayment, a0 as IncomingPaymentAttempt, a2 as IncomingPaymentAttemptStatus, a3 as IncomingPaymentToAttemptsConnection, a4 as Invoice, a6 as InvoiceData, a7 as InvoiceType, a8 as LightningFeeEstimateForInvoiceInput, a9 as LightningFeeEstimateForNodeInput, aa as LightningFeeEstimateOutput, ab as LightningTransaction, ad as LightsparkNode, af as LightsparkNodeOwner, ah as LightsparkNodeStatus, ai as LightsparkNodeToChannelsConnection, aj as LightsparkNodeWithOSK, ak as LightsparkNodeWithRemoteSigning, al as Node, an as NodeAddress, ao as NodeAddressType, ap as NodeToAddressesConnection, aq as OnChainTransaction, as as OutgoingPayment, at as OutgoingPaymentAttempt, au as OutgoingPaymentAttemptStatus, av as OutgoingPaymentAttemptToHopsConnection, ay as OutgoingPaymentToAttemptsConnection, aw as OutgoingPaymentsForInvoiceQueryInput, ax as OutgoingPaymentsForInvoiceQueryOutput, az as PageInfo, aA as PayInvoiceInput, aB as PayInvoiceOutput, aI as PayUmaInvoiceInput, aC as PaymentDirection, aD as PaymentFailureReason, aE as PaymentRequest, aG as PaymentRequestData, aH as PaymentRequestStatus, aJ as Permission, aK as PostTransactionData, aL as RegisterPaymentInput, aM as RegisterPaymentOutput, aN as ReleaseChannelPerCommitmentSecretInput, aO as ReleaseChannelPerCommitmentSecretOutput, aP as ReleasePaymentPreimageInput, aQ as ReleasePaymentPreimageOutput, aR as RemoteSigningSubEventType, aS as RequestWithdrawalInput, aT as RequestWithdrawalOutput, aU as RichText, aV as RiskRating, aW as RoutingTransaction, aY as RoutingTransactionFailureReason, aZ as ScreenNodeInput, a_ as ScreenNodeOutput, a$ as Secret, b0 as SendPaymentInput, b1 as SendPaymentOutput, b2 as SetInvoicePaymentHashInput, b3 as SetInvoicePaymentHashOutput, b9 as SignInvoiceInput, ba as SignInvoiceOutput, bb as SignMessagesInput, bc as SignMessagesOutput, b4 as Signable, b6 as SignablePayload, b8 as SignablePayloadStatus, bd as SingleNodeDashboard, be as Transaction, bg as TransactionFailures, bh as TransactionStatus, bi as TransactionType, bj as TransactionUpdate, bk as UpdateChannelPerCommitmentPointInput, bl as UpdateChannelPerCommitmentPointOutput, bm as UpdateNodeSharedSecretInput, bn as UpdateNodeSharedSecretOutput, bo as Wallet, bp as WalletStatus, bq as WalletToPaymentRequestsConnection, br as WalletToTransactionsConnection, W as WebhookEventType, bs as Withdrawal, bu as WithdrawalMode, bv as WithdrawalRequest, bw as WithdrawalRequestStatus, bx as WithdrawalRequestToChannelClosingTransactionsConnection, by as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, Q as getDepositQuery, Y as getHopQuery, a1 as getIncomingPaymentAttemptQuery, a5 as getInvoiceQuery, ac as getLightningTransactionQuery, ag as getLightsparkNodeOwnerQuery, ae as getLightsparkNodeQuery, am as getNodeQuery, ar as getOnChainTransactionQuery, aF as getPaymentRequestQuery, aX as getRoutingTransactionQuery, b7 as getSignablePayloadQuery, b5 as getSignableQuery, bf as getTransactionQuery, bt as getWithdrawalQuery } from '../index-f040db9f.js';
1
+ export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelSnapshot, p as ChannelStatus, q as ChannelToTransactionsConnection, r as ComplianceProvider, s as Connection, t as CreateApiTokenInput, u as CreateApiTokenOutput, v as CreateInvoiceInput, w as CreateInvoiceOutput, x as CreateLnurlInvoiceInput, y as CreateNodeWalletAddressInput, z as CreateNodeWalletAddressOutput, D as CreateTestModeInvoiceInput, E as CreateTestModeInvoiceOutput, F as CreateTestModePaymentInput, G as CreateTestModePaymentoutput, H as CreateUmaInvoiceInput, I as CurrencyAmount, J as CurrencyUnit, K as DeclineToSignMessagesInput, M as DeclineToSignMessagesOutput, N as DeleteApiTokenInput, O as DeleteApiTokenOutput, P as Deposit, R as Entity, S as FeeEstimate, T as FundNodeInput, U as FundNodeOutput, V as GraphNode, X as Hop, Z as HtlcAttemptFailureCode, _ as IdAndSignature, $ as IncomingPayment, a0 as IncomingPaymentAttempt, a2 as IncomingPaymentAttemptStatus, a3 as IncomingPaymentToAttemptsConnection, a4 as Invoice, a6 as InvoiceData, a7 as InvoiceType, a8 as LightningFeeEstimateForInvoiceInput, a9 as LightningFeeEstimateForNodeInput, aa as LightningFeeEstimateOutput, ab as LightningTransaction, ad as LightsparkNode, af as LightsparkNodeOwner, ah as LightsparkNodeStatus, ai as LightsparkNodeToChannelsConnection, aj as LightsparkNodeWithOSK, ak as LightsparkNodeWithRemoteSigning, al as Node, an as NodeAddress, ao as NodeAddressType, ap as NodeToAddressesConnection, aq as OnChainTransaction, as as OutgoingPayment, at as OutgoingPaymentAttempt, au as OutgoingPaymentAttemptStatus, av as OutgoingPaymentAttemptToHopsConnection, ay as OutgoingPaymentToAttemptsConnection, aw as OutgoingPaymentsForInvoiceQueryInput, ax as OutgoingPaymentsForInvoiceQueryOutput, az as PageInfo, aA as PayInvoiceInput, aB as PayInvoiceOutput, aI as PayUmaInvoiceInput, aC as PaymentDirection, aD as PaymentFailureReason, aE as PaymentRequest, aG as PaymentRequestData, aH as PaymentRequestStatus, aJ as Permission, aK as PostTransactionData, aL as RegisterPaymentInput, aM as RegisterPaymentOutput, aN as ReleaseChannelPerCommitmentSecretInput, aO as ReleaseChannelPerCommitmentSecretOutput, aP as ReleasePaymentPreimageInput, aQ as ReleasePaymentPreimageOutput, aR as RemoteSigningSubEventType, aS as RequestWithdrawalInput, aT as RequestWithdrawalOutput, aU as RichText, aV as RiskRating, aW as RoutingTransaction, aY as RoutingTransactionFailureReason, aZ as ScreenNodeInput, a_ as ScreenNodeOutput, a$ as Secret, b0 as SendPaymentInput, b1 as SendPaymentOutput, b2 as SetInvoicePaymentHashInput, b3 as SetInvoicePaymentHashOutput, b9 as SignInvoiceInput, ba as SignInvoiceOutput, bb as SignMessagesInput, bc as SignMessagesOutput, b4 as Signable, b6 as SignablePayload, b8 as SignablePayloadStatus, bd as SingleNodeDashboard, be as Transaction, bg as TransactionFailures, bh as TransactionStatus, bi as TransactionType, bj as TransactionUpdate, bk as UpdateChannelPerCommitmentPointInput, bl as UpdateChannelPerCommitmentPointOutput, bm as UpdateNodeSharedSecretInput, bn as UpdateNodeSharedSecretOutput, bo as Wallet, bp as WalletStatus, bq as WalletToPaymentRequestsConnection, br as WalletToTransactionsConnection, W as WebhookEventType, bs as Withdrawal, bu as WithdrawalMode, bv as WithdrawalRequest, bw as WithdrawalRequestStatus, bx as WithdrawalRequestToChannelClosingTransactionsConnection, by as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, Q as getDepositQuery, Y as getHopQuery, a1 as getIncomingPaymentAttemptQuery, a5 as getInvoiceQuery, ac as getLightningTransactionQuery, ag as getLightsparkNodeOwnerQuery, ae as getLightsparkNodeQuery, am as getNodeQuery, ar as getOnChainTransactionQuery, aF as getPaymentRequestQuery, aX as getRoutingTransactionQuery, b7 as getSignablePayloadQuery, b5 as getSignableQuery, bf as getTransactionQuery, bt as getWithdrawalQuery } from '../index-5acc6526.js';
2
2
  export { B as BitcoinNetwork } from '../BitcoinNetwork-a816c0be.js';
3
3
  import '@lightsparkdev/core';
4
4
  import 'zen-observable';
@@ -55,7 +55,7 @@ import {
55
55
  import {
56
56
  BitcoinNetwork_default
57
57
  } from "../chunk-K6SAUSAX.js";
58
- import "../chunk-NIMBE7W3.js";
58
+ import "../chunk-BMTV3EA2.js";
59
59
  export {
60
60
  Account_default as Account,
61
61
  AccountToChannelsConnection_default as AccountToChannelsConnection,
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  __commonJS
3
- } from "./chunk-NIMBE7W3.js";
3
+ } from "./chunk-BMTV3EA2.js";
4
4
 
5
5
  // ../../node_modules/text-encoding/lib/encoding-indexes.js
6
6
  var require_encoding_indexes = __commonJS({
7
7
  "../../node_modules/text-encoding/lib/encoding-indexes.js"(exports, module) {
8
+ "use strict";
8
9
  (function(global) {
9
10
  "use strict";
10
11
  if (typeof module !== "undefined" && module.exports) {
@@ -52,6 +53,7 @@ var require_encoding_indexes = __commonJS({
52
53
  // ../../node_modules/text-encoding/lib/encoding.js
53
54
  var require_encoding = __commonJS({
54
55
  "../../node_modules/text-encoding/lib/encoding.js"(exports, module) {
56
+ "use strict";
55
57
  (function(global) {
56
58
  "use strict";
57
59
  if (typeof module !== "undefined" && module.exports && !global["encoding-indexes"]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/lightspark-sdk",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "license": "Apache-2.0",
90
90
  "dependencies": {
91
- "@lightsparkdev/core": "1.0.9",
91
+ "@lightsparkdev/core": "1.0.10",
92
92
  "@lightsparkdev/crypto-wasm": "0.1.2",
93
93
  "auto-bind": "^5.0.1",
94
94
  "crypto-browserify": "^3.12.0",
@@ -110,10 +110,10 @@
110
110
  "eslint-watch": "^8.0.0",
111
111
  "jest": "^29.6.2",
112
112
  "prettier": "3.0.3",
113
- "prettier-plugin-organize-imports": "^3.2.2",
113
+ "prettier-plugin-organize-imports": "^3.2.4",
114
114
  "ts-jest": "^29.1.1",
115
115
  "tsc-absolute": "^1.0.1",
116
- "tsup": "^6.7.0",
116
+ "tsup": "^7.2.0",
117
117
  "typedoc": "^0.24.7",
118
118
  "typescript": "^4.9.5"
119
119
  }
@@ -17,25 +17,29 @@ class AccountTokenAuthProvider implements AuthProvider {
17
17
  autoBind(this);
18
18
  }
19
19
 
20
- async addWsConnectionParams(
20
+ addWsConnectionParams(
21
21
  params: Record<string, string>,
22
22
  ): Promise<Record<string, string>> {
23
- return Object.assign({}, params, {
24
- client_id: this.apiTokenClientId,
25
- client_secret: this.apiTokenClientSecret,
26
- });
23
+ return Promise.resolve(
24
+ Object.assign({}, params, {
25
+ client_id: this.apiTokenClientId,
26
+ client_secret: this.apiTokenClientSecret,
27
+ }),
28
+ );
27
29
  }
28
30
 
29
- async addAuthHeaders(
31
+ addAuthHeaders(
30
32
  headers: Record<string, string>,
31
33
  ): Promise<Record<string, string>> {
32
- return Object.assign({}, headers, {
33
- authorization: `Basic ${b64encode(this.utf8AuthBytes)}`,
34
- });
34
+ return Promise.resolve(
35
+ Object.assign({}, headers, {
36
+ authorization: `Basic ${b64encode(this.utf8AuthBytes)}`,
37
+ }),
38
+ );
35
39
  }
36
40
 
37
- async isAuthorized(): Promise<boolean> {
38
- return true;
41
+ isAuthorized(): Promise<boolean> {
42
+ return Promise.resolve(true);
39
43
  }
40
44
  }
41
45
 
package/src/client.ts CHANGED
@@ -116,7 +116,8 @@ class LightsparkClient {
116
116
  /**
117
117
  * Constructs a new LightsparkClient.
118
118
  *
119
- * @param authProvider The auth provider to use for authentication. Defaults to a stub auth provider. For server-side
119
+ * @param authProvider The auth provider to use for authentication. Defaults to a stub auth provider.
120
+ * For server-side
120
121
  * use, you should use the `AccountTokenAuthProvider`.
121
122
  * @param serverUrl The base URL of the server to connect to. Defaults to lightspark production.
122
123
  * @param cryptoImpl The crypto implementation to use. Defaults to web and node compatible crypto.
@@ -179,7 +180,7 @@ class LightsparkClient {
179
180
  *
180
181
  * @param authProvider
181
182
  */
182
- public async setAuthProvider(authProvider: AuthProvider) {
183
+ public setAuthProvider(authProvider: AuthProvider) {
183
184
  this.requester = new Requester(
184
185
  this.nodeKeyCache,
185
186
  this.LIGHTSPARK_SDK_ENDPOINT,
@@ -797,7 +798,7 @@ class LightsparkClient {
797
798
  * @param transactionId The ID of the transaction to wait for
798
799
  * @param pollTimeoutSecs The timeout in seconds that we will wait before throwing an exception
799
800
  */
800
- public async waitForTransactionComplete(
801
+ public async waitForTransactionComplete<T = Transaction>(
801
802
  transactionId: string,
802
803
  pollTimeoutSecs = 60,
803
804
  ) {
@@ -805,7 +806,7 @@ class LightsparkClient {
805
806
  const pollMaxTimeouts = (pollTimeoutSecs * 1000) / pollIntervalMs;
806
807
  const pollIgnoreErrors = false;
807
808
 
808
- const transaction = (await pollUntil(
809
+ const transaction = await pollUntil(
809
810
  () => {
810
811
  return this.getTransaction(transactionId);
811
812
  },
@@ -833,9 +834,9 @@ class LightsparkClient {
833
834
  "Timeout",
834
835
  "Timeout waiting for transaction to complete.",
835
836
  ),
836
- )) as Transaction;
837
+ );
837
838
 
838
- return transaction;
839
+ return transaction as T;
839
840
  }
840
841
 
841
842
  /**
package/src/helpers.ts CHANGED
@@ -18,7 +18,9 @@ export const assertValidBitcoinNetwork = (
18
18
  ): void => {
19
19
  if (!isBitcoinNetwork(bitcoinNetwork)) {
20
20
  throw new Error(
21
- `Invalid bitcoin network ${bitcoinNetwork}. Valid networks: ${BITCOIN_NETWORKS}`,
21
+ `Invalid bitcoin network ${bitcoinNetwork}. Valid networks: ${BITCOIN_NETWORKS.join(
22
+ ", ",
23
+ )}`,
22
24
  );
23
25
  }
24
26
  };
@@ -29,10 +29,18 @@ import type TransactionType from "./TransactionType.js";
29
29
  /** This is an object representing the connected Lightspark account. You can retrieve this object to see your account information and objects tied to your account. **/
30
30
  class Account implements LightsparkNodeOwner, Entity {
31
31
  constructor(
32
+ /**
33
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
34
+ * string.
35
+ **/
32
36
  public readonly id: string,
37
+ /** The date and time when the entity was first created. **/
33
38
  public readonly createdAt: string,
39
+ /** The date and time when the entity was last updated. **/
34
40
  public readonly updatedAt: string,
41
+ /** The typename of the object **/
35
42
  public readonly typename: string,
43
+ /** The name of this account. **/
36
44
  public readonly name?: string | undefined,
37
45
  ) {
38
46
  autoBind(this);
@@ -6,7 +6,12 @@ import { ChannelFromJson } from "./Channel.js";
6
6
 
7
7
  class AccountToChannelsConnection {
8
8
  constructor(
9
+ /**
10
+ * The total count of objects in this connection, using the current filters. It is different from the
11
+ * number of objects returned in the current page (in the `entities` field).
12
+ **/
9
13
  public readonly count: number,
14
+ /** The channels for the current page of this connection. **/
10
15
  public readonly entities: Channel[],
11
16
  ) {
12
17
  autoBind(this);
@@ -19,24 +19,55 @@ import type TransactionType from "./TransactionType.js";
19
19
  /** This is an object representing a channel on the Lightning Network. You can retrieve this object to get detailed information on a specific Lightning Network channel. **/
20
20
  class Channel implements Entity {
21
21
  constructor(
22
+ /**
23
+ * The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque
24
+ * string.
25
+ **/
22
26
  public readonly id: string,
27
+ /** The date and time when the entity was first created. **/
23
28
  public readonly createdAt: string,
29
+ /** The date and time when the entity was last updated. **/
24
30
  public readonly updatedAt: string,
31
+ /** The local Lightspark node of the channel. **/
25
32
  public readonly localNodeId: string,
33
+ /** The typename of the object **/
26
34
  public readonly typename: string,
35
+ /** The transaction that funded the channel upon channel opening. **/
27
36
  public readonly fundingTransactionId?: string | undefined,
37
+ /**
38
+ * The total amount of funds in this channel, including the channel balance on the local node, the
39
+ * channel balance on the remote node and the on-chain fees to close the channel.
40
+ **/
28
41
  public readonly capacity?: CurrencyAmount | undefined,
42
+ /** The channel balance on the local node. **/
29
43
  public readonly localBalance?: CurrencyAmount | undefined,
44
+ /** The channel balance on the local node that is currently allocated to in-progress payments. **/
30
45
  public readonly localUnsettledBalance?: CurrencyAmount | undefined,
46
+ /** The channel balance on the remote node. **/
31
47
  public readonly remoteBalance?: CurrencyAmount | undefined,
48
+ /** The channel balance on the remote node that is currently allocated to in-progress payments. **/
32
49
  public readonly remoteUnsettledBalance?: CurrencyAmount | undefined,
50
+ /** The channel balance that is currently allocated to in-progress payments. **/
33
51
  public readonly unsettledBalance?: CurrencyAmount | undefined,
52
+ /** The total balance in this channel, including the channel balance on both local and remote nodes. **/
34
53
  public readonly totalBalance?: CurrencyAmount | undefined,
54
+ /** The current status of this channel. **/
35
55
  public readonly status?: ChannelStatus | undefined,
56
+ /**
57
+ * The estimated time to wait for the channel's hash timelock contract to expire when force closing
58
+ * the channel. It is in unit of minutes.
59
+ **/
36
60
  public readonly estimatedForceClosureWaitMinutes?: number | undefined,
61
+ /** The amount to be paid in fees for the current set of commitment transactions. **/
37
62
  public readonly commitFee?: CurrencyAmount | undefined,
63
+ /** The fees charged for routing payments through this channel. **/
38
64
  public readonly fees?: ChannelFees | undefined,
65
+ /** If known, the remote node of the channel. **/
39
66
  public readonly remoteNodeId?: string | undefined,
67
+ /**
68
+ * The unique identifier of the channel on Lightning Network, which is the location in the chain that
69
+ * the channel was confirmed. The format is <block-height>:<tx-index>:<tx-output>.
70
+ **/
40
71
  public readonly shortChannelId?: string | undefined,
41
72
  ) {
42
73
  autoBind(this);