@lightsparkdev/lightspark-sdk 1.0.5 → 1.0.6
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 +8 -0
- package/dist/index.cjs +11 -9
- package/dist/index.js +11 -8
- package/package.json +4 -3
- package/src/client.ts +5 -3
- package/src/webhooks.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @lightsparkdev/lightspark-sdk
|
|
2
2
|
|
|
3
|
+
## 1.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ca58c08: Update createSha256Hash with option to return as hex string and accept string data
|
|
8
|
+
- Updated dependencies [ca58c08]
|
|
9
|
+
- @lightsparkdev/core@1.0.5
|
|
10
|
+
|
|
3
11
|
## 1.0.5
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1933,12 +1933,11 @@ var AccountTokenAuthProvider_default = AccountTokenAuthProvider;
|
|
|
1933
1933
|
// src/client.ts
|
|
1934
1934
|
var import_auto_bind15 = __toESM(require("auto-bind"), 1);
|
|
1935
1935
|
var import_core9 = require("@lightsparkdev/core");
|
|
1936
|
-
var import_crypto = require("crypto");
|
|
1937
1936
|
|
|
1938
1937
|
// package.json
|
|
1939
1938
|
var package_default = {
|
|
1940
1939
|
name: "@lightsparkdev/lightspark-sdk",
|
|
1941
|
-
version: "1.0.
|
|
1940
|
+
version: "1.0.6",
|
|
1942
1941
|
description: "Lightspark JS SDK",
|
|
1943
1942
|
author: "Lightspark Inc.",
|
|
1944
1943
|
keywords: [
|
|
@@ -2018,13 +2017,13 @@ var package_default = {
|
|
|
2018
2017
|
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
|
|
2019
2018
|
lint: "eslint .",
|
|
2020
2019
|
postversion: "yarn build",
|
|
2021
|
-
test: "jest --no-cache --runInBand --bail",
|
|
2020
|
+
test: "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
|
|
2022
2021
|
"types:watch": "tsc-absolute --watch",
|
|
2023
2022
|
types: "tsc"
|
|
2024
2023
|
},
|
|
2025
2024
|
license: "Apache-2.0",
|
|
2026
2025
|
dependencies: {
|
|
2027
|
-
"@lightsparkdev/core": "1.0.
|
|
2026
|
+
"@lightsparkdev/core": "1.0.5",
|
|
2028
2027
|
"@lightsparkdev/crypto-wasm": "0.1.1",
|
|
2029
2028
|
"auto-bind": "^5.0.1",
|
|
2030
2029
|
crypto: "^1.0.1",
|
|
@@ -2041,6 +2040,7 @@ var package_default = {
|
|
|
2041
2040
|
"@lightsparkdev/tsconfig": "0.0.0",
|
|
2042
2041
|
"@types/crypto-js": "^4.1.1",
|
|
2043
2042
|
"@types/jest": "^29.5.3",
|
|
2043
|
+
"@types/node": "^20.2.5",
|
|
2044
2044
|
"@types/ws": "^8.5.4",
|
|
2045
2045
|
eslint: "^8.3.0",
|
|
2046
2046
|
"eslint-watch": "^8.0.0",
|
|
@@ -10762,10 +10762,11 @@ var LightsparkClient = class {
|
|
|
10762
10762
|
* @returns An Invoice object representing the generated invoice.
|
|
10763
10763
|
*/
|
|
10764
10764
|
async createLnurlInvoice(nodeId, amountMsats, metadata, expirySecs = void 0) {
|
|
10765
|
+
const metadataHash = await (0, import_core9.createSha256Hash)(metadata, true);
|
|
10765
10766
|
const variables = {
|
|
10766
10767
|
node_id: nodeId,
|
|
10767
10768
|
amount_msats: amountMsats,
|
|
10768
|
-
metadata_hash:
|
|
10769
|
+
metadata_hash: metadataHash
|
|
10769
10770
|
};
|
|
10770
10771
|
if (expirySecs !== void 0) {
|
|
10771
10772
|
variables["expiry_secs"] = expirySecs;
|
|
@@ -10795,10 +10796,11 @@ var LightsparkClient = class {
|
|
|
10795
10796
|
* @returns An Invoice object representing the generated invoice.
|
|
10796
10797
|
*/
|
|
10797
10798
|
async createUmaInvoice(nodeId, amountMsats, metadata, expirySecs = void 0) {
|
|
10799
|
+
const metadataHash = await (0, import_core9.createSha256Hash)(metadata, true);
|
|
10798
10800
|
const variables = {
|
|
10799
10801
|
node_id: nodeId,
|
|
10800
10802
|
amount_msats: amountMsats,
|
|
10801
|
-
metadata_hash:
|
|
10803
|
+
metadata_hash: metadataHash,
|
|
10802
10804
|
expiry_secs: expirySecs !== void 0 ? expirySecs : 3600
|
|
10803
10805
|
};
|
|
10804
10806
|
const response = await this.requester.makeRawRequest(
|
|
@@ -12352,10 +12354,10 @@ ${FRAGMENT33}
|
|
|
12352
12354
|
};
|
|
12353
12355
|
|
|
12354
12356
|
// src/webhooks.ts
|
|
12355
|
-
var import_crypto2 = require("crypto");
|
|
12356
12357
|
var WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
|
|
12357
|
-
var verifyAndParseWebhook = (data, hexdigest, webhook_secret) => {
|
|
12358
|
-
const
|
|
12358
|
+
var verifyAndParseWebhook = async (data, hexdigest, webhook_secret) => {
|
|
12359
|
+
const { createHmac } = await import("crypto");
|
|
12360
|
+
const sig = createHmac("sha256", webhook_secret).update(data).digest("hex");
|
|
12359
12361
|
if (sig.toLowerCase() !== hexdigest.toLowerCase()) {
|
|
12360
12362
|
throw new Error("Webhook message hash does not match signature");
|
|
12361
12363
|
}
|
package/dist/index.js
CHANGED
|
@@ -115,6 +115,7 @@ var AccountTokenAuthProvider_default = AccountTokenAuthProvider;
|
|
|
115
115
|
// src/client.ts
|
|
116
116
|
import autoBind2 from "auto-bind";
|
|
117
117
|
import {
|
|
118
|
+
createSha256Hash,
|
|
118
119
|
DefaultCrypto as DefaultCrypto2,
|
|
119
120
|
LightsparkAuthException,
|
|
120
121
|
LightsparkException,
|
|
@@ -124,12 +125,11 @@ import {
|
|
|
124
125
|
SigningKeyType as SigningKeyType2,
|
|
125
126
|
StubAuthProvider
|
|
126
127
|
} from "@lightsparkdev/core";
|
|
127
|
-
import { createHash } from "crypto";
|
|
128
128
|
|
|
129
129
|
// package.json
|
|
130
130
|
var package_default = {
|
|
131
131
|
name: "@lightsparkdev/lightspark-sdk",
|
|
132
|
-
version: "1.0.
|
|
132
|
+
version: "1.0.6",
|
|
133
133
|
description: "Lightspark JS SDK",
|
|
134
134
|
author: "Lightspark Inc.",
|
|
135
135
|
keywords: [
|
|
@@ -209,13 +209,13 @@ var package_default = {
|
|
|
209
209
|
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
|
|
210
210
|
lint: "eslint .",
|
|
211
211
|
postversion: "yarn build",
|
|
212
|
-
test: "jest --no-cache --runInBand --bail",
|
|
212
|
+
test: "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
|
|
213
213
|
"types:watch": "tsc-absolute --watch",
|
|
214
214
|
types: "tsc"
|
|
215
215
|
},
|
|
216
216
|
license: "Apache-2.0",
|
|
217
217
|
dependencies: {
|
|
218
|
-
"@lightsparkdev/core": "1.0.
|
|
218
|
+
"@lightsparkdev/core": "1.0.5",
|
|
219
219
|
"@lightsparkdev/crypto-wasm": "0.1.1",
|
|
220
220
|
"auto-bind": "^5.0.1",
|
|
221
221
|
crypto: "^1.0.1",
|
|
@@ -232,6 +232,7 @@ var package_default = {
|
|
|
232
232
|
"@lightsparkdev/tsconfig": "0.0.0",
|
|
233
233
|
"@types/crypto-js": "^4.1.1",
|
|
234
234
|
"@types/jest": "^29.5.3",
|
|
235
|
+
"@types/node": "^20.2.5",
|
|
235
236
|
"@types/ws": "^8.5.4",
|
|
236
237
|
eslint: "^8.3.0",
|
|
237
238
|
"eslint-watch": "^8.0.0",
|
|
@@ -1312,10 +1313,11 @@ var LightsparkClient = class {
|
|
|
1312
1313
|
* @returns An Invoice object representing the generated invoice.
|
|
1313
1314
|
*/
|
|
1314
1315
|
async createLnurlInvoice(nodeId, amountMsats, metadata, expirySecs = void 0) {
|
|
1316
|
+
const metadataHash = await createSha256Hash(metadata, true);
|
|
1315
1317
|
const variables = {
|
|
1316
1318
|
node_id: nodeId,
|
|
1317
1319
|
amount_msats: amountMsats,
|
|
1318
|
-
metadata_hash:
|
|
1320
|
+
metadata_hash: metadataHash
|
|
1319
1321
|
};
|
|
1320
1322
|
if (expirySecs !== void 0) {
|
|
1321
1323
|
variables["expiry_secs"] = expirySecs;
|
|
@@ -1345,10 +1347,11 @@ var LightsparkClient = class {
|
|
|
1345
1347
|
* @returns An Invoice object representing the generated invoice.
|
|
1346
1348
|
*/
|
|
1347
1349
|
async createUmaInvoice(nodeId, amountMsats, metadata, expirySecs = void 0) {
|
|
1350
|
+
const metadataHash = await createSha256Hash(metadata, true);
|
|
1348
1351
|
const variables = {
|
|
1349
1352
|
node_id: nodeId,
|
|
1350
1353
|
amount_msats: amountMsats,
|
|
1351
|
-
metadata_hash:
|
|
1354
|
+
metadata_hash: metadataHash,
|
|
1352
1355
|
expiry_secs: expirySecs !== void 0 ? expirySecs : 3600
|
|
1353
1356
|
};
|
|
1354
1357
|
const response = await this.requester.makeRawRequest(
|
|
@@ -1725,9 +1728,9 @@ var LightsparkClient = class {
|
|
|
1725
1728
|
var client_default = LightsparkClient;
|
|
1726
1729
|
|
|
1727
1730
|
// src/webhooks.ts
|
|
1728
|
-
import { createHmac } from "crypto";
|
|
1729
1731
|
var WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
|
|
1730
|
-
var verifyAndParseWebhook = (data, hexdigest, webhook_secret) => {
|
|
1732
|
+
var verifyAndParseWebhook = async (data, hexdigest, webhook_secret) => {
|
|
1733
|
+
const { createHmac } = await import("crypto");
|
|
1731
1734
|
const sig = createHmac("sha256", webhook_secret).update(data).digest("hex");
|
|
1732
1735
|
if (sig.toLowerCase() !== hexdigest.toLowerCase()) {
|
|
1733
1736
|
throw new Error("Webhook message hash does not match signature");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightsparkdev/lightspark-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Lightspark JS SDK",
|
|
5
5
|
"author": "Lightspark Inc.",
|
|
6
6
|
"keywords": [
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
|
|
81
81
|
"lint": "eslint .",
|
|
82
82
|
"postversion": "yarn build",
|
|
83
|
-
"test": "jest --no-cache --runInBand --bail",
|
|
83
|
+
"test": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
|
|
84
84
|
"types:watch": "tsc-absolute --watch",
|
|
85
85
|
"types": "tsc"
|
|
86
86
|
},
|
|
87
87
|
"license": "Apache-2.0",
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@lightsparkdev/core": "1.0.
|
|
89
|
+
"@lightsparkdev/core": "1.0.5",
|
|
90
90
|
"@lightsparkdev/crypto-wasm": "0.1.1",
|
|
91
91
|
"auto-bind": "^5.0.1",
|
|
92
92
|
"crypto": "^1.0.1",
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
"@lightsparkdev/tsconfig": "0.0.0",
|
|
104
104
|
"@types/crypto-js": "^4.1.1",
|
|
105
105
|
"@types/jest": "^29.5.3",
|
|
106
|
+
"@types/node": "^20.2.5",
|
|
106
107
|
"@types/ws": "^8.5.4",
|
|
107
108
|
"eslint": "^8.3.0",
|
|
108
109
|
"eslint-watch": "^8.0.0",
|
package/src/client.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
SigningKey,
|
|
13
13
|
} from "@lightsparkdev/core";
|
|
14
14
|
import {
|
|
15
|
+
createSha256Hash,
|
|
15
16
|
DefaultCrypto,
|
|
16
17
|
LightsparkAuthException,
|
|
17
18
|
LightsparkException,
|
|
@@ -21,7 +22,6 @@ import {
|
|
|
21
22
|
SigningKeyType,
|
|
22
23
|
StubAuthProvider,
|
|
23
24
|
} from "@lightsparkdev/core";
|
|
24
|
-
import { createHash } from "crypto";
|
|
25
25
|
import packageJson from "../package.json";
|
|
26
26
|
import { BitcoinFeeEstimate as BitcoinFeeEstimateQuery } from "./graphql/BitcoinFeeEstimate.js";
|
|
27
27
|
import { CreateApiToken } from "./graphql/CreateApiToken.js";
|
|
@@ -479,10 +479,11 @@ class LightsparkClient {
|
|
|
479
479
|
metadata: string,
|
|
480
480
|
expirySecs: number | undefined = undefined,
|
|
481
481
|
): Promise<Invoice | undefined> {
|
|
482
|
+
const metadataHash = await createSha256Hash(metadata, true);
|
|
482
483
|
const variables = {
|
|
483
484
|
node_id: nodeId,
|
|
484
485
|
amount_msats: amountMsats,
|
|
485
|
-
metadata_hash:
|
|
486
|
+
metadata_hash: metadataHash,
|
|
486
487
|
};
|
|
487
488
|
if (expirySecs !== undefined) {
|
|
488
489
|
variables["expiry_secs"] = expirySecs;
|
|
@@ -518,10 +519,11 @@ class LightsparkClient {
|
|
|
518
519
|
metadata: string,
|
|
519
520
|
expirySecs: number | undefined = undefined,
|
|
520
521
|
): Promise<Invoice | undefined> {
|
|
522
|
+
const metadataHash = await createSha256Hash(metadata, true);
|
|
521
523
|
const variables = {
|
|
522
524
|
node_id: nodeId,
|
|
523
525
|
amount_msats: amountMsats,
|
|
524
|
-
metadata_hash:
|
|
526
|
+
metadata_hash: metadataHash,
|
|
525
527
|
expiry_secs: expirySecs !== undefined ? expirySecs : 3600,
|
|
526
528
|
};
|
|
527
529
|
const response = await this.requester.makeRawRequest(
|
package/src/webhooks.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createHmac } from "crypto";
|
|
2
1
|
import { WebhookEventType } from "./objects/WebhookEventType.js";
|
|
3
2
|
|
|
4
3
|
export const WEBHOOKS_SIGNATURE_HEADER = "lightspark-signature";
|
|
@@ -11,11 +10,13 @@ export interface WebhookEvent {
|
|
|
11
10
|
wallet_id?: string;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export const verifyAndParseWebhook = (
|
|
13
|
+
export const verifyAndParseWebhook = async (
|
|
15
14
|
data: Uint8Array,
|
|
16
15
|
hexdigest: string,
|
|
17
16
|
webhook_secret: string,
|
|
18
17
|
): Promise<WebhookEvent> => {
|
|
18
|
+
/* dynamic import to avoid bundling crypto in browser */
|
|
19
|
+
const { createHmac } = await import("crypto");
|
|
19
20
|
const sig = createHmac("sha256", webhook_secret).update(data).digest("hex");
|
|
20
21
|
|
|
21
22
|
if (sig.toLowerCase() !== hexdigest.toLowerCase()) {
|