@lightsparkdev/lightspark-sdk 1.0.6 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AuthProvider } from '@lightsparkdev/core';
2
- import { W as WebhookEventType } from './index-dbf06298.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 ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, L as LightsparkClient, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from './index-dbf06298.js';
2
+ import { W as WebhookEventType, L as LightsparkClient } from './index-bddc6d51.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 ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from './index-bddc6d51.js';
4
4
  import { B as BitcoinNetwork } from './BitcoinNetwork-a816c0be.js';
5
5
  import 'zen-observable';
6
6
 
@@ -27,5 +27,15 @@ interface WebhookEvent {
27
27
  wallet_id?: string;
28
28
  }
29
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): void;
39
+ }
30
40
 
31
- export { AccountTokenAuthProvider, BitcoinNetwork, WEBHOOKS_SIGNATURE_HEADER, WebhookEvent, WebhookEventType, assertValidBitcoinNetwork, getBitcoinNetworkOrThrow, isBitcoinNetwork, verifyAndParseWebhook };
41
+ export { AccountTokenAuthProvider, BitcoinNetwork, LightsparkClient, RemoteSigningWebhookHandler, WEBHOOKS_SIGNATURE_HEADER, WebhookEvent, WebhookEventType, assertValidBitcoinNetwork, getBitcoinNetworkOrThrow, isBitcoinNetwork, verifyAndParseWebhook };
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  CurrencyUnit_default,
15
15
  FRAGMENT,
16
16
  FRAGMENT10,
17
+ FRAGMENT11,
17
18
  FRAGMENT2,
18
19
  FRAGMENT3,
19
20
  FRAGMENT4,
@@ -26,6 +27,7 @@ import {
26
27
  GraphNode_default,
27
28
  HtlcAttemptFailureCode_default,
28
29
  IncomingPaymentAttemptStatus_default,
30
+ IncomingPaymentFromJson,
29
31
  IncomingPayment_default,
30
32
  InvoiceDataFromJson,
31
33
  InvoiceFromJson,
@@ -76,7 +78,7 @@ import {
76
78
  getSignableQuery,
77
79
  getTransactionQuery,
78
80
  getWithdrawalQuery
79
- } from "./chunk-K2ZU5YQL.js";
81
+ } from "./chunk-AXCZMV2D.js";
80
82
  import {
81
83
  BitcoinNetwork_default
82
84
  } from "./chunk-K6SAUSAX.js";
@@ -129,7 +131,7 @@ import {
129
131
  // package.json
130
132
  var package_default = {
131
133
  name: "@lightsparkdev/lightspark-sdk",
132
- version: "1.0.6",
134
+ version: "1.1.0",
133
135
  description: "Lightspark JS SDK",
134
136
  author: "Lightspark Inc.",
135
137
  keywords: [
@@ -216,7 +218,7 @@ var package_default = {
216
218
  license: "Apache-2.0",
217
219
  dependencies: {
218
220
  "@lightsparkdev/core": "1.0.5",
219
- "@lightsparkdev/crypto-wasm": "0.1.1",
221
+ "@lightsparkdev/crypto-wasm": "0.1.2",
220
222
  "auto-bind": "^5.0.1",
221
223
  crypto: "^1.0.1",
222
224
  "crypto-browserify": "^3.12.0",
@@ -364,8 +366,8 @@ mutation CreateTestModePayment(
364
366
  encoded_invoice: $encoded_invoice
365
367
  amount_msats: $amount_msats
366
368
  }) {
367
- payment {
368
- ...OutgoingPaymentFragment
369
+ incoming_payment {
370
+ ...IncomingPaymentFragment
369
371
  }
370
372
  }
371
373
  }
@@ -575,7 +577,7 @@ var PayInvoice = `
575
577
  }
576
578
  }
577
579
 
578
- ${FRAGMENT6}
580
+ ${FRAGMENT8}
579
581
  `;
580
582
 
581
583
  // src/graphql/PayUmaInvoice.ts
@@ -602,7 +604,7 @@ var PayUmaInvoice = `
602
604
  }
603
605
  }
604
606
 
605
- ${FRAGMENT6}
607
+ ${FRAGMENT8}
606
608
  `;
607
609
 
608
610
  // src/graphql/RequestWithdrawal.ts
@@ -625,7 +627,7 @@ var RequestWithdrawal = `
625
627
  }
626
628
  }
627
629
 
628
- ${FRAGMENT8}
630
+ ${FRAGMENT9}
629
631
  `;
630
632
 
631
633
  // src/graphql/SendPayment.ts
@@ -652,7 +654,7 @@ var SendPayment = `
652
654
  }
653
655
  }
654
656
 
655
- ${FRAGMENT6}
657
+ ${FRAGMENT8}
656
658
  `;
657
659
 
658
660
  // src/graphql/SingleNodeDashboard.ts
@@ -763,7 +765,7 @@ query SingleNodeDashboard(
763
765
  }
764
766
  }
765
767
 
766
- ${FRAGMENT9}
768
+ ${FRAGMENT10}
767
769
  ${FRAGMENT}
768
770
  `;
769
771
 
@@ -802,7 +804,7 @@ query TransactionsForNode(
802
804
  }
803
805
  }
804
806
 
805
- ${FRAGMENT9}
807
+ ${FRAGMENT10}
806
808
  ${FRAGMENT}
807
809
  `;
808
810
 
@@ -817,7 +819,7 @@ subscription TransactionSubscription(
817
819
  }
818
820
  }
819
821
 
820
- ${FRAGMENT10}
822
+ ${FRAGMENT11}
821
823
  `;
822
824
 
823
825
  // src/NodeKeyLoaderCache.ts
@@ -1706,8 +1708,8 @@ var LightsparkClient = class {
1706
1708
  amount_msats: amountMsats
1707
1709
  },
1708
1710
  constructObject: (responseJson) => {
1709
- return OutgoingPaymentFromJson(
1710
- responseJson.create_test_mode_payment?.payment
1711
+ return IncomingPaymentFromJson(
1712
+ responseJson.create_test_mode_payment?.incoming_payment
1711
1713
  );
1712
1714
  }
1713
1715
  });
@@ -1728,6 +1730,7 @@ var LightsparkClient = class {
1728
1730
  var client_default = LightsparkClient;
1729
1731
 
1730
1732
  // src/webhooks.ts
1733
+ import { wasm_handle_remote_signing_webhook_event } from "@lightsparkdev/crypto-wasm";
1731
1734
  var WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
1732
1735
  var verifyAndParseWebhook = async (data, hexdigest, webhook_secret) => {
1733
1736
  const { createHmac } = await import("crypto");
@@ -1753,6 +1756,31 @@ var parseWebhook = async (data) => {
1753
1756
  wallet_id: event.wallet_id
1754
1757
  };
1755
1758
  };
1759
+ var RemoteSigningWebhookHandler = class {
1760
+ client;
1761
+ #masterSeed;
1762
+ validator;
1763
+ constructor(client, masterSeed, validator) {
1764
+ this.client = client;
1765
+ this.#masterSeed = masterSeed;
1766
+ this.validator = validator;
1767
+ }
1768
+ handleWebhookRequest(data, webhookSignature, webhookSecret) {
1769
+ const response = wasm_handle_remote_signing_webhook_event(
1770
+ data,
1771
+ webhookSignature,
1772
+ webhookSecret,
1773
+ this.#masterSeed,
1774
+ this.validator
1775
+ );
1776
+ const variables = JSON.parse(response.variables);
1777
+ this.client.executeRawQuery({
1778
+ queryPayload: response.query,
1779
+ variables,
1780
+ constructObject: (rawData) => rawData
1781
+ });
1782
+ }
1783
+ };
1756
1784
  export {
1757
1785
  Account_default as Account,
1758
1786
  AccountToChannelsConnection_default as AccountToChannelsConnection,
@@ -1782,6 +1810,7 @@ export {
1782
1810
  PaymentRequestStatus_default as PaymentRequestStatus,
1783
1811
  Permission_default as Permission,
1784
1812
  RemoteSigningSubEventType_default as RemoteSigningSubEventType,
1813
+ RemoteSigningWebhookHandler,
1785
1814
  RiskRating_default as RiskRating,
1786
1815
  RoutingTransactionFailureReason_default as RoutingTransactionFailureReason,
1787
1816
  SignablePayloadStatus_default as SignablePayloadStatus,
@@ -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 ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, W as WebhookEventType, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from '../index-dbf06298.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 ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, W as WebhookEventType, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from '../index-bddc6d51.js';
2
2
  export { B as BitcoinNetwork } from '../BitcoinNetwork-a816c0be.js';
3
3
  import '@lightsparkdev/core';
4
4
  import 'zen-observable';
@@ -51,7 +51,7 @@ import {
51
51
  getSignableQuery,
52
52
  getTransactionQuery,
53
53
  getWithdrawalQuery
54
- } from "../chunk-K2ZU5YQL.js";
54
+ } from "../chunk-AXCZMV2D.js";
55
55
  import {
56
56
  BitcoinNetwork_default
57
57
  } from "../chunk-K6SAUSAX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/lightspark-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -87,7 +87,7 @@
87
87
  "license": "Apache-2.0",
88
88
  "dependencies": {
89
89
  "@lightsparkdev/core": "1.0.5",
90
- "@lightsparkdev/crypto-wasm": "0.1.1",
90
+ "@lightsparkdev/crypto-wasm": "0.1.2",
91
91
  "auto-bind": "^5.0.1",
92
92
  "crypto": "^1.0.1",
93
93
  "crypto-browserify": "^3.12.0",
package/src/client.ts CHANGED
@@ -54,6 +54,8 @@ import type CurrencyAmount from "./objects/CurrencyAmount.js";
54
54
  import { CurrencyAmountFromJson } from "./objects/CurrencyAmount.js";
55
55
  import type FeeEstimate from "./objects/FeeEstimate.js";
56
56
  import { FeeEstimateFromJson } from "./objects/FeeEstimate.js";
57
+ import type IncomingPayment from "./objects/IncomingPayment.js";
58
+ import { IncomingPaymentFromJson } from "./objects/IncomingPayment.js";
57
59
  import type Invoice from "./objects/Invoice.js";
58
60
  import { InvoiceFromJson } from "./objects/Invoice.js";
59
61
  import type InvoiceData from "./objects/InvoiceData.js";
@@ -956,7 +958,7 @@ class LightsparkClient {
956
958
  localNodeId: string,
957
959
  encodedInvoice: string,
958
960
  amountMsats: number | undefined = undefined,
959
- ): Promise<OutgoingPayment | null> {
961
+ ): Promise<IncomingPayment | null> {
960
962
  return await this.executeRawQuery({
961
963
  queryPayload: CreateTestModePayment,
962
964
  variables: {
@@ -966,11 +968,11 @@ class LightsparkClient {
966
968
  },
967
969
  constructObject: (responseJson: {
968
970
  create_test_mode_payment: {
969
- payment: any; // eslint-disable-line @typescript-eslint/no-explicit-any
971
+ incoming_payment: any; // eslint-disable-line @typescript-eslint/no-explicit-any
970
972
  } | null;
971
973
  }) => {
972
- return OutgoingPaymentFromJson(
973
- responseJson.create_test_mode_payment?.payment,
974
+ return IncomingPaymentFromJson(
975
+ responseJson.create_test_mode_payment?.incoming_payment,
974
976
  );
975
977
  },
976
978
  });
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { FRAGMENT as OutgoingPaymentFragment } from "../objects/OutgoingPayment.js";
3
+ import { FRAGMENT as IncomingPaymentFragment } from "../objects/IncomingPayment.js";
4
4
 
5
5
  export const CreateTestModePayment = `
6
6
  mutation CreateTestModePayment(
@@ -13,11 +13,11 @@ mutation CreateTestModePayment(
13
13
  encoded_invoice: $encoded_invoice
14
14
  amount_msats: $amount_msats
15
15
  }) {
16
- payment {
17
- ...OutgoingPaymentFragment
16
+ incoming_payment {
17
+ ...IncomingPaymentFragment
18
18
  }
19
19
  }
20
20
  }
21
21
 
22
- ${OutgoingPaymentFragment}
22
+ ${IncomingPaymentFragment}
23
23
  `;
package/src/webhooks.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { wasm_handle_remote_signing_webhook_event } from "@lightsparkdev/crypto-wasm";
2
+ import type LightsparkClient from "./client.js";
1
3
  import { WebhookEventType } from "./objects/WebhookEventType.js";
2
4
 
3
5
  export const WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
@@ -43,3 +45,43 @@ const parseWebhook = async (data: Uint8Array): Promise<WebhookEvent> => {
43
45
  wallet_id: event.wallet_id,
44
46
  };
45
47
  };
48
+
49
+ type Validator = {
50
+ should_sign: (event: WebhookEvent) => boolean;
51
+ };
52
+
53
+ export class RemoteSigningWebhookHandler {
54
+ client: LightsparkClient;
55
+ #masterSeed: Uint8Array;
56
+ validator: Validator;
57
+
58
+ constructor(
59
+ client: LightsparkClient,
60
+ masterSeed: Uint8Array,
61
+ validator: Validator,
62
+ ) {
63
+ this.client = client;
64
+ this.#masterSeed = masterSeed;
65
+ this.validator = validator;
66
+ }
67
+
68
+ handleWebhookRequest(
69
+ data: Uint8Array,
70
+ webhookSignature: string,
71
+ webhookSecret: string,
72
+ ) {
73
+ const response = wasm_handle_remote_signing_webhook_event(
74
+ data,
75
+ webhookSignature,
76
+ webhookSecret,
77
+ this.#masterSeed,
78
+ this.validator,
79
+ );
80
+ const variables = JSON.parse(response.variables);
81
+ this.client.executeRawQuery({
82
+ queryPayload: response.query,
83
+ variables,
84
+ constructObject: (rawData: unknown) => rawData,
85
+ });
86
+ }
87
+ }