@lightsparkdev/lightspark-sdk 0.1.7 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,6 +30,104 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // package.json
34
+ var require_package = __commonJS({
35
+ "package.json"(exports, module2) {
36
+ module2.exports = {
37
+ name: "@lightsparkdev/lightspark-sdk",
38
+ version: "0.2.1",
39
+ description: "Lightspark JS SDK",
40
+ author: "Lightspark Inc.",
41
+ keywords: [
42
+ "lightspark",
43
+ "bitcoin",
44
+ "lightning",
45
+ "payments",
46
+ "typescript"
47
+ ],
48
+ homepage: "https://github.com/lightsparkdev/js-sdk",
49
+ repository: {
50
+ type: "git",
51
+ url: "https://github.com/lightsparkdev/js-sdk.git"
52
+ },
53
+ bugs: {
54
+ url: "https://github.com/lightsparkdev/js-sdk/issues"
55
+ },
56
+ engines: {
57
+ node: ">=14.16"
58
+ },
59
+ exports: {
60
+ ".": {
61
+ types: "./dist/index.d.ts",
62
+ import: {
63
+ types: "./dist/index.d.ts",
64
+ default: "./dist/index.js"
65
+ },
66
+ module: "./dist/index.js",
67
+ require: "./dist/index.cjs",
68
+ default: "./dist/index.cjs"
69
+ },
70
+ "./objects": {
71
+ types: "./dist/objects/index.d.ts",
72
+ import: {
73
+ types: "./dist/objects/index.d.ts",
74
+ default: "./dist/objects/index.js"
75
+ },
76
+ module: "./dist/objects/index.js",
77
+ require: "./dist/objects/index.cjs",
78
+ default: "./dist/objects/index.cjs"
79
+ }
80
+ },
81
+ type: "module",
82
+ types: "./dist/index.d.ts",
83
+ main: "./dist/index.js",
84
+ module: "./dist/index.js",
85
+ browser: {
86
+ crypto: false
87
+ },
88
+ files: [
89
+ "src/*",
90
+ "dist/*",
91
+ "CHANGELOG.md"
92
+ ],
93
+ scripts: {
94
+ build: "tsup --entry src/index.ts --entry src/objects/index.ts --format cjs,esm --dts",
95
+ "copy-static": "cp ./package.json ./README.md ./LICENSE ./dist/",
96
+ dev: "yarn build -- --watch",
97
+ clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
98
+ lint: "npx prettier --check ./src",
99
+ format: "npx prettier --write ./src",
100
+ test: "tsc --noEmit --project tsconfig-test.json && jest --no-cache --runInBand --bail",
101
+ "type-check": "tsc --noEmit",
102
+ postversion: "yarn build"
103
+ },
104
+ license: "Apache-2.0",
105
+ dependencies: {
106
+ "@lightsparkdev/core": "^0.2.1",
107
+ "auto-bind": "^5.0.1",
108
+ crypto: "^1.0.1",
109
+ "crypto-browserify": "^3.12.0",
110
+ dayjs: "^1.11.7",
111
+ graphql: "^16.6.0",
112
+ "graphql-ws": "^5.11.3",
113
+ ws: "^8.12.1",
114
+ "zen-observable-ts": "^1.1.0"
115
+ },
116
+ devDependencies: {
117
+ "@types/crypto-js": "^4.1.1",
118
+ "@types/ws": "^8.5.4",
119
+ jest: "^29.4.1",
120
+ prettier: "^2.8.4",
121
+ "prettier-plugin-organize-imports": "^3.2.2",
122
+ "ts-jest": "^29.0.5",
123
+ "ts-node": "^10.9.1",
124
+ typescript: "^4.9.5",
125
+ tsconfig: "*"
126
+ }
127
+ };
128
+ }
129
+ });
130
+
30
131
  // src/index.ts
31
132
  var src_exports = {};
32
133
  __export(src_exports, {
@@ -465,6 +566,7 @@ var LightsparkNodeStatus = /* @__PURE__ */ ((LightsparkNodeStatus2) => {
465
566
  LightsparkNodeStatus2["READY"] = "READY";
466
567
  LightsparkNodeStatus2["STOPPED"] = "STOPPED";
467
568
  LightsparkNodeStatus2["TERMINATED"] = "TERMINATED";
569
+ LightsparkNodeStatus2["TERMINATING"] = "TERMINATING";
468
570
  LightsparkNodeStatus2["WALLET_LOCKED"] = "WALLET_LOCKED";
469
571
  LightsparkNodeStatus2["FAILED_TO_DEPLOY"] = "FAILED_TO_DEPLOY";
470
572
  return LightsparkNodeStatus2;
@@ -1353,6 +1455,7 @@ fragment InvoiceDataFragment on InvoiceData {
1353
1455
  }
1354
1456
  invoice_data_created_at: created_at
1355
1457
  invoice_data_expires_at: expires_at
1458
+ invoice_data_memo: memo
1356
1459
  invoice_data_destination: destination {
1357
1460
  __typename
1358
1461
  ... on GraphNode {
@@ -1473,7 +1576,6 @@ fragment InvoiceDataFragment on InvoiceData {
1473
1576
  lightspark_node_status: status
1474
1577
  }
1475
1578
  }
1476
- invoice_data_memo: memo
1477
1579
  }`;
1478
1580
 
1479
1581
  // src/graphql/DecodeInvoice.ts
@@ -2120,6 +2222,7 @@ fragment OutgoingPaymentFragment on OutgoingPayment {
2120
2222
  }
2121
2223
  invoice_data_created_at: created_at
2122
2224
  invoice_data_expires_at: expires_at
2225
+ invoice_data_memo: memo
2123
2226
  invoice_data_destination: destination {
2124
2227
  __typename
2125
2228
  ... on GraphNode {
@@ -2240,7 +2343,6 @@ fragment OutgoingPaymentFragment on OutgoingPayment {
2240
2343
  lightspark_node_status: status
2241
2344
  }
2242
2345
  }
2243
- invoice_data_memo: memo
2244
2346
  }
2245
2347
  }
2246
2348
  outgoing_payment_failure_reason: failure_reason
@@ -2479,7 +2581,7 @@ var WithdrawalRequestToChannelOpeningTransactionsConnectionFromJson = (obj) => {
2479
2581
 
2480
2582
  // src/objects/WithdrawalRequest.ts
2481
2583
  var WithdrawalRequest = class {
2482
- constructor(id, createdAt, updatedAt, amount, bitcoinAddress, withdrawalMode, status, typename, completedAt, withdrawalId) {
2584
+ constructor(id, createdAt, updatedAt, amount, bitcoinAddress, withdrawalMode, status, typename, estimatedAmount, completedAt, withdrawalId) {
2483
2585
  this.id = id;
2484
2586
  this.createdAt = createdAt;
2485
2587
  this.updatedAt = updatedAt;
@@ -2488,6 +2590,7 @@ var WithdrawalRequest = class {
2488
2590
  this.withdrawalMode = withdrawalMode;
2489
2591
  this.status = status;
2490
2592
  this.typename = typename;
2593
+ this.estimatedAmount = estimatedAmount;
2491
2594
  this.completedAt = completedAt;
2492
2595
  this.withdrawalId = withdrawalId;
2493
2596
  (0, import_auto_bind8.default)(this);
@@ -2644,6 +2747,7 @@ var WithdrawalRequestFromJson = (obj) => {
2644
2747
  WithdrawalMode_default[obj["withdrawal_request_withdrawal_mode"]] ?? WithdrawalMode_default.FUTURE_VALUE,
2645
2748
  WithdrawalRequestStatus_default[obj["withdrawal_request_status"]] ?? WithdrawalRequestStatus_default.FUTURE_VALUE,
2646
2749
  "WithdrawalRequest",
2750
+ !!obj["withdrawal_request_estimated_amount"] ? CurrencyAmountFromJson(obj["withdrawal_request_estimated_amount"]) : void 0,
2647
2751
  obj["withdrawal_request_completed_at"],
2648
2752
  obj["withdrawal_request_withdrawal"]?.id ?? void 0
2649
2753
  );
@@ -2662,6 +2766,14 @@ fragment WithdrawalRequestFragment on WithdrawalRequest {
2662
2766
  currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
2663
2767
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
2664
2768
  }
2769
+ withdrawal_request_estimated_amount: estimated_amount {
2770
+ __typename
2771
+ currency_amount_original_value: original_value
2772
+ currency_amount_original_unit: original_unit
2773
+ currency_amount_preferred_currency_unit: preferred_currency_unit
2774
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
2775
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
2776
+ }
2665
2777
  withdrawal_request_bitcoin_address: bitcoin_address
2666
2778
  withdrawal_request_withdrawal_mode: withdrawal_mode
2667
2779
  withdrawal_request_status: status
@@ -3231,6 +3343,7 @@ fragment TransactionFragment on Transaction {
3231
3343
  }
3232
3344
  invoice_data_created_at: created_at
3233
3345
  invoice_data_expires_at: expires_at
3346
+ invoice_data_memo: memo
3234
3347
  invoice_data_destination: destination {
3235
3348
  __typename
3236
3349
  ... on GraphNode {
@@ -3351,7 +3464,6 @@ fragment TransactionFragment on Transaction {
3351
3464
  lightspark_node_status: status
3352
3465
  }
3353
3466
  }
3354
- invoice_data_memo: memo
3355
3467
  }
3356
3468
  }
3357
3469
  outgoing_payment_failure_reason: failure_reason
@@ -3745,6 +3857,7 @@ fragment PaymentRequestFragment on PaymentRequest {
3745
3857
  }
3746
3858
  invoice_data_created_at: created_at
3747
3859
  invoice_data_expires_at: expires_at
3860
+ invoice_data_memo: memo
3748
3861
  invoice_data_destination: destination {
3749
3862
  __typename
3750
3863
  ... on GraphNode {
@@ -3865,7 +3978,6 @@ fragment PaymentRequestFragment on PaymentRequest {
3865
3978
  lightspark_node_status: status
3866
3979
  }
3867
3980
  }
3868
- invoice_data_memo: memo
3869
3981
  }
3870
3982
  invoice_status: status
3871
3983
  invoice_amount_paid: amount_paid {
@@ -4600,6 +4712,7 @@ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types:
4600
4712
  }
4601
4713
  invoice_data_created_at: created_at
4602
4714
  invoice_data_expires_at: expires_at
4715
+ invoice_data_memo: memo
4603
4716
  invoice_data_destination: destination {
4604
4717
  __typename
4605
4718
  ... on GraphNode {
@@ -4720,7 +4833,6 @@ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types:
4720
4833
  lightspark_node_status: status
4721
4834
  }
4722
4835
  }
4723
- invoice_data_memo: memo
4724
4836
  }
4725
4837
  }
4726
4838
  outgoing_payment_failure_reason: failure_reason
@@ -4858,6 +4970,7 @@ query FetchAccountToPaymentRequestsConnection($first: Int, $after: String, $afte
4858
4970
  }
4859
4971
  invoice_data_created_at: created_at
4860
4972
  invoice_data_expires_at: expires_at
4973
+ invoice_data_memo: memo
4861
4974
  invoice_data_destination: destination {
4862
4975
  __typename
4863
4976
  ... on GraphNode {
@@ -4978,7 +5091,6 @@ query FetchAccountToPaymentRequestsConnection($first: Int, $after: String, $afte
4978
5091
  lightspark_node_status: status
4979
5092
  }
4980
5093
  }
4981
- invoice_data_memo: memo
4982
5094
  }
4983
5095
  invoice_status: status
4984
5096
  invoice_amount_paid: amount_paid {
@@ -5069,9 +5181,11 @@ var LightsparkClient = class {
5069
5181
  this.authProvider = authProvider;
5070
5182
  this.serverUrl = serverUrl;
5071
5183
  this.nodeKeyCache = nodeKeyCache;
5184
+ const sdkVersion = require_package().version;
5072
5185
  this.requester = new import_core6.Requester(
5073
5186
  this.nodeKeyCache,
5074
- WALLET_SDK_ENDPOINT,
5187
+ LIGHTSPARK_SDK_ENDPOINT,
5188
+ `js-lightspark-sdk/${sdkVersion}`,
5075
5189
  authProvider,
5076
5190
  serverUrl
5077
5191
  );
@@ -5085,9 +5199,11 @@ var LightsparkClient = class {
5085
5199
  * @param authProvider
5086
5200
  */
5087
5201
  async setAuthProvider(authProvider) {
5202
+ const sdkVersion = require_package().version;
5088
5203
  this.requester = new import_core6.Requester(
5089
5204
  this.nodeKeyCache,
5090
- WALLET_SDK_ENDPOINT,
5205
+ LIGHTSPARK_SDK_ENDPOINT,
5206
+ `js-lightspark-sdk/${sdkVersion}`,
5091
5207
  authProvider,
5092
5208
  this.serverUrl
5093
5209
  );
@@ -5601,7 +5717,7 @@ var LightsparkClient = class {
5601
5717
  return this.requester.executeQuery(query);
5602
5718
  }
5603
5719
  };
5604
- var WALLET_SDK_ENDPOINT = "graphql/server/2023-04-04";
5720
+ var LIGHTSPARK_SDK_ENDPOINT = "graphql/server/2023-04-04";
5605
5721
  var client_default = LightsparkClient;
5606
5722
 
5607
5723
  // src/objects/InvoiceType.ts
@@ -5716,6 +5832,7 @@ fragment InvoiceFragment on Invoice {
5716
5832
  }
5717
5833
  invoice_data_created_at: created_at
5718
5834
  invoice_data_expires_at: expires_at
5835
+ invoice_data_memo: memo
5719
5836
  invoice_data_destination: destination {
5720
5837
  __typename
5721
5838
  ... on GraphNode {
@@ -5836,7 +5953,6 @@ fragment InvoiceFragment on Invoice {
5836
5953
  lightspark_node_status: status
5837
5954
  }
5838
5955
  }
5839
- invoice_data_memo: memo
5840
5956
  }
5841
5957
  invoice_status: status
5842
5958
  invoice_amount_paid: amount_paid {
@@ -6002,6 +6118,7 @@ fragment LightningTransactionFragment on LightningTransaction {
6002
6118
  }
6003
6119
  invoice_data_created_at: created_at
6004
6120
  invoice_data_expires_at: expires_at
6121
+ invoice_data_memo: memo
6005
6122
  invoice_data_destination: destination {
6006
6123
  __typename
6007
6124
  ... on GraphNode {
@@ -6122,7 +6239,6 @@ fragment LightningTransactionFragment on LightningTransaction {
6122
6239
  lightspark_node_status: status
6123
6240
  }
6124
6241
  }
6125
- invoice_data_memo: memo
6126
6242
  }
6127
6243
  }
6128
6244
  outgoing_payment_failure_reason: failure_reason
@@ -6511,6 +6627,11 @@ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
6511
6627
  WebhookEventType2["FUTURE_VALUE"] = "FUTURE_VALUE";
6512
6628
  WebhookEventType2["PAYMENT_FINISHED"] = "PAYMENT_FINISHED";
6513
6629
  WebhookEventType2["NODE_STATUS"] = "NODE_STATUS";
6630
+ WebhookEventType2["WALLET_STATUS"] = "WALLET_STATUS";
6631
+ WebhookEventType2["WALLET_OUTGOING_PAYMENT_FINISHED"] = "WALLET_OUTGOING_PAYMENT_FINISHED";
6632
+ WebhookEventType2["WALLET_INCOMING_PAYMENT_FINISHED"] = "WALLET_INCOMING_PAYMENT_FINISHED";
6633
+ WebhookEventType2["WALLET_WITHDRAWAL_FINISHED"] = "WALLET_WITHDRAWAL_FINISHED";
6634
+ WebhookEventType2["WALLET_FUNDS_RECEIVED"] = "WALLET_FUNDS_RECEIVED";
6514
6635
  return WebhookEventType2;
6515
6636
  })(WebhookEventType || {});
6516
6637
  var WebhookEventType_default = WebhookEventType;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AuthProvider } from '@lightsparkdev/core';
2
- export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as ApiToken, B as BitcoinNetwork, h as BlockchainBalance, C as Channel, i as ChannelClosingTransaction, k as ChannelFees, l as ChannelOpeningTransaction, n as ChannelStatus, o as ChannelToTransactionsConnection, p as CreateApiTokenInput, q as CreateApiTokenOutput, r as CreateInvoiceInput, s as CreateInvoiceOutput, t as CreateNodeWalletAddressInput, u as CreateNodeWalletAddressOutput, v as CurrencyAmount, w as CurrencyUnit, D as DeleteApiTokenInput, x as DeleteApiTokenOutput, y as Deposit, E as Entity, F as FeeEstimate, G as FundNodeInput, H as FundNodeOutput, I as GraphNode, J as Hop, M as HtlcAttemptFailureCode, N as IncomingPayment, O as IncomingPaymentAttempt, Q as IncomingPaymentAttemptStatus, R as IncomingPaymentToAttemptsConnection, S as Invoice, U as InvoiceData, V as InvoiceType, W as LightningFeeEstimateForInvoiceInput, X as LightningFeeEstimateForNodeInput, Y as LightningFeeEstimateOutput, Z as LightningTransaction, L as LightsparkClient, $ as LightsparkNode, a0 as LightsparkNodePurpose, a1 as LightsparkNodeStatus, a2 as LightsparkNodeToChannelsConnection, a3 as Node, a4 as NodeAddress, a5 as NodeAddressType, a6 as NodeToAddressesConnection, a7 as OnChainTransaction, a9 as OutgoingPayment, aa as OutgoingPaymentAttempt, ab as OutgoingPaymentAttemptStatus, ac as OutgoingPaymentAttemptToHopsConnection, ad as OutgoingPaymentToAttemptsConnection, ae as PageInfo, af as PayInvoiceInput, ag as PayInvoiceOutput, ah as PaymentFailureReason, ai as PaymentRequest, ak as PaymentRequestData, al as PaymentRequestStatus, am as Permission, an as RequestWithdrawalInput, ao as RequestWithdrawalOutput, ap as RichText, aq as RoutingTransaction, as as RoutingTransactionFailureReason, at as Secret, au as SendPaymentInput, av as SendPaymentOutput, aw as Transaction, ay as TransactionFailures, az as TransactionStatus, aA as TransactionType, aB as TransactionUpdate, aC as WalletDashboard, aD as WebhookEventType, aE as Withdrawal, aG as WithdrawalMode, aH as WithdrawalRequest, aI as WithdrawalRequestStatus, aJ as WithdrawalRequestToChannelClosingTransactionsConnection, aK as WithdrawalRequestToChannelOpeningTransactionsConnection, g as getApiTokenQuery, j as getChannelClosingTransactionQuery, m as getChannelOpeningTransactionQuery, z as getDepositQuery, K as getHopQuery, P as getIncomingPaymentAttemptQuery, T as getInvoiceQuery, _ as getLightningTransactionQuery, a8 as getOnChainTransactionQuery, aj as getPaymentRequestQuery, ar as getRoutingTransactionQuery, ax as getTransactionQuery, aF as getWithdrawalQuery } from './Withdrawal-27a4d10d.js';
2
+ export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as ApiToken, B as BitcoinNetwork, h as BlockchainBalance, C as Channel, i as ChannelClosingTransaction, k as ChannelFees, l as ChannelOpeningTransaction, n as ChannelStatus, o as ChannelToTransactionsConnection, p as CreateApiTokenInput, q as CreateApiTokenOutput, r as CreateInvoiceInput, s as CreateInvoiceOutput, t as CreateNodeWalletAddressInput, u as CreateNodeWalletAddressOutput, v as CurrencyAmount, w as CurrencyUnit, D as DeleteApiTokenInput, x as DeleteApiTokenOutput, y as Deposit, E as Entity, F as FeeEstimate, G as FundNodeInput, H as FundNodeOutput, I as GraphNode, J as Hop, M as HtlcAttemptFailureCode, N as IncomingPayment, O as IncomingPaymentAttempt, Q as IncomingPaymentAttemptStatus, R as IncomingPaymentToAttemptsConnection, S as Invoice, U as InvoiceData, V as InvoiceType, W as LightningFeeEstimateForInvoiceInput, X as LightningFeeEstimateForNodeInput, Y as LightningFeeEstimateOutput, Z as LightningTransaction, L as LightsparkClient, $ as LightsparkNode, a0 as LightsparkNodePurpose, a1 as LightsparkNodeStatus, a2 as LightsparkNodeToChannelsConnection, a3 as Node, a4 as NodeAddress, a5 as NodeAddressType, a6 as NodeToAddressesConnection, a7 as OnChainTransaction, a9 as OutgoingPayment, aa as OutgoingPaymentAttempt, ab as OutgoingPaymentAttemptStatus, ac as OutgoingPaymentAttemptToHopsConnection, ad as OutgoingPaymentToAttemptsConnection, ae as PageInfo, af as PayInvoiceInput, ag as PayInvoiceOutput, ah as PaymentFailureReason, ai as PaymentRequest, ak as PaymentRequestData, al as PaymentRequestStatus, am as Permission, an as RequestWithdrawalInput, ao as RequestWithdrawalOutput, ap as RichText, aq as RoutingTransaction, as as RoutingTransactionFailureReason, at as Secret, au as SendPaymentInput, av as SendPaymentOutput, aw as Transaction, ay as TransactionFailures, az as TransactionStatus, aA as TransactionType, aB as TransactionUpdate, aC as WalletDashboard, aD as WebhookEventType, aE as Withdrawal, aG as WithdrawalMode, aH as WithdrawalRequest, aI as WithdrawalRequestStatus, aJ as WithdrawalRequestToChannelClosingTransactionsConnection, aK as WithdrawalRequestToChannelOpeningTransactionsConnection, g as getApiTokenQuery, j as getChannelClosingTransactionQuery, m as getChannelOpeningTransactionQuery, z as getDepositQuery, K as getHopQuery, P as getIncomingPaymentAttemptQuery, T as getInvoiceQuery, _ as getLightningTransactionQuery, a8 as getOnChainTransactionQuery, aj as getPaymentRequestQuery, ar as getRoutingTransactionQuery, ax as getTransactionQuery, aF as getWithdrawalQuery } from './Withdrawal-ebb4865c.js';
3
3
  import 'zen-observable';
4
4
 
5
5
  declare class AccountTokenAuthProvider implements AuthProvider {
package/dist/index.js CHANGED
@@ -45,6 +45,7 @@ import {
45
45
  WithdrawalRequestFromJson,
46
46
  WithdrawalRequestStatus_default,
47
47
  WithdrawalRequest_default,
48
+ __commonJS,
48
49
  getApiTokenQuery,
49
50
  getChannelClosingTransactionQuery,
50
51
  getChannelOpeningTransactionQuery,
@@ -58,7 +59,105 @@ import {
58
59
  getRoutingTransactionQuery,
59
60
  getTransactionQuery,
60
61
  getWithdrawalQuery
61
- } from "./chunk-3VRI7CHE.js";
62
+ } from "./chunk-5Z7FB6OT.js";
63
+
64
+ // package.json
65
+ var require_package = __commonJS({
66
+ "package.json"(exports, module) {
67
+ module.exports = {
68
+ name: "@lightsparkdev/lightspark-sdk",
69
+ version: "0.2.1",
70
+ description: "Lightspark JS SDK",
71
+ author: "Lightspark Inc.",
72
+ keywords: [
73
+ "lightspark",
74
+ "bitcoin",
75
+ "lightning",
76
+ "payments",
77
+ "typescript"
78
+ ],
79
+ homepage: "https://github.com/lightsparkdev/js-sdk",
80
+ repository: {
81
+ type: "git",
82
+ url: "https://github.com/lightsparkdev/js-sdk.git"
83
+ },
84
+ bugs: {
85
+ url: "https://github.com/lightsparkdev/js-sdk/issues"
86
+ },
87
+ engines: {
88
+ node: ">=14.16"
89
+ },
90
+ exports: {
91
+ ".": {
92
+ types: "./dist/index.d.ts",
93
+ import: {
94
+ types: "./dist/index.d.ts",
95
+ default: "./dist/index.js"
96
+ },
97
+ module: "./dist/index.js",
98
+ require: "./dist/index.cjs",
99
+ default: "./dist/index.cjs"
100
+ },
101
+ "./objects": {
102
+ types: "./dist/objects/index.d.ts",
103
+ import: {
104
+ types: "./dist/objects/index.d.ts",
105
+ default: "./dist/objects/index.js"
106
+ },
107
+ module: "./dist/objects/index.js",
108
+ require: "./dist/objects/index.cjs",
109
+ default: "./dist/objects/index.cjs"
110
+ }
111
+ },
112
+ type: "module",
113
+ types: "./dist/index.d.ts",
114
+ main: "./dist/index.js",
115
+ module: "./dist/index.js",
116
+ browser: {
117
+ crypto: false
118
+ },
119
+ files: [
120
+ "src/*",
121
+ "dist/*",
122
+ "CHANGELOG.md"
123
+ ],
124
+ scripts: {
125
+ build: "tsup --entry src/index.ts --entry src/objects/index.ts --format cjs,esm --dts",
126
+ "copy-static": "cp ./package.json ./README.md ./LICENSE ./dist/",
127
+ dev: "yarn build -- --watch",
128
+ clean: "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
129
+ lint: "npx prettier --check ./src",
130
+ format: "npx prettier --write ./src",
131
+ test: "tsc --noEmit --project tsconfig-test.json && jest --no-cache --runInBand --bail",
132
+ "type-check": "tsc --noEmit",
133
+ postversion: "yarn build"
134
+ },
135
+ license: "Apache-2.0",
136
+ dependencies: {
137
+ "@lightsparkdev/core": "^0.2.1",
138
+ "auto-bind": "^5.0.1",
139
+ crypto: "^1.0.1",
140
+ "crypto-browserify": "^3.12.0",
141
+ dayjs: "^1.11.7",
142
+ graphql: "^16.6.0",
143
+ "graphql-ws": "^5.11.3",
144
+ ws: "^8.12.1",
145
+ "zen-observable-ts": "^1.1.0"
146
+ },
147
+ devDependencies: {
148
+ "@types/crypto-js": "^4.1.1",
149
+ "@types/ws": "^8.5.4",
150
+ jest: "^29.4.1",
151
+ prettier: "^2.8.4",
152
+ "prettier-plugin-organize-imports": "^3.2.2",
153
+ "ts-jest": "^29.0.5",
154
+ "ts-node": "^10.9.1",
155
+ typescript: "^4.9.5",
156
+ tsconfig: "*"
157
+ }
158
+ };
159
+ }
160
+ });
62
161
 
63
162
  // src/auth/AccountTokenAuthProvider.ts
64
163
  import { b64encode } from "@lightsparkdev/core";
@@ -595,9 +694,11 @@ var LightsparkClient = class {
595
694
  this.authProvider = authProvider;
596
695
  this.serverUrl = serverUrl;
597
696
  this.nodeKeyCache = nodeKeyCache;
697
+ const sdkVersion = require_package().version;
598
698
  this.requester = new Requester(
599
699
  this.nodeKeyCache,
600
- WALLET_SDK_ENDPOINT,
700
+ LIGHTSPARK_SDK_ENDPOINT,
701
+ `js-lightspark-sdk/${sdkVersion}`,
601
702
  authProvider,
602
703
  serverUrl
603
704
  );
@@ -611,9 +712,11 @@ var LightsparkClient = class {
611
712
  * @param authProvider
612
713
  */
613
714
  async setAuthProvider(authProvider) {
715
+ const sdkVersion = require_package().version;
614
716
  this.requester = new Requester(
615
717
  this.nodeKeyCache,
616
- WALLET_SDK_ENDPOINT,
718
+ LIGHTSPARK_SDK_ENDPOINT,
719
+ `js-lightspark-sdk/${sdkVersion}`,
617
720
  authProvider,
618
721
  this.serverUrl
619
722
  );
@@ -1127,7 +1230,7 @@ var LightsparkClient = class {
1127
1230
  return this.requester.executeQuery(query);
1128
1231
  }
1129
1232
  };
1130
- var WALLET_SDK_ENDPOINT = "graphql/server/2023-04-04";
1233
+ var LIGHTSPARK_SDK_ENDPOINT = "graphql/server/2023-04-04";
1131
1234
  var client_default = LightsparkClient;
1132
1235
  export {
1133
1236
  Account_default as Account,
@@ -529,6 +529,7 @@ var LightsparkNodeStatus = /* @__PURE__ */ ((LightsparkNodeStatus2) => {
529
529
  LightsparkNodeStatus2["READY"] = "READY";
530
530
  LightsparkNodeStatus2["STOPPED"] = "STOPPED";
531
531
  LightsparkNodeStatus2["TERMINATED"] = "TERMINATED";
532
+ LightsparkNodeStatus2["TERMINATING"] = "TERMINATING";
532
533
  LightsparkNodeStatus2["WALLET_LOCKED"] = "WALLET_LOCKED";
533
534
  LightsparkNodeStatus2["FAILED_TO_DEPLOY"] = "FAILED_TO_DEPLOY";
534
535
  return LightsparkNodeStatus2;
@@ -1303,6 +1304,7 @@ fragment PaymentRequestFragment on PaymentRequest {
1303
1304
  }
1304
1305
  invoice_data_created_at: created_at
1305
1306
  invoice_data_expires_at: expires_at
1307
+ invoice_data_memo: memo
1306
1308
  invoice_data_destination: destination {
1307
1309
  __typename
1308
1310
  ... on GraphNode {
@@ -1423,7 +1425,6 @@ fragment PaymentRequestFragment on PaymentRequest {
1423
1425
  lightspark_node_status: status
1424
1426
  }
1425
1427
  }
1426
- invoice_data_memo: memo
1427
1428
  }
1428
1429
  invoice_status: status
1429
1430
  invoice_amount_paid: amount_paid {
@@ -2136,6 +2137,7 @@ fragment OutgoingPaymentFragment on OutgoingPayment {
2136
2137
  }
2137
2138
  invoice_data_created_at: created_at
2138
2139
  invoice_data_expires_at: expires_at
2140
+ invoice_data_memo: memo
2139
2141
  invoice_data_destination: destination {
2140
2142
  __typename
2141
2143
  ... on GraphNode {
@@ -2256,7 +2258,6 @@ fragment OutgoingPaymentFragment on OutgoingPayment {
2256
2258
  lightspark_node_status: status
2257
2259
  }
2258
2260
  }
2259
- invoice_data_memo: memo
2260
2261
  }
2261
2262
  }
2262
2263
  outgoing_payment_failure_reason: failure_reason
@@ -2580,6 +2581,7 @@ fragment TransactionFragment on Transaction {
2580
2581
  }
2581
2582
  invoice_data_created_at: created_at
2582
2583
  invoice_data_expires_at: expires_at
2584
+ invoice_data_memo: memo
2583
2585
  invoice_data_destination: destination {
2584
2586
  __typename
2585
2587
  ... on GraphNode {
@@ -2700,7 +2702,6 @@ fragment TransactionFragment on Transaction {
2700
2702
  lightspark_node_status: status
2701
2703
  }
2702
2704
  }
2703
- invoice_data_memo: memo
2704
2705
  }
2705
2706
  }
2706
2707
  outgoing_payment_failure_reason: failure_reason
@@ -3487,6 +3488,7 @@ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types:
3487
3488
  }
3488
3489
  invoice_data_created_at: created_at
3489
3490
  invoice_data_expires_at: expires_at
3491
+ invoice_data_memo: memo
3490
3492
  invoice_data_destination: destination {
3491
3493
  __typename
3492
3494
  ... on GraphNode {
@@ -3607,7 +3609,6 @@ query FetchAccountToTransactionsConnection($first: Int, $after: String, $types:
3607
3609
  lightspark_node_status: status
3608
3610
  }
3609
3611
  }
3610
- invoice_data_memo: memo
3611
3612
  }
3612
3613
  }
3613
3614
  outgoing_payment_failure_reason: failure_reason
@@ -3745,6 +3746,7 @@ query FetchAccountToPaymentRequestsConnection($first: Int, $after: String, $afte
3745
3746
  }
3746
3747
  invoice_data_created_at: created_at
3747
3748
  invoice_data_expires_at: expires_at
3749
+ invoice_data_memo: memo
3748
3750
  invoice_data_destination: destination {
3749
3751
  __typename
3750
3752
  ... on GraphNode {
@@ -3865,7 +3867,6 @@ query FetchAccountToPaymentRequestsConnection($first: Int, $after: String, $afte
3865
3867
  lightspark_node_status: status
3866
3868
  }
3867
3869
  }
3868
- invoice_data_memo: memo
3869
3870
  }
3870
3871
  invoice_status: status
3871
3872
  invoice_amount_paid: amount_paid {
@@ -4193,6 +4194,7 @@ fragment InvoiceFragment on Invoice {
4193
4194
  }
4194
4195
  invoice_data_created_at: created_at
4195
4196
  invoice_data_expires_at: expires_at
4197
+ invoice_data_memo: memo
4196
4198
  invoice_data_destination: destination {
4197
4199
  __typename
4198
4200
  ... on GraphNode {
@@ -4313,7 +4315,6 @@ fragment InvoiceFragment on Invoice {
4313
4315
  lightspark_node_status: status
4314
4316
  }
4315
4317
  }
4316
- invoice_data_memo: memo
4317
4318
  }
4318
4319
  invoice_status: status
4319
4320
  invoice_amount_paid: amount_paid {
@@ -4479,6 +4480,7 @@ fragment LightningTransactionFragment on LightningTransaction {
4479
4480
  }
4480
4481
  invoice_data_created_at: created_at
4481
4482
  invoice_data_expires_at: expires_at
4483
+ invoice_data_memo: memo
4482
4484
  invoice_data_destination: destination {
4483
4485
  __typename
4484
4486
  ... on GraphNode {
@@ -4599,7 +4601,6 @@ fragment LightningTransactionFragment on LightningTransaction {
4599
4601
  lightspark_node_status: status
4600
4602
  }
4601
4603
  }
4602
- invoice_data_memo: memo
4603
4604
  }
4604
4605
  }
4605
4606
  outgoing_payment_failure_reason: failure_reason
@@ -4997,6 +4998,11 @@ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
4997
4998
  WebhookEventType2["FUTURE_VALUE"] = "FUTURE_VALUE";
4998
4999
  WebhookEventType2["PAYMENT_FINISHED"] = "PAYMENT_FINISHED";
4999
5000
  WebhookEventType2["NODE_STATUS"] = "NODE_STATUS";
5001
+ WebhookEventType2["WALLET_STATUS"] = "WALLET_STATUS";
5002
+ WebhookEventType2["WALLET_OUTGOING_PAYMENT_FINISHED"] = "WALLET_OUTGOING_PAYMENT_FINISHED";
5003
+ WebhookEventType2["WALLET_INCOMING_PAYMENT_FINISHED"] = "WALLET_INCOMING_PAYMENT_FINISHED";
5004
+ WebhookEventType2["WALLET_WITHDRAWAL_FINISHED"] = "WALLET_WITHDRAWAL_FINISHED";
5005
+ WebhookEventType2["WALLET_FUNDS_RECEIVED"] = "WALLET_FUNDS_RECEIVED";
5000
5006
  return WebhookEventType2;
5001
5007
  })(WebhookEventType || {});
5002
5008
  var WebhookEventType_default = WebhookEventType;
@@ -5108,7 +5114,7 @@ var WithdrawalRequestToChannelOpeningTransactionsConnectionFromJson = (obj) => {
5108
5114
 
5109
5115
  // src/objects/WithdrawalRequest.ts
5110
5116
  var WithdrawalRequest = class {
5111
- constructor(id, createdAt, updatedAt, amount, bitcoinAddress, withdrawalMode, status, typename, completedAt, withdrawalId) {
5117
+ constructor(id, createdAt, updatedAt, amount, bitcoinAddress, withdrawalMode, status, typename, estimatedAmount, completedAt, withdrawalId) {
5112
5118
  this.id = id;
5113
5119
  this.createdAt = createdAt;
5114
5120
  this.updatedAt = updatedAt;
@@ -5117,6 +5123,7 @@ var WithdrawalRequest = class {
5117
5123
  this.withdrawalMode = withdrawalMode;
5118
5124
  this.status = status;
5119
5125
  this.typename = typename;
5126
+ this.estimatedAmount = estimatedAmount;
5120
5127
  this.completedAt = completedAt;
5121
5128
  this.withdrawalId = withdrawalId;
5122
5129
  (0, import_auto_bind10.default)(this);
@@ -5273,6 +5280,7 @@ var WithdrawalRequestFromJson = (obj) => {
5273
5280
  WithdrawalMode_default[obj["withdrawal_request_withdrawal_mode"]] ?? WithdrawalMode_default.FUTURE_VALUE,
5274
5281
  WithdrawalRequestStatus_default[obj["withdrawal_request_status"]] ?? WithdrawalRequestStatus_default.FUTURE_VALUE,
5275
5282
  "WithdrawalRequest",
5283
+ !!obj["withdrawal_request_estimated_amount"] ? CurrencyAmountFromJson(obj["withdrawal_request_estimated_amount"]) : void 0,
5276
5284
  obj["withdrawal_request_completed_at"],
5277
5285
  obj["withdrawal_request_withdrawal"]?.id ?? void 0
5278
5286
  );
@@ -5291,6 +5299,14 @@ fragment WithdrawalRequestFragment on WithdrawalRequest {
5291
5299
  currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
5292
5300
  currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
5293
5301
  }
5302
+ withdrawal_request_estimated_amount: estimated_amount {
5303
+ __typename
5304
+ currency_amount_original_value: original_value
5305
+ currency_amount_original_unit: original_unit
5306
+ currency_amount_preferred_currency_unit: preferred_currency_unit
5307
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
5308
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
5309
+ }
5294
5310
  withdrawal_request_bitcoin_address: bitcoin_address
5295
5311
  withdrawal_request_withdrawal_mode: withdrawal_mode
5296
5312
  withdrawal_request_status: status
@@ -1,3 +1,3 @@
1
- export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as ApiToken, B as BitcoinNetwork, h as BlockchainBalance, C as Channel, i as ChannelClosingTransaction, k as ChannelFees, l as ChannelOpeningTransaction, n as ChannelStatus, o as ChannelToTransactionsConnection, p as CreateApiTokenInput, q as CreateApiTokenOutput, r as CreateInvoiceInput, s as CreateInvoiceOutput, t as CreateNodeWalletAddressInput, u as CreateNodeWalletAddressOutput, v as CurrencyAmount, w as CurrencyUnit, D as DeleteApiTokenInput, x as DeleteApiTokenOutput, y as Deposit, E as Entity, F as FeeEstimate, G as FundNodeInput, H as FundNodeOutput, I as GraphNode, J as Hop, M as HtlcAttemptFailureCode, N as IncomingPayment, O as IncomingPaymentAttempt, Q as IncomingPaymentAttemptStatus, R as IncomingPaymentToAttemptsConnection, S as Invoice, U as InvoiceData, V as InvoiceType, W as LightningFeeEstimateForInvoiceInput, X as LightningFeeEstimateForNodeInput, Y as LightningFeeEstimateOutput, Z as LightningTransaction, $ as LightsparkNode, a0 as LightsparkNodePurpose, a1 as LightsparkNodeStatus, a2 as LightsparkNodeToChannelsConnection, a3 as Node, a4 as NodeAddress, a5 as NodeAddressType, a6 as NodeToAddressesConnection, a7 as OnChainTransaction, a9 as OutgoingPayment, aa as OutgoingPaymentAttempt, ab as OutgoingPaymentAttemptStatus, ac as OutgoingPaymentAttemptToHopsConnection, ad as OutgoingPaymentToAttemptsConnection, ae as PageInfo, af as PayInvoiceInput, ag as PayInvoiceOutput, ah as PaymentFailureReason, ai as PaymentRequest, ak as PaymentRequestData, al as PaymentRequestStatus, am as Permission, an as RequestWithdrawalInput, ao as RequestWithdrawalOutput, ap as RichText, aq as RoutingTransaction, as as RoutingTransactionFailureReason, at as Secret, au as SendPaymentInput, av as SendPaymentOutput, aw as Transaction, ay as TransactionFailures, az as TransactionStatus, aA as TransactionType, aB as TransactionUpdate, aC as WalletDashboard, aD as WebhookEventType, aE as Withdrawal, aG as WithdrawalMode, aH as WithdrawalRequest, aI as WithdrawalRequestStatus, aJ as WithdrawalRequestToChannelClosingTransactionsConnection, aK as WithdrawalRequestToChannelOpeningTransactionsConnection, g as getApiTokenQuery, j as getChannelClosingTransactionQuery, m as getChannelOpeningTransactionQuery, z as getDepositQuery, K as getHopQuery, P as getIncomingPaymentAttemptQuery, T as getInvoiceQuery, _ as getLightningTransactionQuery, a8 as getOnChainTransactionQuery, aj as getPaymentRequestQuery, ar as getRoutingTransactionQuery, ax as getTransactionQuery, aF as getWithdrawalQuery } from '../Withdrawal-27a4d10d.js';
1
+ export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as ApiToken, B as BitcoinNetwork, h as BlockchainBalance, C as Channel, i as ChannelClosingTransaction, k as ChannelFees, l as ChannelOpeningTransaction, n as ChannelStatus, o as ChannelToTransactionsConnection, p as CreateApiTokenInput, q as CreateApiTokenOutput, r as CreateInvoiceInput, s as CreateInvoiceOutput, t as CreateNodeWalletAddressInput, u as CreateNodeWalletAddressOutput, v as CurrencyAmount, w as CurrencyUnit, D as DeleteApiTokenInput, x as DeleteApiTokenOutput, y as Deposit, E as Entity, F as FeeEstimate, G as FundNodeInput, H as FundNodeOutput, I as GraphNode, J as Hop, M as HtlcAttemptFailureCode, N as IncomingPayment, O as IncomingPaymentAttempt, Q as IncomingPaymentAttemptStatus, R as IncomingPaymentToAttemptsConnection, S as Invoice, U as InvoiceData, V as InvoiceType, W as LightningFeeEstimateForInvoiceInput, X as LightningFeeEstimateForNodeInput, Y as LightningFeeEstimateOutput, Z as LightningTransaction, $ as LightsparkNode, a0 as LightsparkNodePurpose, a1 as LightsparkNodeStatus, a2 as LightsparkNodeToChannelsConnection, a3 as Node, a4 as NodeAddress, a5 as NodeAddressType, a6 as NodeToAddressesConnection, a7 as OnChainTransaction, a9 as OutgoingPayment, aa as OutgoingPaymentAttempt, ab as OutgoingPaymentAttemptStatus, ac as OutgoingPaymentAttemptToHopsConnection, ad as OutgoingPaymentToAttemptsConnection, ae as PageInfo, af as PayInvoiceInput, ag as PayInvoiceOutput, ah as PaymentFailureReason, ai as PaymentRequest, ak as PaymentRequestData, al as PaymentRequestStatus, am as Permission, an as RequestWithdrawalInput, ao as RequestWithdrawalOutput, ap as RichText, aq as RoutingTransaction, as as RoutingTransactionFailureReason, at as Secret, au as SendPaymentInput, av as SendPaymentOutput, aw as Transaction, ay as TransactionFailures, az as TransactionStatus, aA as TransactionType, aB as TransactionUpdate, aC as WalletDashboard, aD as WebhookEventType, aE as Withdrawal, aG as WithdrawalMode, aH as WithdrawalRequest, aI as WithdrawalRequestStatus, aJ as WithdrawalRequestToChannelClosingTransactionsConnection, aK as WithdrawalRequestToChannelOpeningTransactionsConnection, g as getApiTokenQuery, j as getChannelClosingTransactionQuery, m as getChannelOpeningTransactionQuery, z as getDepositQuery, K as getHopQuery, P as getIncomingPaymentAttemptQuery, T as getInvoiceQuery, _ as getLightningTransactionQuery, a8 as getOnChainTransactionQuery, aj as getPaymentRequestQuery, ar as getRoutingTransactionQuery, ax as getTransactionQuery, aF as getWithdrawalQuery } from '../Withdrawal-ebb4865c.js';
2
2
  import '@lightsparkdev/core';
3
3
  import 'zen-observable';