WizardConnect/packages/test-cli/src/cli.ts
2026-03-06 11:38:09 +01:00

60 lines
1.8 KiB
JavaScript

#!/usr/bin/env node
// Copyright (C) 2026 Whiterun LLC,
// This software is licensed under the GNU Lesser General Public License (LGPL), version 3.0 or later.
// A copy of the license can be found in the LICENSE file or at https://www.gnu.org/licenses/lgpl-3.0.html
import { Command } from "commander";
import { runDappMode } from "./dapp.js";
import { runWalletMode } from "./wallet.js";
const program = new Command();
program
.name("wiz-test")
.description("WizardConnect protocol test CLI")
.version("0.1.0");
program
.command("dapp")
.description(
"Run as a dapp — generates URI, waits for wallet connection, logs all messages",
)
.option(
"-r, --relay <url>",
"Nostr relay WebSocket URL",
"wss://relay.cauldron.quest:443",
)
.option(
"-k, --private-key <hex>",
"Existing dapp private key (64 hex chars) — for reconnection testing",
)
.option("--secret <hex>", "Existing secret (hex) — for reconnection testing")
.option(
"--sign",
"Send a dummy sign request after wallet is ready (tests approval flow)",
)
.action(async (options) => {
await runDappMode(options);
});
program
.command("wallet")
.description("Run as a wallet — connects to a dapp URI, pushes test pubkeys")
.option(
"-r, --relay <url>",
"Nostr relay WebSocket URL",
"wss://relay.cauldron.quest:443",
)
.requiredOption("-u, --uri <uri>", "wiz:// URI from dapp")
.option(
"-k, --private-key <hex>",
"Wallet private key (64 hex chars) — random if omitted",
)
.action(async (options) => {
await runWalletMode(options);
});
// Strip bare "--" that npm inserts when forwarding arguments through
// multiple script layers (e.g. `npm run wallet -- --uri ...`).
const argv = process.argv.filter((arg) => arg !== "--");
program.parse(argv);