arc402-cli 0.6.0 → 0.7.1

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.
Files changed (56) hide show
  1. package/dist/commands/backup.d.ts +3 -0
  2. package/dist/commands/backup.d.ts.map +1 -0
  3. package/dist/commands/backup.js +106 -0
  4. package/dist/commands/backup.js.map +1 -0
  5. package/dist/commands/config.d.ts.map +1 -1
  6. package/dist/commands/config.js +11 -1
  7. package/dist/commands/config.js.map +1 -1
  8. package/dist/commands/discover.d.ts.map +1 -1
  9. package/dist/commands/discover.js +60 -15
  10. package/dist/commands/discover.js.map +1 -1
  11. package/dist/commands/doctor.d.ts +3 -0
  12. package/dist/commands/doctor.d.ts.map +1 -0
  13. package/dist/commands/doctor.js +205 -0
  14. package/dist/commands/doctor.js.map +1 -0
  15. package/dist/commands/wallet.d.ts.map +1 -1
  16. package/dist/commands/wallet.js +192 -58
  17. package/dist/commands/wallet.js.map +1 -1
  18. package/dist/commands/watch.d.ts.map +1 -1
  19. package/dist/commands/watch.js +146 -9
  20. package/dist/commands/watch.js.map +1 -1
  21. package/dist/config.d.ts +9 -0
  22. package/dist/config.d.ts.map +1 -1
  23. package/dist/config.js +35 -3
  24. package/dist/config.js.map +1 -1
  25. package/dist/daemon/index.d.ts.map +1 -1
  26. package/dist/daemon/index.js +359 -220
  27. package/dist/daemon/index.js.map +1 -1
  28. package/dist/endpoint-notify.d.ts +9 -1
  29. package/dist/endpoint-notify.d.ts.map +1 -1
  30. package/dist/endpoint-notify.js +116 -3
  31. package/dist/endpoint-notify.js.map +1 -1
  32. package/dist/index.js +26 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/program.d.ts.map +1 -1
  35. package/dist/program.js +4 -0
  36. package/dist/program.js.map +1 -1
  37. package/dist/repl.d.ts.map +1 -1
  38. package/dist/repl.js +45 -34
  39. package/dist/repl.js.map +1 -1
  40. package/dist/ui/format.d.ts.map +1 -1
  41. package/dist/ui/format.js +2 -0
  42. package/dist/ui/format.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/commands/backup.ts +117 -0
  45. package/src/commands/config.ts +12 -2
  46. package/src/commands/discover.ts +74 -21
  47. package/src/commands/doctor.ts +172 -0
  48. package/src/commands/wallet.ts +194 -57
  49. package/src/commands/watch.ts +207 -10
  50. package/src/config.ts +48 -2
  51. package/src/daemon/index.ts +297 -152
  52. package/src/endpoint-notify.ts +86 -3
  53. package/src/index.ts +26 -0
  54. package/src/program.ts +4 -0
  55. package/src/repl.ts +53 -42
  56. package/src/ui/format.ts +1 -0
package/src/config.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
3
  import * as os from "os";
4
+ import { randomUUID } from "crypto";
4
5
 
5
6
  export interface Arc402Config {
6
7
  network: "base-mainnet" | "base-sepolia";
@@ -40,20 +41,46 @@ export interface Arc402Config {
40
41
  telegramBotToken?: string;
41
42
  telegramChatId?: string;
42
43
  telegramThreadId?: number;
44
+ /** Tracks onboarding progress so `wallet deploy` can resume after interruption. */
45
+ onboardingProgress?: {
46
+ walletAddress: string;
47
+ step: number; // last completed step number (2=machineKey, 3=passkey, 4=policy, 5=agent)
48
+ completedSteps: string[];
49
+ };
43
50
  wcSession?: {
44
51
  topic: string;
45
52
  expiry: number; // Unix timestamp
46
53
  account: string; // Phone wallet address
47
54
  chainId: number;
48
55
  };
56
+ deviceId?: string; // UUID identifying the device this config was created on
57
+ lastCliVersion?: string; // Last CLI version that wrote this config (for upgrade detection)
49
58
  }
50
59
 
51
60
  const CONFIG_DIR = path.join(os.homedir(), ".arc402");
52
61
  const CONFIG_PATH = process.env.ARC402_CONFIG || path.join(CONFIG_DIR, "config.json");
62
+ const DEVICE_ID_PATH = path.join(CONFIG_DIR, "device.id");
63
+
64
+ // WalletConnect project ID — get your own at cloud.walletconnect.com
65
+ const DEFAULT_WC_PROJECT_ID = "455e9425343b9156fce1428250c9a54a";
66
+ export const getWcProjectId = () => process.env.WC_PROJECT_ID ?? DEFAULT_WC_PROJECT_ID;
53
67
 
54
68
  export const getConfigPath = () => CONFIG_PATH;
55
69
 
70
+ /** Returns this device's stable UUID, creating it on first call. */
71
+ function getOrCreateDeviceId(): string {
72
+ if (fs.existsSync(DEVICE_ID_PATH)) {
73
+ return fs.readFileSync(DEVICE_ID_PATH, "utf-8").trim();
74
+ }
75
+ const id = randomUUID();
76
+ fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
77
+ fs.writeFileSync(DEVICE_ID_PATH, id, { mode: 0o600 });
78
+ return id;
79
+ }
80
+
56
81
  export function loadConfig(): Arc402Config {
82
+ const thisDeviceId = getOrCreateDeviceId();
83
+
57
84
  if (!fs.existsSync(CONFIG_PATH)) {
58
85
  // Auto-create with Base Mainnet defaults — zero friction
59
86
  const defaults = NETWORK_DEFAULTS["base-mainnet"] ?? {};
@@ -61,7 +88,7 @@ export function loadConfig(): Arc402Config {
61
88
  const autoConfig: Arc402Config = {
62
89
  network: "base-mainnet",
63
90
  rpcUrl: defaults.rpcUrl ?? "https://mainnet.base.org",
64
- walletConnectProjectId: "455e9425343b9156fce1428250c9a54a",
91
+ walletConnectProjectId: getWcProjectId(),
65
92
  ownerAddress: undefined,
66
93
  policyEngineAddress: defaults.policyEngineAddress,
67
94
  trustRegistryAddress: defaults.trustRegistryAddress ?? "",
@@ -74,18 +101,37 @@ export function loadConfig(): Arc402Config {
74
101
  walletFactoryAddress: defaults.walletFactoryAddress,
75
102
  sessionChannelsAddress: defaults.sessionChannelsAddress,
76
103
  disputeModuleAddress: defaults.disputeModuleAddress,
104
+ deviceId: thisDeviceId,
77
105
  };
78
106
  saveConfig(autoConfig);
79
107
  console.log(`◈ Config auto-created at ${CONFIG_PATH} (Base Mainnet)`);
108
+ console.log("⚠ Base Mainnet — real funds at risk. Use arc402 config init for testnet.");
80
109
  return autoConfig;
81
110
  }
82
- return JSON.parse(fs.readFileSync(CONFIG_PATH, "utf-8")) as Arc402Config;
111
+
112
+ const config = JSON.parse(fs.readFileSync(CONFIG_PATH, "utf-8")) as Arc402Config;
113
+
114
+ // Multi-device awareness: warn if config was created on a different device
115
+ if (config.deviceId && config.deviceId !== thisDeviceId) {
116
+ console.warn("⚠ This config was created on a different device. Some keys may not work.");
117
+ }
118
+
119
+ // Backfill deviceId if missing (older config)
120
+ if (!config.deviceId) {
121
+ config.deviceId = thisDeviceId;
122
+ saveConfig(config);
123
+ }
124
+
125
+ return config;
83
126
  }
84
127
 
85
128
  export function saveConfig(config: Arc402Config): void {
86
129
  const configDir = path.dirname(CONFIG_PATH);
87
130
  fs.mkdirSync(configDir, { recursive: true, mode: 0o700 });
88
131
  fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), { mode: 0o600 });
132
+ if (config.privateKey) {
133
+ console.warn("⚠ Private key stored in plaintext at ~/.arc402/config.json");
134
+ }
89
135
  }
90
136
 
91
137
  export const configExists = () => fs.existsSync(CONFIG_PATH);