@lightsparkdev/lightspark-sdk 1.0.6 → 1.0.7

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,13 @@
1
1
  # @lightsparkdev/lightspark-sdk
2
2
 
3
+ ## 1.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - e156e3e: Remote signing webhooks handler and generate latest wasm
8
+ - Updated dependencies [e156e3e]
9
+ - @lightsparkdev/crypto-wasm@0.1.2
10
+
3
11
  ## 1.0.6
4
12
 
5
13
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1865,6 +1865,7 @@ __export(src_exports, {
1865
1865
  PaymentRequestStatus: () => PaymentRequestStatus_default,
1866
1866
  Permission: () => Permission_default,
1867
1867
  RemoteSigningSubEventType: () => RemoteSigningSubEventType_default,
1868
+ RemoteSigningWebhookHandler: () => RemoteSigningWebhookHandler,
1868
1869
  RiskRating: () => RiskRating_default,
1869
1870
  RoutingTransactionFailureReason: () => RoutingTransactionFailureReason_default,
1870
1871
  SignablePayloadStatus: () => SignablePayloadStatus_default,
@@ -1937,7 +1938,7 @@ var import_core9 = require("@lightsparkdev/core");
1937
1938
  // package.json
1938
1939
  var package_default = {
1939
1940
  name: "@lightsparkdev/lightspark-sdk",
1940
- version: "1.0.6",
1941
+ version: "1.0.7",
1941
1942
  description: "Lightspark JS SDK",
1942
1943
  author: "Lightspark Inc.",
1943
1944
  keywords: [
@@ -2024,7 +2025,7 @@ var package_default = {
2024
2025
  license: "Apache-2.0",
2025
2026
  dependencies: {
2026
2027
  "@lightsparkdev/core": "1.0.5",
2027
- "@lightsparkdev/crypto-wasm": "0.1.1",
2028
+ "@lightsparkdev/crypto-wasm": "0.1.2",
2028
2029
  "auto-bind": "^5.0.1",
2029
2030
  crypto: "^1.0.1",
2030
2031
  "crypto-browserify": "^3.12.0",
@@ -12354,6 +12355,7 @@ ${FRAGMENT33}
12354
12355
  };
12355
12356
 
12356
12357
  // src/webhooks.ts
12358
+ var import_crypto_wasm = require("@lightsparkdev/crypto-wasm");
12357
12359
  var WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
12358
12360
  var verifyAndParseWebhook = async (data, hexdigest, webhook_secret) => {
12359
12361
  const { createHmac } = await import("crypto");
@@ -12379,6 +12381,31 @@ var parseWebhook = async (data) => {
12379
12381
  wallet_id: event.wallet_id
12380
12382
  };
12381
12383
  };
12384
+ var RemoteSigningWebhookHandler = class {
12385
+ client;
12386
+ #masterSeed;
12387
+ validator;
12388
+ constructor(client, masterSeed, validator) {
12389
+ this.client = client;
12390
+ this.#masterSeed = masterSeed;
12391
+ this.validator = validator;
12392
+ }
12393
+ handleWebhookRequest(data, webhookSignature, webhookSecret) {
12394
+ const response = (0, import_crypto_wasm.wasm_handle_remote_signing_webhook_event)(
12395
+ data,
12396
+ webhookSignature,
12397
+ webhookSecret,
12398
+ this.#masterSeed,
12399
+ this.validator
12400
+ );
12401
+ const variables = JSON.parse(response.variables);
12402
+ this.client.executeRawQuery({
12403
+ queryPayload: response.query,
12404
+ variables,
12405
+ constructObject: (rawData) => rawData
12406
+ });
12407
+ }
12408
+ };
12382
12409
  // Annotate the CommonJS export names for ESM import in node:
12383
12410
  0 && (module.exports = {
12384
12411
  Account,
@@ -12409,6 +12436,7 @@ var parseWebhook = async (data) => {
12409
12436
  PaymentRequestStatus,
12410
12437
  Permission,
12411
12438
  RemoteSigningSubEventType,
12439
+ RemoteSigningWebhookHandler,
12412
12440
  RiskRating,
12413
12441
  RoutingTransactionFailureReason,
12414
12442
  SignablePayloadStatus,
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-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, 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';
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
@@ -129,7 +129,7 @@ import {
129
129
  // package.json
130
130
  var package_default = {
131
131
  name: "@lightsparkdev/lightspark-sdk",
132
- version: "1.0.6",
132
+ version: "1.0.7",
133
133
  description: "Lightspark JS SDK",
134
134
  author: "Lightspark Inc.",
135
135
  keywords: [
@@ -216,7 +216,7 @@ var package_default = {
216
216
  license: "Apache-2.0",
217
217
  dependencies: {
218
218
  "@lightsparkdev/core": "1.0.5",
219
- "@lightsparkdev/crypto-wasm": "0.1.1",
219
+ "@lightsparkdev/crypto-wasm": "0.1.2",
220
220
  "auto-bind": "^5.0.1",
221
221
  crypto: "^1.0.1",
222
222
  "crypto-browserify": "^3.12.0",
@@ -1728,6 +1728,7 @@ var LightsparkClient = class {
1728
1728
  var client_default = LightsparkClient;
1729
1729
 
1730
1730
  // src/webhooks.ts
1731
+ import { wasm_handle_remote_signing_webhook_event } from "@lightsparkdev/crypto-wasm";
1731
1732
  var WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
1732
1733
  var verifyAndParseWebhook = async (data, hexdigest, webhook_secret) => {
1733
1734
  const { createHmac } = await import("crypto");
@@ -1753,6 +1754,31 @@ var parseWebhook = async (data) => {
1753
1754
  wallet_id: event.wallet_id
1754
1755
  };
1755
1756
  };
1757
+ var RemoteSigningWebhookHandler = class {
1758
+ client;
1759
+ #masterSeed;
1760
+ validator;
1761
+ constructor(client, masterSeed, validator) {
1762
+ this.client = client;
1763
+ this.#masterSeed = masterSeed;
1764
+ this.validator = validator;
1765
+ }
1766
+ handleWebhookRequest(data, webhookSignature, webhookSecret) {
1767
+ const response = wasm_handle_remote_signing_webhook_event(
1768
+ data,
1769
+ webhookSignature,
1770
+ webhookSecret,
1771
+ this.#masterSeed,
1772
+ this.validator
1773
+ );
1774
+ const variables = JSON.parse(response.variables);
1775
+ this.client.executeRawQuery({
1776
+ queryPayload: response.query,
1777
+ variables,
1778
+ constructObject: (rawData) => rawData
1779
+ });
1780
+ }
1781
+ };
1756
1782
  export {
1757
1783
  Account_default as Account,
1758
1784
  AccountToChannelsConnection_default as AccountToChannelsConnection,
@@ -1782,6 +1808,7 @@ export {
1782
1808
  PaymentRequestStatus_default as PaymentRequestStatus,
1783
1809
  Permission_default as Permission,
1784
1810
  RemoteSigningSubEventType_default as RemoteSigningSubEventType,
1811
+ RemoteSigningWebhookHandler,
1785
1812
  RiskRating_default as RiskRating,
1786
1813
  RoutingTransactionFailureReason_default as RoutingTransactionFailureReason,
1787
1814
  SignablePayloadStatus_default as SignablePayloadStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/lightspark-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
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/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
+ }