@lightsparkdev/lightspark-sdk 1.8.0 → 1.8.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 (48) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{chunk-J7GJGYME.js → chunk-4KFNQOMH.js} +84 -39
  3. package/dist/{index-9a69ef6a.d.ts → index-27dad75b.d.ts} +22 -1
  4. package/dist/index.cjs +240 -91
  5. package/dist/index.d.cts +2 -2
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.js +103 -3
  8. package/dist/objects/index.cjs +97 -52
  9. package/dist/objects/index.d.cts +1 -1
  10. package/dist/objects/index.d.ts +1 -1
  11. package/dist/objects/index.js +1 -1
  12. package/package.json +2 -2
  13. package/src/client.ts +89 -8
  14. package/src/graphql/IncomingPaymentsForInvoice.ts +21 -0
  15. package/src/graphql/OutgoingPaymentsForInvoice.ts +21 -0
  16. package/src/objects/Account.ts +4 -2
  17. package/src/objects/ApiToken.ts +2 -2
  18. package/src/objects/AuditLogActor.ts +2 -2
  19. package/src/objects/Channel.ts +2 -2
  20. package/src/objects/ChannelClosingTransaction.ts +2 -2
  21. package/src/objects/ChannelOpeningTransaction.ts +2 -2
  22. package/src/objects/ChannelSnapshot.ts +2 -2
  23. package/src/objects/Deposit.ts +2 -2
  24. package/src/objects/GraphNode.ts +2 -2
  25. package/src/objects/Hop.ts +2 -2
  26. package/src/objects/IncomingPayment.ts +2 -2
  27. package/src/objects/IncomingPaymentAttempt.ts +2 -2
  28. package/src/objects/Invoice.ts +2 -2
  29. package/src/objects/LightningTransaction.ts +2 -2
  30. package/src/objects/LightsparkNode.ts +2 -2
  31. package/src/objects/LightsparkNodeOwner.ts +2 -2
  32. package/src/objects/LightsparkNodeWithOSK.ts +2 -2
  33. package/src/objects/LightsparkNodeWithRemoteSigning.ts +2 -2
  34. package/src/objects/Node.ts +2 -2
  35. package/src/objects/OnChainTransaction.ts +2 -2
  36. package/src/objects/OutgoingPayment.ts +2 -2
  37. package/src/objects/OutgoingPaymentAttempt.ts +2 -2
  38. package/src/objects/PaymentRequest.ts +2 -2
  39. package/src/objects/RoutingTransaction.ts +2 -2
  40. package/src/objects/Signable.ts +2 -2
  41. package/src/objects/SignablePayload.ts +2 -2
  42. package/src/objects/Transaction.ts +2 -2
  43. package/src/objects/UmaInvitation.ts +2 -2
  44. package/src/objects/Wallet.ts +2 -2
  45. package/src/objects/Withdrawal.ts +2 -2
  46. package/src/objects/WithdrawalRequest.ts +2 -2
  47. package/src/tests/generated-objects.test.ts +93 -0
  48. package/src/tests/serialization.test.ts +0 -21
@@ -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 AccountToWithdrawalRequestsConnection, h as ApiToken, j as AuditLogActor, B as Balances, l as BlockchainBalance, C as CancelInvoiceInput, m as CancelInvoiceOutput, n as Channel, o as ChannelClosingTransaction, q as ChannelFees, r as ChannelOpeningTransaction, t as ChannelSnapshot, v as ChannelStatus, w as ChannelToTransactionsConnection, x as ClaimUmaInvitationInput, y as ClaimUmaInvitationOutput, z as ClaimUmaInvitationWithIncentivesInput, D as ClaimUmaInvitationWithIncentivesOutput, E as ComplianceProvider, F as Connection, G as CreateApiTokenInput, H as CreateApiTokenOutput, I as CreateInvitationWithIncentivesInput, J as CreateInvitationWithIncentivesOutput, K as CreateInvoiceInput, M as CreateInvoiceOutput, N as CreateLnurlInvoiceInput, O as CreateNodeWalletAddressInput, P as CreateNodeWalletAddressOutput, Q as CreateTestModeInvoiceInput, R as CreateTestModeInvoiceOutput, S as CreateTestModePaymentInput, T as CreateTestModePaymentoutput, U as CreateUmaInvitationInput, V as CreateUmaInvitationOutput, X as CreateUmaInvoiceInput, Y as CurrencyAmount, Z as CurrencyUnit, _ as DailyLiquidityForecast, $ as DeclineToSignMessagesInput, a0 as DeclineToSignMessagesOutput, a1 as DeleteApiTokenInput, a2 as DeleteApiTokenOutput, a3 as Deposit, a5 as Entity, a6 as FailHtlcsInput, a7 as FailHtlcsOutput, a8 as FeeEstimate, a9 as FundNodeInput, aa as FundNodeOutput, ab as GraphNode, ac as Hop, ae as HtlcAttemptFailureCode, af as IdAndSignature, ag as IncentivesIneligibilityReason, ah as IncentivesStatus, ai as IncomingPayment, aj as IncomingPaymentAttempt, al as IncomingPaymentAttemptStatus, am as IncomingPaymentToAttemptsConnection, an as IncomingPaymentsForInvoiceQueryInput, ao as IncomingPaymentsForInvoiceQueryOutput, ap as Invoice, ar as InvoiceData, as as InvoiceForPaymentHashInput, at as InvoiceForPaymentHashOutput, au as InvoiceType, av as LightningFeeEstimateForInvoiceInput, aw as LightningFeeEstimateForNodeInput, ax as LightningFeeEstimateOutput, ay as LightningPaymentDirection, az as LightningTransaction, aB as LightsparkNode, aD as LightsparkNodeOwner, aF as LightsparkNodeStatus, aG as LightsparkNodeToChannelsConnection, aH as LightsparkNodeToDailyLiquidityForecastsConnection, aI as LightsparkNodeWithOSK, aJ as LightsparkNodeWithRemoteSigning, aK as MultiSigAddressValidationParameters, aL as Node, aN as NodeAddress, aO as NodeAddressType, aP as NodeToAddressesConnection, aQ as OnChainFeeTarget, aR as OnChainTransaction, aT as OutgoingPayment, aU as OutgoingPaymentAttempt, aV as OutgoingPaymentAttemptStatus, aW as OutgoingPaymentAttemptToHopsConnection, aX as OutgoingPaymentForIdempotencyKeyInput, aY as OutgoingPaymentForIdempotencyKeyOutput, aZ as OutgoingPaymentToAttemptsConnection, a_ as OutgoingPaymentsForInvoiceQueryInput, a$ as OutgoingPaymentsForInvoiceQueryOutput, b0 as OutgoingPaymentsForPaymentHashQueryInput, b1 as OutgoingPaymentsForPaymentHashQueryOutput, b2 as PageInfo, b3 as PayInvoiceInput, b4 as PayInvoiceOutput, b5 as PayUmaInvoiceInput, b6 as PaymentDirection, b7 as PaymentFailureReason, b8 as PaymentRequest, ba as PaymentRequestData, bb as PaymentRequestStatus, bc as Permission, bd as PostTransactionData, be as RegionCode, bf as RegisterPaymentInput, bg as RegisterPaymentOutput, bh as ReleaseChannelPerCommitmentSecretInput, bi as ReleaseChannelPerCommitmentSecretOutput, bj as ReleasePaymentPreimageInput, bk as ReleasePaymentPreimageOutput, bl as RemoteSigningSubEventType, bm as RequestInitiator, bn as RequestWithdrawalInput, bo as RequestWithdrawalOutput, bp as RichText, bq as RiskRating, br as RoutingTransaction, bt as RoutingTransactionFailureReason, bu as ScreenNodeInput, bv as ScreenNodeOutput, bw as Secret, bx as SendPaymentInput, by as SendPaymentOutput, bz as SetInvoicePaymentHashInput, bA as SetInvoicePaymentHashOutput, bB as SignInvoiceInput, bC as SignInvoiceOutput, bD as SignMessagesInput, bE as SignMessagesOutput, bF as Signable, bH as SignablePayload, bJ as SignablePayloadStatus, bK as SingleNodeDashboard, bL as Transaction, bN as TransactionFailures, bO as TransactionStatus, bP as TransactionType, bQ as TransactionUpdate, bR as UmaInvitation, bT as UpdateChannelPerCommitmentPointInput, bU as UpdateChannelPerCommitmentPointOutput, bV as UpdateNodeSharedSecretInput, bW as UpdateNodeSharedSecretOutput, bX as Wallet, bY as WalletStatus, bZ as WalletToPaymentRequestsConnection, b_ as WalletToTransactionsConnection, b$ as WalletToWithdrawalRequestsConnection, W as WebhookEventType, c0 as Withdrawal, c2 as WithdrawalFeeEstimateInput, c3 as WithdrawalFeeEstimateOutput, c4 as WithdrawalMode, c5 as WithdrawalRequest, c6 as WithdrawalRequestStatus, c7 as WithdrawalRequestToChannelClosingTransactionsConnection, c8 as WithdrawalRequestToChannelOpeningTransactionsConnection, c9 as WithdrawalRequestToWithdrawalsConnection, i as getApiTokenQuery, k as getAuditLogActorQuery, p as getChannelClosingTransactionQuery, s as getChannelOpeningTransactionQuery, u as getChannelSnapshotQuery, a4 as getDepositQuery, ad as getHopQuery, ak as getIncomingPaymentAttemptQuery, aq as getInvoiceQuery, aA as getLightningTransactionQuery, aE as getLightsparkNodeOwnerQuery, aC as getLightsparkNodeQuery, aM as getNodeQuery, aS as getOnChainTransactionQuery, b9 as getPaymentRequestQuery, bs as getRoutingTransactionQuery, bI as getSignablePayloadQuery, bG as getSignableQuery, bM as getTransactionQuery, bS as getUmaInvitationQuery, c1 as getWithdrawalQuery } from '../index-9a69ef6a.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 AccountToWithdrawalRequestsConnection, h as ApiToken, j as AuditLogActor, B as Balances, l as BlockchainBalance, C as CancelInvoiceInput, m as CancelInvoiceOutput, n as Channel, o as ChannelClosingTransaction, q as ChannelFees, r as ChannelOpeningTransaction, t as ChannelSnapshot, v as ChannelStatus, w as ChannelToTransactionsConnection, x as ClaimUmaInvitationInput, y as ClaimUmaInvitationOutput, z as ClaimUmaInvitationWithIncentivesInput, D as ClaimUmaInvitationWithIncentivesOutput, E as ComplianceProvider, F as Connection, G as CreateApiTokenInput, H as CreateApiTokenOutput, I as CreateInvitationWithIncentivesInput, J as CreateInvitationWithIncentivesOutput, K as CreateInvoiceInput, M as CreateInvoiceOutput, N as CreateLnurlInvoiceInput, O as CreateNodeWalletAddressInput, P as CreateNodeWalletAddressOutput, Q as CreateTestModeInvoiceInput, R as CreateTestModeInvoiceOutput, S as CreateTestModePaymentInput, T as CreateTestModePaymentoutput, U as CreateUmaInvitationInput, V as CreateUmaInvitationOutput, X as CreateUmaInvoiceInput, Y as CurrencyAmount, Z as CurrencyUnit, _ as DailyLiquidityForecast, $ as DeclineToSignMessagesInput, a0 as DeclineToSignMessagesOutput, a1 as DeleteApiTokenInput, a2 as DeleteApiTokenOutput, a3 as Deposit, a5 as Entity, a6 as FailHtlcsInput, a7 as FailHtlcsOutput, a8 as FeeEstimate, a9 as FundNodeInput, aa as FundNodeOutput, ab as GraphNode, ac as Hop, ae as HtlcAttemptFailureCode, af as IdAndSignature, ag as IncentivesIneligibilityReason, ah as IncentivesStatus, ai as IncomingPayment, aj as IncomingPaymentAttempt, al as IncomingPaymentAttemptStatus, am as IncomingPaymentToAttemptsConnection, an as IncomingPaymentsForInvoiceQueryInput, ao as IncomingPaymentsForInvoiceQueryOutput, ap as Invoice, ar as InvoiceData, as as InvoiceForPaymentHashInput, at as InvoiceForPaymentHashOutput, au as InvoiceType, av as LightningFeeEstimateForInvoiceInput, aw as LightningFeeEstimateForNodeInput, ax as LightningFeeEstimateOutput, ay as LightningPaymentDirection, az as LightningTransaction, aB as LightsparkNode, aD as LightsparkNodeOwner, aF as LightsparkNodeStatus, aG as LightsparkNodeToChannelsConnection, aH as LightsparkNodeToDailyLiquidityForecastsConnection, aI as LightsparkNodeWithOSK, aJ as LightsparkNodeWithRemoteSigning, aK as MultiSigAddressValidationParameters, aL as Node, aN as NodeAddress, aO as NodeAddressType, aP as NodeToAddressesConnection, aQ as OnChainFeeTarget, aR as OnChainTransaction, aT as OutgoingPayment, aU as OutgoingPaymentAttempt, aV as OutgoingPaymentAttemptStatus, aW as OutgoingPaymentAttemptToHopsConnection, aX as OutgoingPaymentForIdempotencyKeyInput, aY as OutgoingPaymentForIdempotencyKeyOutput, aZ as OutgoingPaymentToAttemptsConnection, a_ as OutgoingPaymentsForInvoiceQueryInput, a$ as OutgoingPaymentsForInvoiceQueryOutput, b0 as OutgoingPaymentsForPaymentHashQueryInput, b1 as OutgoingPaymentsForPaymentHashQueryOutput, b2 as PageInfo, b3 as PayInvoiceInput, b4 as PayInvoiceOutput, b5 as PayUmaInvoiceInput, b6 as PaymentDirection, b7 as PaymentFailureReason, b8 as PaymentRequest, ba as PaymentRequestData, bb as PaymentRequestStatus, bc as Permission, bd as PostTransactionData, be as RegionCode, bf as RegisterPaymentInput, bg as RegisterPaymentOutput, bh as ReleaseChannelPerCommitmentSecretInput, bi as ReleaseChannelPerCommitmentSecretOutput, bj as ReleasePaymentPreimageInput, bk as ReleasePaymentPreimageOutput, bl as RemoteSigningSubEventType, bm as RequestInitiator, bn as RequestWithdrawalInput, bo as RequestWithdrawalOutput, bp as RichText, bq as RiskRating, br as RoutingTransaction, bt as RoutingTransactionFailureReason, bu as ScreenNodeInput, bv as ScreenNodeOutput, bw as Secret, bx as SendPaymentInput, by as SendPaymentOutput, bz as SetInvoicePaymentHashInput, bA as SetInvoicePaymentHashOutput, bB as SignInvoiceInput, bC as SignInvoiceOutput, bD as SignMessagesInput, bE as SignMessagesOutput, bF as Signable, bH as SignablePayload, bJ as SignablePayloadStatus, bK as SingleNodeDashboard, bL as Transaction, bN as TransactionFailures, bO as TransactionStatus, bP as TransactionType, bQ as TransactionUpdate, bR as UmaInvitation, bT as UpdateChannelPerCommitmentPointInput, bU as UpdateChannelPerCommitmentPointOutput, bV as UpdateNodeSharedSecretInput, bW as UpdateNodeSharedSecretOutput, bX as Wallet, bY as WalletStatus, bZ as WalletToPaymentRequestsConnection, b_ as WalletToTransactionsConnection, b$ as WalletToWithdrawalRequestsConnection, W as WebhookEventType, c0 as Withdrawal, c2 as WithdrawalFeeEstimateInput, c3 as WithdrawalFeeEstimateOutput, c4 as WithdrawalMode, c5 as WithdrawalRequest, c6 as WithdrawalRequestStatus, c7 as WithdrawalRequestToChannelClosingTransactionsConnection, c8 as WithdrawalRequestToChannelOpeningTransactionsConnection, c9 as WithdrawalRequestToWithdrawalsConnection, i as getApiTokenQuery, k as getAuditLogActorQuery, p as getChannelClosingTransactionQuery, s as getChannelOpeningTransactionQuery, u as getChannelSnapshotQuery, a4 as getDepositQuery, ad as getHopQuery, ak as getIncomingPaymentAttemptQuery, aq as getInvoiceQuery, aA as getLightningTransactionQuery, aE as getLightsparkNodeOwnerQuery, aC as getLightsparkNodeQuery, aM as getNodeQuery, aS as getOnChainTransactionQuery, b9 as getPaymentRequestQuery, bs as getRoutingTransactionQuery, bI as getSignablePayloadQuery, bG as getSignableQuery, bM as getTransactionQuery, bS as getUmaInvitationQuery, c1 as getWithdrawalQuery } from '../index-27dad75b.js';
2
2
  export { B as BitcoinNetwork } from '../BitcoinNetwork-4f6ea015.js';
3
3
  import '@lightsparkdev/core';
4
4
  import 'zen-observable';
@@ -59,7 +59,7 @@ import {
59
59
  getTransactionQuery,
60
60
  getUmaInvitationQuery,
61
61
  getWithdrawalQuery
62
- } from "../chunk-J7GJGYME.js";
62
+ } from "../chunk-4KFNQOMH.js";
63
63
  import {
64
64
  BitcoinNetwork_default
65
65
  } from "../chunk-K6SAUSAX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/lightspark-sdk",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "license": "Apache-2.0",
87
87
  "dependencies": {
88
- "@lightsparkdev/core": "1.2.0",
88
+ "@lightsparkdev/core": "1.2.1",
89
89
  "@lightsparkdev/crypto-wasm": "0.1.4",
90
90
  "crypto-browserify": "^3.12.0",
91
91
  "dayjs": "^1.11.7",
package/src/client.ts CHANGED
@@ -3,26 +3,26 @@
3
3
  import autoBind from "auto-bind";
4
4
  import type Observable from "zen-observable";
5
5
 
6
- import type {
7
- AuthProvider,
8
- CryptoInterface,
9
- KeyOrAliasType,
10
- Maybe,
11
- Query,
12
- SigningKey,
13
- } from "@lightsparkdev/core";
14
6
  import {
15
7
  DefaultCrypto,
16
8
  LightsparkAuthException,
17
9
  LightsparkException,
18
10
  LightsparkSigningException,
11
+ LoggingLevel,
19
12
  NodeKeyCache,
20
13
  Requester,
21
14
  SigningKeyType,
22
15
  StubAuthProvider,
23
16
  bytesToHex,
17
+ logger as coreLogger,
24
18
  createSha256Hash,
25
19
  pollUntil,
20
+ type AuthProvider,
21
+ type CryptoInterface,
22
+ type KeyOrAliasType,
23
+ type Maybe,
24
+ type Query,
25
+ type SigningKey,
26
26
  } from "@lightsparkdev/core";
27
27
  import packageJson from "../package.json";
28
28
  import NodeKeyLoaderCache from "./NodeKeyLoaderCache.js";
@@ -44,11 +44,13 @@ import { DecodeInvoice } from "./graphql/DecodeInvoice.js";
44
44
  import { DeleteApiToken } from "./graphql/DeleteApiToken.js";
45
45
  import { FetchUmaInvitation } from "./graphql/FetchUmaInvitation.js";
46
46
  import { FundNode } from "./graphql/FundNode.js";
47
+ import { IncomingPaymentsForInvoice } from "./graphql/IncomingPaymentsForInvoice.js";
47
48
  import { InvoiceForPaymentHash } from "./graphql/InvoiceForPaymentHash.js";
48
49
  import { LightningFeeEstimateForInvoice } from "./graphql/LightningFeeEstimateForInvoice.js";
49
50
  import { LightningFeeEstimateForNode } from "./graphql/LightningFeeEstimateForNode.js";
50
51
  import type { AccountDashboard } from "./graphql/MultiNodeDashboard.js";
51
52
  import { MultiNodeDashboard } from "./graphql/MultiNodeDashboard.js";
53
+ import { OutgoingPaymentsForInvoice } from "./graphql/OutgoingPaymentsForInvoice.js";
52
54
  import { OutgoingPaymentsForPaymentHash } from "./graphql/OutgoingPaymentsForPaymentHash.js";
53
55
  import { PayInvoice } from "./graphql/PayInvoice.js";
54
56
  import { PayUmaInvoice } from "./graphql/PayUmaInvoice.js";
@@ -62,6 +64,7 @@ import { TransactionSubscription } from "./graphql/TransactionSubscription.js";
62
64
  import { TransactionsForNode } from "./graphql/TransactionsForNode.js";
63
65
  import { WithdrawalFeeEstimate } from "./graphql/WithdrawalFeeEstimate.js";
64
66
  import { RiskRating, TransactionStatus } from "./index.js";
67
+ import { logger } from "./logger.js";
65
68
  import Account from "./objects/Account.js";
66
69
  import { ApiTokenFromJson } from "./objects/ApiToken.js";
67
70
  import BitcoinNetwork from "./objects/BitcoinNetwork.js";
@@ -1531,6 +1534,70 @@ class LightsparkClient {
1531
1534
  });
1532
1535
  }
1533
1536
 
1537
+ /**
1538
+ * Fetches Outgoing payments for a given invoice if there are any.
1539
+ *
1540
+ * @param encodedInvoice encoded invoice associated with outgoing payment
1541
+ * @param statuses Filter to only include payments with the given statuses. If not provided, all statuses are included.
1542
+ */
1543
+ public async outgoingPaymentsForInvoice(
1544
+ encodedInvoice: string,
1545
+ statuses: TransactionStatus[] | undefined = undefined,
1546
+ ): Promise<OutgoingPayment[]> {
1547
+ return await this.executeRawQuery({
1548
+ queryPayload: OutgoingPaymentsForInvoice,
1549
+ variables: {
1550
+ encoded_invoice: encodedInvoice,
1551
+ statuses: statuses,
1552
+ },
1553
+ constructObject: (responseJson: {
1554
+ outgoing_payments_for_invoice: any; // eslint-disable-line @typescript-eslint/no-explicit-any
1555
+ }) => {
1556
+ if (
1557
+ !responseJson.outgoing_payments_for_invoice ||
1558
+ !responseJson.outgoing_payments_for_invoice.payments
1559
+ ) {
1560
+ return [];
1561
+ }
1562
+ return responseJson.outgoing_payments_for_invoice.payments.map(
1563
+ (payment) => OutgoingPaymentFromJson(payment),
1564
+ );
1565
+ },
1566
+ });
1567
+ }
1568
+
1569
+ /**
1570
+ * Fetches Incoming payments for a given invoice if there are any.
1571
+ *
1572
+ * @param invoiceId id of associated invoice
1573
+ * @param statuses Filter to only include payments with the given statuses. If not provided, all statuses are included.
1574
+ */
1575
+ public async incomingPaymentsForInvoice(
1576
+ invoiceId: string,
1577
+ statuses: TransactionStatus[] | undefined = undefined,
1578
+ ): Promise<IncomingPayment[]> {
1579
+ return await this.executeRawQuery({
1580
+ queryPayload: IncomingPaymentsForInvoice,
1581
+ variables: {
1582
+ invoice_id: invoiceId,
1583
+ statuses: statuses,
1584
+ },
1585
+ constructObject: (responseJson: {
1586
+ incoming_payments_for_invoice: any; // eslint-disable-line @typescript-eslint/no-explicit-any
1587
+ }) => {
1588
+ if (
1589
+ !responseJson.incoming_payments_for_invoice ||
1590
+ !responseJson.incoming_payments_for_invoice.payments
1591
+ ) {
1592
+ return [];
1593
+ }
1594
+ return responseJson.incoming_payments_for_invoice.payments.map(
1595
+ (payment) => IncomingPaymentFromJson(payment),
1596
+ );
1597
+ },
1598
+ });
1599
+ }
1600
+
1534
1601
  private async hashPhoneNumber(e164PhoneNumber: string): Promise<string> {
1535
1602
  const e164PhoneRegex = /^\+[1-9]\d{1,14}$/;
1536
1603
  if (!e164PhoneRegex.test(e164PhoneNumber)) {
@@ -1571,6 +1638,20 @@ class LightsparkClient {
1571
1638
  public executeRawQuery<T>(query: Query<T>): Promise<T | null> {
1572
1639
  return this.requester.executeQuery(query);
1573
1640
  }
1641
+
1642
+ /**
1643
+ * Enable logging for debugging purposes
1644
+ *
1645
+ * @param enabled Whether logging should be enabled.
1646
+ * @param level The logging level to use.
1647
+ * */
1648
+ public setLoggingEnabled(
1649
+ enabled: boolean,
1650
+ level: LoggingLevel = LoggingLevel.Info,
1651
+ ) {
1652
+ coreLogger.setEnabled(enabled, level);
1653
+ logger.setEnabled(enabled, level);
1654
+ }
1574
1655
  }
1575
1656
 
1576
1657
  export default LightsparkClient;
@@ -0,0 +1,21 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import { FRAGMENT as IncomingPaymentFragment } from "../objects/IncomingPayment.js";
4
+
5
+ export const IncomingPaymentsForInvoice = `
6
+ query IncomingPaymentsForInvoice(
7
+ $invoice_id: Hash32!,
8
+ $statuses: [TransactionStatus!]
9
+ ) {
10
+ incoming_payments_for_invoice(input: {
11
+ invoice_id: $invoice_id
12
+ statuses: $statuses
13
+ }) {
14
+ payments {
15
+ ...IncomingPaymentFragment
16
+ }
17
+ }
18
+ }
19
+
20
+ ${IncomingPaymentFragment}
21
+ `;
@@ -0,0 +1,21 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import { FRAGMENT as OutgoingPaymentFragment } from "../objects/OutgoingPayment.js";
4
+
5
+ export const OutgoingPaymentsForInvoice = `
6
+ query OutgoingPaymentsForInvoice(
7
+ $encoded_invoice: Hash32!,
8
+ $statuses: [TransactionStatus!]
9
+ ) {
10
+ outgoing_payments_for_invoice(input: {
11
+ encoded_invoice: $encoded_invoice
12
+ statuses: $statuses
13
+ }) {
14
+ payments {
15
+ ...OutgoingPaymentFragment
16
+ }
17
+ }
18
+ }
19
+
20
+ ${OutgoingPaymentFragment}
21
+ `;
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type AccountToApiTokensConnection from "./AccountToApiTokensConnection.js";
@@ -1891,7 +1891,9 @@ ${FRAGMENT}
1891
1891
  `,
1892
1892
  variables: {},
1893
1893
  constructObject: (data: unknown) =>
1894
- data && typeof data === "object" && "current_account" in data
1894
+ isObject(data) &&
1895
+ "current_account" in data &&
1896
+ isObject(data.current_account)
1895
1897
  ? AccountFromJson(data.current_account)
1896
1898
  : null,
1897
1899
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import Permission from "./Permission.js";
5
5
 
6
6
  /**
@@ -95,7 +95,7 @@ ${FRAGMENT}
95
95
  `,
96
96
  variables: { id },
97
97
  constructObject: (data: unknown) =>
98
- data && typeof data === "object" && "entity" in data
98
+ isObject(data) && "entity" in data && isObject(data.entity)
99
99
  ? ApiTokenFromJson(data.entity)
100
100
  : null,
101
101
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type ApiToken from "./ApiToken.js";
5
5
  import Permission from "./Permission.js";
6
6
 
@@ -90,7 +90,7 @@ ${FRAGMENT}
90
90
  `,
91
91
  variables: { id },
92
92
  constructObject: (data: unknown) =>
93
- data && typeof data === "object" && "entity" in data
93
+ isObject(data) && "entity" in data && isObject(data.entity)
94
94
  ? AuditLogActorFromJson(data.entity)
95
95
  : null,
96
96
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type ChannelFees from "./ChannelFees.js";
@@ -182,7 +182,7 @@ ${FRAGMENT}
182
182
  `,
183
183
  variables: { id },
184
184
  constructObject: (data: unknown) =>
185
- data && typeof data === "object" && "entity" in data
185
+ isObject(data) && "entity" in data && isObject(data.entity)
186
186
  ? ChannelFromJson(data.entity)
187
187
  : null,
188
188
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -164,7 +164,7 @@ ${FRAGMENT}
164
164
  `,
165
165
  variables: { id },
166
166
  constructObject: (data: unknown) =>
167
- data && typeof data === "object" && "entity" in data
167
+ isObject(data) && "entity" in data && isObject(data.entity)
168
168
  ? ChannelClosingTransactionFromJson(data.entity)
169
169
  : null,
170
170
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -164,7 +164,7 @@ ${FRAGMENT}
164
164
  `,
165
165
  variables: { id },
166
166
  constructObject: (data: unknown) =>
167
- data && typeof data === "object" && "entity" in data
167
+ isObject(data) && "entity" in data && isObject(data.entity)
168
168
  ? ChannelOpeningTransactionFromJson(data.entity)
169
169
  : null,
170
170
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -162,7 +162,7 @@ ${FRAGMENT}
162
162
  `,
163
163
  variables: { id },
164
164
  constructObject: (data: unknown) =>
165
- data && typeof data === "object" && "entity" in data
165
+ isObject(data) && "entity" in data && isObject(data.entity)
166
166
  ? ChannelSnapshotFromJson(data.entity)
167
167
  : null,
168
168
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -156,7 +156,7 @@ ${FRAGMENT}
156
156
  `,
157
157
  variables: { id },
158
158
  constructObject: (data: unknown) =>
159
- data && typeof data === "object" && "entity" in data
159
+ isObject(data) && "entity" in data && isObject(data.entity)
160
160
  ? DepositFromJson(data.entity)
161
161
  : null,
162
162
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import BitcoinNetwork from "./BitcoinNetwork.js";
@@ -108,7 +108,7 @@ ${FRAGMENT}
108
108
  `,
109
109
  variables: { id },
110
110
  constructObject: (data: unknown) =>
111
- data && typeof data === "object" && "entity" in data
111
+ isObject(data) && "entity" in data && isObject(data.entity)
112
112
  ? GraphNodeFromJson(data.entity)
113
113
  : null,
114
114
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -125,7 +125,7 @@ ${FRAGMENT}
125
125
  `,
126
126
  variables: { id },
127
127
  constructObject: (data: unknown) =>
128
- data && typeof data === "object" && "entity" in data
128
+ isObject(data) && "entity" in data && isObject(data.entity)
129
129
  ? HopFromJson(data.entity)
130
130
  : null,
131
131
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -140,7 +140,7 @@ ${FRAGMENT}
140
140
  `,
141
141
  variables: { id },
142
142
  constructObject: (data: unknown) =>
143
- data && typeof data === "object" && "entity" in data
143
+ isObject(data) && "entity" in data && isObject(data.entity)
144
144
  ? IncomingPaymentFromJson(data.entity)
145
145
  : null,
146
146
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -111,7 +111,7 @@ ${FRAGMENT}
111
111
  `,
112
112
  variables: { id },
113
113
  constructObject: (data: unknown) =>
114
- data && typeof data === "object" && "entity" in data
114
+ isObject(data) && "entity" in data && isObject(data.entity)
115
115
  ? IncomingPaymentAttemptFromJson(data.entity)
116
116
  : null,
117
117
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -407,7 +407,7 @@ ${FRAGMENT}
407
407
  `,
408
408
  variables: { id },
409
409
  constructObject: (data: unknown) =>
410
- data && typeof data === "object" && "entity" in data
410
+ isObject(data) && "entity" in data && isObject(data.entity)
411
411
  ? InvoiceFromJson(data.entity)
412
412
  : null,
413
413
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type CurrencyAmount from "./CurrencyAmount.js";
5
5
  import {
6
6
  CurrencyAmountFromJson,
@@ -680,7 +680,7 @@ ${FRAGMENT}
680
680
  `,
681
681
  variables: { id },
682
682
  constructObject: (data: unknown) =>
683
- data && typeof data === "object" && "entity" in data
683
+ isObject(data) && "entity" in data && isObject(data.entity)
684
684
  ? LightningTransactionFromJson(data.entity)
685
685
  : null,
686
686
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type LightsparkClient from "../client.js";
5
5
  import type Balances from "./Balances.js";
6
6
  import { BalancesFromJson, BalancesToJson } from "./Balances.js";
@@ -662,7 +662,7 @@ ${FRAGMENT}
662
662
  `,
663
663
  variables: { id },
664
664
  constructObject: (data: unknown) =>
665
- data && typeof data === "object" && "entity" in data
665
+ isObject(data) && "entity" in data && isObject(data.entity)
666
666
  ? LightsparkNodeFromJson(data.entity)
667
667
  : null,
668
668
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import Account from "./Account.js";
5
5
  import { BalancesFromJson, BalancesToJson } from "./Balances.js";
6
6
  import Wallet from "./Wallet.js";
@@ -155,7 +155,7 @@ ${FRAGMENT}
155
155
  `,
156
156
  variables: { id },
157
157
  constructObject: (data: unknown) =>
158
- data && typeof data === "object" && "entity" in data
158
+ isObject(data) && "entity" in data && isObject(data.entity)
159
159
  ? LightsparkNodeOwnerFromJson(data.entity)
160
160
  : null,
161
161
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type Balances from "./Balances.js";
@@ -361,7 +361,7 @@ ${FRAGMENT}
361
361
  `,
362
362
  variables: { id },
363
363
  constructObject: (data: unknown) =>
364
- data && typeof data === "object" && "entity" in data
364
+ isObject(data) && "entity" in data && isObject(data.entity)
365
365
  ? LightsparkNodeWithOSKFromJson(data.entity)
366
366
  : null,
367
367
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type Balances from "./Balances.js";
@@ -354,7 +354,7 @@ ${FRAGMENT}
354
354
  `,
355
355
  variables: { id },
356
356
  constructObject: (data: unknown) =>
357
- data && typeof data === "object" && "entity" in data
357
+ isObject(data) && "entity" in data && isObject(data.entity)
358
358
  ? LightsparkNodeWithRemoteSigningFromJson(data.entity)
359
359
  : null,
360
360
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type LightsparkClient from "../client.js";
5
5
  import { BalancesFromJson, BalancesToJson } from "./Balances.js";
6
6
  import BitcoinNetwork from "./BitcoinNetwork.js";
@@ -631,7 +631,7 @@ ${FRAGMENT}
631
631
  `,
632
632
  variables: { id },
633
633
  constructObject: (data: unknown) =>
634
- data && typeof data === "object" && "entity" in data
634
+ isObject(data) && "entity" in data && isObject(data.entity)
635
635
  ? NodeFromJson(data.entity)
636
636
  : null,
637
637
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { LightsparkException, type Query } from "@lightsparkdev/core";
3
+ import { LightsparkException, isObject, type Query } from "@lightsparkdev/core";
4
4
  import type ChannelClosingTransaction from "./ChannelClosingTransaction.js";
5
5
  import type ChannelOpeningTransaction from "./ChannelOpeningTransaction.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -426,7 +426,7 @@ ${FRAGMENT}
426
426
  `,
427
427
  variables: { id },
428
428
  constructObject: (data: unknown) =>
429
- data && typeof data === "object" && "entity" in data
429
+ isObject(data) && "entity" in data && isObject(data.entity)
430
430
  ? OnChainTransactionFromJson(data.entity)
431
431
  : null,
432
432
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -164,7 +164,7 @@ ${FRAGMENT}
164
164
  `,
165
165
  variables: { id },
166
166
  constructObject: (data: unknown) =>
167
- data && typeof data === "object" && "entity" in data
167
+ isObject(data) && "entity" in data && isObject(data.entity)
168
168
  ? OutgoingPaymentFromJson(data.entity)
169
169
  : null,
170
170
  };
@@ -1,6 +1,6 @@
1
1
  // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
2
 
3
- import { type Query } from "@lightsparkdev/core";
3
+ import { isObject, type Query } from "@lightsparkdev/core";
4
4
  import autoBind from "auto-bind";
5
5
  import type LightsparkClient from "../client.js";
6
6
  import type CurrencyAmount from "./CurrencyAmount.js";
@@ -144,7 +144,7 @@ ${FRAGMENT}
144
144
  `,
145
145
  variables: { id },
146
146
  constructObject: (data: unknown) =>
147
- data && typeof data === "object" && "entity" in data
147
+ isObject(data) && "entity" in data && isObject(data.entity)
148
148
  ? OutgoingPaymentAttemptFromJson(data.entity)
149
149
  : null,
150
150
  };