@lightsparkdev/lightspark-sdk 0.2.1 → 0.2.3

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
@@ -35,7 +35,7 @@ var require_package = __commonJS({
35
35
  "package.json"(exports, module2) {
36
36
  module2.exports = {
37
37
  name: "@lightsparkdev/lightspark-sdk",
38
- version: "0.2.1",
38
+ version: "0.2.2",
39
39
  description: "Lightspark JS SDK",
40
40
  author: "Lightspark Inc.",
41
41
  keywords: [
@@ -158,6 +158,7 @@ __export(src_exports, {
158
158
  RoutingTransactionFailureReason: () => RoutingTransactionFailureReason_default,
159
159
  TransactionStatus: () => TransactionStatus_default,
160
160
  TransactionType: () => TransactionType_default,
161
+ Wallet: () => Wallet_default,
161
162
  WebhookEventType: () => WebhookEventType_default,
162
163
  WithdrawalMode: () => WithdrawalMode_default,
163
164
  WithdrawalRequest: () => WithdrawalRequest_default,
@@ -209,8 +210,9 @@ var AccountTokenAuthProvider = class {
209
210
  var AccountTokenAuthProvider_default = AccountTokenAuthProvider;
210
211
 
211
212
  // src/client.ts
212
- var import_auto_bind12 = __toESM(require("auto-bind"), 1);
213
213
  var import_core6 = require("@lightsparkdev/core");
214
+ var import_auto_bind13 = __toESM(require("auto-bind"), 1);
215
+ var import_core7 = require("@lightsparkdev/core");
214
216
 
215
217
  // src/objects/CurrencyUnit.ts
216
218
  var CurrencyUnit = /* @__PURE__ */ ((CurrencyUnit2) => {
@@ -3758,7 +3760,7 @@ ${FRAGMENT19}
3758
3760
  `;
3759
3761
 
3760
3762
  // src/objects/Account.ts
3761
- var import_auto_bind11 = __toESM(require("auto-bind"), 1);
3763
+ var import_auto_bind12 = __toESM(require("auto-bind"), 1);
3762
3764
 
3763
3765
  // src/objects/AccountToApiTokensConnection.ts
3764
3766
  var AccountToApiTokensConnectionFromJson = (obj) => {
@@ -4043,6 +4045,168 @@ var AccountToTransactionsConnectionFromJson = (obj) => {
4043
4045
  };
4044
4046
  };
4045
4047
 
4048
+ // src/objects/Wallet.ts
4049
+ var import_auto_bind11 = __toESM(require("auto-bind"), 1);
4050
+
4051
+ // src/objects/Balances.ts
4052
+ var BalancesFromJson = (obj) => {
4053
+ return {
4054
+ ownedBalance: CurrencyAmountFromJson(obj["balances_owned_balance"]),
4055
+ availableToSendBalance: CurrencyAmountFromJson(
4056
+ obj["balances_available_to_send_balance"]
4057
+ ),
4058
+ availableToWithdrawBalance: CurrencyAmountFromJson(
4059
+ obj["balances_available_to_withdraw_balance"]
4060
+ )
4061
+ };
4062
+ };
4063
+
4064
+ // src/objects/Wallet.ts
4065
+ var Wallet = class {
4066
+ constructor(id, createdAt, updatedAt, thirdPartyIdentifier, typename, lastLoginAt, balances) {
4067
+ this.id = id;
4068
+ this.createdAt = createdAt;
4069
+ this.updatedAt = updatedAt;
4070
+ this.thirdPartyIdentifier = thirdPartyIdentifier;
4071
+ this.typename = typename;
4072
+ this.lastLoginAt = lastLoginAt;
4073
+ this.balances = balances;
4074
+ (0, import_auto_bind11.default)(this);
4075
+ }
4076
+ async getTotalAmountReceived(client, createdAfterDate = void 0, createdBeforeDate = void 0) {
4077
+ return await client.executeRawQuery({
4078
+ queryPayload: `
4079
+ query FetchWalletTotalAmountReceived($created_after_date: DateTime, $created_before_date: DateTime) {
4080
+ current_wallet {
4081
+ ... on Wallet {
4082
+ total_amount_received(, created_after_date: $created_after_date, created_before_date: $created_before_date) {
4083
+ __typename
4084
+ currency_amount_original_value: original_value
4085
+ currency_amount_original_unit: original_unit
4086
+ currency_amount_preferred_currency_unit: preferred_currency_unit
4087
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
4088
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
4089
+ }
4090
+ }
4091
+ }
4092
+ }
4093
+ `,
4094
+ variables: {
4095
+ created_after_date: createdAfterDate,
4096
+ created_before_date: createdBeforeDate
4097
+ },
4098
+ constructObject: (json) => {
4099
+ const connection = json["current_wallet"]["total_amount_received"];
4100
+ return CurrencyAmountFromJson(connection);
4101
+ }
4102
+ });
4103
+ }
4104
+ async getTotalAmountSent(client, createdAfterDate = void 0, createdBeforeDate = void 0) {
4105
+ return await client.executeRawQuery({
4106
+ queryPayload: `
4107
+ query FetchWalletTotalAmountSent($created_after_date: DateTime, $created_before_date: DateTime) {
4108
+ current_wallet {
4109
+ ... on Wallet {
4110
+ total_amount_sent(, created_after_date: $created_after_date, created_before_date: $created_before_date) {
4111
+ __typename
4112
+ currency_amount_original_value: original_value
4113
+ currency_amount_original_unit: original_unit
4114
+ currency_amount_preferred_currency_unit: preferred_currency_unit
4115
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
4116
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
4117
+ }
4118
+ }
4119
+ }
4120
+ }
4121
+ `,
4122
+ variables: {
4123
+ created_after_date: createdAfterDate,
4124
+ created_before_date: createdBeforeDate
4125
+ },
4126
+ constructObject: (json) => {
4127
+ const connection = json["current_wallet"]["total_amount_sent"];
4128
+ return CurrencyAmountFromJson(connection);
4129
+ }
4130
+ });
4131
+ }
4132
+ static getWalletQuery() {
4133
+ return {
4134
+ queryPayload: `
4135
+ query GetWallet {
4136
+ current_wallet {
4137
+ ... on Wallet {
4138
+ ...WalletFragment
4139
+ }
4140
+ }
4141
+ }
4142
+
4143
+ ${FRAGMENT21}
4144
+ `,
4145
+ variables: {},
4146
+ constructObject: (data) => WalletFromJson(data.current_wallet)
4147
+ };
4148
+ }
4149
+ };
4150
+ var WalletFromJson = (obj) => {
4151
+ return new Wallet(
4152
+ obj["wallet_id"],
4153
+ obj["wallet_created_at"],
4154
+ obj["wallet_updated_at"],
4155
+ obj["wallet_third_party_identifier"],
4156
+ "Wallet",
4157
+ obj["wallet_last_login_at"],
4158
+ !!obj["wallet_balances"] ? BalancesFromJson(obj["wallet_balances"]) : void 0
4159
+ );
4160
+ };
4161
+ var FRAGMENT21 = `
4162
+ fragment WalletFragment on Wallet {
4163
+ __typename
4164
+ wallet_id: id
4165
+ wallet_created_at: created_at
4166
+ wallet_updated_at: updated_at
4167
+ wallet_last_login_at: last_login_at
4168
+ wallet_balances: balances {
4169
+ __typename
4170
+ balances_owned_balance: owned_balance {
4171
+ __typename
4172
+ currency_amount_original_value: original_value
4173
+ currency_amount_original_unit: original_unit
4174
+ currency_amount_preferred_currency_unit: preferred_currency_unit
4175
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
4176
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
4177
+ }
4178
+ balances_available_to_send_balance: available_to_send_balance {
4179
+ __typename
4180
+ currency_amount_original_value: original_value
4181
+ currency_amount_original_unit: original_unit
4182
+ currency_amount_preferred_currency_unit: preferred_currency_unit
4183
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
4184
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
4185
+ }
4186
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
4187
+ __typename
4188
+ currency_amount_original_value: original_value
4189
+ currency_amount_original_unit: original_unit
4190
+ currency_amount_preferred_currency_unit: preferred_currency_unit
4191
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
4192
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
4193
+ }
4194
+ }
4195
+ wallet_third_party_identifier: third_party_identifier
4196
+ }`;
4197
+ var Wallet_default = Wallet;
4198
+
4199
+ // src/objects/AccountToWalletsConnection.ts
4200
+ var AccountToWalletsConnectionFromJson = (obj) => {
4201
+ return {
4202
+ pageInfo: PageInfoFromJson(obj["account_to_wallets_connection_page_info"]),
4203
+ count: obj["account_to_wallets_connection_count"],
4204
+ entities: obj["account_to_wallets_connection_entities"].map(
4205
+ (e) => WalletFromJson(e)
4206
+ )
4207
+ };
4208
+ };
4209
+
4046
4210
  // src/objects/Account.ts
4047
4211
  var Account = class {
4048
4212
  constructor(id, createdAt, updatedAt, typename, name) {
@@ -4051,7 +4215,7 @@ var Account = class {
4051
4215
  this.updatedAt = updatedAt;
4052
4216
  this.typename = typename;
4053
4217
  this.name = name;
4054
- (0, import_auto_bind11.default)(this);
4218
+ (0, import_auto_bind12.default)(this);
4055
4219
  }
4056
4220
  async getApiTokens(client, first = void 0) {
4057
4221
  return await client.executeRawQuery({
@@ -5129,6 +5293,69 @@ query FetchAccountToPaymentRequestsConnection($first: Int, $after: String, $afte
5129
5293
  }
5130
5294
  });
5131
5295
  }
5296
+ async getWallets(client, first = void 0) {
5297
+ return await client.executeRawQuery({
5298
+ queryPayload: `
5299
+ query FetchAccountToWalletsConnection($first: Int) {
5300
+ current_account {
5301
+ ... on Account {
5302
+ wallets(, first: $first) {
5303
+ __typename
5304
+ account_to_wallets_connection_page_info: page_info {
5305
+ __typename
5306
+ page_info_has_next_page: has_next_page
5307
+ page_info_has_previous_page: has_previous_page
5308
+ page_info_start_cursor: start_cursor
5309
+ page_info_end_cursor: end_cursor
5310
+ }
5311
+ account_to_wallets_connection_count: count
5312
+ account_to_wallets_connection_entities: entities {
5313
+ __typename
5314
+ wallet_id: id
5315
+ wallet_created_at: created_at
5316
+ wallet_updated_at: updated_at
5317
+ wallet_last_login_at: last_login_at
5318
+ wallet_balances: balances {
5319
+ __typename
5320
+ balances_owned_balance: owned_balance {
5321
+ __typename
5322
+ currency_amount_original_value: original_value
5323
+ currency_amount_original_unit: original_unit
5324
+ currency_amount_preferred_currency_unit: preferred_currency_unit
5325
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
5326
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
5327
+ }
5328
+ balances_available_to_send_balance: available_to_send_balance {
5329
+ __typename
5330
+ currency_amount_original_value: original_value
5331
+ currency_amount_original_unit: original_unit
5332
+ currency_amount_preferred_currency_unit: preferred_currency_unit
5333
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
5334
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
5335
+ }
5336
+ balances_available_to_withdraw_balance: available_to_withdraw_balance {
5337
+ __typename
5338
+ currency_amount_original_value: original_value
5339
+ currency_amount_original_unit: original_unit
5340
+ currency_amount_preferred_currency_unit: preferred_currency_unit
5341
+ currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
5342
+ currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
5343
+ }
5344
+ }
5345
+ wallet_third_party_identifier: third_party_identifier
5346
+ }
5347
+ }
5348
+ }
5349
+ }
5350
+ }
5351
+ `,
5352
+ variables: { first },
5353
+ constructObject: (json) => {
5354
+ const connection = json["current_account"]["wallets"];
5355
+ return AccountToWalletsConnectionFromJson(connection);
5356
+ }
5357
+ });
5358
+ }
5132
5359
  static getAccountQuery() {
5133
5360
  return {
5134
5361
  queryPayload: `
@@ -5140,7 +5367,7 @@ query GetAccount {
5140
5367
  }
5141
5368
  }
5142
5369
 
5143
- ${FRAGMENT21}
5370
+ ${FRAGMENT22}
5144
5371
  `,
5145
5372
  variables: {},
5146
5373
  constructObject: (data) => AccountFromJson(data.current_account)
@@ -5156,7 +5383,7 @@ var AccountFromJson = (obj) => {
5156
5383
  obj["account_name"]
5157
5384
  );
5158
5385
  };
5159
- var FRAGMENT21 = `
5386
+ var FRAGMENT22 = `
5160
5387
  fragment AccountFragment on Account {
5161
5388
  __typename
5162
5389
  account_id: id
@@ -5177,21 +5404,24 @@ var LightsparkClient = class {
5177
5404
  * @param nodeKeyCache This is used to cache node keys for the duration of the session. Defaults to a new instance of
5178
5405
  * `NodeKeyCache`. You should not need to change this.
5179
5406
  */
5180
- constructor(authProvider = new import_core6.StubAuthProvider(), serverUrl = "api.lightspark.com", nodeKeyCache = new import_core6.NodeKeyCache()) {
5407
+ constructor(authProvider = new import_core7.StubAuthProvider(), serverUrl = "api.lightspark.com", cryptoImpl = import_core7.DefaultCrypto) {
5181
5408
  this.authProvider = authProvider;
5182
5409
  this.serverUrl = serverUrl;
5183
- this.nodeKeyCache = nodeKeyCache;
5410
+ this.cryptoImpl = cryptoImpl;
5184
5411
  const sdkVersion = require_package().version;
5185
- this.requester = new import_core6.Requester(
5412
+ this.nodeKeyCache = new import_core7.NodeKeyCache(this.cryptoImpl);
5413
+ this.requester = new import_core7.Requester(
5186
5414
  this.nodeKeyCache,
5187
5415
  LIGHTSPARK_SDK_ENDPOINT,
5188
5416
  `js-lightspark-sdk/${sdkVersion}`,
5189
5417
  authProvider,
5190
- serverUrl
5418
+ serverUrl,
5419
+ this.cryptoImpl
5191
5420
  );
5192
- (0, import_auto_bind12.default)(this);
5421
+ (0, import_auto_bind13.default)(this);
5193
5422
  }
5194
5423
  requester;
5424
+ nodeKeyCache;
5195
5425
  /**
5196
5426
  * Sets the auth provider for the client. This is useful for switching between auth providers if you are using
5197
5427
  * multiple accounts or waiting for the user to log in.
@@ -5200,12 +5430,13 @@ var LightsparkClient = class {
5200
5430
  */
5201
5431
  async setAuthProvider(authProvider) {
5202
5432
  const sdkVersion = require_package().version;
5203
- this.requester = new import_core6.Requester(
5433
+ this.requester = new import_core7.Requester(
5204
5434
  this.nodeKeyCache,
5205
5435
  LIGHTSPARK_SDK_ENDPOINT,
5206
5436
  `js-lightspark-sdk/${sdkVersion}`,
5207
5437
  authProvider,
5208
- this.serverUrl
5438
+ this.serverUrl,
5439
+ this.cryptoImpl
5209
5440
  );
5210
5441
  this.authProvider = authProvider;
5211
5442
  }
@@ -5272,10 +5503,10 @@ var LightsparkClient = class {
5272
5503
  network: bitcoinNetwork
5273
5504
  });
5274
5505
  if (!response.current_account) {
5275
- throw new import_core6.LightsparkAuthException("No current account");
5506
+ throw new import_core7.LightsparkAuthException("No current account");
5276
5507
  }
5277
5508
  if (!response.current_account.dashboard_overview_nodes || response.current_account.dashboard_overview_nodes.entities.length === 0) {
5278
- throw new import_core6.LightsparkException(
5509
+ throw new import_core7.LightsparkException(
5279
5510
  "NO_NODES_FOUND",
5280
5511
  `No nodes found for this dashboard request. This could mean one of a few things:
5281
5512
  1. You are requesting MAINNET nodes, but you have no MAINNET nodes yet. In this case, request BitcoinNetwork.REGTEST instead.
@@ -5344,11 +5575,11 @@ var LightsparkClient = class {
5344
5575
  transactionsAfterDate
5345
5576
  });
5346
5577
  if (!response.current_account) {
5347
- throw new import_core6.LightsparkAuthException("No current account");
5578
+ throw new import_core7.LightsparkAuthException("No current account");
5348
5579
  }
5349
5580
  const account = response.current_account;
5350
5581
  if (!account.dashboard_overview_nodes || !account.dashboard_overview_nodes.entities || account.dashboard_overview_nodes.entities.length === 0) {
5351
- throw new import_core6.LightsparkException(
5582
+ throw new import_core7.LightsparkException(
5352
5583
  "InvalidOrMissingNode",
5353
5584
  "No nodes found for node dashboard"
5354
5585
  );
@@ -5497,7 +5728,7 @@ var LightsparkClient = class {
5497
5728
  console.warn("No encrypted key found for node " + nodeId);
5498
5729
  return false;
5499
5730
  }
5500
- const signingPrivateKey = await (0, import_core6.decryptSecretWithNodePassword)(
5731
+ const signingPrivateKey = await this.cryptoImpl.decryptSecretWithNodePassword(
5501
5732
  encryptedKey.cipher,
5502
5733
  encryptedKey.encrypted_value,
5503
5734
  password
@@ -5509,7 +5740,7 @@ var LightsparkClient = class {
5509
5740
  }
5510
5741
  let signingPrivateKeyPEM = "";
5511
5742
  if (new Uint8Array(signingPrivateKey)[0] === 48) {
5512
- signingPrivateKeyPEM = (0, import_core6.b64encode)(signingPrivateKey);
5743
+ signingPrivateKeyPEM = (0, import_core7.b64encode)(signingPrivateKey);
5513
5744
  } else {
5514
5745
  const dec = new TextDecoder();
5515
5746
  signingPrivateKeyPEM = dec.decode(signingPrivateKey);
@@ -5569,7 +5800,7 @@ var LightsparkClient = class {
5569
5800
  payerNodeId
5570
5801
  );
5571
5802
  if (response.pay_invoice?.payment.outgoing_payment_failure_message) {
5572
- throw new import_core6.LightsparkException(
5803
+ throw new import_core7.LightsparkException(
5573
5804
  "PaymentError",
5574
5805
  response.pay_invoice?.payment.outgoing_payment_failure_message.rich_text_text
5575
5806
  );
@@ -5604,7 +5835,7 @@ var LightsparkClient = class {
5604
5835
  payerNodeId
5605
5836
  );
5606
5837
  if (response.send_payment?.payment.outgoing_payment_failure_message) {
5607
- throw new import_core6.LightsparkException(
5838
+ throw new import_core7.LightsparkException(
5608
5839
  "PaymentError",
5609
5840
  response.send_payment?.payment.outgoing_payment_failure_message.rich_text_text
5610
5841
  );
@@ -5748,7 +5979,7 @@ var DepositFromJson = (obj) => {
5748
5979
  numConfirmations: obj["deposit_num_confirmations"]
5749
5980
  };
5750
5981
  };
5751
- var FRAGMENT22 = `
5982
+ var FRAGMENT23 = `
5752
5983
  fragment DepositFragment on Deposit {
5753
5984
  __typename
5754
5985
  deposit_id: id
@@ -5792,7 +6023,7 @@ query GetDeposit($id: ID!) {
5792
6023
  }
5793
6024
  }
5794
6025
 
5795
- ${FRAGMENT22}
6026
+ ${FRAGMENT23}
5796
6027
  `,
5797
6028
  variables: { id },
5798
6029
  constructObject: (data) => DepositFromJson(data.entity)
@@ -5811,7 +6042,7 @@ var InvoiceFromJson = (obj) => {
5811
6042
  amountPaid: !!obj["invoice_amount_paid"] ? CurrencyAmountFromJson(obj["invoice_amount_paid"]) : void 0
5812
6043
  };
5813
6044
  };
5814
- var FRAGMENT23 = `
6045
+ var FRAGMENT24 = `
5815
6046
  fragment InvoiceFragment on Invoice {
5816
6047
  __typename
5817
6048
  invoice_id: id
@@ -5975,7 +6206,7 @@ query GetInvoice($id: ID!) {
5975
6206
  }
5976
6207
  }
5977
6208
 
5978
- ${FRAGMENT23}
6209
+ ${FRAGMENT24}
5979
6210
  `,
5980
6211
  variables: { id },
5981
6212
  constructObject: (data) => InvoiceFromJson(data.entity)
@@ -5983,7 +6214,7 @@ ${FRAGMENT23}
5983
6214
  };
5984
6215
 
5985
6216
  // src/objects/LightningTransaction.ts
5986
- var import_core7 = require("@lightsparkdev/core");
6217
+ var import_core8 = require("@lightsparkdev/core");
5987
6218
  var LightningTransactionFromJson = (obj) => {
5988
6219
  if (obj["__typename"] == "IncomingPayment") {
5989
6220
  return new IncomingPayment_default(
@@ -6037,12 +6268,12 @@ var LightningTransactionFromJson = (obj) => {
6037
6268
  failureReason: !!obj["routing_transaction_failure_reason"] ? RoutingTransactionFailureReason_default[obj["routing_transaction_failure_reason"]] ?? RoutingTransactionFailureReason_default.FUTURE_VALUE : null
6038
6269
  };
6039
6270
  }
6040
- throw new import_core7.LightsparkException(
6271
+ throw new import_core8.LightsparkException(
6041
6272
  "DeserializationError",
6042
6273
  `Couldn't find a concrete type for interface LightningTransaction corresponding to the typename=${obj["__typename"]}`
6043
6274
  );
6044
6275
  };
6045
- var FRAGMENT24 = `
6276
+ var FRAGMENT25 = `
6046
6277
  fragment LightningTransactionFragment on LightningTransaction {
6047
6278
  __typename
6048
6279
  ... on IncomingPayment {
@@ -6295,7 +6526,7 @@ query GetLightningTransaction($id: ID!) {
6295
6526
  }
6296
6527
  }
6297
6528
 
6298
- ${FRAGMENT24}
6529
+ ${FRAGMENT25}
6299
6530
  `,
6300
6531
  variables: { id },
6301
6532
  constructObject: (data) => LightningTransactionFromJson(data.entity)
@@ -6303,7 +6534,7 @@ ${FRAGMENT24}
6303
6534
  };
6304
6535
 
6305
6536
  // src/objects/OnChainTransaction.ts
6306
- var import_core8 = require("@lightsparkdev/core");
6537
+ var import_core9 = require("@lightsparkdev/core");
6307
6538
  var OnChainTransactionFromJson = (obj) => {
6308
6539
  if (obj["__typename"] == "ChannelClosingTransaction") {
6309
6540
  return {
@@ -6377,12 +6608,12 @@ var OnChainTransactionFromJson = (obj) => {
6377
6608
  numConfirmations: obj["withdrawal_num_confirmations"]
6378
6609
  };
6379
6610
  }
6380
- throw new import_core8.LightsparkException(
6611
+ throw new import_core9.LightsparkException(
6381
6612
  "DeserializationError",
6382
6613
  `Couldn't find a concrete type for interface OnChainTransaction corresponding to the typename=${obj["__typename"]}`
6383
6614
  );
6384
6615
  };
6385
- var FRAGMENT25 = `
6616
+ var FRAGMENT26 = `
6386
6617
  fragment OnChainTransactionFragment on OnChainTransaction {
6387
6618
  __typename
6388
6619
  ... on ChannelClosingTransaction {
@@ -6525,7 +6756,7 @@ query GetOnChainTransaction($id: ID!) {
6525
6756
  }
6526
6757
  }
6527
6758
 
6528
- ${FRAGMENT25}
6759
+ ${FRAGMENT26}
6529
6760
  `,
6530
6761
  variables: { id },
6531
6762
  constructObject: (data) => OnChainTransactionFromJson(data.entity)
@@ -6550,7 +6781,7 @@ var RoutingTransactionFromJson = (obj) => {
6550
6781
  failureReason: !!obj["routing_transaction_failure_reason"] ? RoutingTransactionFailureReason_default[obj["routing_transaction_failure_reason"]] ?? RoutingTransactionFailureReason_default.FUTURE_VALUE : null
6551
6782
  };
6552
6783
  };
6553
- var FRAGMENT26 = `
6784
+ var FRAGMENT27 = `
6554
6785
  fragment RoutingTransactionFragment on RoutingTransaction {
6555
6786
  __typename
6556
6787
  routing_transaction_id: id
@@ -6598,7 +6829,7 @@ query GetRoutingTransaction($id: ID!) {
6598
6829
  }
6599
6830
  }
6600
6831
 
6601
- ${FRAGMENT26}
6832
+ ${FRAGMENT27}
6602
6833
  `,
6603
6834
  variables: { id },
6604
6835
  constructObject: (data) => RoutingTransactionFromJson(data.entity)
@@ -6655,7 +6886,7 @@ var WithdrawalFromJson = (obj) => {
6655
6886
  numConfirmations: obj["withdrawal_num_confirmations"]
6656
6887
  };
6657
6888
  };
6658
- var FRAGMENT27 = `
6889
+ var FRAGMENT28 = `
6659
6890
  fragment WithdrawalFragment on Withdrawal {
6660
6891
  __typename
6661
6892
  withdrawal_id: id
@@ -6699,7 +6930,7 @@ query GetWithdrawal($id: ID!) {
6699
6930
  }
6700
6931
  }
6701
6932
 
6702
- ${FRAGMENT27}
6933
+ ${FRAGMENT28}
6703
6934
  `,
6704
6935
  variables: { id },
6705
6936
  constructObject: (data) => WithdrawalFromJson(data.entity)
@@ -6734,6 +6965,7 @@ ${FRAGMENT27}
6734
6965
  RoutingTransactionFailureReason,
6735
6966
  TransactionStatus,
6736
6967
  TransactionType,
6968
+ Wallet,
6737
6969
  WebhookEventType,
6738
6970
  WithdrawalMode,
6739
6971
  WithdrawalRequest,
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-ebb4865c.js';
2
+ 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 BitcoinNetwork, j as BlockchainBalance, C as Channel, k as ChannelClosingTransaction, m as ChannelFees, n as ChannelOpeningTransaction, p as ChannelStatus, q as ChannelToTransactionsConnection, r as CreateApiTokenInput, s as CreateApiTokenOutput, t as CreateInvoiceInput, u as CreateInvoiceOutput, v as CreateNodeWalletAddressInput, w as CreateNodeWalletAddressOutput, x as CurrencyAmount, y as CurrencyUnit, D as DeleteApiTokenInput, z as DeleteApiTokenOutput, E as Deposit, G as Entity, H as FeeEstimate, I as FundNodeInput, J as FundNodeOutput, K as GraphNode, M as Hop, O as HtlcAttemptFailureCode, P as IncomingPayment, Q as IncomingPaymentAttempt, S as IncomingPaymentAttemptStatus, T as IncomingPaymentToAttemptsConnection, U as Invoice, W as InvoiceData, X as InvoiceType, Y as LightningFeeEstimateForInvoiceInput, Z as LightningFeeEstimateForNodeInput, _ as LightningFeeEstimateOutput, $ as LightningTransaction, L as LightsparkClient, a1 as LightsparkNode, a2 as LightsparkNodePurpose, a3 as LightsparkNodeStatus, a4 as LightsparkNodeToChannelsConnection, a5 as Node, a6 as NodeAddress, a7 as NodeAddressType, a8 as NodeToAddressesConnection, a9 as OnChainTransaction, ab as OutgoingPayment, ac as OutgoingPaymentAttempt, ad as OutgoingPaymentAttemptStatus, ae as OutgoingPaymentAttemptToHopsConnection, af as OutgoingPaymentToAttemptsConnection, ag as PageInfo, ah as PayInvoiceInput, ai as PayInvoiceOutput, aj as PaymentFailureReason, ak as PaymentRequest, am as PaymentRequestData, an as PaymentRequestStatus, ao as Permission, ap as RequestWithdrawalInput, aq as RequestWithdrawalOutput, ar as RichText, as as RoutingTransaction, au as RoutingTransactionFailureReason, av as Secret, aw as SendPaymentInput, ax as SendPaymentOutput, ay as Transaction, aA as TransactionFailures, aB as TransactionStatus, aC as TransactionType, aD as TransactionUpdate, aE as Wallet, aF as WalletDashboard, aG as WebhookEventType, aH as Withdrawal, aJ as WithdrawalMode, aK as WithdrawalRequest, aL as WithdrawalRequestStatus, aM as WithdrawalRequestToChannelClosingTransactionsConnection, aN as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, l as getChannelClosingTransactionQuery, o as getChannelOpeningTransactionQuery, F as getDepositQuery, N as getHopQuery, R as getIncomingPaymentAttemptQuery, V as getInvoiceQuery, a0 as getLightningTransactionQuery, aa as getOnChainTransactionQuery, al as getPaymentRequestQuery, at as getRoutingTransactionQuery, az as getTransactionQuery, aI as getWithdrawalQuery } from './Withdrawal-6e015ff8.js';
3
3
  import 'zen-observable';
4
4
 
5
5
  declare class AccountTokenAuthProvider implements AuthProvider {
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ import {
40
40
  TransactionStatus_default,
41
41
  TransactionType_default,
42
42
  TransactionUpdateFromJson,
43
+ Wallet_default,
43
44
  WebhookEventType_default,
44
45
  WithdrawalMode_default,
45
46
  WithdrawalRequestFromJson,
@@ -59,14 +60,14 @@ import {
59
60
  getRoutingTransactionQuery,
60
61
  getTransactionQuery,
61
62
  getWithdrawalQuery
62
- } from "./chunk-5Z7FB6OT.js";
63
+ } from "./chunk-ZBDRJ7IU.js";
63
64
 
64
65
  // package.json
65
66
  var require_package = __commonJS({
66
67
  "package.json"(exports, module) {
67
68
  module.exports = {
68
69
  name: "@lightsparkdev/lightspark-sdk",
69
- version: "0.2.1",
70
+ version: "0.2.2",
70
71
  description: "Lightspark JS SDK",
71
72
  author: "Lightspark Inc.",
72
73
  keywords: [
@@ -190,13 +191,13 @@ var AccountTokenAuthProvider = class {
190
191
  var AccountTokenAuthProvider_default = AccountTokenAuthProvider;
191
192
 
192
193
  // src/client.ts
194
+ import { LightsparkSigningException } from "@lightsparkdev/core";
193
195
  import autoBind2 from "auto-bind";
194
196
  import {
195
197
  b64encode as b64encode2,
196
- decryptSecretWithNodePassword,
198
+ DefaultCrypto,
197
199
  LightsparkAuthException,
198
200
  LightsparkException,
199
- LightsparkSigningException,
200
201
  NodeKeyCache,
201
202
  Requester,
202
203
  StubAuthProvider
@@ -690,21 +691,24 @@ var LightsparkClient = class {
690
691
  * @param nodeKeyCache This is used to cache node keys for the duration of the session. Defaults to a new instance of
691
692
  * `NodeKeyCache`. You should not need to change this.
692
693
  */
693
- constructor(authProvider = new StubAuthProvider(), serverUrl = "api.lightspark.com", nodeKeyCache = new NodeKeyCache()) {
694
+ constructor(authProvider = new StubAuthProvider(), serverUrl = "api.lightspark.com", cryptoImpl = DefaultCrypto) {
694
695
  this.authProvider = authProvider;
695
696
  this.serverUrl = serverUrl;
696
- this.nodeKeyCache = nodeKeyCache;
697
+ this.cryptoImpl = cryptoImpl;
697
698
  const sdkVersion = require_package().version;
699
+ this.nodeKeyCache = new NodeKeyCache(this.cryptoImpl);
698
700
  this.requester = new Requester(
699
701
  this.nodeKeyCache,
700
702
  LIGHTSPARK_SDK_ENDPOINT,
701
703
  `js-lightspark-sdk/${sdkVersion}`,
702
704
  authProvider,
703
- serverUrl
705
+ serverUrl,
706
+ this.cryptoImpl
704
707
  );
705
708
  autoBind2(this);
706
709
  }
707
710
  requester;
711
+ nodeKeyCache;
708
712
  /**
709
713
  * Sets the auth provider for the client. This is useful for switching between auth providers if you are using
710
714
  * multiple accounts or waiting for the user to log in.
@@ -718,7 +722,8 @@ var LightsparkClient = class {
718
722
  LIGHTSPARK_SDK_ENDPOINT,
719
723
  `js-lightspark-sdk/${sdkVersion}`,
720
724
  authProvider,
721
- this.serverUrl
725
+ this.serverUrl,
726
+ this.cryptoImpl
722
727
  );
723
728
  this.authProvider = authProvider;
724
729
  }
@@ -1010,7 +1015,7 @@ var LightsparkClient = class {
1010
1015
  console.warn("No encrypted key found for node " + nodeId);
1011
1016
  return false;
1012
1017
  }
1013
- const signingPrivateKey = await decryptSecretWithNodePassword(
1018
+ const signingPrivateKey = await this.cryptoImpl.decryptSecretWithNodePassword(
1014
1019
  encryptedKey.cipher,
1015
1020
  encryptedKey.encrypted_value,
1016
1021
  password
@@ -1260,6 +1265,7 @@ export {
1260
1265
  RoutingTransactionFailureReason_default as RoutingTransactionFailureReason,
1261
1266
  TransactionStatus_default as TransactionStatus,
1262
1267
  TransactionType_default as TransactionType,
1268
+ Wallet_default as Wallet,
1263
1269
  WebhookEventType_default as WebhookEventType,
1264
1270
  WithdrawalMode_default as WithdrawalMode,
1265
1271
  WithdrawalRequest_default as WithdrawalRequest,