@toon-protocol/rig 2.3.0 → 2.4.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.
package/README.md CHANGED
@@ -4,7 +4,10 @@ Git-to-TOON write path core — build git objects and NIP-34 events for the Rig
4
4
 
5
5
  | command | owner | what it does |
6
6
  | --- | --- | --- |
7
- | `rig init` | rig (free) | one-shot repo setup: identity + `toon.*` git config |
7
+ | `rig identity create` | rig (free) | mint a fresh BIP-39 identity into the encrypted keystore — the phrase is shown ONCE. Removes the cold-start wall |
8
+ | `rig identity show` | rig (free) | the active identity's source + derived pubkey (never the phrase) |
9
+ | `rig identity import` | rig (free) | write an existing phrase (read from stdin, never argv) to the keystore |
10
+ | `rig init` | rig (free) | one-shot repo setup: identity (offers to generate one) + `toon.*` git config |
8
11
  | `rig remote add/remove/list` | rig (free) | relays as REAL git remotes (`origin` = default publish target) |
9
12
  | `rig clone <relay-url> <owner>/<repo-id> [dir]` | rig (free) | bootstrap a repo from TOON: relay state + SHA-verified Arweave objects → a real, push-capable git repository. Shadows `git clone` |
10
13
  | `rig fetch [remote]` | rig (free) | download the missing object delta + update `refs/remotes/<remote>/*` (no merge — `rig merge origin/main`). Shadows `git fetch` |
@@ -23,13 +26,20 @@ Git-to-TOON write path core — build git objects and NIP-34 events for the Rig
23
26
  ```sh
24
27
  npm install -g @toon-protocol/rig
25
28
 
26
- # 1. identity — a BIP-39 seed phrase, either in your environment…
27
- export RIG_MNEMONIC="abandon abandon about"
28
- # …or in a project-local .env (gitignore it!):
29
- echo 'RIG_MNEMONIC="abandon abandon … about"' >> .env
29
+ # 1. identity — mint one on the spot (no BIP-39 tooling needed). The seed
30
+ # phrase is shown ONCE (write it down) and stored in an encrypted keystore
31
+ # under ~/.toon-client. This is the cold-start step `git init` never needs.
32
+ rig identity create
33
+ rig identity show # active source + derived pubkey (never the phrase)
34
+ # Already have a phrase? Bring it instead of generating:
35
+ export RIG_MNEMONIC="abandon abandon … about" # env, or…
36
+ echo 'RIG_MNEMONIC="abandon abandon … about"' >> .env # project .env (gitignore it!)
37
+ rig identity import # …or import it into the keystore (reads stdin)
30
38
 
31
39
  # 2. one-shot repo setup (free): writes toon.repoid + toon.owner to the
32
- # repo's local git config and reports which identity source is active
40
+ # repo's local git config and reports which identity source is active.
41
+ # No identity yet? `rig init` offers to generate one (or pass
42
+ # --generate-identity for the non-interactive path).
33
43
  rig init # default repo id = directory name
34
44
  rig init --repo-id my-repo # or pick one
35
45
 
@@ -111,8 +121,20 @@ The passthrough is exempt from the `--json` contract: `rig status --json` runs `
111
121
 
112
122
  The CLI is **standalone by default**: it embeds its own payment client built
113
123
  from your seed phrase (`@toon-protocol/client` is a regular dependency,
114
- installed automatically with the package) — no daemon is ever required. The
115
- mnemonic is resolved along one precedence chain — highest first:
124
+ installed automatically with the package) — no daemon is ever required.
125
+
126
+ **No phrase yet? Generate one — `rig identity create`.** It mints a fresh
127
+ BIP-39 mnemonic (via the client's generator — no external BIP-39 tooling),
128
+ shows it ONCE with a backup warning, and writes it to the encrypted keystore
129
+ under `TOON_CLIENT_HOME`. It refuses to overwrite an existing identity without
130
+ `--force`. `rig identity show` reports the active source + pubkey (never the
131
+ phrase); `rig identity import` writes an existing phrase (read from stdin,
132
+ never a CLI argument) to the keystore. `--json` on **`create`** is the ONE
133
+ sanctioned path that emits the phrase (in a `mnemonic` field — treat as
134
+ secret); `show`/`import` never do. `rig init` also offers to generate on a
135
+ chain miss (or `rig init --generate-identity`).
136
+
137
+ The mnemonic is resolved along one precedence chain — highest first:
116
138
 
117
139
  1. `RIG_MNEMONIC` environment variable
118
140
  2. `TOON_CLIENT_MNEMONIC` environment variable — deprecated alias, warns on
@@ -1,11 +1,14 @@
1
1
  // src/cli/identity.ts
2
- import { existsSync, readFileSync } from "fs";
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
3
3
  import { homedir } from "os";
4
4
  import { dirname, join } from "path";
5
5
  var MissingIdentityError = class extends Error {
6
6
  constructor(configPath) {
7
7
  super(
8
- `no identity found \u2014 rig needs a BIP-39 seed phrase to sign and pay. Provide one of (highest precedence first):
8
+ `no identity found \u2014 rig needs a BIP-39 seed phrase to sign and pay.
9
+ Generate one now (no BIP-39 tooling needed):
10
+ \u2022 \`rig identity create\` \u2014 mint a fresh identity into the encrypted keystore (shows the phrase once to back up)
11
+ Or point rig at an existing phrase (highest precedence first):
9
12
  \u2022 RIG_MNEMONIC environment variable
10
13
  \u2022 RIG_MNEMONIC=<phrase> in a project-local .env file (gitignore it!)
11
14
  \u2022 the shared client config at ${configPath} (mnemonic or keystorePath + TOON_CLIENT_KEYSTORE_PASSWORD)`
@@ -14,9 +17,14 @@ var MissingIdentityError = class extends Error {
14
17
  }
15
18
  };
16
19
  var DEFAULT_KEYSTORE_PASSWORD = "toon-client-default";
20
+ function clientStateDir(env) {
21
+ return env["TOON_CLIENT_HOME"] ?? join(homedir(), ".toon-client");
22
+ }
17
23
  function clientConfigPath(env) {
18
- const dir = env["TOON_CLIENT_HOME"] ?? join(homedir(), ".toon-client");
19
- return join(dir, "config.json");
24
+ return join(clientStateDir(env), "config.json");
25
+ }
26
+ function clientKeystorePath(env) {
27
+ return join(clientStateDir(env), "keystore.json");
20
28
  }
21
29
  function readClientConfigFile(path) {
22
30
  try {
@@ -28,6 +36,25 @@ function readClientConfigFile(path) {
28
36
  );
29
37
  }
30
38
  }
39
+ function linkKeystoreInClientConfig(env, keystorePath, autoPassword) {
40
+ const configPath = clientConfigPath(env);
41
+ mkdirSync(dirname(configPath), { recursive: true });
42
+ const existing = readClientConfigFile(configPath);
43
+ const merged = {
44
+ ...existing,
45
+ keystorePath,
46
+ ...autoPassword ? { keystoreAutoPassword: true } : (
47
+ // A user-set password: drop any stale auto flag so decryption
48
+ // requires TOON_CLIENT_KEYSTORE_PASSWORD.
49
+ { keystoreAutoPassword: false }
50
+ )
51
+ };
52
+ writeFileSync(configPath, JSON.stringify(merged, null, 2) + "\n", {
53
+ encoding: "utf8",
54
+ mode: 384
55
+ });
56
+ return configPath;
57
+ }
31
58
  var DOTENV_LINE_RE = /^\s*(?:export\s+)?RIG_MNEMONIC\s*=\s*(.*)\s*$/;
32
59
  function parseDotenvMnemonic(content) {
33
60
  let found;
@@ -132,6 +159,11 @@ async function resolveIdentity(options) {
132
159
 
133
160
  export {
134
161
  MissingIdentityError,
162
+ DEFAULT_KEYSTORE_PASSWORD,
163
+ clientConfigPath,
164
+ clientKeystorePath,
165
+ readClientConfigFile,
166
+ linkKeystoreInClientConfig,
135
167
  resolveIdentity
136
168
  };
137
- //# sourceMappingURL=chunk-CW4HJNMU.js.map
169
+ //# sourceMappingURL=chunk-XGFBDUQX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/identity.ts"],"sourcesContent":["/**\n * Identity resolution for the standalone-only `rig` CLI (#248).\n *\n * One precedence chain, used by every command that signs or pays:\n *\n * 1. `RIG_MNEMONIC` environment variable\n * 2. `TOON_CLIENT_MNEMONIC` environment variable — DEPRECATED alias of the\n * env tier (a one-line stderr warning fires when it is the source)\n * 3. project-local `.env` — walked up from the working directory (through\n * the repo root to the filesystem root); ONLY the `RIG_MNEMONIC` line is\n * parsed out of it (never loaded into the process env, never required\n * to exist)\n * 4. the shared `~/.toon-client` state dir (`TOON_CLIENT_HOME` override):\n * encrypted keystore (`keystorePath` + `TOON_CLIENT_KEYSTORE_PASSWORD`,\n * auto-password fallback for daemon-provisioned keystores), then the\n * plain `mnemonic` config field — the pre-#248 standalone-context logic\n *\n * The BIP-44 `mnemonicAccountIndex` from the shared config file applies to\n * every source (same convention as the daemon), so the derived pubkey never\n * depends on WHERE the phrase came from.\n *\n * The phrase itself is never written anywhere by rig (not to git config, not\n * to any repo file) and never printed — callers report only the SOURCE and\n * the derived pubkey.\n *\n * Key derivation and keystore decryption live in the `@toon-protocol/client`\n * dependency, loaded via dynamic import so this module can be statically\n * imported by every command without dragging the client into runs that fail\n * earlier (usage errors, missing git repo, …).\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\n\n/** Where the mnemonic came from (reported in output; the phrase never is). */\nexport type IdentitySourceKind =\n /** `RIG_MNEMONIC` environment variable. */\n | 'env'\n /** `TOON_CLIENT_MNEMONIC` environment variable (deprecated alias). */\n | 'env-alias'\n /** `RIG_MNEMONIC` parsed out of a project-local `.env` file. */\n | 'dotenv'\n /** Encrypted keystore referenced by the shared client config. */\n | 'keystore'\n /** Plain `mnemonic` field of the shared client config file. */\n | 'config';\n\n/** A resolved signing identity: source + derived pubkey (never the phrase). */\nexport interface ResolvedIdentity {\n /** The BIP-39 phrase. Handle with care; never log or persist it. */\n mnemonic: string;\n /** BIP-44 account index used for derivation (shared config, default 0). */\n accountIndex: number;\n source: IdentitySourceKind;\n /** Human-facing source label, e.g. `RIG_MNEMONIC env` or a file path. */\n sourceLabel: string;\n /** Derived Nostr pubkey (hex) — the repo owner / `toon.owner` value. */\n pubkey: string;\n}\n\n/** No mnemonic could be resolved anywhere on the chain. */\nexport class MissingIdentityError extends Error {\n constructor(configPath: string) {\n super(\n 'no identity found — rig needs a BIP-39 seed phrase to sign and pay.\\n' +\n 'Generate one now (no BIP-39 tooling needed):\\n' +\n ' • `rig identity create` — mint a fresh identity into the encrypted ' +\n 'keystore (shows the phrase once to back up)\\n' +\n 'Or point rig at an existing phrase (highest precedence first):\\n' +\n ' • RIG_MNEMONIC environment variable\\n' +\n ' • RIG_MNEMONIC=<phrase> in a project-local .env file (gitignore it!)\\n' +\n ` • the shared client config at ${configPath} (mnemonic or ` +\n 'keystorePath + TOON_CLIENT_KEYSTORE_PASSWORD)'\n );\n this.name = 'MissingIdentityError';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Shared client config conventions (duplicated from client-mcp — the same\n// note as standalone/nonce-guard.ts: no @toon-protocol/client-mcp import)\n// ---------------------------------------------------------------------------\n\n/**\n * Duplicated daemon convention (client-mcp `daemon/config.ts`): the password\n * used to encrypt a keystore rig auto-provisions (`rig identity create`\n * with no `TOON_CLIENT_KEYSTORE_PASSWORD` set) so the identity reloads across\n * runs with no env var. At-rest obfuscation only.\n */\nexport const DEFAULT_KEYSTORE_PASSWORD = 'toon-client-default';\n\n/** Shared client state dir: `TOON_CLIENT_HOME`, else `~/.toon-client`. */\nexport function clientStateDir(env: NodeJS.ProcessEnv): string {\n return env['TOON_CLIENT_HOME'] ?? join(homedir(), '.toon-client');\n}\n\n/** Shared client config file path (`<state-dir>/config.json`). */\nexport function clientConfigPath(env: NodeJS.ProcessEnv): string {\n return join(clientStateDir(env), 'config.json');\n}\n\n/** Default encrypted-keystore path (`<state-dir>/keystore.json`) — the same\n * convention the daemon's first-run provisioning uses. */\nexport function clientKeystorePath(env: NodeJS.ProcessEnv): string {\n return join(clientStateDir(env), 'keystore.json');\n}\n\n/** The subset of the shared client config file identity resolution reads. */\nexport interface ClientConfigIdentityFields {\n mnemonic?: unknown;\n mnemonicAccountIndex?: unknown;\n keystorePath?: unknown;\n keystoreAutoPassword?: unknown;\n}\n\nexport function readClientConfigFile(path: string): ClientConfigIdentityFields {\n try {\n return JSON.parse(readFileSync(path, 'utf8')) as ClientConfigIdentityFields;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return {};\n throw new Error(\n `failed to read client config at ${path}: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n}\n\n/**\n * Link a freshly written keystore into the shared client config so the\n * keystore tier of {@link resolveIdentity} (and the daemon) picks it up on the\n * next run — merging into any existing config, preserving every other field,\n * and writing owner-only (mode 0o600). `keystoreAutoPassword` records whether\n * rig chose the default password (so a user-set password still requires the\n * env var to decrypt, exactly like the daemon's first-run convention).\n */\nexport function linkKeystoreInClientConfig(\n env: NodeJS.ProcessEnv,\n keystorePath: string,\n autoPassword: boolean\n): string {\n const configPath = clientConfigPath(env);\n mkdirSync(dirname(configPath), { recursive: true });\n const existing = readClientConfigFile(configPath) as Record<string, unknown>;\n const merged: Record<string, unknown> = {\n ...existing,\n keystorePath,\n ...(autoPassword\n ? { keystoreAutoPassword: true }\n : // A user-set password: drop any stale auto flag so decryption\n // requires TOON_CLIENT_KEYSTORE_PASSWORD.\n { keystoreAutoPassword: false }),\n };\n writeFileSync(configPath, JSON.stringify(merged, null, 2) + '\\n', {\n encoding: 'utf8',\n mode: 0o600,\n });\n return configPath;\n}\n\n// ---------------------------------------------------------------------------\n// .env parsing (RIG_MNEMONIC only — never arbitrary env loading)\n// ---------------------------------------------------------------------------\n\nconst DOTENV_LINE_RE = /^\\s*(?:export\\s+)?RIG_MNEMONIC\\s*=\\s*(.*)\\s*$/;\n\n/**\n * Extract ONLY the `RIG_MNEMONIC` value from `.env` file content. Supports\n * `export ` prefixes, single/double quotes, full-line `#` comments, and\n * inline ` #` comments on unquoted values. Multiple assignments: the last\n * one wins (shell-sourcing semantics). An empty value counts as unset.\n * Nothing is ever loaded into `process.env`.\n */\nexport function parseDotenvMnemonic(content: string): string | undefined {\n let found: string | undefined;\n for (const line of content.split(/\\r?\\n/)) {\n const match = DOTENV_LINE_RE.exec(line);\n if (!match) continue;\n let value = (match[1] ?? '').trim();\n const quote = value[0];\n if ((quote === '\"' || quote === \"'\") && value.length >= 2 && value.endsWith(quote)) {\n value = value.slice(1, -1);\n } else {\n // Unquoted: an inline comment starts at the first whitespace-preceded #.\n const hash = value.search(/\\s#/);\n if (hash !== -1) value = value.slice(0, hash);\n value = value.trim();\n }\n if (value !== '') found = value;\n }\n return found;\n}\n\n/**\n * Walk up from `startDir` (the working directory — the walk passes through\n * the repo root) to the filesystem root, returning the first `.env` file\n * that defines `RIG_MNEMONIC`. `stopDir` bounds the walk (tests).\n */\nexport function findDotenvMnemonic(\n startDir: string,\n stopDir?: string\n): { path: string; mnemonic: string } | undefined {\n let dir = startDir;\n for (;;) {\n const candidate = join(dir, '.env');\n if (existsSync(candidate)) {\n try {\n const mnemonic = parseDotenvMnemonic(readFileSync(candidate, 'utf8'));\n if (mnemonic !== undefined) return { path: candidate, mnemonic };\n } catch {\n // Unreadable .env → keep walking; the file is never required.\n }\n }\n if (stopDir !== undefined && dir === stopDir) return undefined;\n const parent = dirname(dir);\n if (parent === dir) return undefined;\n dir = parent;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Resolution\n// ---------------------------------------------------------------------------\n\nexport interface ResolveIdentityOptions {\n env: NodeJS.ProcessEnv;\n /** Working directory the `.env` walk starts from. */\n cwd: string;\n /** Stderr line sink for the deprecated-alias warning. */\n warn(line: string): void;\n /** Bound the `.env` walk-up (tests only). */\n dotenvStopDir?: string;\n}\n\n/** The resolved source before any derivation (dependency-free). */\ninterface MnemonicSource {\n mnemonic: string;\n source: IdentitySourceKind;\n sourceLabel: string;\n}\n\nfunction resolveMnemonicSource(\n options: ResolveIdentityOptions,\n file: ClientConfigIdentityFields,\n configPath: string\n): MnemonicSource | { keystorePath: string } {\n const { env } = options;\n\n const rigEnv = env['RIG_MNEMONIC']?.trim();\n if (rigEnv) {\n return { mnemonic: rigEnv, source: 'env', sourceLabel: 'RIG_MNEMONIC env' };\n }\n\n const aliasEnv = env['TOON_CLIENT_MNEMONIC']?.trim();\n if (aliasEnv) {\n options.warn(\n 'rig: TOON_CLIENT_MNEMONIC is deprecated — rename the variable to RIG_MNEMONIC'\n );\n return {\n mnemonic: aliasEnv,\n source: 'env-alias',\n sourceLabel: 'TOON_CLIENT_MNEMONIC env (deprecated alias)',\n };\n }\n\n const dotenv = findDotenvMnemonic(options.cwd, options.dotenvStopDir);\n if (dotenv) {\n return {\n mnemonic: dotenv.mnemonic,\n source: 'dotenv',\n sourceLabel: dotenv.path,\n };\n }\n\n if (typeof file.keystorePath === 'string' && file.keystorePath !== '') {\n return { keystorePath: file.keystorePath };\n }\n if (typeof file.mnemonic === 'string' && file.mnemonic.trim() !== '') {\n return {\n mnemonic: file.mnemonic.trim(),\n source: 'config',\n sourceLabel: configPath,\n };\n }\n throw new MissingIdentityError(configPath);\n}\n\n/**\n * Load the client key helpers. `@toon-protocol/client` is a regular runtime\n * dependency (#259); the import stays dynamic purely so commands that fail\n * earlier never pay its startup cost.\n */\nasync function loadClientKeys(): Promise<{\n loadKeystore(path: string, password: string): string;\n deriveNostrKeyFromMnemonic(\n mnemonic: string,\n accountIndex?: number\n ): { secretKey: Uint8Array; pubkey: string };\n}> {\n return await import('@toon-protocol/client');\n}\n\n/**\n * Resolve the CLI signing identity along the precedence chain and derive its\n * Nostr pubkey. Throws {@link MissingIdentityError} (with the full\n * three-option remediation) when nothing on the chain yields a phrase.\n */\nexport async function resolveIdentity(\n options: ResolveIdentityOptions\n): Promise<ResolvedIdentity> {\n const configPath = clientConfigPath(options.env);\n const file = readClientConfigFile(configPath);\n const picked = resolveMnemonicSource(options, file, configPath);\n\n const keys = await loadClientKeys();\n let source: MnemonicSource;\n if ('keystorePath' in picked) {\n const password =\n options.env['TOON_CLIENT_KEYSTORE_PASSWORD'] ??\n (file.keystoreAutoPassword === true ? DEFAULT_KEYSTORE_PASSWORD : undefined);\n if (!password) {\n throw new Error(\n `keystorePath is set in ${configPath} but TOON_CLIENT_KEYSTORE_PASSWORD is not provided`\n );\n }\n source = {\n mnemonic: keys.loadKeystore(picked.keystorePath, password),\n source: 'keystore',\n sourceLabel: picked.keystorePath,\n };\n } else {\n source = picked;\n }\n\n const accountIndex =\n typeof file.mnemonicAccountIndex === 'number' ? file.mnemonicAccountIndex : 0;\n const { pubkey } = keys.deriveNostrKeyFromMnemonic(source.mnemonic, accountIndex);\n return { ...source, accountIndex, pubkey };\n}\n"],"mappings":";AA+BA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AA6BvB,IAAM,uBAAN,cAAmC,MAAM;AAAA,EAC9C,YAAY,YAAoB;AAC9B;AAAA,MACE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAOqC,UAAU;AAAA,IAEjD;AACA,SAAK,OAAO;AAAA,EACd;AACF;AAaO,IAAM,4BAA4B;A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