@lightsparkdev/lightspark-sdk 1.0.0 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @lightsparkdev/lightspark-sdk
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 808c77a: Consolidate some imports to lightspark-sdk and core
8
+ - Updated dependencies [808c77a]
9
+ - @lightsparkdev/core@1.0.1
10
+
3
11
  ## 1.0.0
4
12
 
5
13
  ### Major Changes
@@ -0,0 +1,18 @@
1
+ /** This is an enum identifying a particular Bitcoin Network. **/
2
+ declare enum BitcoinNetwork {
3
+ /**
4
+ * This is an enum value that represents values that could be added in the future.
5
+ * Clients should support unknown values as more of them could be added without notice.
6
+ */
7
+ FUTURE_VALUE = "FUTURE_VALUE",
8
+ /** The production version of the Bitcoin Blockchain. **/
9
+ MAINNET = "MAINNET",
10
+ /** A test version of the Bitcoin Blockchain, maintained by Lightspark. **/
11
+ REGTEST = "REGTEST",
12
+ /** A test version of the Bitcoin Blockchain, maintained by a centralized organization. Not in use at Lightspark. **/
13
+ SIGNET = "SIGNET",
14
+ /** A test version of the Bitcoin Blockchain, publicly available. **/
15
+ TESTNET = "TESTNET"
16
+ }
17
+
18
+ export { BitcoinNetwork as B };
@@ -0,0 +1,27 @@
1
+ // src/helpers.ts
2
+ var BITCOIN_NETWORKS = [
3
+ "MAINNET" /* MAINNET */,
4
+ "TESTNET" /* TESTNET */,
5
+ "SIGNET" /* SIGNET */,
6
+ "REGTEST" /* REGTEST */
7
+ ];
8
+ var isBitcoinNetwork = (bitcoinNetwork) => {
9
+ return BITCOIN_NETWORKS.includes(bitcoinNetwork);
10
+ };
11
+ var assertValidBitcoinNetwork = (bitcoinNetwork) => {
12
+ if (!isBitcoinNetwork(bitcoinNetwork)) {
13
+ throw new Error(
14
+ `Invalid bitcoin network ${bitcoinNetwork}. Valid networks: ${BITCOIN_NETWORKS}`
15
+ );
16
+ }
17
+ };
18
+ var getBitcoinNetworkOrThrow = (bitcoinNetwork) => {
19
+ assertValidBitcoinNetwork(bitcoinNetwork.toUpperCase());
20
+ return bitcoinNetwork;
21
+ };
22
+
23
+ export {
24
+ isBitcoinNetwork,
25
+ assertValidBitcoinNetwork,
26
+ getBitcoinNetworkOrThrow
27
+ };
@@ -1,3 +1,7 @@
1
+ import {
2
+ BitcoinNetwork_default
3
+ } from "./chunk-K6SAUSAX.js";
4
+
1
5
  // src/objects/Account.ts
2
6
  import autoBind12 from "auto-bind";
3
7
 
@@ -420,17 +424,6 @@ var AccountToChannelsConnection_default = AccountToChannelsConnection;
420
424
  import { LightsparkException } from "@lightsparkdev/core";
421
425
  import autoBind5 from "auto-bind";
422
426
 
423
- // src/objects/BitcoinNetwork.ts
424
- var BitcoinNetwork = /* @__PURE__ */ ((BitcoinNetwork2) => {
425
- BitcoinNetwork2["FUTURE_VALUE"] = "FUTURE_VALUE";
426
- BitcoinNetwork2["MAINNET"] = "MAINNET";
427
- BitcoinNetwork2["REGTEST"] = "REGTEST";
428
- BitcoinNetwork2["SIGNET"] = "SIGNET";
429
- BitcoinNetwork2["TESTNET"] = "TESTNET";
430
- return BitcoinNetwork2;
431
- })(BitcoinNetwork || {});
432
- var BitcoinNetwork_default = BitcoinNetwork;
433
-
434
427
  // src/objects/BlockchainBalance.ts
435
428
  var BlockchainBalanceFromJson = (obj) => {
436
429
  return {
@@ -8816,7 +8809,6 @@ export {
8816
8809
  ApiTokenFromJson,
8817
8810
  FRAGMENT as FRAGMENT3,
8818
8811
  getApiTokenQuery,
8819
- BitcoinNetwork_default,
8820
8812
  NodeAddressType_default,
8821
8813
  GraphNode_default,
8822
8814
  LightsparkNodeStatus_default,
@@ -0,0 +1,14 @@
1
+ // src/objects/BitcoinNetwork.ts
2
+ var BitcoinNetwork = /* @__PURE__ */ ((BitcoinNetwork2) => {
3
+ BitcoinNetwork2["FUTURE_VALUE"] = "FUTURE_VALUE";
4
+ BitcoinNetwork2["MAINNET"] = "MAINNET";
5
+ BitcoinNetwork2["REGTEST"] = "REGTEST";
6
+ BitcoinNetwork2["SIGNET"] = "SIGNET";
7
+ BitcoinNetwork2["TESTNET"] = "TESTNET";
8
+ return BitcoinNetwork2;
9
+ })(BitcoinNetwork || {});
10
+ var BitcoinNetwork_default = BitcoinNetwork;
11
+
12
+ export {
13
+ BitcoinNetwork_default
14
+ };
package/dist/env.cjs ADDED
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/env.ts
31
+ var env_exports = {};
32
+ __export(env_exports, {
33
+ RequiredCredentials: () => RequiredCredentials,
34
+ getCredentialsFromEnvOrThrow: () => getCredentialsFromEnvOrThrow
35
+ });
36
+ module.exports = __toCommonJS(env_exports);
37
+ var import_dotenv = __toESM(require("dotenv"), 1);
38
+
39
+ // src/helpers.ts
40
+ var BITCOIN_NETWORKS = [
41
+ "MAINNET" /* MAINNET */,
42
+ "TESTNET" /* TESTNET */,
43
+ "SIGNET" /* SIGNET */,
44
+ "REGTEST" /* REGTEST */
45
+ ];
46
+ var isBitcoinNetwork = (bitcoinNetwork) => {
47
+ return BITCOIN_NETWORKS.includes(bitcoinNetwork);
48
+ };
49
+ var assertValidBitcoinNetwork = (bitcoinNetwork) => {
50
+ if (!isBitcoinNetwork(bitcoinNetwork)) {
51
+ throw new Error(
52
+ `Invalid bitcoin network ${bitcoinNetwork}. Valid networks: ${BITCOIN_NETWORKS}`
53
+ );
54
+ }
55
+ };
56
+ var getBitcoinNetworkOrThrow = (bitcoinNetwork) => {
57
+ assertValidBitcoinNetwork(bitcoinNetwork.toUpperCase());
58
+ return bitcoinNetwork;
59
+ };
60
+
61
+ // src/env.ts
62
+ var RequiredCredentials = /* @__PURE__ */ ((RequiredCredentials2) => {
63
+ RequiredCredentials2["ClientId"] = "LIGHTSPARK_API_TOKEN_CLIENT_ID";
64
+ RequiredCredentials2["ClientSecret"] = "LIGHTSPARK_API_TOKEN_CLIENT_SECRET";
65
+ RequiredCredentials2["BitcoinNetwork"] = "BITCOIN_NETWORK";
66
+ return RequiredCredentials2;
67
+ })(RequiredCredentials || {});
68
+ var getCredentialsFromEnvOrThrow = () => {
69
+ const env = import_dotenv.default.config({
70
+ path: process.env.HOME + "/.lightsparkapienv"
71
+ }).parsed || {};
72
+ const missingTestCredentials = Object.values(RequiredCredentials).filter(
73
+ (cred) => !env[cred]
74
+ );
75
+ if (missingTestCredentials.length) {
76
+ throw new Error(
77
+ `Missing test credentials. Please set ${missingTestCredentials.join(
78
+ ", "
79
+ )} environment variables.`
80
+ );
81
+ }
82
+ const apiTokenClientId = env["LIGHTSPARK_API_TOKEN_CLIENT_ID" /* ClientId */];
83
+ const apiTokenClientSecret = env["LIGHTSPARK_API_TOKEN_CLIENT_SECRET" /* ClientSecret */];
84
+ const bitcoinNetwork = getBitcoinNetworkOrThrow(
85
+ env["BITCOIN_NETWORK" /* BitcoinNetwork */]
86
+ );
87
+ const testNodePassword = "1234!@#$";
88
+ const baseUrl = env["LIGHTSPARK_BASE_URL"] || "api.lightspark.com";
89
+ return {
90
+ apiTokenClientId,
91
+ apiTokenClientSecret,
92
+ bitcoinNetwork,
93
+ testNodePassword,
94
+ baseUrl
95
+ };
96
+ };
97
+ // Annotate the CommonJS export names for ESM import in node:
98
+ 0 && (module.exports = {
99
+ RequiredCredentials,
100
+ getCredentialsFromEnvOrThrow
101
+ });
package/dist/env.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { B as BitcoinNetwork } from './BitcoinNetwork-a816c0be.js';
2
+
3
+ type EnvCredentials = {
4
+ apiTokenClientId: string;
5
+ apiTokenClientSecret: string;
6
+ bitcoinNetwork: BitcoinNetwork;
7
+ testNodePassword: string;
8
+ baseUrl: string;
9
+ };
10
+ declare enum RequiredCredentials {
11
+ ClientId = "LIGHTSPARK_API_TOKEN_CLIENT_ID",
12
+ ClientSecret = "LIGHTSPARK_API_TOKEN_CLIENT_SECRET",
13
+ BitcoinNetwork = "BITCOIN_NETWORK"
14
+ }
15
+ declare const getCredentialsFromEnvOrThrow: () => EnvCredentials;
16
+
17
+ export { EnvCredentials, RequiredCredentials, getCredentialsFromEnvOrThrow };
package/dist/env.js ADDED
@@ -0,0 +1,47 @@
1
+ import {
2
+ getBitcoinNetworkOrThrow
3
+ } from "./chunk-5RDIWPBE.js";
4
+ import "./chunk-K6SAUSAX.js";
5
+ import "./chunk-NIMBE7W3.js";
6
+
7
+ // src/env.ts
8
+ import dotenv from "dotenv";
9
+ var RequiredCredentials = /* @__PURE__ */ ((RequiredCredentials2) => {
10
+ RequiredCredentials2["ClientId"] = "LIGHTSPARK_API_TOKEN_CLIENT_ID";
11
+ RequiredCredentials2["ClientSecret"] = "LIGHTSPARK_API_TOKEN_CLIENT_SECRET";
12
+ RequiredCredentials2["BitcoinNetwork"] = "BITCOIN_NETWORK";
13
+ return RequiredCredentials2;
14
+ })(RequiredCredentials || {});
15
+ var getCredentialsFromEnvOrThrow = () => {
16
+ const env = dotenv.config({
17
+ path: process.env.HOME + "/.lightsparkapienv"
18
+ }).parsed || {};
19
+ const missingTestCredentials = Object.values(RequiredCredentials).filter(
20
+ (cred) => !env[cred]
21
+ );
22
+ if (missingTestCredentials.length) {
23
+ throw new Error(
24
+ `Missing test credentials. Please set ${missingTestCredentials.join(
25
+ ", "
26
+ )} environment variables.`
27
+ );
28
+ }
29
+ const apiTokenClientId = env["LIGHTSPARK_API_TOKEN_CLIENT_ID" /* ClientId */];
30
+ const apiTokenClientSecret = env["LIGHTSPARK_API_TOKEN_CLIENT_SECRET" /* ClientSecret */];
31
+ const bitcoinNetwork = getBitcoinNetworkOrThrow(
32
+ env["BITCOIN_NETWORK" /* BitcoinNetwork */]
33
+ );
34
+ const testNodePassword = "1234!@#$";
35
+ const baseUrl = env["LIGHTSPARK_BASE_URL"] || "api.lightspark.com";
36
+ return {
37
+ apiTokenClientId,
38
+ apiTokenClientSecret,
39
+ bitcoinNetwork,
40
+ testNodePassword,
41
+ baseUrl
42
+ };
43
+ };
44
+ export {
45
+ RequiredCredentials,
46
+ getCredentialsFromEnvOrThrow
47
+ };
@@ -1,5 +1,6 @@
1
1
  import { Maybe, Query, AuthProvider, CryptoInterface, SigningKey, KeyOrAliasType } from '@lightsparkdev/core';
2
2
  import Observable from 'zen-observable';
3
+ import { B as BitcoinNetwork } from './BitcoinNetwork-a816c0be.js';
3
4
 
4
5
  /** This enum identifies the unit of currency associated with a CurrencyAmount. **/
5
6
  declare enum CurrencyUnit {
@@ -321,23 +322,6 @@ declare class AccountToChannelsConnection {
321
322
  constructor(count: number, entities: Channel[]);
322
323
  }
323
324
 
324
- /** This is an enum identifying a particular Bitcoin Network. **/
325
- declare enum BitcoinNetwork {
326
- /**
327
- * This is an enum value that represents values that could be added in the future.
328
- * Clients should support unknown values as more of them could be added without notice.
329
- */
330
- FUTURE_VALUE = "FUTURE_VALUE",
331
- /** The production version of the Bitcoin Blockchain. **/
332
- MAINNET = "MAINNET",
333
- /** A test version of the Bitcoin Blockchain, maintained by Lightspark. **/
334
- REGTEST = "REGTEST",
335
- /** A test version of the Bitcoin Blockchain, maintained by a centralized organization. Not in use at Lightspark. **/
336
- SIGNET = "SIGNET",
337
- /** A test version of the Bitcoin Blockchain, publicly available. **/
338
- TESTNET = "TESTNET"
339
- }
340
-
341
325
  /** This is an object representing a detailed breakdown of the balance for a Lightspark Node. **/
342
326
  type BlockchainBalance = {
343
327
  /** The total wallet balance, including unconfirmed UTXOs. **/
@@ -2309,4 +2293,4 @@ type Withdrawal = OnChainTransaction & Transaction & Entity & {
2309
2293
  };
2310
2294
  declare const getWithdrawalQuery: (id: string) => Query<Withdrawal>;
2311
2295
 
2312
- export { IncomingPayment as $, Account as A, Balances as B, Channel as C, CreateTestModeInvoiceInput as D, CreateTestModeInvoiceOutput as E, CreateTestModePaymentInput as F, CreateTestModePaymentoutput as G, CreateUmaInvoiceInput as H, CurrencyAmount as I, CurrencyUnit as J, DeclineToSignMessagesInput as K, LightsparkClient as L, DeclineToSignMessagesOutput as M, DeleteApiTokenInput as N, DeleteApiTokenOutput as O, Deposit as P, getDepositQuery as Q, Entity as R, FeeEstimate as S, FundNodeInput as T, FundNodeOutput as U, GraphNode as V, WebhookEventType as W, Hop as X, getHopQuery as Y, HtlcAttemptFailureCode as Z, IdAndSignature as _, AccountToApiTokensConnection as a, SendPaymentOutput as a$, IncomingPaymentAttempt as a0, getIncomingPaymentAttemptQuery as a1, IncomingPaymentAttemptStatus as a2, IncomingPaymentToAttemptsConnection as a3, Invoice as a4, getInvoiceQuery as a5, InvoiceData as a6, InvoiceType as a7, LightningFeeEstimateForInvoiceInput as a8, LightningFeeEstimateForNodeInput as a9, PaymentDirection as aA, PaymentFailureReason as aB, PaymentRequest as aC, getPaymentRequestQuery as aD, PaymentRequestData as aE, PaymentRequestStatus as aF, PayUmaInvoiceInput as aG, Permission as aH, PostTransactionData as aI, RegisterPaymentInput as aJ, RegisterPaymentOutput as aK, ReleaseChannelPerCommitmentSecretInput as aL, ReleaseChannelPerCommitmentSecretOutput as aM, ReleasePaymentPreimageInput as aN, ReleasePaymentPreimageOutput as aO, RemoteSigningSubEventType as aP, RequestWithdrawalInput as aQ, RequestWithdrawalOutput as aR, RichText as aS, RiskRating as aT, RoutingTransaction as aU, getRoutingTransactionQuery as aV, RoutingTransactionFailureReason as aW, ScreenNodeInput as aX, ScreenNodeOutput as aY, Secret as aZ, SendPaymentInput as a_, LightningFeeEstimateOutput as aa, LightningTransaction as ab, getLightningTransactionQuery as ac, LightsparkNode as ad, LightsparkNodeOwner as ae, getLightsparkNodeOwnerQuery as af, LightsparkNodeStatus as ag, LightsparkNodeToChannelsConnection as ah, LightsparkNodeWithOSK as ai, LightsparkNodeWithRemoteSigning as aj, Node as ak, NodeAddress as al, NodeAddressType as am, NodeToAddressesConnection as an, OnChainTransaction as ao, getOnChainTransactionQuery as ap, OutgoingPayment as aq, OutgoingPaymentAttempt as ar, OutgoingPaymentAttemptStatus as as, OutgoingPaymentAttemptToHopsConnection as at, OutgoingPaymentsForInvoiceQueryInput as au, OutgoingPaymentsForInvoiceQueryOutput as av, OutgoingPaymentToAttemptsConnection as aw, PageInfo as ax, PayInvoiceInput as ay, PayInvoiceOutput as az, AccountToChannelsConnection as b, SetInvoicePaymentHashInput as b0, SetInvoicePaymentHashOutput as b1, Signable as b2, getSignableQuery as b3, SignablePayload as b4, getSignablePayloadQuery as b5, SignablePayloadStatus as b6, SignInvoiceInput as b7, SignInvoiceOutput as b8, SignMessagesInput as b9, SignMessagesOutput as ba, SingleNodeDashboard as bb, Transaction as bc, getTransactionQuery as bd, TransactionFailures as be, TransactionStatus as bf, TransactionType as bg, TransactionUpdate as bh, UpdateChannelPerCommitmentPointInput as bi, UpdateChannelPerCommitmentPointOutput as bj, UpdateNodeSharedSecretInput as bk, UpdateNodeSharedSecretOutput as bl, Wallet as bm, WalletStatus as bn, WalletToPaymentRequestsConnection as bo, WalletToTransactionsConnection as bp, Withdrawal as bq, getWithdrawalQuery as br, WithdrawalMode as bs, WithdrawalRequest as bt, WithdrawalRequestStatus as bu, WithdrawalRequestToChannelClosingTransactionsConnection as bv, WithdrawalRequestToChannelOpeningTransactionsConnection as bw, AccountToNodesConnection as c, AccountToPaymentRequestsConnection as d, AccountToTransactionsConnection as e, AccountToWalletsConnection as f, ApiToken as g, getApiTokenQuery as h, BitcoinNetwork as i, BlockchainBalance as j, ChannelClosingTransaction as k, getChannelClosingTransactionQuery as l, ChannelFees as m, ChannelOpeningTransaction as n, getChannelOpeningTransactionQuery as o, ChannelStatus as p, ChannelToTransactionsConnection as q, ComplianceProvider as r, Connection as s, CreateApiTokenInput as t, CreateApiTokenOutput as u, CreateInvoiceInput as v, CreateInvoiceOutput as w, CreateLnurlInvoiceInput as x, CreateNodeWalletAddressInput as y, CreateNodeWalletAddressOutput as z };
2296
+ export { IncomingPaymentAttempt as $, Account as A, Balances as B, Channel as C, CreateTestModeInvoiceOutput as D, CreateTestModePaymentInput as E, CreateTestModePaymentoutput as F, CreateUmaInvoiceInput as G, CurrencyAmount as H, CurrencyUnit as I, DeclineToSignMessagesInput as J, DeclineToSignMessagesOutput as K, LightsparkClient as L, DeleteApiTokenInput as M, DeleteApiTokenOutput as N, Deposit as O, getDepositQuery as P, Entity as Q, FeeEstimate as R, FundNodeInput as S, FundNodeOutput as T, GraphNode as U, Hop as V, WebhookEventType as W, getHopQuery as X, HtlcAttemptFailureCode as Y, IdAndSignature as Z, IncomingPayment as _, AccountToApiTokensConnection as a, SetInvoicePaymentHashInput as a$, getIncomingPaymentAttemptQuery as a0, IncomingPaymentAttemptStatus as a1, IncomingPaymentToAttemptsConnection as a2, Invoice as a3, getInvoiceQuery as a4, InvoiceData as a5, InvoiceType as a6, LightningFeeEstimateForInvoiceInput as a7, LightningFeeEstimateForNodeInput as a8, LightningFeeEstimateOutput as a9, PaymentFailureReason as aA, PaymentRequest as aB, getPaymentRequestQuery as aC, PaymentRequestData as aD, PaymentRequestStatus as aE, PayUmaInvoiceInput as aF, Permission as aG, PostTransactionData as aH, RegisterPaymentInput as aI, RegisterPaymentOutput as aJ, ReleaseChannelPerCommitmentSecretInput as aK, ReleaseChannelPerCommitmentSecretOutput as aL, ReleasePaymentPreimageInput as aM, ReleasePaymentPreimageOutput as aN, RemoteSigningSubEventType as aO, RequestWithdrawalInput as aP, RequestWithdrawalOutput as aQ, RichText as aR, RiskRating as aS, RoutingTransaction as aT, getRoutingTransactionQuery as aU, RoutingTransactionFailureReason as aV, ScreenNodeInput as aW, ScreenNodeOutput as aX, Secret as aY, SendPaymentInput as aZ, SendPaymentOutput as a_, LightningTransaction as aa, getLightningTransactionQuery as ab, LightsparkNode as ac, LightsparkNodeOwner as ad, getLightsparkNodeOwnerQuery as ae, LightsparkNodeStatus as af, LightsparkNodeToChannelsConnection as ag, LightsparkNodeWithOSK as ah, LightsparkNodeWithRemoteSigning as ai, Node as aj, NodeAddress as ak, NodeAddressType as al, NodeToAddressesConnection as am, OnChainTransaction as an, getOnChainTransactionQuery as ao, OutgoingPayment as ap, OutgoingPaymentAttempt as aq, OutgoingPaymentAttemptStatus as ar, OutgoingPaymentAttemptToHopsConnection as as, OutgoingPaymentsForInvoiceQueryInput as at, OutgoingPaymentsForInvoiceQueryOutput as au, OutgoingPaymentToAttemptsConnection as av, PageInfo as aw, PayInvoiceInput as ax, PayInvoiceOutput as ay, PaymentDirection as az, AccountToChannelsConnection as b, SetInvoicePaymentHashOutput as b0, Signable as b1, getSignableQuery as b2, SignablePayload as b3, getSignablePayloadQuery as b4, SignablePayloadStatus as b5, SignInvoiceInput as b6, SignInvoiceOutput as b7, SignMessagesInput as b8, SignMessagesOutput as b9, SingleNodeDashboard as ba, Transaction as bb, getTransactionQuery as bc, TransactionFailures as bd, TransactionStatus as be, TransactionType as bf, TransactionUpdate as bg, UpdateChannelPerCommitmentPointInput as bh, UpdateChannelPerCommitmentPointOutput as bi, UpdateNodeSharedSecretInput as bj, UpdateNodeSharedSecretOutput as bk, Wallet as bl, WalletStatus as bm, WalletToPaymentRequestsConnection as bn, WalletToTransactionsConnection as bo, Withdrawal as bp, getWithdrawalQuery as bq, WithdrawalMode as br, WithdrawalRequest as bs, WithdrawalRequestStatus as bt, WithdrawalRequestToChannelClosingTransactionsConnection as bu, WithdrawalRequestToChannelOpeningTransactionsConnection as bv, AccountToNodesConnection as c, AccountToPaymentRequestsConnection as d, AccountToTransactionsConnection as e, AccountToWalletsConnection as f, ApiToken as g, getApiTokenQuery as h, BlockchainBalance as i, ChannelClosingTransaction as j, getChannelClosingTransactionQuery as k, ChannelFees as l, ChannelOpeningTransaction as m, getChannelOpeningTransactionQuery as n, ChannelStatus as o, ChannelToTransactionsConnection as p, ComplianceProvider as q, Connection as r, CreateApiTokenInput as s, CreateApiTokenOutput as t, CreateInvoiceInput as u, CreateInvoiceOutput as v, CreateLnurlInvoiceInput as w, CreateNodeWalletAddressInput as x, CreateNodeWalletAddressOutput as y, CreateTestModeInvoiceInput as z };
package/dist/index.cjs CHANGED
@@ -1877,7 +1877,9 @@ __export(src_exports, {
1877
1877
  WithdrawalMode: () => WithdrawalMode_default,
1878
1878
  WithdrawalRequest: () => WithdrawalRequest_default,
1879
1879
  WithdrawalRequestStatus: () => WithdrawalRequestStatus_default,
1880
+ assertValidBitcoinNetwork: () => assertValidBitcoinNetwork,
1880
1881
  getApiTokenQuery: () => getApiTokenQuery,
1882
+ getBitcoinNetworkOrThrow: () => getBitcoinNetworkOrThrow,
1881
1883
  getChannelClosingTransactionQuery: () => getChannelClosingTransactionQuery,
1882
1884
  getChannelOpeningTransactionQuery: () => getChannelOpeningTransactionQuery,
1883
1885
  getDepositQuery: () => getDepositQuery,
@@ -1893,6 +1895,7 @@ __export(src_exports, {
1893
1895
  getSignableQuery: () => getSignableQuery,
1894
1896
  getTransactionQuery: () => getTransactionQuery,
1895
1897
  getWithdrawalQuery: () => getWithdrawalQuery,
1898
+ isBitcoinNetwork: () => isBitcoinNetwork,
1896
1899
  verifyAndParseWebhook: () => verifyAndParseWebhook
1897
1900
  });
1898
1901
  module.exports = __toCommonJS(src_exports);
@@ -1935,7 +1938,7 @@ var import_crypto = require("crypto");
1935
1938
  // package.json
1936
1939
  var package_default = {
1937
1940
  name: "@lightsparkdev/lightspark-sdk",
1938
- version: "1.0.0",
1941
+ version: "1.0.1",
1939
1942
  description: "Lightspark JS SDK",
1940
1943
  author: "Lightspark Inc.",
1941
1944
  keywords: [
@@ -1976,6 +1979,16 @@ var package_default = {
1976
1979
  module: "./dist/objects/index.js",
1977
1980
  require: "./dist/objects/index.cjs",
1978
1981
  default: "./dist/objects/index.cjs"
1982
+ },
1983
+ "./env": {
1984
+ types: "./dist/env.d.ts",
1985
+ import: {
1986
+ types: "./dist/env.d.ts",
1987
+ default: "./dist/env.js"
1988
+ },
1989
+ module: "./dist/env.js",
1990
+ require: "./dist/env.cjs",
1991
+ default: "./dist/env.cjs"
1979
1992
  }
1980
1993
  },
1981
1994
  type: "module",
@@ -1993,7 +2006,7 @@ var package_default = {
1993
2006
  "CHANGELOG.md"
1994
2007
  ],
1995
2008
  scripts: {
1996
- build: "tsup",
2009
+ build: "yarn tsc && tsup",
1997
2010
  clean: "rm -rf .turbo && rm -rf dist",
1998
2011
  dev: "yarn build -- --watch",
1999
2012
  docs: "typedoc src",
@@ -2010,11 +2023,12 @@ var package_default = {
2010
2023
  },
2011
2024
  license: "Apache-2.0",
2012
2025
  dependencies: {
2013
- "@lightsparkdev/core": "1.0.0",
2026
+ "@lightsparkdev/core": "1.0.1",
2014
2027
  "auto-bind": "^5.0.1",
2015
2028
  crypto: "^1.0.1",
2016
2029
  "crypto-browserify": "^3.12.0",
2017
2030
  dayjs: "^1.11.7",
2031
+ dotenv: "^16.3.1",
2018
2032
  graphql: "^16.6.0",
2019
2033
  "graphql-ws": "^5.11.3",
2020
2034
  ws: "^8.12.1",
@@ -6959,7 +6973,7 @@ var MasterSeedSigningKeyLoader = class {
6959
6973
 
6960
6974
  // src/NodeKeyLoaderCache.ts
6961
6975
  var NodeKeyLoaderCache = class {
6962
- constructor(nodeKeyCache, cryptoImpl = DefaultCrypto) {
6976
+ constructor(nodeKeyCache, cryptoImpl = import_core6.DefaultCrypto) {
6963
6977
  this.nodeKeyCache = nodeKeyCache;
6964
6978
  this.cryptoImpl = cryptoImpl;
6965
6979
  this.idToLoader = /* @__PURE__ */ new Map();
@@ -7008,11 +7022,12 @@ var NodeKeyLoaderCache = class {
7008
7022
  if (!loaderResult) {
7009
7023
  return;
7010
7024
  }
7011
- return this.nodeKeyCache.loadKey(
7025
+ const key = await this.nodeKeyCache.loadKey(
7012
7026
  id,
7013
7027
  { key: loaderResult.key },
7014
7028
  loaderResult.type
7015
7029
  );
7030
+ return key || void 0;
7016
7031
  }
7017
7032
  };
7018
7033
 
@@ -11150,6 +11165,28 @@ var LightsparkClient = class {
11150
11165
  };
11151
11166
  var client_default = LightsparkClient;
11152
11167
 
11168
+ // src/helpers.ts
11169
+ var BITCOIN_NETWORKS = [
11170
+ "MAINNET" /* MAINNET */,
11171
+ "TESTNET" /* TESTNET */,
11172
+ "SIGNET" /* SIGNET */,
11173
+ "REGTEST" /* REGTEST */
11174
+ ];
11175
+ var isBitcoinNetwork = (bitcoinNetwork) => {
11176
+ return BITCOIN_NETWORKS.includes(bitcoinNetwork);
11177
+ };
11178
+ var assertValidBitcoinNetwork = (bitcoinNetwork) => {
11179
+ if (!isBitcoinNetwork(bitcoinNetwork)) {
11180
+ throw new Error(
11181
+ `Invalid bitcoin network ${bitcoinNetwork}. Valid networks: ${BITCOIN_NETWORKS}`
11182
+ );
11183
+ }
11184
+ };
11185
+ var getBitcoinNetworkOrThrow = (bitcoinNetwork) => {
11186
+ assertValidBitcoinNetwork(bitcoinNetwork.toUpperCase());
11187
+ return bitcoinNetwork;
11188
+ };
11189
+
11153
11190
  // src/objects/ComplianceProvider.ts
11154
11191
  var ComplianceProvider = /* @__PURE__ */ ((ComplianceProvider2) => {
11155
11192
  ComplianceProvider2["FUTURE_VALUE"] = "FUTURE_VALUE";
@@ -12373,7 +12410,9 @@ var parseWebhook = async (data) => {
12373
12410
  WithdrawalMode,
12374
12411
  WithdrawalRequest,
12375
12412
  WithdrawalRequestStatus,
12413
+ assertValidBitcoinNetwork,
12376
12414
  getApiTokenQuery,
12415
+ getBitcoinNetworkOrThrow,
12377
12416
  getChannelClosingTransactionQuery,
12378
12417
  getChannelOpeningTransactionQuery,
12379
12418
  getDepositQuery,
@@ -12389,5 +12428,6 @@ var parseWebhook = async (data) => {
12389
12428
  getSignableQuery,
12390
12429
  getTransactionQuery,
12391
12430
  getWithdrawalQuery,
12431
+ isBitcoinNetwork,
12392
12432
  verifyAndParseWebhook
12393
12433
  });
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { AuthProvider } from '@lightsparkdev/core';
2
- import { W as WebhookEventType } from './index-09d4ac20.js';
3
- export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BitcoinNetwork, j as BlockchainBalance, C as Channel, k as ChannelClosingTransaction, m as ChannelFees, n as ChannelOpeningTransaction, p as ChannelStatus, q as ChannelToTransactionsConnection, r as ComplianceProvider, s as Connection, t as CreateApiTokenInput, u as CreateApiTokenOutput, v as CreateInvoiceInput, w as CreateInvoiceOutput, x as CreateLnurlInvoiceInput, y as CreateNodeWalletAddressInput, z as CreateNodeWalletAddressOutput, D as CreateTestModeInvoiceInput, E as CreateTestModeInvoiceOutput, F as CreateTestModePaymentInput, G as CreateTestModePaymentoutput, H as CreateUmaInvoiceInput, I as CurrencyAmount, J as CurrencyUnit, K as DeclineToSignMessagesInput, M as DeclineToSignMessagesOutput, N as DeleteApiTokenInput, O as DeleteApiTokenOutput, P as Deposit, R as Entity, S as FeeEstimate, T as FundNodeInput, U as FundNodeOutput, V as GraphNode, X as Hop, Z as HtlcAttemptFailureCode, _ as IdAndSignature, $ as IncomingPayment, a0 as IncomingPaymentAttempt, a2 as IncomingPaymentAttemptStatus, a3 as IncomingPaymentToAttemptsConnection, a4 as Invoice, a6 as InvoiceData, a7 as InvoiceType, a8 as LightningFeeEstimateForInvoiceInput, a9 as LightningFeeEstimateForNodeInput, aa as LightningFeeEstimateOutput, ab as LightningTransaction, L as LightsparkClient, ad as LightsparkNode, ae as LightsparkNodeOwner, ag as LightsparkNodeStatus, ah as LightsparkNodeToChannelsConnection, ai as LightsparkNodeWithOSK, aj as LightsparkNodeWithRemoteSigning, ak as Node, al as NodeAddress, am as NodeAddressType, an as NodeToAddressesConnection, ao as OnChainTransaction, aq as OutgoingPayment, ar as OutgoingPaymentAttempt, as as OutgoingPaymentAttemptStatus, at as OutgoingPaymentAttemptToHopsConnection, aw as OutgoingPaymentToAttemptsConnection, au as OutgoingPaymentsForInvoiceQueryInput, av as OutgoingPaymentsForInvoiceQueryOutput, ax as PageInfo, ay as PayInvoiceInput, az as PayInvoiceOutput, aG as PayUmaInvoiceInput, aA as PaymentDirection, aB as PaymentFailureReason, aC as PaymentRequest, aE as PaymentRequestData, aF as PaymentRequestStatus, aH as Permission, aI as PostTransactionData, aJ as RegisterPaymentInput, aK as RegisterPaymentOutput, aL as ReleaseChannelPerCommitmentSecretInput, aM as ReleaseChannelPerCommitmentSecretOutput, aN as ReleasePaymentPreimageInput, aO as ReleasePaymentPreimageOutput, aP as RemoteSigningSubEventType, aQ as RequestWithdrawalInput, aR as RequestWithdrawalOutput, aS as RichText, aT as RiskRating, aU as RoutingTransaction, aW as RoutingTransactionFailureReason, aX as ScreenNodeInput, aY as ScreenNodeOutput, aZ as Secret, a_ as SendPaymentInput, a$ as SendPaymentOutput, b0 as SetInvoicePaymentHashInput, b1 as SetInvoicePaymentHashOutput, b7 as SignInvoiceInput, b8 as SignInvoiceOutput, b9 as SignMessagesInput, ba as SignMessagesOutput, b2 as Signable, b4 as SignablePayload, b6 as SignablePayloadStatus, bb as SingleNodeDashboard, bc as Transaction, be as TransactionFailures, bf as TransactionStatus, bg as TransactionType, bh as TransactionUpdate, bi as UpdateChannelPerCommitmentPointInput, bj as UpdateChannelPerCommitmentPointOutput, bk as UpdateNodeSharedSecretInput, bl as UpdateNodeSharedSecretOutput, bm as Wallet, bn as WalletStatus, bo as WalletToPaymentRequestsConnection, bp as WalletToTransactionsConnection, bq as Withdrawal, bs as WithdrawalMode, bt as WithdrawalRequest, bu as WithdrawalRequestStatus, bv as WithdrawalRequestToChannelClosingTransactionsConnection, bw as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, l as getChannelClosingTransactionQuery, o as getChannelOpeningTransactionQuery, Q as getDepositQuery, Y as getHopQuery, a1 as getIncomingPaymentAttemptQuery, a5 as getInvoiceQuery, ac as getLightningTransactionQuery, af as getLightsparkNodeOwnerQuery, ap as getOnChainTransactionQuery, aD as getPaymentRequestQuery, aV as getRoutingTransactionQuery, b5 as getSignablePayloadQuery, b3 as getSignableQuery, bd as getTransactionQuery, br as getWithdrawalQuery } from './index-09d4ac20.js';
2
+ import { W as WebhookEventType } from './index-dbf06298.js';
3
+ export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as AccountToWalletsConnection, g as ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, L as LightsparkClient, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from './index-dbf06298.js';
4
+ import { B as BitcoinNetwork } from './BitcoinNetwork-a816c0be.js';
4
5
  import 'zen-observable';
5
6
 
6
7
  declare class AccountTokenAuthProvider implements AuthProvider {
@@ -13,6 +14,10 @@ declare class AccountTokenAuthProvider implements AuthProvider {
13
14
  isAuthorized(): Promise<boolean>;
14
15
  }
15
16
 
17
+ declare const isBitcoinNetwork: (bitcoinNetwork: BitcoinNetwork) => boolean;
18
+ declare const assertValidBitcoinNetwork: (bitcoinNetwork: BitcoinNetwork) => void;
19
+ declare const getBitcoinNetworkOrThrow: (bitcoinNetwork: BitcoinNetwork) => BitcoinNetwork;
20
+
16
21
  declare const WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
17
22
  interface WebhookEvent {
18
23
  event_type: WebhookEventType;
@@ -23,4 +28,4 @@ interface WebhookEvent {
23
28
  }
24
29
  declare const verifyAndParseWebhook: (data: Uint8Array, hexdigest: string, webhook_secret: string) => Promise<WebhookEvent>;
25
30
 
26
- export { AccountTokenAuthProvider, WEBHOOKS_SIGNATURE_HEADER, WebhookEvent, WebhookEventType, verifyAndParseWebhook };
31
+ export { AccountTokenAuthProvider, BitcoinNetwork, WEBHOOKS_SIGNATURE_HEADER, WebhookEvent, WebhookEventType, assertValidBitcoinNetwork, getBitcoinNetworkOrThrow, isBitcoinNetwork, verifyAndParseWebhook };
package/dist/index.js CHANGED
@@ -1,8 +1,12 @@
1
+ import {
2
+ assertValidBitcoinNetwork,
3
+ getBitcoinNetworkOrThrow,
4
+ isBitcoinNetwork
5
+ } from "./chunk-5RDIWPBE.js";
1
6
  import {
2
7
  AccountToChannelsConnection_default,
3
8
  Account_default,
4
9
  ApiTokenFromJson,
5
- BitcoinNetwork_default,
6
10
  ChannelStatus_default,
7
11
  Channel_default,
8
12
  ComplianceProvider_default,
@@ -72,7 +76,10 @@ import {
72
76
  getSignableQuery,
73
77
  getTransactionQuery,
74
78
  getWithdrawalQuery
75
- } from "./chunk-LZC5C5NI.js";
79
+ } from "./chunk-K2ZU5YQL.js";
80
+ import {
81
+ BitcoinNetwork_default
82
+ } from "./chunk-K6SAUSAX.js";
76
83
  import "./chunk-NIMBE7W3.js";
77
84
 
78
85
  // src/auth/AccountTokenAuthProvider.ts
@@ -122,7 +129,7 @@ import { createHash } from "crypto";
122
129
  // package.json
123
130
  var package_default = {
124
131
  name: "@lightsparkdev/lightspark-sdk",
125
- version: "1.0.0",
132
+ version: "1.0.1",
126
133
  description: "Lightspark JS SDK",
127
134
  author: "Lightspark Inc.",
128
135
  keywords: [
@@ -163,6 +170,16 @@ var package_default = {
163
170
  module: "./dist/objects/index.js",
164
171
  require: "./dist/objects/index.cjs",
165
172
  default: "./dist/objects/index.cjs"
173
+ },
174
+ "./env": {
175
+ types: "./dist/env.d.ts",
176
+ import: {
177
+ types: "./dist/env.d.ts",
178
+ default: "./dist/env.js"
179
+ },
180
+ module: "./dist/env.js",
181
+ require: "./dist/env.cjs",
182
+ default: "./dist/env.cjs"
166
183
  }
167
184
  },
168
185
  type: "module",
@@ -180,7 +197,7 @@ var package_default = {
180
197
  "CHANGELOG.md"
181
198
  ],
182
199
  scripts: {
183
- build: "tsup",
200
+ build: "yarn tsc && tsup",
184
201
  clean: "rm -rf .turbo && rm -rf dist",
185
202
  dev: "yarn build -- --watch",
186
203
  docs: "typedoc src",
@@ -197,11 +214,12 @@ var package_default = {
197
214
  },
198
215
  license: "Apache-2.0",
199
216
  dependencies: {
200
- "@lightsparkdev/core": "1.0.0",
217
+ "@lightsparkdev/core": "1.0.1",
201
218
  "auto-bind": "^5.0.1",
202
219
  crypto: "^1.0.1",
203
220
  "crypto-browserify": "^3.12.0",
204
221
  dayjs: "^1.11.7",
222
+ dotenv: "^16.3.1",
205
223
  graphql: "^16.6.0",
206
224
  "graphql-ws": "^5.11.3",
207
225
  ws: "^8.12.1",
@@ -801,6 +819,7 @@ ${FRAGMENT10}
801
819
 
802
820
  // src/NodeKeyLoaderCache.ts
803
821
  import {
822
+ DefaultCrypto,
804
823
  LightsparkSigningException as LightsparkSigningException2
805
824
  } from "@lightsparkdev/core";
806
825
 
@@ -968,11 +987,12 @@ var NodeKeyLoaderCache = class {
968
987
  if (!loaderResult) {
969
988
  return;
970
989
  }
971
- return this.nodeKeyCache.loadKey(
990
+ const key = await this.nodeKeyCache.loadKey(
972
991
  id,
973
992
  { key: loaderResult.key },
974
993
  loaderResult.type
975
994
  );
995
+ return key || void 0;
976
996
  }
977
997
  };
978
998
 
@@ -1764,7 +1784,9 @@ export {
1764
1784
  WithdrawalMode_default as WithdrawalMode,
1765
1785
  WithdrawalRequest_default as WithdrawalRequest,
1766
1786
  WithdrawalRequestStatus_default as WithdrawalRequestStatus,
1787
+ assertValidBitcoinNetwork,
1767
1788
  getApiTokenQuery,
1789
+ getBitcoinNetworkOrThrow,
1768
1790
  getChannelClosingTransactionQuery,
1769
1791
  getChannelOpeningTransactionQuery,
1770
1792
  getDepositQuery,
@@ -1780,5 +1802,6 @@ export {
1780
1802
  getSignableQuery,
1781
1803
  getTransactionQuery,
1782
1804
  getWithdrawalQuery,
1805
+ isBitcoinNetwork,
1783
1806
  verifyAndParseWebhook
1784
1807
  };
@@ -1,3 +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 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 ComplianceProvider, s as Connection, t as CreateApiTokenInput, u as CreateApiTokenOutput, v as CreateInvoiceInput, w as CreateInvoiceOutput, x as CreateLnurlInvoiceInput, y as CreateNodeWalletAddressInput, z as CreateNodeWalletAddressOutput, D as CreateTestModeInvoiceInput, E as CreateTestModeInvoiceOutput, F as CreateTestModePaymentInput, G as CreateTestModePaymentoutput, H as CreateUmaInvoiceInput, I as CurrencyAmount, J as CurrencyUnit, K as DeclineToSignMessagesInput, M as DeclineToSignMessagesOutput, N as DeleteApiTokenInput, O as DeleteApiTokenOutput, P as Deposit, R as Entity, S as FeeEstimate, T as FundNodeInput, U as FundNodeOutput, V as GraphNode, X as Hop, Z as HtlcAttemptFailureCode, _ as IdAndSignature, $ as IncomingPayment, a0 as IncomingPaymentAttempt, a2 as IncomingPaymentAttemptStatus, a3 as IncomingPaymentToAttemptsConnection, a4 as Invoice, a6 as InvoiceData, a7 as InvoiceType, a8 as LightningFeeEstimateForInvoiceInput, a9 as LightningFeeEstimateForNodeInput, aa as LightningFeeEstimateOutput, ab as LightningTransaction, ad as LightsparkNode, ae as LightsparkNodeOwner, ag as LightsparkNodeStatus, ah as LightsparkNodeToChannelsConnection, ai as LightsparkNodeWithOSK, aj as LightsparkNodeWithRemoteSigning, ak as Node, al as NodeAddress, am as NodeAddressType, an as NodeToAddressesConnection, ao as OnChainTransaction, aq as OutgoingPayment, ar as OutgoingPaymentAttempt, as as OutgoingPaymentAttemptStatus, at as OutgoingPaymentAttemptToHopsConnection, aw as OutgoingPaymentToAttemptsConnection, au as OutgoingPaymentsForInvoiceQueryInput, av as OutgoingPaymentsForInvoiceQueryOutput, ax as PageInfo, ay as PayInvoiceInput, az as PayInvoiceOutput, aG as PayUmaInvoiceInput, aA as PaymentDirection, aB as PaymentFailureReason, aC as PaymentRequest, aE as PaymentRequestData, aF as PaymentRequestStatus, aH as Permission, aI as PostTransactionData, aJ as RegisterPaymentInput, aK as RegisterPaymentOutput, aL as ReleaseChannelPerCommitmentSecretInput, aM as ReleaseChannelPerCommitmentSecretOutput, aN as ReleasePaymentPreimageInput, aO as ReleasePaymentPreimageOutput, aP as RemoteSigningSubEventType, aQ as RequestWithdrawalInput, aR as RequestWithdrawalOutput, aS as RichText, aT as RiskRating, aU as RoutingTransaction, aW as RoutingTransactionFailureReason, aX as ScreenNodeInput, aY as ScreenNodeOutput, aZ as Secret, a_ as SendPaymentInput, a$ as SendPaymentOutput, b0 as SetInvoicePaymentHashInput, b1 as SetInvoicePaymentHashOutput, b7 as SignInvoiceInput, b8 as SignInvoiceOutput, b9 as SignMessagesInput, ba as SignMessagesOutput, b2 as Signable, b4 as SignablePayload, b6 as SignablePayloadStatus, bb as SingleNodeDashboard, bc as Transaction, be as TransactionFailures, bf as TransactionStatus, bg as TransactionType, bh as TransactionUpdate, bi as UpdateChannelPerCommitmentPointInput, bj as UpdateChannelPerCommitmentPointOutput, bk as UpdateNodeSharedSecretInput, bl as UpdateNodeSharedSecretOutput, bm as Wallet, bn as WalletStatus, bo as WalletToPaymentRequestsConnection, bp as WalletToTransactionsConnection, W as WebhookEventType, bq as Withdrawal, bs as WithdrawalMode, bt as WithdrawalRequest, bu as WithdrawalRequestStatus, bv as WithdrawalRequestToChannelClosingTransactionsConnection, bw as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, l as getChannelClosingTransactionQuery, o as getChannelOpeningTransactionQuery, Q as getDepositQuery, Y as getHopQuery, a1 as getIncomingPaymentAttemptQuery, a5 as getInvoiceQuery, ac as getLightningTransactionQuery, af as getLightsparkNodeOwnerQuery, ap as getOnChainTransactionQuery, aD as getPaymentRequestQuery, aV as getRoutingTransactionQuery, b5 as getSignablePayloadQuery, b3 as getSignableQuery, bd as getTransactionQuery, br as getWithdrawalQuery } from '../index-09d4ac20.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 ApiToken, B as Balances, i as BlockchainBalance, C as Channel, j as ChannelClosingTransaction, l as ChannelFees, m as ChannelOpeningTransaction, o as ChannelStatus, p as ChannelToTransactionsConnection, q as ComplianceProvider, r as Connection, s as CreateApiTokenInput, t as CreateApiTokenOutput, u as CreateInvoiceInput, v as CreateInvoiceOutput, w as CreateLnurlInvoiceInput, x as CreateNodeWalletAddressInput, y as CreateNodeWalletAddressOutput, z as CreateTestModeInvoiceInput, D as CreateTestModeInvoiceOutput, E as CreateTestModePaymentInput, F as CreateTestModePaymentoutput, G as CreateUmaInvoiceInput, H as CurrencyAmount, I as CurrencyUnit, J as DeclineToSignMessagesInput, K as DeclineToSignMessagesOutput, M as DeleteApiTokenInput, N as DeleteApiTokenOutput, O as Deposit, Q as Entity, R as FeeEstimate, S as FundNodeInput, T as FundNodeOutput, U as GraphNode, V as Hop, Y as HtlcAttemptFailureCode, Z as IdAndSignature, _ as IncomingPayment, $ as IncomingPaymentAttempt, a1 as IncomingPaymentAttemptStatus, a2 as IncomingPaymentToAttemptsConnection, a3 as Invoice, a5 as InvoiceData, a6 as InvoiceType, a7 as LightningFeeEstimateForInvoiceInput, a8 as LightningFeeEstimateForNodeInput, a9 as LightningFeeEstimateOutput, aa as LightningTransaction, ac as LightsparkNode, ad as LightsparkNodeOwner, af as LightsparkNodeStatus, ag as LightsparkNodeToChannelsConnection, ah as LightsparkNodeWithOSK, ai as LightsparkNodeWithRemoteSigning, aj as Node, ak as NodeAddress, al as NodeAddressType, am as NodeToAddressesConnection, an as OnChainTransaction, ap as OutgoingPayment, aq as OutgoingPaymentAttempt, ar as OutgoingPaymentAttemptStatus, as as OutgoingPaymentAttemptToHopsConnection, av as OutgoingPaymentToAttemptsConnection, at as OutgoingPaymentsForInvoiceQueryInput, au as OutgoingPaymentsForInvoiceQueryOutput, aw as PageInfo, ax as PayInvoiceInput, ay as PayInvoiceOutput, aF as PayUmaInvoiceInput, az as PaymentDirection, aA as PaymentFailureReason, aB as PaymentRequest, aD as PaymentRequestData, aE as PaymentRequestStatus, aG as Permission, aH as PostTransactionData, aI as RegisterPaymentInput, aJ as RegisterPaymentOutput, aK as ReleaseChannelPerCommitmentSecretInput, aL as ReleaseChannelPerCommitmentSecretOutput, aM as ReleasePaymentPreimageInput, aN as ReleasePaymentPreimageOutput, aO as RemoteSigningSubEventType, aP as RequestWithdrawalInput, aQ as RequestWithdrawalOutput, aR as RichText, aS as RiskRating, aT as RoutingTransaction, aV as RoutingTransactionFailureReason, aW as ScreenNodeInput, aX as ScreenNodeOutput, aY as Secret, aZ as SendPaymentInput, a_ as SendPaymentOutput, a$ as SetInvoicePaymentHashInput, b0 as SetInvoicePaymentHashOutput, b6 as SignInvoiceInput, b7 as SignInvoiceOutput, b8 as SignMessagesInput, b9 as SignMessagesOutput, b1 as Signable, b3 as SignablePayload, b5 as SignablePayloadStatus, ba as SingleNodeDashboard, bb as Transaction, bd as TransactionFailures, be as TransactionStatus, bf as TransactionType, bg as TransactionUpdate, bh as UpdateChannelPerCommitmentPointInput, bi as UpdateChannelPerCommitmentPointOutput, bj as UpdateNodeSharedSecretInput, bk as UpdateNodeSharedSecretOutput, bl as Wallet, bm as WalletStatus, bn as WalletToPaymentRequestsConnection, bo as WalletToTransactionsConnection, W as WebhookEventType, bp as Withdrawal, br as WithdrawalMode, bs as WithdrawalRequest, bt as WithdrawalRequestStatus, bu as WithdrawalRequestToChannelClosingTransactionsConnection, bv as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, k as getChannelClosingTransactionQuery, n as getChannelOpeningTransactionQuery, P as getDepositQuery, X as getHopQuery, a0 as getIncomingPaymentAttemptQuery, a4 as getInvoiceQuery, ab as getLightningTransactionQuery, ae as getLightsparkNodeOwnerQuery, ao as getOnChainTransactionQuery, aC as getPaymentRequestQuery, aU as getRoutingTransactionQuery, b4 as getSignablePayloadQuery, b2 as getSignableQuery, bc as getTransactionQuery, bq as getWithdrawalQuery } from '../index-dbf06298.js';
2
+ export { B as BitcoinNetwork } from '../BitcoinNetwork-a816c0be.js';
2
3
  import '@lightsparkdev/core';
3
4
  import 'zen-observable';
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  AccountToChannelsConnection_default,
3
3
  Account_default,
4
- BitcoinNetwork_default,
5
4
  ChannelStatus_default,
6
5
  Channel_default,
7
6
  ComplianceProvider_default,
@@ -52,7 +51,10 @@ import {
52
51
  getSignableQuery,
53
52
  getTransactionQuery,
54
53
  getWithdrawalQuery
55
- } from "../chunk-LZC5C5NI.js";
54
+ } from "../chunk-K2ZU5YQL.js";
55
+ import {
56
+ BitcoinNetwork_default
57
+ } from "../chunk-K6SAUSAX.js";
56
58
  import "../chunk-NIMBE7W3.js";
57
59
  export {
58
60
  Account_default as Account,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/lightspark-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -41,6 +41,16 @@
41
41
  "module": "./dist/objects/index.js",
42
42
  "require": "./dist/objects/index.cjs",
43
43
  "default": "./dist/objects/index.cjs"
44
+ },
45
+ "./env": {
46
+ "types": "./dist/env.d.ts",
47
+ "import": {
48
+ "types": "./dist/env.d.ts",
49
+ "default": "./dist/env.js"
50
+ },
51
+ "module": "./dist/env.js",
52
+ "require": "./dist/env.cjs",
53
+ "default": "./dist/env.cjs"
44
54
  }
45
55
  },
46
56
  "type": "module",
@@ -58,7 +68,7 @@
58
68
  "CHANGELOG.md"
59
69
  ],
60
70
  "scripts": {
61
- "build": "tsup",
71
+ "build": "yarn tsc && tsup",
62
72
  "clean": "rm -rf .turbo && rm -rf dist",
63
73
  "dev": "yarn build -- --watch",
64
74
  "docs": "typedoc src",
@@ -75,11 +85,12 @@
75
85
  },
76
86
  "license": "Apache-2.0",
77
87
  "dependencies": {
78
- "@lightsparkdev/core": "1.0.0",
88
+ "@lightsparkdev/core": "1.0.1",
79
89
  "auto-bind": "^5.0.1",
80
90
  "crypto": "^1.0.1",
81
91
  "crypto-browserify": "^3.12.0",
82
92
  "dayjs": "^1.11.7",
93
+ "dotenv": "^16.3.1",
83
94
  "graphql": "^16.6.0",
84
95
  "graphql-ws": "^5.11.3",
85
96
  "ws": "^8.12.1",
@@ -1,4 +1,5 @@
1
1
  import {
2
+ DefaultCrypto,
2
3
  LightsparkSigningException,
3
4
  type CryptoInterface,
4
5
  type NodeKeyCache,
@@ -78,10 +79,11 @@ export default class NodeKeyLoaderCache {
78
79
  return;
79
80
  }
80
81
 
81
- return this.nodeKeyCache.loadKey(
82
+ const key = await this.nodeKeyCache.loadKey(
82
83
  id,
83
84
  { key: loaderResult.key },
84
85
  loaderResult.type,
85
86
  );
87
+ return key || undefined;
86
88
  }
87
89
  }
package/src/env.ts ADDED
@@ -0,0 +1,54 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ /* These utils are only needed in NodeJS contexts and so the file is exported separately
4
+ in the package to avoid eg unnecessary browser bundling */
5
+ import dotenv from "dotenv";
6
+ import { getBitcoinNetworkOrThrow } from "./helpers.js";
7
+ import { type BitcoinNetwork } from "./objects/BitcoinNetwork.js";
8
+
9
+ export type EnvCredentials = {
10
+ apiTokenClientId: string;
11
+ apiTokenClientSecret: string;
12
+ bitcoinNetwork: BitcoinNetwork;
13
+ testNodePassword: string;
14
+ baseUrl: string;
15
+ };
16
+
17
+ export enum RequiredCredentials {
18
+ ClientId = "LIGHTSPARK_API_TOKEN_CLIENT_ID",
19
+ ClientSecret = "LIGHTSPARK_API_TOKEN_CLIENT_SECRET",
20
+ BitcoinNetwork = "BITCOIN_NETWORK",
21
+ }
22
+
23
+ export const getCredentialsFromEnvOrThrow = (): EnvCredentials => {
24
+ const env =
25
+ dotenv.config({
26
+ path: process.env.HOME + "/.lightsparkapienv",
27
+ }).parsed || {};
28
+
29
+ const missingTestCredentials = Object.values(RequiredCredentials).filter(
30
+ (cred) => !env[cred],
31
+ );
32
+ if (missingTestCredentials.length) {
33
+ throw new Error(
34
+ `Missing test credentials. Please set ${missingTestCredentials.join(
35
+ ", ",
36
+ )} environment variables.`,
37
+ );
38
+ }
39
+
40
+ const apiTokenClientId = env[RequiredCredentials.ClientId]!;
41
+ const apiTokenClientSecret = env[RequiredCredentials.ClientSecret]!;
42
+ const bitcoinNetwork = getBitcoinNetworkOrThrow(
43
+ env[RequiredCredentials.BitcoinNetwork]! as BitcoinNetwork,
44
+ );
45
+ const testNodePassword = "1234!@#$";
46
+ const baseUrl = env["LIGHTSPARK_BASE_URL"] || "api.lightspark.com";
47
+ return {
48
+ apiTokenClientId,
49
+ apiTokenClientSecret,
50
+ bitcoinNetwork,
51
+ testNodePassword,
52
+ baseUrl,
53
+ };
54
+ };
package/src/helpers.ts ADDED
@@ -0,0 +1,31 @@
1
+ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2
+
3
+ import { BitcoinNetwork } from "./objects/BitcoinNetwork.js";
4
+
5
+ const BITCOIN_NETWORKS = [
6
+ BitcoinNetwork.MAINNET,
7
+ BitcoinNetwork.TESTNET,
8
+ BitcoinNetwork.SIGNET,
9
+ BitcoinNetwork.REGTEST,
10
+ ];
11
+
12
+ export const isBitcoinNetwork = (bitcoinNetwork: BitcoinNetwork) => {
13
+ return BITCOIN_NETWORKS.includes(bitcoinNetwork);
14
+ };
15
+
16
+ export const assertValidBitcoinNetwork = (
17
+ bitcoinNetwork: BitcoinNetwork,
18
+ ): void => {
19
+ if (!isBitcoinNetwork(bitcoinNetwork)) {
20
+ throw new Error(
21
+ `Invalid bitcoin network ${bitcoinNetwork}. Valid networks: ${BITCOIN_NETWORKS}`,
22
+ );
23
+ }
24
+ };
25
+
26
+ export const getBitcoinNetworkOrThrow = (
27
+ bitcoinNetwork: BitcoinNetwork,
28
+ ): BitcoinNetwork => {
29
+ assertValidBitcoinNetwork(bitcoinNetwork.toUpperCase() as BitcoinNetwork);
30
+ return bitcoinNetwork;
31
+ };
package/src/index.ts CHANGED
@@ -2,5 +2,6 @@
2
2
 
3
3
  export * from "./auth/index.js";
4
4
  export { default as LightsparkClient } from "./client.js";
5
+ export * from "./helpers.js";
5
6
  export * from "./objects/index.js";
6
7
  export * from "./webhooks.js";