@lightsparkdev/lightspark-sdk 0.3.0 → 0.3.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 +15 -0
- package/dist/chunk-NIMBE7W3.js +8 -0
- package/dist/{chunk-7GDCZ2RB.js → chunk-PD33OHE4.js} +1 -6
- package/dist/{Withdrawal-e4b8b697.d.ts → index-d2343f8f.d.ts} +1 -1
- package/dist/index.cjs +1842 -7
- package/dist/index.d.ts +13 -2
- package/dist/index.js +39 -8
- 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 +6 -5
- 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,14 @@ 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 verify_and_parse_webhook: (data: Uint8Array, hexdigest: string, webhook_secret: string) => Promise<WebhookEvent>;
|
|
24
|
+
declare const parse_webhook: (data: Uint8Array) => Promise<WebhookEvent>;
|
|
25
|
+
|
|
26
|
+
export { AccountTokenAuthProvider, WEBHOOKS_SIGNATURE_HEADER, WebhookEvent, WebhookEventType, parse_webhook, verify_and_parse_webhook };
|
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.2",
|
|
71
74
|
description: "Lightspark JS SDK",
|
|
72
75
|
author: "Lightspark Inc.",
|
|
73
76
|
keywords: [
|
|
@@ -130,12 +133,12 @@ var require_package = __commonJS({
|
|
|
130
133
|
format: "npx prettier --write ./src",
|
|
131
134
|
lint: "npx prettier --check ./src",
|
|
132
135
|
postversion: "yarn build",
|
|
133
|
-
test: "
|
|
136
|
+
test: "jest --no-cache --runInBand --bail",
|
|
134
137
|
"type-check": "tsc --noEmit"
|
|
135
138
|
},
|
|
136
139
|
license: "Apache-2.0",
|
|
137
140
|
dependencies: {
|
|
138
|
-
"@lightsparkdev/core": "0.3.
|
|
141
|
+
"@lightsparkdev/core": "0.3.1",
|
|
139
142
|
"auto-bind": "^5.0.1",
|
|
140
143
|
crypto: "^1.0.1",
|
|
141
144
|
"crypto-browserify": "^3.12.0",
|
|
@@ -148,11 +151,12 @@ var require_package = __commonJS({
|
|
|
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
|
-
jest: "^29.
|
|
156
|
+
jest: "^29.5.0",
|
|
153
157
|
prettier: "^2.8.4",
|
|
154
158
|
"prettier-plugin-organize-imports": "^3.2.2",
|
|
155
|
-
"ts-jest": "^29.0
|
|
159
|
+
"ts-jest": "^29.1.0",
|
|
156
160
|
"ts-node": "^10.9.1",
|
|
157
161
|
tsconfig: "*",
|
|
158
162
|
typescript: "^4.9.5"
|
|
@@ -1344,6 +1348,30 @@ var LightsparkClient = class {
|
|
|
1344
1348
|
};
|
|
1345
1349
|
var LIGHTSPARK_SDK_ENDPOINT = "graphql/server/2023-04-04";
|
|
1346
1350
|
var client_default = LightsparkClient;
|
|
1351
|
+
|
|
1352
|
+
// src/webhooks.ts
|
|
1353
|
+
import { createHmac } from "crypto";
|
|
1354
|
+
var WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
|
|
1355
|
+
var verify_and_parse_webhook = (data, hexdigest, webhook_secret) => {
|
|
1356
|
+
const sig = createHmac("sha256", webhook_secret).update(data).digest("hex");
|
|
1357
|
+
if (sig.toLowerCase() !== hexdigest.toLowerCase()) {
|
|
1358
|
+
throw new Error("Webhook message hash does not match signature");
|
|
1359
|
+
}
|
|
1360
|
+
return parse_webhook(data);
|
|
1361
|
+
};
|
|
1362
|
+
var parse_webhook = async (data) => {
|
|
1363
|
+
if (typeof TextDecoder === "undefined") {
|
|
1364
|
+
const TextDecoder2 = (await import("./text-encoding-MDIPJAHL.js")).TextDecoder;
|
|
1365
|
+
}
|
|
1366
|
+
const dataStr = new TextDecoder().decode(data);
|
|
1367
|
+
const event = JSON.parse(dataStr);
|
|
1368
|
+
return {
|
|
1369
|
+
event_type: WebhookEventType[event.event_type],
|
|
1370
|
+
event_id: event.event_id,
|
|
1371
|
+
timestamp: new Date(event.timestamp),
|
|
1372
|
+
entity_id: event.entity_id
|
|
1373
|
+
};
|
|
1374
|
+
};
|
|
1347
1375
|
export {
|
|
1348
1376
|
Account_default as Account,
|
|
1349
1377
|
AccountToChannelsConnection_default as AccountToChannelsConnection,
|
|
@@ -1372,6 +1400,7 @@ export {
|
|
|
1372
1400
|
RoutingTransactionFailureReason_default as RoutingTransactionFailureReason,
|
|
1373
1401
|
TransactionStatus_default as TransactionStatus,
|
|
1374
1402
|
TransactionType_default as TransactionType,
|
|
1403
|
+
WEBHOOKS_SIGNATURE_HEADER,
|
|
1375
1404
|
Wallet_default as Wallet,
|
|
1376
1405
|
WebhookEventType_default as WebhookEventType,
|
|
1377
1406
|
WithdrawalMode_default as WithdrawalMode,
|
|
@@ -1389,5 +1418,7 @@ export {
|
|
|
1389
1418
|
getPaymentRequestQuery,
|
|
1390
1419
|
getRoutingTransactionQuery,
|
|
1391
1420
|
getTransactionQuery,
|
|
1392
|
-
getWithdrawalQuery
|
|
1421
|
+
getWithdrawalQuery,
|
|
1422
|
+
parse_webhook,
|
|
1423
|
+
verify_and_parse_webhook
|
|
1393
1424
|
};
|
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,
|