@lightsparkdev/lightspark-sdk 0.3.1 → 0.3.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/CHANGELOG.md +20 -0
- package/README.md +4 -5
- package/dist/chunk-NIMBE7W3.js +8 -0
- package/dist/{chunk-7GDCZ2RB.js → chunk-PD33OHE4.js} +1 -6
- package/dist/{index-e4b8b697.d.ts → index-d2343f8f.d.ts} +1 -1
- package/dist/index.cjs +1848 -12
- package/dist/index.d.ts +12 -2
- package/dist/index.js +46 -13
- package/dist/objects/index.d.ts +1 -1
- package/dist/objects/index.js +2 -1
- package/dist/text-encoding-MDIPJAHL.js +1808 -0
- package/package.json +12 -10
- package/src/__tests__/webhooks.test.ts +26 -0
- package/src/index.ts +1 -0
- package/src/webhooks.ts +42 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AuthProvider } from '@lightsparkdev/core';
|
|
2
|
-
|
|
2
|
+
import { W as WebhookEventType } from './index-d2343f8f.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 CreateApiTokenInput, s as CreateApiTokenOutput, t as CreateInvoiceInput, u as CreateInvoiceOutput, v as CreateNodeWalletAddressInput, w as CreateNodeWalletAddressOutput, x as CreateTestModeInvoiceInput, y as CreateTestModeInvoiceOutput, z as CreateTestModePaymentInput, D as CreateTestModePaymentoutput, E as CurrencyAmount, F as CurrencyUnit, G as DeleteApiTokenInput, H as DeleteApiTokenOutput, I as Deposit, K as Entity, M as FeeEstimate, N as FundNodeInput, O as FundNodeOutput, P as GraphNode, Q as Hop, S as HtlcAttemptFailureCode, T as IncomingPayment, U as IncomingPaymentAttempt, X as IncomingPaymentAttemptStatus, Y as IncomingPaymentToAttemptsConnection, Z as Invoice, $ as InvoiceData, a0 as InvoiceType, a1 as LightningFeeEstimateForInvoiceInput, a2 as LightningFeeEstimateForNodeInput, a3 as LightningFeeEstimateOutput, a4 as LightningTransaction, L as LightsparkClient, a6 as LightsparkNode, a7 as LightsparkNodePurpose, a8 as LightsparkNodeStatus, a9 as LightsparkNodeToChannelsConnection, aa as Node, ab as NodeAddress, ac as NodeAddressType, ad as NodeToAddressesConnection, ae as OnChainTransaction, ag as OutgoingPayment, ah as OutgoingPaymentAttempt, ai as OutgoingPaymentAttemptStatus, aj as OutgoingPaymentAttemptToHopsConnection, ak as OutgoingPaymentToAttemptsConnection, al as PageInfo, am as PayInvoiceInput, an as PayInvoiceOutput, ao as PaymentFailureReason, ap as PaymentRequest, ar as PaymentRequestData, as as PaymentRequestStatus, at as Permission, au as RequestWithdrawalInput, av as RequestWithdrawalOutput, aw as RichText, ax as RoutingTransaction, az as RoutingTransactionFailureReason, aA as Secret, aB as SendPaymentInput, aC as SendPaymentOutput, aD as SingleNodeDashboard, aE as Transaction, aG as TransactionFailures, aH as TransactionStatus, aI as TransactionType, aJ as TransactionUpdate, aK as Wallet, aL as Withdrawal, aN as WithdrawalMode, aO as WithdrawalRequest, aP as WithdrawalRequestStatus, aQ as WithdrawalRequestToChannelClosingTransactionsConnection, aR as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, l as getChannelClosingTransactionQuery, o as getChannelOpeningTransactionQuery, J as getDepositQuery, R as getHopQuery, V as getIncomingPaymentAttemptQuery, _ as getInvoiceQuery, a5 as getLightningTransactionQuery, af as getOnChainTransactionQuery, aq as getPaymentRequestQuery, ay as getRoutingTransactionQuery, aF as getTransactionQuery, aM as getWithdrawalQuery } from './index-d2343f8f.js';
|
|
3
4
|
import 'zen-observable';
|
|
4
5
|
|
|
5
6
|
declare class AccountTokenAuthProvider implements AuthProvider {
|
|
@@ -12,4 +13,13 @@ declare class AccountTokenAuthProvider implements AuthProvider {
|
|
|
12
13
|
isAuthorized(): Promise<boolean>;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
declare const WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
|
|
17
|
+
interface WebhookEvent {
|
|
18
|
+
event_type: WebhookEventType;
|
|
19
|
+
event_id: string;
|
|
20
|
+
timestamp: Date;
|
|
21
|
+
entity_id: string;
|
|
22
|
+
}
|
|
23
|
+
declare const verifyAndParseWebhook: (data: Uint8Array, hexdigest: string, webhook_secret: string) => Promise<WebhookEvent>;
|
|
24
|
+
|
|
25
|
+
export { AccountTokenAuthProvider, WEBHOOKS_SIGNATURE_HEADER, WebhookEvent, WebhookEventType, verifyAndParseWebhook };
|
package/dist/index.js
CHANGED
|
@@ -41,12 +41,12 @@ import {
|
|
|
41
41
|
TransactionType_default,
|
|
42
42
|
TransactionUpdateFromJson,
|
|
43
43
|
Wallet_default,
|
|
44
|
+
WebhookEventType,
|
|
44
45
|
WebhookEventType_default,
|
|
45
46
|
WithdrawalMode_default,
|
|
46
47
|
WithdrawalRequestFromJson,
|
|
47
48
|
WithdrawalRequestStatus_default,
|
|
48
49
|
WithdrawalRequest_default,
|
|
49
|
-
__commonJS,
|
|
50
50
|
getApiTokenQuery,
|
|
51
51
|
getChannelClosingTransactionQuery,
|
|
52
52
|
getChannelOpeningTransactionQuery,
|
|
@@ -60,14 +60,17 @@ import {
|
|
|
60
60
|
getRoutingTransactionQuery,
|
|
61
61
|
getTransactionQuery,
|
|
62
62
|
getWithdrawalQuery
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-PD33OHE4.js";
|
|
64
|
+
import {
|
|
65
|
+
__commonJS
|
|
66
|
+
} from "./chunk-NIMBE7W3.js";
|
|
64
67
|
|
|
65
68
|
// package.json
|
|
66
69
|
var require_package = __commonJS({
|
|
67
70
|
"package.json"(exports, module) {
|
|
68
71
|
module.exports = {
|
|
69
72
|
name: "@lightsparkdev/lightspark-sdk",
|
|
70
|
-
version: "0.3.
|
|
73
|
+
version: "0.3.3",
|
|
71
74
|
description: "Lightspark JS SDK",
|
|
72
75
|
author: "Lightspark Inc.",
|
|
73
76
|
keywords: [
|
|
@@ -124,37 +127,39 @@ var require_package = __commonJS({
|
|
|
124
127
|
],
|
|
125
128
|
scripts: {
|
|
126
129
|
build: "tsup --entry src/index.ts --entry src/objects/index.ts --format cjs,esm --dts",
|
|
127
|
-
clean: "rm -rf .turbo && rm -rf
|
|
130
|
+
clean: "rm -rf .turbo && rm -rf dist",
|
|
128
131
|
dev: "yarn build -- --watch",
|
|
129
132
|
docs: "typedoc src",
|
|
130
|
-
format: "
|
|
131
|
-
|
|
133
|
+
format: "prettier src --check",
|
|
134
|
+
"format:fix": "prettier src --write",
|
|
135
|
+
lint: "prettier --check ./src",
|
|
132
136
|
postversion: "yarn build",
|
|
133
|
-
test: "
|
|
134
|
-
|
|
137
|
+
test: "jest --no-cache --runInBand --bail",
|
|
138
|
+
types: "tsc"
|
|
135
139
|
},
|
|
136
140
|
license: "Apache-2.0",
|
|
137
141
|
dependencies: {
|
|
138
|
-
"@lightsparkdev/core": "0.3.
|
|
142
|
+
"@lightsparkdev/core": "0.3.2",
|
|
139
143
|
"auto-bind": "^5.0.1",
|
|
140
144
|
crypto: "^1.0.1",
|
|
141
145
|
"crypto-browserify": "^3.12.0",
|
|
142
146
|
dayjs: "^1.11.7",
|
|
143
147
|
graphql: "^16.6.0",
|
|
144
148
|
"graphql-ws": "^5.11.3",
|
|
145
|
-
typedoc: "^0.24.7",
|
|
146
149
|
ws: "^8.12.1",
|
|
147
150
|
"zen-observable-ts": "^1.1.0"
|
|
148
151
|
},
|
|
149
152
|
devDependencies: {
|
|
150
153
|
"@types/crypto-js": "^4.1.1",
|
|
154
|
+
"@types/jest": "^29.5.2",
|
|
151
155
|
"@types/ws": "^8.5.4",
|
|
152
156
|
jest: "^29.4.1",
|
|
153
|
-
prettier: "
|
|
154
|
-
"prettier-plugin-organize-imports": "^3.2.2",
|
|
157
|
+
prettier: "2.8.7",
|
|
155
158
|
"ts-jest": "^29.0.5",
|
|
156
159
|
"ts-node": "^10.9.1",
|
|
157
160
|
tsconfig: "*",
|
|
161
|
+
tsup: "^6.7.0",
|
|
162
|
+
typedoc: "^0.24.7",
|
|
158
163
|
typescript: "^4.9.5"
|
|
159
164
|
}
|
|
160
165
|
};
|
|
@@ -1344,6 +1349,32 @@ var LightsparkClient = class {
|
|
|
1344
1349
|
};
|
|
1345
1350
|
var LIGHTSPARK_SDK_ENDPOINT = "graphql/server/2023-04-04";
|
|
1346
1351
|
var client_default = LightsparkClient;
|
|
1352
|
+
|
|
1353
|
+
// src/webhooks.ts
|
|
1354
|
+
import { createHmac } from "crypto";
|
|
1355
|
+
var WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
|
|
1356
|
+
var verifyAndParseWebhook = (data, hexdigest, webhook_secret) => {
|
|
1357
|
+
const sig = createHmac("sha256", webhook_secret).update(data).digest("hex");
|
|
1358
|
+
if (sig.toLowerCase() !== hexdigest.toLowerCase()) {
|
|
1359
|
+
throw new Error("Webhook message hash does not match signature");
|
|
1360
|
+
}
|
|
1361
|
+
return parseWebhook(data);
|
|
1362
|
+
};
|
|
1363
|
+
var parseWebhook = async (data) => {
|
|
1364
|
+
let td = TextDecoder;
|
|
1365
|
+
if (typeof td === "undefined") {
|
|
1366
|
+
const tdModule = await import("./text-encoding-MDIPJAHL.js");
|
|
1367
|
+
td = tdModule.TextDecoder;
|
|
1368
|
+
}
|
|
1369
|
+
const dataStr = new td().decode(data);
|
|
1370
|
+
const event = JSON.parse(dataStr);
|
|
1371
|
+
return {
|
|
1372
|
+
event_type: WebhookEventType[event.event_type],
|
|
1373
|
+
event_id: event.event_id,
|
|
1374
|
+
timestamp: new Date(event.timestamp),
|
|
1375
|
+
entity_id: event.entity_id
|
|
1376
|
+
};
|
|
1377
|
+
};
|
|
1347
1378
|
export {
|
|
1348
1379
|
Account_default as Account,
|
|
1349
1380
|
AccountToChannelsConnection_default as AccountToChannelsConnection,
|
|
@@ -1372,6 +1403,7 @@ export {
|
|
|
1372
1403
|
RoutingTransactionFailureReason_default as RoutingTransactionFailureReason,
|
|
1373
1404
|
TransactionStatus_default as TransactionStatus,
|
|
1374
1405
|
TransactionType_default as TransactionType,
|
|
1406
|
+
WEBHOOKS_SIGNATURE_HEADER,
|
|
1375
1407
|
Wallet_default as Wallet,
|
|
1376
1408
|
WebhookEventType_default as WebhookEventType,
|
|
1377
1409
|
WithdrawalMode_default as WithdrawalMode,
|
|
@@ -1389,5 +1421,6 @@ export {
|
|
|
1389
1421
|
getPaymentRequestQuery,
|
|
1390
1422
|
getRoutingTransactionQuery,
|
|
1391
1423
|
getTransactionQuery,
|
|
1392
|
-
getWithdrawalQuery
|
|
1424
|
+
getWithdrawalQuery,
|
|
1425
|
+
verifyAndParseWebhook
|
|
1393
1426
|
};
|
package/dist/objects/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as Account, a as AccountToApiTokensConnection, b as AccountToChannelsConnection, c as AccountToNodesConnection, d as AccountToPaymentRequestsConnection, e as AccountToTransactionsConnection, f as 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 CreateTestModeInvoiceInput, y as CreateTestModeInvoiceOutput, z as CreateTestModePaymentInput, D as CreateTestModePaymentoutput, E as CurrencyAmount, F as CurrencyUnit, G as DeleteApiTokenInput, H as DeleteApiTokenOutput, I as Deposit, K as Entity, M as FeeEstimate, N as FundNodeInput, O as FundNodeOutput, P as GraphNode, Q as Hop, S as HtlcAttemptFailureCode, T as IncomingPayment, U as IncomingPaymentAttempt,
|
|
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 CreateApiTokenInput, s as CreateApiTokenOutput, t as CreateInvoiceInput, u as CreateInvoiceOutput, v as CreateNodeWalletAddressInput, w as CreateNodeWalletAddressOutput, x as CreateTestModeInvoiceInput, y as CreateTestModeInvoiceOutput, z as CreateTestModePaymentInput, D as CreateTestModePaymentoutput, E as CurrencyAmount, F as CurrencyUnit, G as DeleteApiTokenInput, H as DeleteApiTokenOutput, I as Deposit, K as Entity, M as FeeEstimate, N as FundNodeInput, O as FundNodeOutput, P as GraphNode, Q as Hop, S as HtlcAttemptFailureCode, T as IncomingPayment, U as IncomingPaymentAttempt, X as IncomingPaymentAttemptStatus, Y as IncomingPaymentToAttemptsConnection, Z as Invoice, $ as InvoiceData, a0 as InvoiceType, a1 as LightningFeeEstimateForInvoiceInput, a2 as LightningFeeEstimateForNodeInput, a3 as LightningFeeEstimateOutput, a4 as LightningTransaction, a6 as LightsparkNode, a7 as LightsparkNodePurpose, a8 as LightsparkNodeStatus, a9 as LightsparkNodeToChannelsConnection, aa as Node, ab as NodeAddress, ac as NodeAddressType, ad as NodeToAddressesConnection, ae as OnChainTransaction, ag as OutgoingPayment, ah as OutgoingPaymentAttempt, ai as OutgoingPaymentAttemptStatus, aj as OutgoingPaymentAttemptToHopsConnection, ak as OutgoingPaymentToAttemptsConnection, al as PageInfo, am as PayInvoiceInput, an as PayInvoiceOutput, ao as PaymentFailureReason, ap as PaymentRequest, ar as PaymentRequestData, as as PaymentRequestStatus, at as Permission, au as RequestWithdrawalInput, av as RequestWithdrawalOutput, aw as RichText, ax as RoutingTransaction, az as RoutingTransactionFailureReason, aA as Secret, aB as SendPaymentInput, aC as SendPaymentOutput, aD as SingleNodeDashboard, aE as Transaction, aG as TransactionFailures, aH as TransactionStatus, aI as TransactionType, aJ as TransactionUpdate, aK as Wallet, W as WebhookEventType, aL as Withdrawal, aN as WithdrawalMode, aO as WithdrawalRequest, aP as WithdrawalRequestStatus, aQ as WithdrawalRequestToChannelClosingTransactionsConnection, aR as WithdrawalRequestToChannelOpeningTransactionsConnection, h as getApiTokenQuery, l as getChannelClosingTransactionQuery, o as getChannelOpeningTransactionQuery, J as getDepositQuery, R as getHopQuery, V as getIncomingPaymentAttemptQuery, _ as getInvoiceQuery, a5 as getLightningTransactionQuery, af as getOnChainTransactionQuery, aq as getPaymentRequestQuery, ay as getRoutingTransactionQuery, aF as getTransactionQuery, aM as getWithdrawalQuery } from '../index-d2343f8f.js';
|
|
2
2
|
import '@lightsparkdev/core';
|
|
3
3
|
import 'zen-observable';
|
package/dist/objects/index.js
CHANGED
|
@@ -42,7 +42,8 @@ import {
|
|
|
42
42
|
getRoutingTransactionQuery,
|
|
43
43
|
getTransactionQuery,
|
|
44
44
|
getWithdrawalQuery
|
|
45
|
-
} from "../chunk-
|
|
45
|
+
} from "../chunk-PD33OHE4.js";
|
|
46
|
+
import "../chunk-NIMBE7W3.js";
|
|
46
47
|
export {
|
|
47
48
|
Account_default as Account,
|
|
48
49
|
AccountToChannelsConnection_default as AccountToChannelsConnection,
|