@getalby/cli 0.2.2 → 0.2.4
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/build/index.js +1 -1
- package/build/tools/lightning/fetch_l402.js +6 -7
- package/build/utils.js +16 -1
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -24,7 +24,7 @@ const program = new Command();
|
|
|
24
24
|
program
|
|
25
25
|
.name("alby-cli")
|
|
26
26
|
.description("CLI for Nostr Wallet Connect (NIP-47) with lightning tools")
|
|
27
|
-
.version("0.2.
|
|
27
|
+
.version("0.2.4")
|
|
28
28
|
.option("-c, --connection-secret <string>", "NWC connection secret (nostr+walletconnect://...) or path to file containing it (preferred)")
|
|
29
29
|
.addHelpText("afterAll", `
|
|
30
30
|
Security:
|
|
@@ -13,14 +13,13 @@ export async function fetchL402(client, params) {
|
|
|
13
13
|
else if (params.headers) {
|
|
14
14
|
requestOptions.headers = params.headers;
|
|
15
15
|
}
|
|
16
|
-
const webln = {
|
|
17
|
-
sendPayment: async (invoice) => {
|
|
18
|
-
const result = await client.payInvoice({ invoice });
|
|
19
|
-
return { preimage: result.preimage };
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
16
|
const result = await fetchWithL402(params.url, requestOptions, {
|
|
23
|
-
|
|
17
|
+
wallet: {
|
|
18
|
+
sendPayment: async (invoice) => {
|
|
19
|
+
const result = await client.payInvoice({ invoice });
|
|
20
|
+
return { preimage: result.preimage };
|
|
21
|
+
},
|
|
22
|
+
},
|
|
24
23
|
});
|
|
25
24
|
const responseContent = await result.text();
|
|
26
25
|
if (!result.ok) {
|
package/build/utils.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { NWCClient } from "@getalby/sdk";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
3
5
|
export function getClient(program) {
|
|
4
6
|
const opts = program.opts();
|
|
5
7
|
let connectionSecret = opts.connectionSecret;
|
|
@@ -8,7 +10,20 @@ export function getClient(program) {
|
|
|
8
10
|
connectionSecret = process.env.NWC_URL;
|
|
9
11
|
}
|
|
10
12
|
if (!connectionSecret) {
|
|
11
|
-
|
|
13
|
+
const defaultPath = join(homedir(), ".alby-cli", "connection-secret.key");
|
|
14
|
+
try {
|
|
15
|
+
connectionSecret = readFileSync(defaultPath, "utf-8").trim();
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
const err = error;
|
|
19
|
+
if (err.code !== "ENOENT") {
|
|
20
|
+
// only throw an error if it's not a file not found error
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (!connectionSecret) {
|
|
26
|
+
console.error("Error: No connection secret found. Pass -c <secret>, set NWC_URL, or create ~/.alby-cli/connection-secret.key");
|
|
12
27
|
process.exit(1);
|
|
13
28
|
}
|
|
14
29
|
// Auto-detect: if it doesn't start with the protocol, treat as file path
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@getalby/cli",
|
|
3
3
|
"description": "CLI for Nostr Wallet Connect (NIP-47) with a few additional useful lightning tools",
|
|
4
4
|
"repository": "https://github.com/getAlby/cli.git",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.4",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
8
8
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"author": "Alby contributors",
|
|
35
35
|
"license": "MIT",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@getalby/lightning-tools": "^
|
|
37
|
+
"@getalby/lightning-tools": "^7.0.2",
|
|
38
38
|
"@getalby/sdk": "^7.0.0",
|
|
39
39
|
"commander": "^13.1.0"
|
|
40
40
|
},
|