@lightsparkdev/lightspark-sdk 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/BitcoinNetwork-a816c0be.d.ts +18 -0
- package/dist/chunk-5RDIWPBE.js +27 -0
- package/dist/{chunk-LZC5C5NI.js → chunk-K2ZU5YQL.js} +4 -12
- package/dist/chunk-K6SAUSAX.js +14 -0
- package/dist/env.cjs +101 -0
- package/dist/env.d.ts +17 -0
- package/dist/env.js +47 -0
- package/dist/{index-09d4ac20.d.ts → index-dbf06298.d.ts} +2 -18
- package/dist/index.cjs +70 -22
- package/dist/index.d.ts +8 -3
- package/dist/index.js +54 -25
- package/dist/objects/index.d.ts +2 -1
- package/dist/objects/index.js +4 -2
- package/package.json +15 -3
- package/src/NodeKeyLoaderCache.ts +3 -1
- package/src/SigningKeyLoader.ts +28 -20
- package/src/env.ts +54 -0
- package/src/helpers.ts +31 -0
- package/src/index.ts +1 -0
- package/src/lightspark_crypto/lightspark_crypto.d.ts +0 -157
- package/src/lightspark_crypto/lightspark_crypto.js +0 -1010
- package/src/lightspark_crypto/lightspark_crypto_bg.wasm +0 -0
- package/src/lightspark_crypto/lightspark_crypto_bg.wasm.d.ts +0 -120
- package/src/lightspark_crypto/package.json +0 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @lightsparkdev/lightspark-sdk
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e2b1515: - [uma] Add fetchPublicKeyForVasp
|
|
8
|
+
- [lightspark-cli] add payUmaInvoice
|
|
9
|
+
- [lightspark-cli] allow generate-node-keys to be used without running init-env and always asks user to choose the bitcoin network to generate the node keys
|
|
10
|
+
- [lightspark-cli] updates commands to get bitcoin network from the selected node in most scenarios
|
|
11
|
+
- [lightspark-sdk] use crypto-wasm for crypto operations
|
|
12
|
+
- [lightspark-sdk] dynamically import crypto-wasm for node environments only
|
|
13
|
+
|
|
14
|
+
## 1.0.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 808c77a: Consolidate some imports to lightspark-sdk and core
|
|
19
|
+
- Updated dependencies [808c77a]
|
|
20
|
+
- @lightsparkdev/core@1.0.1
|
|
21
|
+
|
|
3
22
|
## 1.0.0
|
|
4
23
|
|
|
5
24
|
### 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 {
|
|
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.
|
|
1941
|
+
version: "1.0.2",
|
|
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,13 @@ var package_default = {
|
|
|
2010
2023
|
},
|
|
2011
2024
|
license: "Apache-2.0",
|
|
2012
2025
|
dependencies: {
|
|
2013
|
-
"@lightsparkdev/core": "1.0.
|
|
2026
|
+
"@lightsparkdev/core": "1.0.1",
|
|
2027
|
+
"@lightsparkdev/crypto-wasm": "0.1.0",
|
|
2014
2028
|
"auto-bind": "^5.0.1",
|
|
2015
2029
|
crypto: "^1.0.1",
|
|
2016
2030
|
"crypto-browserify": "^3.12.0",
|
|
2017
2031
|
dayjs: "^1.11.7",
|
|
2032
|
+
dotenv: "^16.3.1",
|
|
2018
2033
|
graphql: "^16.6.0",
|
|
2019
2034
|
"graphql-ws": "^5.11.3",
|
|
2020
2035
|
ws: "^8.12.1",
|
|
@@ -6870,22 +6885,7 @@ var RecoverNodeSigningKey = `
|
|
|
6870
6885
|
`;
|
|
6871
6886
|
|
|
6872
6887
|
// src/SigningKeyLoader.ts
|
|
6873
|
-
var import_lightspark_crypto = require("../src/lightspark_crypto/lightspark_crypto.js");
|
|
6874
6888
|
var SIGNING_KEY_PATH = "m/5";
|
|
6875
|
-
var getCryptoLibNetwork = (bitcoinNetwork) => {
|
|
6876
|
-
switch (bitcoinNetwork) {
|
|
6877
|
-
case BitcoinNetwork_default.MAINNET:
|
|
6878
|
-
return import_lightspark_crypto.Network.Bitcoin;
|
|
6879
|
-
case BitcoinNetwork_default.TESTNET:
|
|
6880
|
-
return import_lightspark_crypto.Network.Testnet;
|
|
6881
|
-
case BitcoinNetwork_default.REGTEST:
|
|
6882
|
-
return import_lightspark_crypto.Network.Regtest;
|
|
6883
|
-
default:
|
|
6884
|
-
throw new Error(
|
|
6885
|
-
`Unsupported lightspark_crypto network ${bitcoinNetwork}.`
|
|
6886
|
-
);
|
|
6887
|
-
}
|
|
6888
|
-
};
|
|
6889
6889
|
function isNodeIdAndPasswordSigningKeyLoaderArgs(args) {
|
|
6890
6890
|
return args.password !== void 0;
|
|
6891
6891
|
}
|
|
@@ -6948,9 +6948,31 @@ var MasterSeedSigningKeyLoader = class {
|
|
|
6948
6948
|
this.network = args.network;
|
|
6949
6949
|
}
|
|
6950
6950
|
async loadSigningKey() {
|
|
6951
|
-
|
|
6951
|
+
if (import_core5.isBrowser) {
|
|
6952
|
+
throw new import_core5.LightsparkSigningException(
|
|
6953
|
+
"Browser environments not supported for master seed signing key loader."
|
|
6954
|
+
);
|
|
6955
|
+
}
|
|
6956
|
+
const { LightsparkSigner, Network } = await import("@lightsparkdev/crypto-wasm");
|
|
6957
|
+
let cryptoLibNetwork;
|
|
6958
|
+
switch (this.network) {
|
|
6959
|
+
case BitcoinNetwork_default.MAINNET:
|
|
6960
|
+
cryptoLibNetwork = Network.Bitcoin;
|
|
6961
|
+
break;
|
|
6962
|
+
case BitcoinNetwork_default.TESTNET:
|
|
6963
|
+
cryptoLibNetwork = Network.Testnet;
|
|
6964
|
+
break;
|
|
6965
|
+
case BitcoinNetwork_default.REGTEST:
|
|
6966
|
+
cryptoLibNetwork = Network.Regtest;
|
|
6967
|
+
break;
|
|
6968
|
+
default:
|
|
6969
|
+
throw new Error(
|
|
6970
|
+
`Unsupported lightspark_crypto network ${this.network}.`
|
|
6971
|
+
);
|
|
6972
|
+
}
|
|
6973
|
+
const lightsparkSigner = LightsparkSigner.from_bytes(
|
|
6952
6974
|
this.masterSeed,
|
|
6953
|
-
|
|
6975
|
+
cryptoLibNetwork
|
|
6954
6976
|
);
|
|
6955
6977
|
const privateKey = lightsparkSigner.derive_private_key(SIGNING_KEY_PATH);
|
|
6956
6978
|
return { key: privateKey, type: import_core5.SigningKeyType.Secp256k1SigningKey };
|
|
@@ -6959,7 +6981,7 @@ var MasterSeedSigningKeyLoader = class {
|
|
|
6959
6981
|
|
|
6960
6982
|
// src/NodeKeyLoaderCache.ts
|
|
6961
6983
|
var NodeKeyLoaderCache = class {
|
|
6962
|
-
constructor(nodeKeyCache, cryptoImpl = DefaultCrypto) {
|
|
6984
|
+
constructor(nodeKeyCache, cryptoImpl = import_core6.DefaultCrypto) {
|
|
6963
6985
|
this.nodeKeyCache = nodeKeyCache;
|
|
6964
6986
|
this.cryptoImpl = cryptoImpl;
|
|
6965
6987
|
this.idToLoader = /* @__PURE__ */ new Map();
|
|
@@ -7008,11 +7030,12 @@ var NodeKeyLoaderCache = class {
|
|
|
7008
7030
|
if (!loaderResult) {
|
|
7009
7031
|
return;
|
|
7010
7032
|
}
|
|
7011
|
-
|
|
7033
|
+
const key = await this.nodeKeyCache.loadKey(
|
|
7012
7034
|
id,
|
|
7013
7035
|
{ key: loaderResult.key },
|
|
7014
7036
|
loaderResult.type
|
|
7015
7037
|
);
|
|
7038
|
+
return key || void 0;
|
|
7016
7039
|
}
|
|
7017
7040
|
};
|
|
7018
7041
|
|
|
@@ -11150,6 +11173,28 @@ var LightsparkClient = class {
|
|
|
11150
11173
|
};
|
|
11151
11174
|
var client_default = LightsparkClient;
|
|
11152
11175
|
|
|
11176
|
+
// src/helpers.ts
|
|
11177
|
+
var BITCOIN_NETWORKS = [
|
|
11178
|
+
"MAINNET" /* MAINNET */,
|
|
11179
|
+
"TESTNET" /* TESTNET */,
|
|
11180
|
+
"SIGNET" /* SIGNET */,
|
|
11181
|
+
"REGTEST" /* REGTEST */
|
|
11182
|
+
];
|
|
11183
|
+
var isBitcoinNetwork = (bitcoinNetwork) => {
|
|
11184
|
+
return BITCOIN_NETWORKS.includes(bitcoinNetwork);
|
|
11185
|
+
};
|
|
11186
|
+
var assertValidBitcoinNetwork = (bitcoinNetwork) => {
|
|
11187
|
+
if (!isBitcoinNetwork(bitcoinNetwork)) {
|
|
11188
|
+
throw new Error(
|
|
11189
|
+
`Invalid bitcoin network ${bitcoinNetwork}. Valid networks: ${BITCOIN_NETWORKS}`
|
|
11190
|
+
);
|
|
11191
|
+
}
|
|
11192
|
+
};
|
|
11193
|
+
var getBitcoinNetworkOrThrow = (bitcoinNetwork) => {
|
|
11194
|
+
assertValidBitcoinNetwork(bitcoinNetwork.toUpperCase());
|
|
11195
|
+
return bitcoinNetwork;
|
|
11196
|
+
};
|
|
11197
|
+
|
|
11153
11198
|
// src/objects/ComplianceProvider.ts
|
|
11154
11199
|
var ComplianceProvider = /* @__PURE__ */ ((ComplianceProvider2) => {
|
|
11155
11200
|
ComplianceProvider2["FUTURE_VALUE"] = "FUTURE_VALUE";
|
|
@@ -12373,7 +12418,9 @@ var parseWebhook = async (data) => {
|
|
|
12373
12418
|
WithdrawalMode,
|
|
12374
12419
|
WithdrawalRequest,
|
|
12375
12420
|
WithdrawalRequestStatus,
|
|
12421
|
+
assertValidBitcoinNetwork,
|
|
12376
12422
|
getApiTokenQuery,
|
|
12423
|
+
getBitcoinNetworkOrThrow,
|
|
12377
12424
|
getChannelClosingTransactionQuery,
|
|
12378
12425
|
getChannelOpeningTransactionQuery,
|
|
12379
12426
|
getDepositQuery,
|
|
@@ -12389,5 +12436,6 @@ var parseWebhook = async (data) => {
|
|
|
12389
12436
|
getSignableQuery,
|
|
12390
12437
|
getTransactionQuery,
|
|
12391
12438
|
getWithdrawalQuery,
|
|
12439
|
+
isBitcoinNetwork,
|
|
12392
12440
|
verifyAndParseWebhook
|
|
12393
12441
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthProvider } from '@lightsparkdev/core';
|
|
2
|
-
import { W as WebhookEventType } from './index-
|
|
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
|
|
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 };
|