@getalby/cli
Advanced tools
@@ -7,3 +7,3 @@ import { fetch402 } from "../tools/lightning/fetch.js"; | ||
| .description("Fetch a payment-protected resource (auto-detects L402, X402, MPP)") | ||
| .requiredOption("-u, --url <url>", "URL to fetch") | ||
| .argument("<url>", "URL to fetch") | ||
| .option("-m, --method <method>", "HTTP method (GET, POST, etc.)") | ||
@@ -13,7 +13,7 @@ .option("-b, --body <json>", "Request body (JSON string)") | ||
| .option("--max-amount <sats>", "Maximum amount in sats to pay per request. Aborts if the endpoint requests more. (default: 5000, 0 = no limit)", parseInt) | ||
| .action(async (options) => { | ||
| .action(async (url, options) => { | ||
| await handleError(async () => { | ||
| const client = await getClient(program); | ||
| const result = await fetch402(client, { | ||
| url: options.url, | ||
| url: url, | ||
| method: options.method, | ||
@@ -20,0 +20,0 @@ body: options.body, |
+1
-1
@@ -35,3 +35,3 @@ #!/usr/bin/env node | ||
| " $ npx @getalby/cli pay-invoice --invoice lnbc...") | ||
| .version("0.4.1") | ||
| .version("0.5.0") | ||
| .option("-w, --wallet-name <name>", "Use a named wallet's connection secret (~/.alby-cli/connection-secret-<name>.key)") | ||
@@ -38,0 +38,0 @@ .option("-c, --connection-secret <string>", "NWC connection secret (nostr+walletconnect://...) or path to file containing it (preferred)") |
+11
-7
@@ -98,2 +98,13 @@ import { NWAClient, NWCClient } from "@getalby/sdk"; | ||
| } | ||
| // Check for pending connections BEFORE reading the existing connection file. | ||
| // When `auth --force` is used, the old connection-secret.key still exists. | ||
| // If we read it first, we'd skip the pending connection and silently use | ||
| // the old connection instead of completing the new one. | ||
| if (!connectionSecret && existsSync(pendingPath)) { | ||
| if (opts.verbose) { | ||
| console.error("Pending connection found. Waiting for wallet approval..."); | ||
| } | ||
| const pendingRelayPath = getPendingConnectionRelayPath(walletName); | ||
| return await completePendingConnection(pendingPath, connectionPath, undefined, opts.verbose, pendingRelayPath); | ||
| } | ||
| if (!connectionSecret) { | ||
@@ -109,9 +120,2 @@ try { | ||
| } | ||
| if (!connectionSecret && existsSync(pendingPath)) { | ||
| if (opts.verbose) { | ||
| console.error("Pending connection found. Waiting for wallet approval..."); | ||
| } | ||
| const pendingRelayPath = getPendingConnectionRelayPath(walletName); | ||
| return await completePendingConnection(pendingPath, connectionPath, undefined, opts.verbose, pendingRelayPath); | ||
| } | ||
| if (!connectionSecret) { | ||
@@ -118,0 +122,0 @@ throw new Error("No connection secret provided. Pass -c <secret or file path>, set NWC_URL, use --wallet-name <name>, or create ~/.alby-cli/connection-secret.key"); |
+1
-1
@@ -5,3 +5,3 @@ { | ||
| "repository": "https://github.com/getAlby/cli.git", | ||
| "version": "0.4.1", | ||
| "version": "0.5.0", | ||
| "type": "module", | ||
@@ -8,0 +8,0 @@ "main": "build/index.js", |
+3
-3
@@ -126,9 +126,9 @@ # Alby NWC CLI | ||
| # Fetch a payment-protected resource (auto-detects L402, X402, MPP) | ||
| npx @getalby/cli fetch --url "https://example.com/api" | ||
| npx @getalby/cli fetch "https://example.com/api" | ||
| # Fetch with custom method, headers, and body | ||
| npx @getalby/cli fetch --url "https://example.com/api" --method POST --body '{"query":"hello"}' --headers '{"Accept":"application/json"}' | ||
| npx @getalby/cli fetch "https://example.com/api" --method POST --body '{"query":"hello"}' --headers '{"Accept":"application/json"}' | ||
| # Fetch with a custom max amount (default: 5000 sats, 0 = no limit) | ||
| npx @getalby/cli fetch --url "https://example.com/api" --max-amount 1000 | ||
| npx @getalby/cli fetch "https://example.com/api" --max-amount 1000 | ||
@@ -135,0 +135,0 @@ # Wait for a payment notification |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
75054
0.35%1340
0.3%