@lightsparkdev/lightspark-sdk 1.2.0 → 1.2.2

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 (57) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{chunk-5RDIWPBE.js → chunk-D32EWIPX.js} +3 -1
  3. package/dist/{chunk-VTPDR6P4.js → chunk-GLL4KTUT.js} +353 -15
  4. package/dist/env.cjs +3 -1
  5. package/dist/env.d.cts +17 -0
  6. package/dist/env.js +2 -2
  7. package/dist/{index-f040db9f.d.ts → index-eb604025.d.ts} +1377 -15
  8. package/dist/index.cjs +682 -94
  9. package/dist/index.d.cts +41 -0
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.js +290 -37
  12. package/dist/objects/index.cjs +345 -5
  13. package/dist/objects/index.d.cts +4 -0
  14. package/dist/objects/index.d.ts +1 -1
  15. package/dist/objects/index.js +10 -2
  16. package/dist/{text-encoding-MDIPJAHL.js → text-encoding-26SMKBAQ.js} +3 -1
  17. package/package.json +4 -4
  18. package/src/auth/AccountTokenAuthProvider.ts +15 -11
  19. package/src/client.ts +201 -7
  20. package/src/graphql/ClaimUmaInvitation.ts +21 -0
  21. package/src/graphql/ClaimUmaInvitationWithIncentives.ts +25 -0
  22. package/src/graphql/CreateUmaInvitation.ts +19 -0
  23. package/src/graphql/CreateUmaInvitationWithIncentives.ts +23 -0
  24. package/src/graphql/FetchUmaInvitation.ts +15 -0
  25. package/src/helpers.ts +3 -1
  26. package/src/objects/Account.ts +8 -0
  27. package/src/objects/AccountToChannelsConnection.ts +5 -0
  28. package/src/objects/Channel.ts +31 -0
  29. package/src/objects/ClaimUmaInvitationInput.ts +26 -0
  30. package/src/objects/ClaimUmaInvitationOutput.ts +30 -0
  31. package/src/objects/ClaimUmaInvitationWithIncentivesInput.ts +44 -0
  32. package/src/objects/ClaimUmaInvitationWithIncentivesOutput.ts +33 -0
  33. package/src/objects/CreateInvitationWithIncentivesInput.ts +37 -0
  34. package/src/objects/CreateInvitationWithIncentivesOutput.ts +32 -0
  35. package/src/objects/CreateUmaInvitationInput.ts +22 -0
  36. package/src/objects/CreateUmaInvitationOutput.ts +30 -0
  37. package/src/objects/Entity.ts +13 -0
  38. package/src/objects/GraphNode.ts +28 -0
  39. package/src/objects/IncentivesIneligibilityReason.ts +24 -0
  40. package/src/objects/IncentivesStatus.ts +18 -0
  41. package/src/objects/IncomingPayment.ts +17 -0
  42. package/src/objects/LightsparkNodeWithOSK.ts +61 -0
  43. package/src/objects/LightsparkNodeWithRemoteSigning.ts +60 -0
  44. package/src/objects/OutgoingPayment.ts +20 -0
  45. package/src/objects/OutgoingPaymentAttempt.ts +31 -0
  46. package/src/objects/RegionCode.ts +510 -0
  47. package/src/objects/UmaInvitation.ts +113 -0
  48. package/src/objects/Wallet.ts +12 -0
  49. package/src/objects/WebhookEventType.ts +4 -0
  50. package/src/objects/WithdrawalRequest.ts +17 -0
  51. package/src/objects/index.ts +15 -0
  52. package/src/tests/integration/constants.ts +10 -0
  53. package/src/tests/integration/general-regtest.test.ts +633 -0
  54. package/src/tests/serialization.test.ts +5 -2
  55. package/src/webhooks.ts +1 -1
  56. package/src/tests/integration/client.test.ts +0 -207
  57. /package/dist/{chunk-NIMBE7W3.js → chunk-BMTV3EA2.js} +0 -0
@@ -0,0 +1,41 @@
1
+ import { AuthProvider } from '@lightsparkdev/core';
2
+ import { W as WebhookEventType, L as LightsparkClient } from './index-eb604025.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 ClaimUmaInvitationInput, s as ClaimUmaInvitationOutput, t as ClaimUmaInvitationWithIncentivesInput, u as ClaimUmaInvitationWithIncentivesOutput, v as ComplianceProvider, w as Connection, x as CreateApiTokenInput, y as CreateApiTokenOutput, z as CreateInvitationWithIncentivesInput, D as CreateInvitationWithIncentivesOutput, E as CreateInvoiceInput, F as CreateInvoiceOutput, G as CreateLnurlInvoiceInput, H as CreateNodeWalletAddressInput, I as CreateNodeWalletAddressOutput, J as CreateTestModeInvoiceInput, K as CreateTestModeInvoiceOutput, M as CreateTestModePaymentInput, N as CreateTestModePaymentoutput, O as CreateUmaInvitationInput, P as CreateUmaInvitationOutput, Q as CreateUmaInvoiceInput, R as CurrencyAmount, S as CurrencyUnit, T as DeclineToSignMessagesInput, U as DeclineToSignMessagesOutput, V as DeleteApiTokenInput, X as DeleteApiTokenOutput, Y as Deposit, _ as Entity, $ as FeeEstimate, a0 as FundNodeInput, a1 as FundNodeOutput, a2 as GraphNode, a3 as Hop, a5 as HtlcAttemptFailureCode, a6 as IdAndSignature, a7 as IncentivesIneligibilityReason, a8 as IncentivesStatus, a9 as IncomingPayment, aa as IncomingPaymentAttempt, ac as IncomingPaymentAttemptStatus, ad as IncomingPaymentToAttemptsConnection, ae as Invoice, ag as InvoiceData, ah as InvoiceType, ai as LightningFeeEstimateForInvoiceInput, aj as LightningFeeEstimateForNodeInput, ak as LightningFeeEstimateOutput, al as LightningTransaction, an as LightsparkNode, ap as LightsparkNodeOwner, ar as LightsparkNodeStatus, as as LightsparkNodeToChannelsConnection, at as LightsparkNodeWithOSK, au as LightsparkNodeWithRemoteSigning, av as Node, ax as NodeAddress, ay as NodeAddressType, az as NodeToAddressesConnection, aA as OnChainTransaction, aC as OutgoingPayment, aD as OutgoingPaymentAttempt, aE as OutgoingPaymentAttemptStatus, aF as OutgoingPaymentAttemptToHopsConnection, aI as OutgoingPaymentToAttemptsConnection, aG as OutgoingPaymentsForInvoiceQueryInput, aH as OutgoingPaymentsForInvoiceQueryOutput, aJ as PageInfo, aK as PayInvoiceInput, aL as PayInvoiceOutput, aS as PayUmaInvoiceInput, aM as PaymentDirection, aN as PaymentFailureReason, aO as PaymentRequest, aQ as PaymentRequestData, aR as PaymentRequestStatus, aT as Permission, aU as PostTransactionData, aV as RegionCode, aW as RegisterPaymentInput, aX as RegisterPaymentOutput, aY as ReleaseChannelPerCommitmentSecretInput, aZ as ReleaseChannelPerCommitmentSecretOutput, a_ as ReleasePaymentPreimageInput, a$ as ReleasePaymentPreimageOutput, b0 as RemoteSigningSubEventType, b1 as RequestWithdrawalInput, b2 as RequestWithdrawalOutput, b3 as RichText, b4 as RiskRating, b5 as RoutingTransaction, b7 as RoutingTransactionFailureReason, b8 as ScreenNodeInput, b9 as ScreenNodeOutput, ba as Secret, bb as SendPaymentInput, bc as SendPaymentOutput, bd as SetInvoicePaymentHashInput, be as SetInvoicePaymentHashOutput, bk as SignInvoiceInput, bl as SignInvoiceOutput, bm as SignMessagesInput, bn as SignMessagesOutput, bf as Signable, bh as SignablePayload, bj as SignablePayloadStatus, bo as SingleNodeDashboard, bp as Transaction, br as TransactionFailures, bs as TransactionStatus, bt as TransactionType, bu as TransactionUpdate, bv as UmaInvitation, bx as UpdateChannelPerCommitmentPointInput, by as UpdateChannelPerCommitmentPointOutput, bz as UpdateNodeSharedSecretInput, bA as UpdateNodeSharedSecretOutput, bB as Wallet, bC as WalletStatus, bD as WalletToPaymentRequestsConnection, bE as WalletToTransactionsConnection, bF as Withdrawal, bH as WithdrawalMode, bI as WithdrawalRequest, bJ as WithdrawalRequestStatus, bK as WithdrawalRequestToChannelClosingTransactionsConnection, bL as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, Z as getDepositQuery, a4 as getHopQuery, ab as getIncomingPaymentAttemptQuery, af as getInvoiceQuery, am as getLightningTransactionQuery, aq as getLightsparkNodeOwnerQuery, ao as getLightsparkNodeQuery, aw as getNodeQuery, aB as getOnChainTransactionQuery, aP as getPaymentRequestQuery, b6 as getRoutingTransactionQuery, bi as getSignablePayloadQuery, bg as getSignableQuery, bq as getTransactionQuery, bw as getUmaInvitationQuery, bG as getWithdrawalQuery } from './index-eb604025.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-eb604025.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 ClaimUmaInvitationInput, s as ClaimUmaInvitationOutput, t as ClaimUmaInvitationWithIncentivesInput, u as ClaimUmaInvitationWithIncentivesOutput, v as ComplianceProvider, w as Connection, x as CreateApiTokenInput, y as CreateApiTokenOutput, z as CreateInvitationWithIncentivesInput, D as CreateInvitationWithIncentivesOutput, E as CreateInvoiceInput, F as CreateInvoiceOutput, G as CreateLnurlInvoiceInput, H as CreateNodeWalletAddressInput, I as CreateNodeWalletAddressOutput, J as CreateTestModeInvoiceInput, K as CreateTestModeInvoiceOutput, M as CreateTestModePaymentInput, N as CreateTestModePaymentoutput, O as CreateUmaInvitationInput, P as CreateUmaInvitationOutput, Q as CreateUmaInvoiceInput, R as CurrencyAmount, S as CurrencyUnit, T as DeclineToSignMessagesInput, U as DeclineToSignMessagesOutput, V as DeleteApiTokenInput, X as DeleteApiTokenOutput, Y as Deposit, _ as Entity, $ as FeeEstimate, a0 as FundNodeInput, a1 as FundNodeOutput, a2 as GraphNode, a3 as Hop, a5 as HtlcAttemptFailureCode, a6 as IdAndSignature, a7 as IncentivesIneligibilityReason, a8 as IncentivesStatus, a9 as IncomingPayment, aa as IncomingPaymentAttempt, ac as IncomingPaymentAttemptStatus, ad as IncomingPaymentToAttemptsConnection, ae as Invoice, ag as InvoiceData, ah as InvoiceType, ai as LightningFeeEstimateForInvoiceInput, aj as LightningFeeEstimateForNodeInput, ak as LightningFeeEstimateOutput, al as LightningTransaction, an as LightsparkNode, ap as LightsparkNodeOwner, ar as LightsparkNodeStatus, as as LightsparkNodeToChannelsConnection, at as LightsparkNodeWithOSK, au as LightsparkNodeWithRemoteSigning, av as Node, ax as NodeAddress, ay as NodeAddressType, az as NodeToAddressesConnection, aA as OnChainTransaction, aC as OutgoingPayment, aD as OutgoingPaymentAttempt, aE as OutgoingPaymentAttemptStatus, aF as OutgoingPaymentAttemptToHopsConnection, aI as OutgoingPaymentToAttemptsConnection, aG as OutgoingPaymentsForInvoiceQueryInput, aH as OutgoingPaymentsForInvoiceQueryOutput, aJ as PageInfo, aK as PayInvoiceInput, aL as PayInvoiceOutput, aS as PayUmaInvoiceInput, aM as PaymentDirection, aN as PaymentFailureReason, aO as PaymentRequest, aQ as PaymentRequestData, aR as PaymentRequestStatus, aT as Permission, aU as PostTransactionData, aV as RegionCode, aW as RegisterPaymentInput, aX as RegisterPaymentOutput, aY as ReleaseChannelPerCommitmentSecretInput, aZ as ReleaseChannelPerCommitmentSecretOutput, a_ as ReleasePaymentPreimageInput, a$ as ReleasePaymentPreimageOutput, b0 as RemoteSigningSubEventType, b1 as RequestWithdrawalInput, b2 as RequestWithdrawalOutput, b3 as RichText, b4 as RiskRating, b5 as RoutingTransaction, b7 as RoutingTransactionFailureReason, b8 as ScreenNodeInput, b9 as ScreenNodeOutput, ba as Secret, bb as SendPaymentInput, bc as SendPaymentOutput, bd as SetInvoicePaymentHashInput, be as SetInvoicePaymentHashOutput, bk as SignInvoiceInput, bl as SignInvoiceOutput, bm as SignMessagesInput, bn as SignMessagesOutput, bf as Signable, bh as SignablePayload, bj as SignablePayloadStatus, bo as SingleNodeDashboard, bp as Transaction, br as TransactionFailures, bs as TransactionStatus, bt as TransactionType, bu as TransactionUpdate, bv as UmaInvitation, bx as UpdateChannelPerCommitmentPointInput, by as UpdateChannelPerCommitmentPointOutput, bz as UpdateNodeSharedSecretInput, bA as UpdateNodeSharedSecretOutput, bB as Wallet, bC as WalletStatus, bD as WalletToPaymentRequestsConnection, bE as WalletToTransactionsConnection, bF as Withdrawal, bH as WithdrawalMode, bI as WithdrawalRequest, bJ as WithdrawalRequestStatus, bK as WithdrawalRequestToChannelClosingTransactionsConnection, bL as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, Z as getDepositQuery, a4 as getHopQuery, ab as getIncomingPaymentAttemptQuery, af as getInvoiceQuery, am as getLightningTransactionQuery, aq as getLightsparkNodeOwnerQuery, ao as getLightsparkNodeQuery, aw as getNodeQuery, aB as getOnChainTransactionQuery, aP as getPaymentRequestQuery, b6 as getRoutingTransactionQuery, bi as getSignablePayloadQuery, bg as getSignableQuery, bq as getTransactionQuery, bw as getUmaInvitationQuery, bG as getWithdrawalQuery } from './index-eb604025.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,
@@ -16,6 +16,7 @@ import {
16
16
  FRAGMENT10,
17
17
  FRAGMENT11,
18
18
  FRAGMENT12,
19
+ FRAGMENT13,
19
20
  FRAGMENT2,
20
21
  FRAGMENT3,
21
22
  FRAGMENT4,
@@ -27,6 +28,8 @@ import {
27
28
  FeeEstimateFromJson,
28
29
  GraphNode_default,
29
30
  HtlcAttemptFailureCode_default,
31
+ IncentivesIneligibilityReason_default,
32
+ IncentivesStatus_default,
30
33
  IncomingPaymentAttemptStatus_default,
31
34
  IncomingPaymentFromJson,
32
35
  IncomingPayment_default,
@@ -46,6 +49,7 @@ import {
46
49
  PaymentRequestFromJson,
47
50
  PaymentRequestStatus_default,
48
51
  Permission_default,
52
+ RegionCode_default,
49
53
  RemoteSigningSubEventType_default,
50
54
  RiskRating_default,
51
55
  RoutingTransactionFailureReason_default,
@@ -54,6 +58,7 @@ import {
54
58
  TransactionStatus_default,
55
59
  TransactionType_default,
56
60
  TransactionUpdateFromJson,
61
+ UmaInvitationFromJson,
57
62
  WalletStatus_default,
58
63
  Wallet_default,
59
64
  WebhookEventType,
@@ -79,12 +84,13 @@ import {
79
84
  getSignablePayloadQuery,
80
85
  getSignableQuery,
81
86
  getTransactionQuery,
87
+ getUmaInvitationQuery,
82
88
  getWithdrawalQuery
83
- } from "./chunk-VTPDR6P4.js";
89
+ } from "./chunk-GLL4KTUT.js";
84
90
  import {
85
91
  BitcoinNetwork_default
86
92
  } from "./chunk-K6SAUSAX.js";
87
- import "./chunk-NIMBE7W3.js";
93
+ import "./chunk-BMTV3EA2.js";
88
94
 
89
95
  // src/auth/AccountTokenAuthProvider.ts
90
96
  import { b64encode } from "@lightsparkdev/core";
@@ -99,19 +105,23 @@ var AccountTokenAuthProvider = class {
99
105
  autoBind(this);
100
106
  }
101
107
  utf8AuthBytes;
102
- async addWsConnectionParams(params) {
103
- return Object.assign({}, params, {
104
- client_id: this.apiTokenClientId,
105
- client_secret: this.apiTokenClientSecret
106
- });
108
+ addWsConnectionParams(params) {
109
+ return Promise.resolve(
110
+ Object.assign({}, params, {
111
+ client_id: this.apiTokenClientId,
112
+ client_secret: this.apiTokenClientSecret
113
+ })
114
+ );
107
115
  }
108
- async addAuthHeaders(headers) {
109
- return Object.assign({}, headers, {
110
- authorization: `Basic ${b64encode(this.utf8AuthBytes)}`
111
- });
116
+ addAuthHeaders(headers) {
117
+ return Promise.resolve(
118
+ Object.assign({}, headers, {
119
+ authorization: `Basic ${b64encode(this.utf8AuthBytes)}`
120
+ })
121
+ );
112
122
  }
113
- async isAuthorized() {
114
- return true;
123
+ isAuthorized() {
124
+ return Promise.resolve(true);
115
125
  }
116
126
  };
117
127
  var AccountTokenAuthProvider_default = AccountTokenAuthProvider;
@@ -134,7 +144,7 @@ import {
134
144
  // package.json
135
145
  var package_default = {
136
146
  name: "@lightsparkdev/lightspark-sdk",
137
- version: "1.2.0",
147
+ version: "1.2.2",
138
148
  description: "Lightspark JS SDK",
139
149
  author: "Lightspark Inc.",
140
150
  keywords: [
@@ -222,7 +232,7 @@ var package_default = {
222
232
  },
223
233
  license: "Apache-2.0",
224
234
  dependencies: {
225
- "@lightsparkdev/core": "1.0.9",
235
+ "@lightsparkdev/core": "1.0.10",
226
236
  "@lightsparkdev/crypto-wasm": "0.1.2",
227
237
  "auto-bind": "^5.0.1",
228
238
  "crypto-browserify": "^3.12.0",
@@ -244,10 +254,10 @@ var package_default = {
244
254
  "eslint-watch": "^8.0.0",
245
255
  jest: "^29.6.2",
246
256
  prettier: "3.0.3",
247
- "prettier-plugin-organize-imports": "^3.2.2",
257
+ "prettier-plugin-organize-imports": "^3.2.4",
248
258
  "ts-jest": "^29.1.1",
249
259
  "tsc-absolute": "^1.0.1",
250
- tsup: "^6.7.0",
260
+ tsup: "^7.2.0",
251
261
  typedoc: "^0.24.7",
252
262
  typescript: "^4.9.5"
253
263
  }
@@ -264,6 +274,48 @@ var BitcoinFeeEstimate = `
264
274
  ${FRAGMENT2}
265
275
  `;
266
276
 
277
+ // src/graphql/ClaimUmaInvitation.ts
278
+ var ClaimUmaInvitation = `
279
+ mutation ClaimUmaInvitation(
280
+ $invitationCode: String!
281
+ $inviteeUma: String!
282
+ ) {
283
+ claim_uma_invitation(input: {
284
+ invitation_code: $invitationCode
285
+ invitee_uma: $inviteeUma
286
+ }) {
287
+ invitation {
288
+ ...UmaInvitationFragment
289
+ }
290
+ }
291
+ }
292
+
293
+ ${FRAGMENT3}
294
+ `;
295
+
296
+ // src/graphql/ClaimUmaInvitationWithIncentives.ts
297
+ var ClaimUmaInvitationWithIncentives = `
298
+ mutation ClaimUmaInvitationWithIncentives(
299
+ $invitationCode: String!
300
+ $inviteeUma: String!
301
+ $inviteePhoneHash: String!
302
+ $inviteeRegion: RegionCode!
303
+ ) {
304
+ claim_uma_invitation_with_incentives(input: {
305
+ invitation_code: $invitationCode
306
+ invitee_uma: $inviteeUma
307
+ invitee_phone_hash: $inviteePhoneHash
308
+ invitee_region: $inviteeRegion
309
+ }) {
310
+ invitation {
311
+ ...UmaInvitationFragment
312
+ }
313
+ }
314
+ }
315
+
316
+ ${FRAGMENT3}
317
+ `;
318
+
267
319
  // src/graphql/CreateApiToken.ts
268
320
  var CreateApiToken = `
269
321
  mutation CreateApiToken(
@@ -281,7 +333,7 @@ var CreateApiToken = `
281
333
  }
282
334
  }
283
335
 
284
- ${FRAGMENT3}
336
+ ${FRAGMENT4}
285
337
  `;
286
338
 
287
339
  // src/graphql/CreateInvoice.ts
@@ -322,7 +374,7 @@ mutation CreateLnurlInvoice(
322
374
  }
323
375
  }
324
376
  }
325
- ${FRAGMENT5}
377
+ ${FRAGMENT6}
326
378
  `;
327
379
 
328
380
  // src/graphql/CreateNodeWalletAddress.ts
@@ -375,7 +427,45 @@ mutation CreateTestModePayment(
375
427
  }
376
428
  }
377
429
 
378
- ${FRAGMENT6}
430
+ ${FRAGMENT7}
431
+ `;
432
+
433
+ // src/graphql/CreateUmaInvitation.ts
434
+ var CreateUmaInvitation = `
435
+ mutation CreateUmaInvitation(
436
+ $inviterUma: String!
437
+ ) {
438
+ create_uma_invitation(input: {
439
+ inviter_uma: $inviterUma
440
+ }) {
441
+ invitation {
442
+ ...UmaInvitationFragment
443
+ }
444
+ }
445
+ }
446
+
447
+ ${FRAGMENT3}
448
+ `;
449
+
450
+ // src/graphql/CreateUmaInvitationWithIncentives.ts
451
+ var CreateUmaInvitationWithIncentives = `
452
+ mutation CreateUmaInvitationWithIncentives(
453
+ $inviterUma: String!
454
+ $inviterPhoneHash: String!
455
+ $inviterRegion: RegionCode!
456
+ ) {
457
+ create_uma_invitation_with_incentives(input: {
458
+ inviter_uma: $inviterUma
459
+ inviter_phone_hash: $inviterPhoneHash
460
+ inviter_region: $inviterRegion
461
+ }) {
462
+ invitation {
463
+ ...UmaInvitationFragment
464
+ }
465
+ }
466
+ }
467
+
468
+ ${FRAGMENT3}
379
469
  `;
380
470
 
381
471
  // src/graphql/CreateUmaInvoice.ts
@@ -397,7 +487,7 @@ mutation CreateUmaInvoice(
397
487
  }
398
488
  }
399
489
  }
400
- ${FRAGMENT5}
490
+ ${FRAGMENT6}
401
491
  `;
402
492
 
403
493
  // src/graphql/DecodeInvoice.ts
@@ -411,7 +501,7 @@ var DecodeInvoice = `
411
501
  }
412
502
  }
413
503
 
414
- ${FRAGMENT4}
504
+ ${FRAGMENT5}
415
505
  `;
416
506
 
417
507
  // src/graphql/DeleteApiToken.ts
@@ -427,6 +517,19 @@ var DeleteApiToken = `
427
517
  }
428
518
  `;
429
519
 
520
+ // src/graphql/FetchUmaInvitation.ts
521
+ var FetchUmaInvitation = `
522
+ query FetchUmaInvitation(
523
+ $invitationCode: String!
524
+ ) {
525
+ uma_invitation_by_code(code: $invitationCode) {
526
+ ...UmaInvitationFragment
527
+ }
528
+ }
529
+
530
+ ${FRAGMENT3}
531
+ `;
532
+
430
533
  // src/graphql/FundNode.ts
431
534
  var FundNode = `
432
535
  mutation FundNode(
@@ -459,7 +562,7 @@ var LightningFeeEstimateForInvoice = `
459
562
  }
460
563
  }
461
564
 
462
- ${FRAGMENT7}
565
+ ${FRAGMENT8}
463
566
  `;
464
567
 
465
568
  // src/graphql/LightningFeeEstimateForNode.ts
@@ -478,7 +581,7 @@ var LightningFeeEstimateForNode = `
478
581
  }
479
582
  }
480
583
 
481
- ${FRAGMENT7}
584
+ ${FRAGMENT8}
482
585
  `;
483
586
 
484
587
  // src/graphql/MultiNodeDashboard.ts
@@ -580,7 +683,7 @@ var PayInvoice = `
580
683
  }
581
684
  }
582
685
 
583
- ${FRAGMENT8}
686
+ ${FRAGMENT9}
584
687
  `;
585
688
 
586
689
  // src/graphql/PaymentRequestsForNode.ts
@@ -611,7 +714,7 @@ query PaymentRequestsForNode(
611
714
  }
612
715
  }
613
716
 
614
- ${FRAGMENT9}
717
+ ${FRAGMENT10}
615
718
  `;
616
719
 
617
720
  // src/graphql/PayUmaInvoice.ts
@@ -638,7 +741,7 @@ var PayUmaInvoice = `
638
741
  }
639
742
  }
640
743
 
641
- ${FRAGMENT8}
744
+ ${FRAGMENT9}
642
745
  `;
643
746
 
644
747
  // src/graphql/RequestWithdrawal.ts
@@ -661,7 +764,7 @@ var RequestWithdrawal = `
661
764
  }
662
765
  }
663
766
 
664
- ${FRAGMENT10}
767
+ ${FRAGMENT11}
665
768
  `;
666
769
 
667
770
  // src/graphql/SendPayment.ts
@@ -688,7 +791,7 @@ var SendPayment = `
688
791
  }
689
792
  }
690
793
 
691
- ${FRAGMENT8}
794
+ ${FRAGMENT9}
692
795
  `;
693
796
 
694
797
  // src/graphql/SingleNodeDashboard.ts
@@ -799,7 +902,7 @@ query SingleNodeDashboard(
799
902
  }
800
903
  }
801
904
 
802
- ${FRAGMENT11}
905
+ ${FRAGMENT12}
803
906
  ${FRAGMENT}
804
907
  `;
805
908
 
@@ -838,7 +941,7 @@ query TransactionsForNode(
838
941
  }
839
942
  }
840
943
 
841
- ${FRAGMENT11}
944
+ ${FRAGMENT12}
842
945
  ${FRAGMENT}
843
946
  `;
844
947
 
@@ -853,7 +956,7 @@ subscription TransactionSubscription(
853
956
  }
854
957
  }
855
958
 
856
- ${FRAGMENT12}
959
+ ${FRAGMENT13}
857
960
  `;
858
961
 
859
962
  // src/NodeKeyLoaderCache.ts
@@ -1046,7 +1149,8 @@ var LightsparkClient = class {
1046
1149
  /**
1047
1150
  * Constructs a new LightsparkClient.
1048
1151
  *
1049
- * @param authProvider The auth provider to use for authentication. Defaults to a stub auth provider. For server-side
1152
+ * @param authProvider The auth provider to use for authentication. Defaults to a stub auth provider.
1153
+ * For server-side
1050
1154
  * use, you should use the `AccountTokenAuthProvider`.
1051
1155
  * @param serverUrl The base URL of the server to connect to. Defaults to lightspark production.
1052
1156
  * @param cryptoImpl The crypto implementation to use. Defaults to web and node compatible crypto.
@@ -1103,7 +1207,7 @@ var LightsparkClient = class {
1103
1207
  *
1104
1208
  * @param authProvider
1105
1209
  */
1106
- async setAuthProvider(authProvider) {
1210
+ setAuthProvider(authProvider) {
1107
1211
  this.requester = new Requester(
1108
1212
  this.nodeKeyCache,
1109
1213
  this.LIGHTSPARK_SDK_ENDPOINT,
@@ -1813,6 +1917,151 @@ var LightsparkClient = class {
1813
1917
  }
1814
1918
  });
1815
1919
  }
1920
+ /**
1921
+ * Creates an UMA invitation. If you are part of the incentive program, you should use
1922
+ * [createUmaInvitationWithIncentives].
1923
+ *
1924
+ * @param inviterUma The UMA of the inviter.
1925
+ * @returns The invitation that was created.
1926
+ */
1927
+ async createUmaInvitation(inviterUma) {
1928
+ return await this.executeRawQuery({
1929
+ queryPayload: CreateUmaInvitation,
1930
+ variables: {
1931
+ inviterUma
1932
+ },
1933
+ constructObject: (responseJson) => {
1934
+ if (!responseJson.create_uma_invitation?.invitation) {
1935
+ throw new LightsparkException(
1936
+ "CreateUmaInvitationError",
1937
+ "Unable to create UMA invitation"
1938
+ );
1939
+ }
1940
+ return UmaInvitationFromJson(
1941
+ responseJson.create_uma_invitation?.invitation
1942
+ );
1943
+ }
1944
+ });
1945
+ }
1946
+ /**
1947
+ * Creates an UMA invitation as part of the incentive program.
1948
+ * @param inviterUma The UMA of the inviter.
1949
+ * @param inviterPhoneNumber The phone number of the inviter in E164 format.
1950
+ * @param inviterRegion The region of the inviter.
1951
+ * @returns The invitation that was created.
1952
+ */
1953
+ async createUmaInvitationWithIncentives(inviterUma, inviterPhoneNumber, inviterRegion) {
1954
+ const inviterPhoneHash = await this.hashPhoneNumber(inviterPhoneNumber);
1955
+ return await this.executeRawQuery({
1956
+ queryPayload: CreateUmaInvitationWithIncentives,
1957
+ variables: {
1958
+ inviterUma,
1959
+ inviterPhoneHash,
1960
+ inviterRegion
1961
+ },
1962
+ constructObject: (responseJson) => {
1963
+ if (!responseJson.create_uma_invitation_with_incentives?.invitation) {
1964
+ throw new LightsparkException(
1965
+ "CreateUmaInvitationError",
1966
+ "Unable to create UMA invitation"
1967
+ );
1968
+ }
1969
+ return UmaInvitationFromJson(
1970
+ responseJson.create_uma_invitation_with_incentives?.invitation
1971
+ );
1972
+ }
1973
+ });
1974
+ }
1975
+ /**
1976
+ * Claims an UMA invitation. If you are part of the incentive program, you should use
1977
+ * [claimUmaInvitationWithIncentives].
1978
+ *
1979
+ * @param invitationCode The invitation code to claim.
1980
+ * @param inviteeUma The UMA of the invitee.
1981
+ * @returns The invitation that was claimed.
1982
+ */
1983
+ async claimUmaInvitation(invitationCode, inviteeUma) {
1984
+ return await this.executeRawQuery({
1985
+ queryPayload: ClaimUmaInvitation,
1986
+ variables: {
1987
+ invitationCode,
1988
+ inviteeUma
1989
+ },
1990
+ constructObject: (responseJson) => {
1991
+ if (!responseJson.claim_uma_invitation?.invitation) {
1992
+ throw new LightsparkException(
1993
+ "ClaimUmaInvitationError",
1994
+ "Unable to claim UMA invitation"
1995
+ );
1996
+ }
1997
+ return UmaInvitationFromJson(
1998
+ responseJson.claim_uma_invitation?.invitation
1999
+ );
2000
+ }
2001
+ });
2002
+ }
2003
+ /**
2004
+ * Claims an UMA invitation as part of the incentive program.
2005
+ *
2006
+ * @param invitationCode The invitation code to claim.
2007
+ * @param inviteeUma The UMA of the invitee.
2008
+ * @param inviteePhoneNumber The phone number of the invitee in E164 format.
2009
+ * @param inviteeRegion The region of the invitee.
2010
+ * @returns The invitation that was claimed.
2011
+ */
2012
+ async claimUmaInvitationWithIncentives(invitationCode, inviteeUma, inviteePhoneNumber, inviteeRegion) {
2013
+ const inviteePhoneHash = await this.hashPhoneNumber(inviteePhoneNumber);
2014
+ return await this.executeRawQuery({
2015
+ queryPayload: ClaimUmaInvitationWithIncentives,
2016
+ variables: {
2017
+ invitationCode,
2018
+ inviteeUma,
2019
+ inviteePhoneHash,
2020
+ inviteeRegion
2021
+ },
2022
+ constructObject: (responseJson) => {
2023
+ if (!responseJson.claim_uma_invitation_with_incentives?.invitation) {
2024
+ throw new LightsparkException(
2025
+ "ClaimUmaInvitationError",
2026
+ "Unable to claim UMA invitation"
2027
+ );
2028
+ }
2029
+ return UmaInvitationFromJson(
2030
+ responseJson.claim_uma_invitation_with_incentives?.invitation
2031
+ );
2032
+ }
2033
+ });
2034
+ }
2035
+ /**
2036
+ * Fetches an UMA invitation by its invitation code.
2037
+ *
2038
+ * @param invitationCode The code of the invitation to fetch.
2039
+ * @returns The invitation with the given code, or null if no invitation exists with that code.
2040
+ */
2041
+ async fetchUmaInvitation(invitationCode) {
2042
+ return await this.executeRawQuery({
2043
+ queryPayload: FetchUmaInvitation,
2044
+ variables: {
2045
+ invitationCode
2046
+ },
2047
+ constructObject: (responseJson) => {
2048
+ if (!responseJson.uma_invitation_by_code) {
2049
+ return null;
2050
+ }
2051
+ return UmaInvitationFromJson(responseJson.uma_invitation_by_code);
2052
+ }
2053
+ });
2054
+ }
2055
+ async hashPhoneNumber(e164PhoneNumber) {
2056
+ const e164PhoneRegex = /^\+[1-9]\d{1,14}$/;
2057
+ if (!e164PhoneRegex.test(e164PhoneNumber)) {
2058
+ throw new LightsparkException(
2059
+ "InvalidPhoneNumber",
2060
+ "Invalid phone number. Phone number must be in E164 format."
2061
+ );
2062
+ }
2063
+ return await createSha256Hash(e164PhoneNumber, true);
2064
+ }
1816
2065
  /**
1817
2066
  * Executes a raw `Query` against the Lightspark API.
1818
2067
  *
@@ -1842,7 +2091,7 @@ var verifyAndParseWebhook = async (data, hexdigest, webhook_secret) => {
1842
2091
  var parseWebhook = async (data) => {
1843
2092
  let td = TextDecoder;
1844
2093
  if (typeof td === "undefined") {
1845
- const tdModule = await import("./text-encoding-MDIPJAHL.js");
2094
+ const tdModule = await import("./text-encoding-26SMKBAQ.js");
1846
2095
  td = tdModule.TextDecoder;
1847
2096
  }
1848
2097
  const dataStr = new td().decode(data);
@@ -1873,7 +2122,7 @@ var RemoteSigningWebhookHandler = class {
1873
2122
  this.validator
1874
2123
  );
1875
2124
  const variables = JSON.parse(response.variables);
1876
- this.client.executeRawQuery({
2125
+ return this.client.executeRawQuery({
1877
2126
  queryPayload: response.query,
1878
2127
  variables,
1879
2128
  constructObject: (rawData) => rawData
@@ -1891,6 +2140,8 @@ export {
1891
2140
  CurrencyUnit_default as CurrencyUnit,
1892
2141
  GraphNode_default as GraphNode,
1893
2142
  HtlcAttemptFailureCode_default as HtlcAttemptFailureCode,
2143
+ IncentivesIneligibilityReason_default as IncentivesIneligibilityReason,
2144
+ IncentivesStatus_default as IncentivesStatus,
1894
2145
  IncomingPayment_default as IncomingPayment,
1895
2146
  IncomingPaymentAttemptStatus_default as IncomingPaymentAttemptStatus,
1896
2147
  InvoiceType_default as InvoiceType,
@@ -1906,6 +2157,7 @@ export {
1906
2157
  PaymentFailureReason_default as PaymentFailureReason,
1907
2158
  PaymentRequestStatus_default as PaymentRequestStatus,
1908
2159
  Permission_default as Permission,
2160
+ RegionCode_default as RegionCode,
1909
2161
  RemoteSigningSubEventType_default as RemoteSigningSubEventType,
1910
2162
  RemoteSigningWebhookHandler,
1911
2163
  RiskRating_default as RiskRating,
@@ -1939,6 +2191,7 @@ export {
1939
2191
  getSignablePayloadQuery,
1940
2192
  getSignableQuery,
1941
2193
  getTransactionQuery,
2194
+ getUmaInvitationQuery,
1942
2195
  getWithdrawalQuery,
1943
2196
  isBitcoinNetwork,
1944
2197
  verifyAndParseWebhook