@did-btcr2/cli 0.15.0 → 0.16.0

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 (71) hide show
  1. package/README.md +47 -6
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/cjs/index.js +563 -117
  4. package/dist/esm/src/cli.js +7 -4
  5. package/dist/esm/src/cli.js.map +1 -1
  6. package/dist/esm/src/commands/config.js +11 -15
  7. package/dist/esm/src/commands/config.js.map +1 -1
  8. package/dist/esm/src/commands/create.js +4 -1
  9. package/dist/esm/src/commands/create.js.map +1 -1
  10. package/dist/esm/src/commands/deactivate.js +3 -1
  11. package/dist/esm/src/commands/deactivate.js.map +1 -1
  12. package/dist/esm/src/commands/index.js +2 -0
  13. package/dist/esm/src/commands/index.js.map +1 -1
  14. package/dist/esm/src/commands/init.js +63 -0
  15. package/dist/esm/src/commands/init.js.map +1 -0
  16. package/dist/esm/src/commands/keystore.js +81 -0
  17. package/dist/esm/src/commands/keystore.js.map +1 -0
  18. package/dist/esm/src/commands/profile.js +1 -1
  19. package/dist/esm/src/commands/profile.js.map +1 -1
  20. package/dist/esm/src/commands/update.js +3 -1
  21. package/dist/esm/src/commands/update.js.map +1 -1
  22. package/dist/esm/src/config.js +85 -28
  23. package/dist/esm/src/config.js.map +1 -1
  24. package/dist/esm/src/keystore/file-key-store.js +340 -32
  25. package/dist/esm/src/keystore/file-key-store.js.map +1 -1
  26. package/dist/esm/src/keystore/passphrase.js +40 -10
  27. package/dist/esm/src/keystore/passphrase.js.map +1 -1
  28. package/dist/esm/src/keystore/paths.js +6 -18
  29. package/dist/esm/src/keystore/paths.js.map +1 -1
  30. package/dist/esm/src/paths.js +59 -0
  31. package/dist/esm/src/paths.js.map +1 -0
  32. package/dist/esm/src/types.js.map +1 -1
  33. package/dist/types/src/cli.d.ts.map +1 -1
  34. package/dist/types/src/commands/config.d.ts.map +1 -1
  35. package/dist/types/src/commands/create.d.ts.map +1 -1
  36. package/dist/types/src/commands/deactivate.d.ts.map +1 -1
  37. package/dist/types/src/commands/index.d.ts +2 -0
  38. package/dist/types/src/commands/index.d.ts.map +1 -1
  39. package/dist/types/src/commands/init.d.ts +13 -0
  40. package/dist/types/src/commands/init.d.ts.map +1 -0
  41. package/dist/types/src/commands/keystore.d.ts +10 -0
  42. package/dist/types/src/commands/keystore.d.ts.map +1 -0
  43. package/dist/types/src/commands/update.d.ts.map +1 -1
  44. package/dist/types/src/config.d.ts +38 -14
  45. package/dist/types/src/config.d.ts.map +1 -1
  46. package/dist/types/src/keystore/file-key-store.d.ts +86 -10
  47. package/dist/types/src/keystore/file-key-store.d.ts.map +1 -1
  48. package/dist/types/src/keystore/passphrase.d.ts +16 -1
  49. package/dist/types/src/keystore/passphrase.d.ts.map +1 -1
  50. package/dist/types/src/keystore/paths.d.ts +6 -10
  51. package/dist/types/src/keystore/paths.d.ts.map +1 -1
  52. package/dist/types/src/paths.d.ts +54 -0
  53. package/dist/types/src/paths.d.ts.map +1 -0
  54. package/dist/types/src/types.d.ts +38 -0
  55. package/dist/types/src/types.d.ts.map +1 -1
  56. package/package.json +3 -3
  57. package/src/cli.ts +8 -3
  58. package/src/commands/config.ts +12 -14
  59. package/src/commands/create.ts +4 -1
  60. package/src/commands/deactivate.ts +3 -1
  61. package/src/commands/index.ts +2 -0
  62. package/src/commands/init.ts +74 -0
  63. package/src/commands/keystore.ts +98 -0
  64. package/src/commands/profile.ts +1 -1
  65. package/src/commands/update.ts +3 -1
  66. package/src/config.ts +93 -32
  67. package/src/keystore/file-key-store.ts +455 -43
  68. package/src/keystore/passphrase.ts +48 -8
  69. package/src/keystore/paths.ts +6 -19
  70. package/src/paths.ts +79 -0
  71. package/src/types.ts +13 -1
@@ -1,21 +1,9 @@
1
- import { homedir } from 'node:os';
2
- import { join } from 'node:path';
3
- import { blankToUndef } from '../types.js';
4
1
  /**
5
- * Default keystore file path, following the XDG Base Directory Specification's
6
- * data directory. Secret key material is data a user accumulates, so it lives
7
- * under the data directory, kept separate from the configuration directory used
8
- * for portable settings.
9
- *
10
- * Resolution order:
11
- * 1. `$XDG_DATA_HOME/btcr2/keystore.json`
12
- * 2. `%LOCALAPPDATA%/btcr2/keystore.json` (Windows)
13
- * 3. `~/.local/share/btcr2/keystore.json` (fallback)
2
+ * The default keystore path now lives alongside the config file under a single
3
+ * CLI home root (`<home>/keystore.json`, ADR 079). The implementation lives in
4
+ * `../paths.ts` (the single source of truth for on-disk state locations); it is
5
+ * re-exported here so existing `./paths.js` importers in the keystore layer keep
6
+ * their import surface.
14
7
  */
15
- export function defaultKeystorePath() {
16
- const base = blankToUndef(process.env.XDG_DATA_HOME)
17
- ?? blankToUndef(process.env.LOCALAPPDATA)
18
- ?? join(homedir(), '.local', 'share');
19
- return join(base, 'btcr2', 'keystore.json');
20
- }
8
+ export { defaultKeystorePath } from '../paths.js';
21
9
  //# sourceMappingURL=paths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../../src/keystore/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;WAC/C,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;WACtC,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxC,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;AAC9C,CAAC"}
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../../src/keystore/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { homedir } from 'node:os';
2
+ import { join } from 'node:path';
3
+ import { blankToUndef } from './types.js';
4
+ /** Environment variable naming the CLI home directory (all state colocated). */
5
+ export const ENV_HOME = 'BTCR2_HOME';
6
+ /** The config and keystore file names, kept side by side under the home root. */
7
+ export const CONFIG_FILENAME = 'config.json';
8
+ export const KEYSTORE_FILENAME = 'keystore.json';
9
+ /**
10
+ * Resolves the CLI home directory: the single root that holds `config.json` and
11
+ * `keystore.json` side by side (ADR 079). Resolution order, highest wins:
12
+ *
13
+ * 1. `--home <dir>` (the {@link PathOverrides.home} flag)
14
+ * 2. `$BTCR2_HOME`
15
+ * 3. the platform default (see {@link platformDefaultHome})
16
+ *
17
+ * A blank value at any layer defers to the next, mirroring the `blankToUndef`
18
+ * treatment every other precedence layer uses, so an exported-but-empty
19
+ * `BTCR2_HOME` does not resolve the home to a bare relative path.
20
+ */
21
+ export function resolveHome(overrides) {
22
+ return blankToUndef(overrides?.home)
23
+ ?? blankToUndef(process.env[ENV_HOME])
24
+ ?? platformDefaultHome();
25
+ }
26
+ /**
27
+ * The default home when no `--home` / `$BTCR2_HOME` override is present, chosen
28
+ * per OS so the location is idiomatic while staying a single colocated dir:
29
+ *
30
+ * - Windows: `%LOCALAPPDATA%\btcr2` (fallback `%APPDATA%\btcr2`, then the user
31
+ * profile), the native place for per-user application state.
32
+ * - Linux / macOS: `~/.btcr2`, the short, teachable dot-directory in the same
33
+ * family as `~/.ssh`, `~/.aws`, and `~/.gnupg`.
34
+ */
35
+ export function platformDefaultHome() {
36
+ if (process.platform === 'win32') {
37
+ const base = blankToUndef(process.env.LOCALAPPDATA)
38
+ ?? blankToUndef(process.env.APPDATA)
39
+ ?? homedir();
40
+ return join(base, 'btcr2');
41
+ }
42
+ return join(homedir(), '.btcr2');
43
+ }
44
+ /**
45
+ * Default config-file path: `<home>/config.json`. The `--config` flag, when
46
+ * present, overrides it wholesale (it names a specific file, not a home).
47
+ */
48
+ export function defaultConfigPath(overrides) {
49
+ return join(resolveHome(overrides), CONFIG_FILENAME);
50
+ }
51
+ /**
52
+ * Default keystore path: `<home>/keystore.json`. The `--keystore` flag and a
53
+ * profile's `identity.keystore` (resolved in `config.ts`) override it; this
54
+ * function is the final fallback in that chain.
55
+ */
56
+ export function defaultKeystorePath(overrides) {
57
+ return join(resolveHome(overrides), KEYSTORE_FILENAME);
58
+ }
59
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAiB1C,gFAAgF;AAChF,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAC7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEjD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAC,SAAyB;IACnD,OAAO,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC;WAC/B,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;WACnC,mBAAmB,EAAE,CAAC;AAC7B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;eAC9C,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;eACjC,OAAO,EAAE,CAAC;QACf,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAyB;IACzD,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC,CAAC;AACvD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAyB;IAC3D,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC,CAAC;AACzD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,kBAAkB,GAAoB;IACjD,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS;CACpE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAyB;IACpD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AACjD,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,kBAAkB,GAAoB;IACjD,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS;CACpE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAyB;IACpD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AACjD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAWpD,OAAO,EAA8D,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAI1G;;GAEG;AACH,qBAAa,WAAW;IACtB,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC;;;;;;;;;;;;;OAaG;gBAED,OAAO,GAAE,UAA8B,EACvC,eAAe,GAAE,UAA+B;IA+ClD;;;;OAIG;IACU,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CASjD"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAapD,OAAO,EAA8D,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAI1G;;GAEG;AACH,qBAAa,WAAW;IACtB,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC;;;;;;;;;;;;;OAaG;gBAED,OAAO,GAAE,UAA8B,EACvC,eAAe,GAAE,UAA+B;IAkDlD;;;;OAIG;IACU,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CASjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBzC,OAAO,KAAK,EAAiB,aAAa,EAAiB,MAAM,aAAa,CAAC;AAG/E,sFAAsF;AACtF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,GAAG,IAAI,CA4H1F"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBzC,OAAO,KAAK,EAAiB,aAAa,EAAiB,MAAM,aAAa,CAAC;AAG/E,sFAAsF;AACtF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,GAAG,IAAI,CA0H1F"}
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/commands/create.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAuB,MAAM,cAAc,CAAC;AAKpE,OAAO,KAAK,EAAiB,aAAa,EAAiB,MAAM,aAAa,CAAC;AAS/E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAW,OAAO,EACzB,OAAO,EAAW,UAAU,EAC5B,eAAe,EAAG,UAAU,EAC5B,OAAO,EAAW,MAAM,aAAa,GACpC,IAAI,CAuGN"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/commands/create.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAuB,MAAM,cAAc,CAAC;AAKpE,OAAO,KAAK,EAAiB,aAAa,EAAiB,MAAM,aAAa,CAAC;AAS/E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAW,OAAO,EACzB,OAAO,EAAW,UAAU,EAC5B,eAAe,EAAG,UAAU,EAC5B,OAAO,EAAW,MAAM,aAAa,GACpC,IAAI,CAyGN"}
@@ -1 +1 @@
1
- {"version":3,"file":"deactivate.d.ts","sourceRoot":"","sources":["../../../../src/commands/deactivate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAgE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAI7G,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,aAAa,CAAC;AAKvE,wBAAgB,yBAAyB,CACvC,OAAO,EAAG,OAAO,EACjB,OAAO,EAAG,UAAU,EACpB,OAAO,EAAG,MAAM,aAAa,GAC5B,IAAI,CAsGN"}
1
+ {"version":3,"file":"deactivate.d.ts","sourceRoot":"","sources":["../../../../src/commands/deactivate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAiG,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAI9I,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,aAAa,CAAC;AAKvE,wBAAgB,yBAAyB,CACvC,OAAO,EAAG,OAAO,EACjB,OAAO,EAAG,UAAU,EACpB,OAAO,EAAG,MAAM,aAAa,GAC5B,IAAI,CAwGN"}
@@ -1,8 +1,10 @@
1
+ export { registerInitCommand } from './init.js';
1
2
  export { registerCreateCommand } from './create.js';
2
3
  export { registerResolveCommand } from './resolve.js';
3
4
  export { registerUpdateCommand } from './update.js';
4
5
  export { registerDeactivateCommand } from './deactivate.js';
5
6
  export { registerKeyCommand } from './key.js';
7
+ export { registerKeystoreCommand } from './keystore.js';
6
8
  export { registerConfigCommand } from './config.js';
7
9
  export { registerProfileCommand } from './profile.js';
8
10
  export { registerCompletionCommand } from './completion.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Command } from 'commander';
2
+ import type { GlobalOptions } from '../types.js';
3
+ /**
4
+ * Registers the top-level `btcr2 init`: the one-command entry point that creates
5
+ * the btcr2 home (ADR 079), writes a default config if none exists, and
6
+ * establishes the keystore if none exists (encrypted with a confirmed passphrase
7
+ * by default, or `--dev` for an unencrypted testnet keystore). Idempotent:
8
+ * existing files are left untouched unless `--force` is given. Establishing the
9
+ * passphrase here, up front and confirmed, is what keeps the first `key generate`
10
+ * off the accidental-first-seal path (ADR 080).
11
+ */
12
+ export declare function registerInitCommand(program: Command, globals: () => GlobalOptions): void;
13
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQzC,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,GAAG,IAAI,CAsDxF"}
@@ -0,0 +1,10 @@
1
+ import type { Command } from 'commander';
2
+ import type { GlobalOptions } from '../types.js';
3
+ /**
4
+ * Registers the `keystore` command group: establish, inspect, and re-key the
5
+ * encrypted keystore (ADR 080). These operate on the keystore file directly (no
6
+ * Bitcoin connection or KeyManager) and never decrypt a key except when
7
+ * re-sealing during `change-passphrase`.
8
+ */
9
+ export declare function registerKeystoreCommand(program: Command, globals: () => GlobalOptions): void;
10
+ //# sourceMappingURL=keystore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keystore.d.ts","sourceRoot":"","sources":["../../../../src/commands/keystore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,GAAG,IAAI,CAkF5F"}
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/commands/update.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAgE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAI7G,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,aAAa,CAAC;AAEvE,wBAAgB,qBAAqB,CACnC,OAAO,EAAG,OAAO,EACjB,OAAO,EAAG,UAAU,EACpB,OAAO,EAAG,MAAM,aAAa,GAC5B,IAAI,CAyGN"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/commands/update.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAiG,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAI9I,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,aAAa,CAAC;AAEvE,wBAAgB,qBAAqB,CACnC,OAAO,EAAG,OAAO,EACjB,OAAO,EAAG,UAAU,EACpB,OAAO,EAAG,MAAM,aAAa,GAC5B,IAAI,CA2GN"}
@@ -1,6 +1,8 @@
1
1
  import { type BitcoinApiConfig, type CasConfig, type DidBtcr2Api } from '@did-btcr2/api';
2
2
  import type { BroadcastOptions } from '@did-btcr2/method';
3
- import { type NetworkOption, type OutputFormat } from './types.js';
3
+ import { defaultConfigPath } from './paths.js';
4
+ import { type KeystoreProtectionLabel, type NetworkOption, type OutputFormat } from './types.js';
5
+ export { defaultConfigPath };
4
6
  /**
5
7
  * Endpoint overrides provided via CLI flags, env vars, or config file.
6
8
  * These override the per-network defaults the SDK applies
@@ -28,9 +30,11 @@ export type ConnectionOverrides = {
28
30
  btcRpcWallet?: string;
29
31
  /** Extra Bitcoin Core RPC headers as raw `Key: Value` flag values (repeatable). */
30
32
  btcRpcHeader?: string[];
33
+ /** CLI home root from `--home`. Colocates config.json + keystore.json (ADR 079). */
34
+ home?: string;
31
35
  config?: string;
32
36
  profile?: string;
33
- /** Keystore file path. Overrides the default `$XDG_DATA_HOME/btcr2/keystore.json`. */
37
+ /** Keystore file path. Overrides the home default `<home>/keystore.json`. */
34
38
  keystore?: string;
35
39
  /** Path to a file holding the keystore passphrase (for unattended use). */
36
40
  passphraseFile?: string;
@@ -123,6 +127,13 @@ export declare const CONFIG_SCHEMA_VERSION = 1;
123
127
  * absent file (ENOENT) still starts from `{}`.
124
128
  */
125
129
  export declare function writeConfigFile(path: string, mutate: (raw: Record<string, unknown>) => void): void;
130
+ /**
131
+ * Writes a default config scaffold to `path`: schema version, a `text` output
132
+ * default, and one empty profile per supported network. Shared by `config init`
133
+ * and `btcr2 init` so the seeded config is identical. Writes atomically (file
134
+ * 0600, dir 0700); the caller decides whether to overwrite an existing file.
135
+ */
136
+ export declare function writeDefaultConfigFile(path: string): void;
126
137
  /** Reads the value at a dotted path (e.g. `profiles.regtest.btc.rest`). */
127
138
  export declare function getConfigPath(config: Record<string, unknown>, path: string): unknown;
128
139
  /** Sets the value at a dotted path, creating intermediate objects. */
@@ -170,15 +181,6 @@ export declare const ENV_VARS: {
170
181
  * Only defined (non-empty) values are included.
171
182
  */
172
183
  export declare function readEnvOverrides(): ConnectionOverrides;
173
- /**
174
- * Default config file path following the XDG Base Directory Specification.
175
- *
176
- * Resolution order:
177
- * 1. `$XDG_CONFIG_HOME/btcr2/config.json`
178
- * 2. `%APPDATA%/btcr2/config.json` (Windows)
179
- * 3. `~/.config/btcr2/config.json` (fallback)
180
- */
181
- export declare function defaultConfigPath(): string;
182
184
  /**
183
185
  * Reads and JSON-parses a config file without applying the schema-version
184
186
  * ceiling check. Returns `undefined` only for a genuinely absent file (ENOENT).
@@ -245,6 +247,7 @@ export declare function profileNetworkMismatch(network: NetworkOption, overrides
245
247
  export declare function resolveOutputFormat(options: {
246
248
  output?: string;
247
249
  config?: string;
250
+ home?: string;
248
251
  }): OutputFormat;
249
252
  /**
250
253
  * Resolves the Bitcoin and CAS connection config for a network by merging,
@@ -364,12 +367,33 @@ export declare function runDoctor(network: NetworkOption, overrides?: Connection
364
367
  * CLI flags -> env vars -> config file profile -> network defaults.
365
368
  */
366
369
  export declare function defaultApiFactory(network?: NetworkOption, overrides?: ConnectionOverrides): DidBtcr2Api;
370
+ /**
371
+ * The protection mode of the resolved keystore, read without decrypting or
372
+ * prompting: `encrypted`, `dev` (plaintext), or `absent`. Used by `keystore
373
+ * status`, `config path`, and the mainnet guard.
374
+ */
375
+ export declare function resolveKeystoreProtection(overrides?: ConnectionOverrides): KeystoreProtectionLabel;
376
+ /**
377
+ * Hard-refuses using an unencrypted dev keystore for a mainnet operation (ADR
378
+ * 080). A plaintext key must never sign or seal a `bitcoin` did:btcr2; the check
379
+ * reads only the keystore's protection header, so it never decrypts or prompts.
380
+ * A no-op for every other network and for encrypted/absent keystores.
381
+ */
382
+ export declare function assertKeystoreAllowedForNetwork(network: NetworkOption, overrides?: ConnectionOverrides): void;
367
383
  /**
368
384
  * Resolves the keystore file path: the `--keystore` flag, else the active
369
- * profile's `identity.keystore`, else the default XDG keystore path. The flag
370
- * always wins over the profile default.
385
+ * profile's `identity.keystore`, else the default `<home>/keystore.json` (ADR
386
+ * 079). The flag always wins over the profile default and never reads the config.
387
+ *
388
+ * A malformed config aborts loudly by default so a keystore-mutating command
389
+ * never silently reads or writes the wrong store. Pass `lenient: true` only for
390
+ * diagnostic/recovery commands (`config path`, `keystore status`) that must still
391
+ * report a path instead of crashing on the very config you ran them to fix; those
392
+ * fall back to the home default when the profile identity cannot be read.
371
393
  */
372
- export declare function resolveKeystorePath(overrides?: ConnectionOverrides): string;
394
+ export declare function resolveKeystorePath(overrides?: ConnectionOverrides, options?: {
395
+ lenient?: boolean;
396
+ }): string;
373
397
  /**
374
398
  * Resolves the signing-key reference for update/deactivate: the `--signing-key`
375
399
  * flag, else the active profile's `identity.default`, else `undefined` (letting
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8E,KAAK,gBAAgB,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGrK,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAS1D,OAAO,EAAoC,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAErG;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,CAAC,EAAU,MAAM,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AAS,CAAC,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAa5G;AAoBD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,mBAAmB,GAAG,MAAM,GAAG,SAAS,CAExF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,mBAAmB,GAAG,WAAW,CAKxG;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAUxD"}
@@ -1,33 +1,61 @@
1
1
  import type { KeyEntry, KeyIdentifier, KeyValueStore } from '@did-btcr2/key-manager';
2
+ import type { KeystoreProtectionLabel } from '../types.js';
2
3
  import type { ArgonParams } from './envelope.js';
3
4
  import { type LockOptions } from './lock.js';
4
5
  /** Current on-disk keystore file format version. */
5
6
  export declare const KEYSTORE_VERSION: 1;
7
+ /**
8
+ * How a keystore protects its secrets on disk:
9
+ * - `passphrase`: each secret is sealed in its own argon2id + XChaCha20-Poly1305
10
+ * envelope, all opened by one shared, verifier-checked passphrase.
11
+ * - `none`: a dev keystore; secrets are stored as plaintext bytes. Never prompts;
12
+ * refused for mainnet (ADR 080). For disposable testnet material only.
13
+ */
14
+ export type KeystoreProtection = 'passphrase' | 'none';
6
15
  /** Options for constructing a {@link FileKeyStore}. */
7
16
  export type FileKeyStoreOptions = {
8
17
  /** Keystore file path. Defaults to {@link defaultKeystorePath}. */
9
18
  path?: string;
10
- /** Supplies the passphrase lazily, called only when a secret must be sealed or opened. */
11
- getPassphrase: () => string;
19
+ /**
20
+ * Supplies the passphrase lazily, called only when a secret must be sealed or
21
+ * opened. `confirm` is passed as `true` only while establishing a fresh
22
+ * encrypted keystore's passphrase, so the provider prompts twice and requires
23
+ * a match; it is a no-op for non-interactive sources.
24
+ */
25
+ getPassphrase: (opts?: {
26
+ confirm?: boolean;
27
+ }) => string;
12
28
  /** argon2id cost parameters used when sealing new secrets. Defaults to {@link DEFAULT_ARGON_PARAMS}. */
13
29
  argonParams?: ArgonParams;
14
30
  /** Tuning for the cross-process write lock. Defaults documented on {@link LockOptions}. */
15
31
  lock?: LockOptions;
32
+ /**
33
+ * Protection mode to use when *establishing* a fresh keystore. Defaults to
34
+ * `passphrase` (encrypted). Ignored for an existing keystore, whose on-disk
35
+ * `protection` always wins.
36
+ */
37
+ protection?: KeystoreProtection;
16
38
  };
17
39
  /**
18
- * A Node-only, file-backed {@link KeyValueStore} that encrypts secret keys at
40
+ * A Node-only, file-backed {@link KeyValueStore} that protects secret keys at
19
41
  * rest. It satisfies the synchronous store contract by caching the parsed file
20
42
  * in memory at construction and flushing the whole file atomically on every
21
43
  * mutation.
22
44
  *
45
+ * Encrypted keystores seal each secret in its own argon2id + XChaCha20-Poly1305
46
+ * envelope under one shared passphrase, and store a `verifier` sentinel so a
47
+ * candidate passphrase is checked before it is used (ADR 080): the first
48
+ * passphrase is established with a confirm prompt, and every later use is
49
+ * verified, so a typo is a loud failure rather than a key sealed under an
50
+ * unknown or divergent passphrase. Dev keystores (`protection: 'none'`) store
51
+ * secrets as plaintext and never prompt; they are refused for mainnet by the
52
+ * command layer.
53
+ *
23
54
  * Every mutation runs under an exclusive cross-process lock and, inside that
24
- * lock, reloads the file from disk before applying its change and flushing.
25
- * Caching at construction and flushing the whole file is otherwise a lost-update
26
- * race: two `btcr2` processes that each load, then each write, would have the
27
- * second overwrite the first. The lock serializes the writers and the reload
28
- * merges any change the other made, so concurrent invocations compose instead of
29
- * clobbering. Reads stay lock-free: an atomic rename means a concurrent reader
30
- * always sees a complete file, old or new.
55
+ * lock, reloads the file from disk before applying its change and flushing, so
56
+ * concurrent `btcr2` invocations compose instead of clobbering. Reads stay
57
+ * lock-free: an atomic rename means a concurrent reader always sees a complete
58
+ * file, old or new.
31
59
  *
32
60
  * Secrets are materialized only through {@link FileKeyStore.get}. The
33
61
  * {@link FileKeyStore.list} and {@link FileKeyStore.entries} projections omit
@@ -60,5 +88,53 @@ export declare class FileKeyStore implements KeyValueStore<KeyIdentifier, KeyEnt
60
88
  * clears it. Throws if the identifier is not a known key.
61
89
  */
62
90
  setActive(id: KeyIdentifier | undefined): void;
91
+ /** The keystore's protection mode. */
92
+ get protection(): KeystoreProtection;
93
+ /**
94
+ * Re-seals every sealed secret and the verifier under a new passphrase (ADR
95
+ * 080), returning the number of secrets re-sealed. Verifies the current
96
+ * passphrase against the verifier first. Refused on a dev keystore, which has
97
+ * no passphrase.
98
+ */
99
+ changePassphrase(oldPassphrase: string, newPassphrase: string): number;
63
100
  }
101
+ /** A no-decrypt, no-prompt summary of a keystore file for `keystore status`. */
102
+ export interface KeystoreSummary {
103
+ protection: KeystoreProtectionLabel;
104
+ established: boolean;
105
+ keyCount: number;
106
+ active: string | undefined;
107
+ }
108
+ /**
109
+ * Summarizes a keystore file by structure alone: protection mode, whether a
110
+ * passphrase is established, key count, and active key. Never decrypts, never
111
+ * prompts, and never throws (a missing or unreadable file reports `absent`), so
112
+ * it is safe for `keystore status`, `config path`, and the mainnet dev-keystore
113
+ * guard.
114
+ */
115
+ export declare function keystoreSummary(path: string): KeystoreSummary;
116
+ /** The protection label of a keystore file, without decrypting or prompting. */
117
+ export declare function keystoreProtection(path: string): KeystoreProtectionLabel;
118
+ /** Options for {@link initKeystore}. */
119
+ export interface InitKeystoreOptions {
120
+ protection: KeystoreProtection;
121
+ getPassphrase: (opts?: {
122
+ confirm?: boolean;
123
+ }) => string;
124
+ argonParams?: ArgonParams;
125
+ }
126
+ /**
127
+ * Establishes a fresh keystore file (ADR 080). An encrypted keystore prompts
128
+ * (with confirm) for the passphrase and writes the verifier; a dev keystore
129
+ * writes a plaintext-mode header with no passphrase. The caller is responsible
130
+ * for refusing to overwrite an existing keystore; this always writes the file.
131
+ */
132
+ export declare function initKeystore(path: string, options: InitKeystoreOptions): void;
133
+ /**
134
+ * Re-seals every secret in an encrypted keystore under a new passphrase (ADR
135
+ * 080), returning the count re-sealed. The old and new passphrases are supplied
136
+ * explicitly, so the store's own passphrase provider is never invoked (a wrong
137
+ * current passphrase is caught by the verifier). Refused on a dev keystore.
138
+ */
139
+ export declare function changeKeystorePassphrase(path: string, oldPassphrase: string, newPassphrase: string, argonParams?: ArgonParams): number;
64
140
  //# sourceMappingURL=file-key-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-key-store.d.ts","sourceRoot":"","sources":["../../../../src/keystore/file-key-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIrF,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAG3D,oDAAoD;AACpD,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAwB3C,uDAAuD;AACvD,MAAM,MAAM,mBAAmB,GAAG;IAChC,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0FAA0F;IAC1F,aAAa,EAAE,MAAM,MAAM,CAAC;IAC5B,wGAAwG;IACxG,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,2FAA2F;IAC3F,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,YAAa,YAAW,aAAa,CAAC,aAAa,EAAE,QAAQ,CAAC;;gBAS7D,OAAO,EAAE,mBAAmB;IAiHxC,GAAG,CAAC,EAAE,EAAE,aAAa,GAAG,QAAQ,GAAG,SAAS;IA0B5C,GAAG,CAAC,EAAE,EAAE,aAAa,GAAG,OAAO;IAI/B,GAAG,CAAC,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI;IAgB7C,MAAM,CAAC,EAAE,EAAE,aAAa,GAAG,OAA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CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,MAAM,CAAC;IACzD,WAAW,CAAC,EAAI,WAAW,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAW7E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAY,MAAM,EACtB,aAAa,EAAG,MAAM,EACtB,aAAa,EAAG,MAAM,EACtB,WAAW,CAAC,EAAI,WAAW,GAC1B,MAAM,CAaR"}
@@ -8,13 +8,28 @@ export type PassphraseOptions = {
8
8
  prompt?: string;
9
9
  /** When true, prompt twice and require the entries to match (for a new keystore). */
10
10
  confirm?: boolean;
11
+ /**
12
+ * When true, skip the environment variable and passphrase file and require a
13
+ * fresh terminal entry. Used for the *new* passphrase in `change-passphrase`,
14
+ * where the env var / file holds the *current* passphrase and must not silently
15
+ * satisfy the new one (which would make the change a no-op).
16
+ */
17
+ forcePrompt?: boolean;
11
18
  };
12
19
  /**
13
20
  * Acquires a passphrase without ever reading it from a command-line flag value
14
21
  * (which would leak into process listings and shell history). Resolution order:
15
22
  * the {@link ENV_KEYSTORE_PASSPHRASE} environment variable, a passphrase file,
16
23
  * then a non-echoing terminal prompt. Throws if none is available and standard
17
- * input is not a terminal.
24
+ * input is not a terminal. When `forcePrompt` is set, the env var and file are
25
+ * skipped and a terminal entry is required.
18
26
  */
19
27
  export declare function acquirePassphrase(options?: PassphraseOptions): string;
28
+ /**
29
+ * Removes the last whole UTF-8 character from an accumulating byte array in
30
+ * place: pops any trailing continuation bytes (0b10xxxxxx) then the leading
31
+ * byte. Exported for testing; a backspace mid-entry must not strand a fragment
32
+ * that later decodes to U+FFFD.
33
+ */
34
+ export declare function dropLastUtf8Char(bytes: number[]): void;
20
35
  //# sourceMappingURL=passphrase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"passphrase.d.ts","sourceRoot":"","sources":["../../../../src/keystore/passphrase.ts"],"names":[],"mappings":"AAGA,qFAAqF;AACrF,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAEnE,wDAAwD;AACxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,wFAAwF;IACxF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAyBzE"}
1
+ {"version":3,"file":"passphrase.d.ts","sourceRoot":"","sources":["../../../../src/keystore/passphrase.ts"],"names":[],"mappings":"AAGA,qFAAqF;AACrF,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAEnE,wDAAwD;AACxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,wFAAwF;IACxF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CA2BzE;AAuBD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAGtD"}
@@ -1,13 +1,9 @@
1
1
  /**
2
- * Default keystore file path, following the XDG Base Directory Specification's
3
- * data directory. Secret key material is data a user accumulates, so it lives
4
- * under the data directory, kept separate from the configuration directory used
5
- * for portable settings.
6
- *
7
- * Resolution order:
8
- * 1. `$XDG_DATA_HOME/btcr2/keystore.json`
9
- * 2. `%LOCALAPPDATA%/btcr2/keystore.json` (Windows)
10
- * 3. `~/.local/share/btcr2/keystore.json` (fallback)
2
+ * The default keystore path now lives alongside the config file under a single
3
+ * CLI home root (`<home>/keystore.json`, ADR 079). The implementation lives in
4
+ * `../paths.ts` (the single source of truth for on-disk state locations); it is
5
+ * re-exported here so existing `./paths.js` importers in the keystore layer keep
6
+ * their import surface.
11
7
  */
12
- export declare function defaultKeystorePath(): string;
8
+ export { defaultKeystorePath } from '../paths.js';
13
9
  //# sourceMappingURL=paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../../src/keystore/paths.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAK5C"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../../src/keystore/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * State-location overrides that influence where the CLI keeps its home
3
+ * directory and its two state files. A subset of the broader
4
+ * `ConnectionOverrides`, restated here so this module (the single source of
5
+ * truth for on-disk locations) has no runtime dependency on `config.ts`.
6
+ */
7
+ export interface PathOverrides {
8
+ /** Explicit home root from the `--home` flag. Wins over `$BTCR2_HOME`. */
9
+ home?: string;
10
+ /** Explicit config-file path from the `--config` flag. Overrides the home default. */
11
+ config?: string;
12
+ /** Explicit keystore path from the `--keystore` flag. Overrides the home default. */
13
+ keystore?: string;
14
+ }
15
+ /** Environment variable naming the CLI home directory (all state colocated). */
16
+ export declare const ENV_HOME = "BTCR2_HOME";
17
+ /** The config and keystore file names, kept side by side under the home root. */
18
+ export declare const CONFIG_FILENAME = "config.json";
19
+ export declare const KEYSTORE_FILENAME = "keystore.json";
20
+ /**
21
+ * Resolves the CLI home directory: the single root that holds `config.json` and
22
+ * `keystore.json` side by side (ADR 079). Resolution order, highest wins:
23
+ *
24
+ * 1. `--home <dir>` (the {@link PathOverrides.home} flag)
25
+ * 2. `$BTCR2_HOME`
26
+ * 3. the platform default (see {@link platformDefaultHome})
27
+ *
28
+ * A blank value at any layer defers to the next, mirroring the `blankToUndef`
29
+ * treatment every other precedence layer uses, so an exported-but-empty
30
+ * `BTCR2_HOME` does not resolve the home to a bare relative path.
31
+ */
32
+ export declare function resolveHome(overrides?: PathOverrides): string;
33
+ /**
34
+ * The default home when no `--home` / `$BTCR2_HOME` override is present, chosen
35
+ * per OS so the location is idiomatic while staying a single colocated dir:
36
+ *
37
+ * - Windows: `%LOCALAPPDATA%\btcr2` (fallback `%APPDATA%\btcr2`, then the user
38
+ * profile), the native place for per-user application state.
39
+ * - Linux / macOS: `~/.btcr2`, the short, teachable dot-directory in the same
40
+ * family as `~/.ssh`, `~/.aws`, and `~/.gnupg`.
41
+ */
42
+ export declare function platformDefaultHome(): string;
43
+ /**
44
+ * Default config-file path: `<home>/config.json`. The `--config` flag, when
45
+ * present, overrides it wholesale (it names a specific file, not a home).
46
+ */
47
+ export declare function defaultConfigPath(overrides?: PathOverrides): string;
48
+ /**
49
+ * Default keystore path: `<home>/keystore.json`. The `--keystore` flag and a
50
+ * profile's `identity.keystore` (resolved in `config.ts`) override it; this
51
+ * function is the final fallback in that chain.
52
+ */
53
+ export declare function defaultKeystorePath(overrides?: PathOverrides): string;
54
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/paths.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,0EAA0E;IAC1E,IAAI,CAAC,EAAO,MAAM,CAAC;IACnB,sFAAsF;IACtF,MAAM,CAAC,EAAK,MAAM,CAAC;IACnB,qFAAqF;IACrF,QAAQ,CAAC,EAAG,MAAM,CAAC;CACpB;AAED,gFAAgF;AAChF,eAAO,MAAM,QAAQ,eAAe,CAAC;AAErC,iFAAiF;AACjF,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAC7C,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,SAAS,CAAC,EAAE,aAAa,GAAG,MAAM,CAI7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAQ5C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,aAAa,GAAG,MAAM,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,CAAC,EAAE,aAAa,GAAG,MAAM,CAErE"}