@interop/did-cli 0.13.0 → 0.15.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 (102) hide show
  1. package/CHANGELOG.md +166 -6
  2. package/README.md +172 -26
  3. package/dist/commands/did/create.d.ts +22 -0
  4. package/dist/commands/did/create.d.ts.map +1 -1
  5. package/dist/commands/did/create.js +6 -27
  6. package/dist/commands/did/create.js.map +1 -1
  7. package/dist/commands/did/service.d.ts +19 -4
  8. package/dist/commands/did/service.d.ts.map +1 -1
  9. package/dist/commands/did/service.js +46 -45
  10. package/dist/commands/did/service.js.map +1 -1
  11. package/dist/commands/did/webvh-update.d.ts +72 -9
  12. package/dist/commands/did/webvh-update.d.ts.map +1 -1
  13. package/dist/commands/did/webvh-update.js +177 -61
  14. package/dist/commands/did/webvh-update.js.map +1 -1
  15. package/dist/commands/did.d.ts.map +1 -1
  16. package/dist/commands/did.js +10 -1
  17. package/dist/commands/did.js.map +1 -1
  18. package/dist/commands/key.d.ts.map +1 -1
  19. package/dist/commands/key.js +5 -8
  20. package/dist/commands/key.js.map +1 -1
  21. package/dist/commands/was/request-grant.d.ts +39 -0
  22. package/dist/commands/was/request-grant.d.ts.map +1 -0
  23. package/dist/commands/was/request-grant.js +250 -0
  24. package/dist/commands/was/request-grant.js.map +1 -0
  25. package/dist/commands/was/resource.d.ts +21 -7
  26. package/dist/commands/was/resource.d.ts.map +1 -1
  27. package/dist/commands/was/resource.js +40 -15
  28. package/dist/commands/was/resource.js.map +1 -1
  29. package/dist/commands/was/shared.d.ts +43 -3
  30. package/dist/commands/was/shared.d.ts.map +1 -1
  31. package/dist/commands/was/shared.js +82 -4
  32. package/dist/commands/was/shared.js.map +1 -1
  33. package/dist/commands/was/shell/completer.d.ts +24 -0
  34. package/dist/commands/was/shell/completer.d.ts.map +1 -0
  35. package/dist/commands/was/shell/completer.js +99 -0
  36. package/dist/commands/was/shell/completer.js.map +1 -0
  37. package/dist/commands/was/shell/dispatcher.d.ts +27 -0
  38. package/dist/commands/was/shell/dispatcher.d.ts.map +1 -0
  39. package/dist/commands/was/shell/dispatcher.js +227 -0
  40. package/dist/commands/was/shell/dispatcher.js.map +1 -0
  41. package/dist/commands/was/shell/session.d.ts +37 -0
  42. package/dist/commands/was/shell/session.d.ts.map +1 -0
  43. package/dist/commands/was/shell/session.js +67 -0
  44. package/dist/commands/was/shell/session.js.map +1 -0
  45. package/dist/commands/was/shell/tokenize.d.ts +19 -0
  46. package/dist/commands/was/shell/tokenize.d.ts.map +1 -0
  47. package/dist/commands/was/shell/tokenize.js +77 -0
  48. package/dist/commands/was/shell/tokenize.js.map +1 -0
  49. package/dist/commands/was/shell.d.ts +30 -0
  50. package/dist/commands/was/shell.d.ts.map +1 -0
  51. package/dist/commands/was/shell.js +170 -0
  52. package/dist/commands/was/shell.js.map +1 -0
  53. package/dist/commands/was/tree.d.ts +6 -1
  54. package/dist/commands/was/tree.d.ts.map +1 -1
  55. package/dist/commands/was/tree.js +12 -5
  56. package/dist/commands/was/tree.js.map +1 -1
  57. package/dist/commands/was.d.ts.map +1 -1
  58. package/dist/commands/was.js +34 -1
  59. package/dist/commands/was.js.map +1 -1
  60. package/dist/commands/zcap.d.ts +22 -2
  61. package/dist/commands/zcap.d.ts.map +1 -1
  62. package/dist/commands/zcap.js +75 -4
  63. package/dist/commands/zcap.js.map +1 -1
  64. package/dist/keys/seed.d.ts +21 -0
  65. package/dist/keys/seed.d.ts.map +1 -0
  66. package/dist/keys/seed.js +41 -0
  67. package/dist/keys/seed.js.map +1 -0
  68. package/dist/keys/webvh-signer.d.ts +18 -13
  69. package/dist/keys/webvh-signer.d.ts.map +1 -1
  70. package/dist/keys/webvh-signer.js +5 -20
  71. package/dist/keys/webvh-signer.js.map +1 -1
  72. package/dist/storage.d.ts.map +1 -1
  73. package/dist/storage.js +57 -10
  74. package/dist/storage.js.map +1 -1
  75. package/dist/was/address.d.ts +24 -0
  76. package/dist/was/address.d.ts.map +1 -1
  77. package/dist/was/address.js +49 -3
  78. package/dist/was/address.js.map +1 -1
  79. package/dist/was/capability.d.ts.map +1 -1
  80. package/dist/was/capability.js +4 -1
  81. package/dist/was/capability.js.map +1 -1
  82. package/dist/was/client.d.ts +10 -3
  83. package/dist/was/client.d.ts.map +1 -1
  84. package/dist/was/client.js +27 -6
  85. package/dist/was/client.js.map +1 -1
  86. package/dist/was/request-grant.d.ts +147 -0
  87. package/dist/was/request-grant.d.ts.map +1 -0
  88. package/dist/was/request-grant.js +256 -0
  89. package/dist/was/request-grant.js.map +1 -0
  90. package/dist/zcap/create.d.ts +1 -1
  91. package/dist/zcap/create.js +1 -1
  92. package/dist/zcap/delegate.d.ts +1 -1
  93. package/dist/zcap/delegate.js +1 -1
  94. package/dist/zcap/encoding.d.ts +17 -5
  95. package/dist/zcap/encoding.d.ts.map +1 -1
  96. package/dist/zcap/encoding.js +31 -17
  97. package/dist/zcap/encoding.js.map +1 -1
  98. package/dist/zcap/resolve.d.ts +17 -4
  99. package/dist/zcap/resolve.d.ts.map +1 -1
  100. package/dist/zcap/resolve.js +25 -8
  101. package/dist/zcap/resolve.js.map +1 -1
  102. package/package.json +22 -20
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The mutable interactive-shell session state. The signing server/DID defaults
3
+ * ride the `WAS_SERVER_URL` / `WAS_DID` environment channel (see
4
+ * `runWasShell`), so the session only tracks the working directory.
5
+ */
6
+ export interface ShellSession {
7
+ /** The current path segments: `[]`, `[space]`, or `[space, collection]`. */
8
+ cwd: string[];
9
+ }
10
+ /**
11
+ * Computes a new working directory from a `cd`/`use` argument. Supports an
12
+ * absolute path (leading `/`), `.`/`..` navigation, a relative path joined onto
13
+ * the current cwd, and a full space URL (which also yields the server origin to
14
+ * adopt as the session default). Throws when the result would descend past a
15
+ * collection.
16
+ *
17
+ * @param options {object}
18
+ * @param options.cwd {string[]} The current working directory segments.
19
+ * @param options.arg {string} The `cd`/`use` argument.
20
+ * @returns {{cwd: string[], server?: string}}
21
+ */
22
+ export declare function resolveCwdChange({ cwd, arg }: {
23
+ cwd: string[];
24
+ arg: string;
25
+ }): {
26
+ cwd: string[];
27
+ server?: string;
28
+ };
29
+ /**
30
+ * Formats a working directory for display in the prompt (`/`, `/space`, or
31
+ * `/space/collection`).
32
+ *
33
+ * @param cwd {string[]}
34
+ * @returns {string}
35
+ */
36
+ export declare function formatCwd(cwd: string[]): string;
37
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/commands/was/shell/session.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,GAAG,EAAE,MAAM,EAAE,CAAA;CACd;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,GAAG,EACH,GAAG,EACJ,EAAE;IACD,GAAG,EAAE,MAAM,EAAE,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG;IAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAyCrC;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,CAE/C"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The interactive shell's working-directory model: a current path of up to two
3
+ * segments (`[]` root, `[space]`, or `[space, collection]`) plus the `cd`/`use`
4
+ * math that walks it. A WAS path is at most `SPACE/COLLECTION/RESOURCE` deep,
5
+ * so the cwd never descends past a collection (resources are leaves you `get`,
6
+ * not directories you enter).
7
+ */
8
+ import { parseWasAddress, tryParseHttpUrl } from '../../../was/address.js';
9
+ /**
10
+ * Computes a new working directory from a `cd`/`use` argument. Supports an
11
+ * absolute path (leading `/`), `.`/`..` navigation, a relative path joined onto
12
+ * the current cwd, and a full space URL (which also yields the server origin to
13
+ * adopt as the session default). Throws when the result would descend past a
14
+ * collection.
15
+ *
16
+ * @param options {object}
17
+ * @param options.cwd {string[]} The current working directory segments.
18
+ * @param options.arg {string} The `cd`/`use` argument.
19
+ * @returns {{cwd: string[], server?: string}}
20
+ */
21
+ export function resolveCwdChange({ cwd, arg }) {
22
+ if (tryParseHttpUrl(arg)) {
23
+ const parsed = parseWasAddress(arg);
24
+ if (parsed.resourceId !== undefined) {
25
+ throw new Error(`Cannot cd to "${arg}": it addresses a resource, not a directory.`);
26
+ }
27
+ const next = [parsed.spaceRef];
28
+ if (parsed.collectionId !== undefined) {
29
+ next.push(parsed.collectionId);
30
+ }
31
+ return { cwd: next, server: parsed.server };
32
+ }
33
+ let next;
34
+ let path = arg;
35
+ if (path.startsWith('/')) {
36
+ next = [];
37
+ path = path.slice(1);
38
+ }
39
+ else {
40
+ next = [...cwd];
41
+ }
42
+ for (const segment of path.split('/')) {
43
+ if (segment === '' || segment === '.') {
44
+ continue;
45
+ }
46
+ if (segment === '..') {
47
+ next = next.slice(0, -1);
48
+ continue;
49
+ }
50
+ next.push(segment);
51
+ }
52
+ if (next.length > 2) {
53
+ throw new Error(`Cannot cd to "${arg}": a WAS path is at most SPACE/COLLECTION deep.`);
54
+ }
55
+ return { cwd: next };
56
+ }
57
+ /**
58
+ * Formats a working directory for display in the prompt (`/`, `/space`, or
59
+ * `/space/collection`).
60
+ *
61
+ * @param cwd {string[]}
62
+ * @returns {string}
63
+ */
64
+ export function formatCwd(cwd) {
65
+ return `/${cwd.join('/')}`;
66
+ }
67
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/commands/was/shell/session.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAY1E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,GAAG,EACH,GAAG,EAIJ;IACC,IAAI,eAAe,CAAC,GAAG,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B,GAAG,iDAAiD,CACtE,CAAA;IACH,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAA;AACtB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,GAAa;IACrC,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;AAC5B,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Splits an interactive-shell input line into argv tokens, honoring single
3
+ * quotes, double quotes, and backslash escapes so quoted paths and payloads
4
+ * survive the trip to commander. Kept dependency-free, consistent with the
5
+ * project's no-inquirer / no-chalk stance.
6
+ *
7
+ * Quoting rules mirror a POSIX shell closely enough for path entry: single
8
+ * quotes are literal (no escapes inside), double quotes allow backslash to
9
+ * escape the next character, and a bare backslash escapes the next character.
10
+ * An unterminated quote throws.
11
+ */
12
+ /**
13
+ * Tokenizes a shell input line into argv-style tokens.
14
+ *
15
+ * @param line {string}
16
+ * @returns {string[]}
17
+ */
18
+ export declare function tokenizeShellLine(line: string): string[];
19
+ //# sourceMappingURL=tokenize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenize.d.ts","sourceRoot":"","sources":["../../../../src/commands/was/shell/tokenize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CA8DxD"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Splits an interactive-shell input line into argv tokens, honoring single
3
+ * quotes, double quotes, and backslash escapes so quoted paths and payloads
4
+ * survive the trip to commander. Kept dependency-free, consistent with the
5
+ * project's no-inquirer / no-chalk stance.
6
+ *
7
+ * Quoting rules mirror a POSIX shell closely enough for path entry: single
8
+ * quotes are literal (no escapes inside), double quotes allow backslash to
9
+ * escape the next character, and a bare backslash escapes the next character.
10
+ * An unterminated quote throws.
11
+ */
12
+ /**
13
+ * Tokenizes a shell input line into argv-style tokens.
14
+ *
15
+ * @param line {string}
16
+ * @returns {string[]}
17
+ */
18
+ export function tokenizeShellLine(line) {
19
+ const tokens = [];
20
+ let current = '';
21
+ let hasToken = false;
22
+ let quote;
23
+ for (let index = 0; index < line.length; index++) {
24
+ const char = line[index];
25
+ if (quote) {
26
+ if (char === quote) {
27
+ quote = undefined;
28
+ }
29
+ else if (char === '\\' && quote === '"') {
30
+ const next = line[index + 1];
31
+ if (next === undefined) {
32
+ current += char;
33
+ }
34
+ else {
35
+ current += next;
36
+ index++;
37
+ }
38
+ }
39
+ else {
40
+ current += char;
41
+ }
42
+ continue;
43
+ }
44
+ if (char === '"' || char === "'") {
45
+ quote = char;
46
+ hasToken = true;
47
+ continue;
48
+ }
49
+ if (char === '\\') {
50
+ const next = line[index + 1];
51
+ if (next !== undefined) {
52
+ current += next;
53
+ index++;
54
+ }
55
+ hasToken = true;
56
+ continue;
57
+ }
58
+ if (char === ' ' || char === '\t') {
59
+ if (hasToken) {
60
+ tokens.push(current);
61
+ current = '';
62
+ hasToken = false;
63
+ }
64
+ continue;
65
+ }
66
+ current += char;
67
+ hasToken = true;
68
+ }
69
+ if (quote) {
70
+ throw new Error('Unterminated quote in input.');
71
+ }
72
+ if (hasToken) {
73
+ tokens.push(current);
74
+ }
75
+ return tokens;
76
+ }
77
+ //# sourceMappingURL=tokenize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenize.js","sourceRoot":"","sources":["../../../../src/commands/was/shell/tokenize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,OAAO,GAAG,EAAE,CAAA;IAChB,IAAI,QAAQ,GAAG,KAAK,CAAA;IACpB,IAAI,KAA4B,CAAA;IAEhC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EA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,SAAQ;QACV,CAAC;QAED,OAAO,IAAI,IAAI,CAAA;QACf,QAAQ,GAAG,IAAI,CAAA;IACjB,CAAC;IAED,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;IACjD,CAAC;IACD,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACtB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * Builds the `shell [path]` command. `[path]` is the initial working directory
4
+ * and `--server`/`--did` seed the session defaults.
5
+ *
6
+ * @returns {Command}
7
+ */
8
+ export declare function makeWasShellCommand(): Command;
9
+ /**
10
+ * Runs the interactive WAS shell: snapshots the env defaults, builds and
11
+ * shell-configures the command tree, and drives a readline question loop until
12
+ * `exit`/`quit` or end-of-input. Server/DID env defaults and the address base
13
+ * are restored on exit.
14
+ *
15
+ * @param options {object}
16
+ * @param [options.path] {string} Initial working directory.
17
+ * @param [options.server] {string} Initial `WAS_SERVER_URL` default.
18
+ * @param [options.did] {string} Initial `WAS_DID` default.
19
+ * @param [options.input] {NodeJS.ReadableStream} REPL input (defaults to stdin).
20
+ * @param [options.output] {NodeJS.WritableStream} REPL output (defaults to stderr).
21
+ * @returns {Promise<number>} The process exit code (always 0).
22
+ */
23
+ export declare function runWasShell({ path, server, did, input, output }?: {
24
+ path?: string;
25
+ server?: string;
26
+ did?: string;
27
+ input?: NodeJS.ReadableStream;
28
+ output?: NodeJS.WritableStream;
29
+ }): Promise<number>;
30
+ //# sourceMappingURL=shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/commands/was/shell.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAWnC;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAiB7C;AA+CD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAAC,EAChC,IAAI,EACJ,MAAM,EACN,GAAG,EACH,KAAqB,EACrB,MAAuB,EACxB,GAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC,cAAc,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAA;CAC1B,GAAG,OAAO,CAAC,MAAM,CAAC,CAmFvB"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * `was shell` -- an interactive REPL over the `was` command tree. It builds the
3
+ * existing `makeWasCommand()` tree once and re-`parseAsync`es it per input
4
+ * line, so every subcommand, the space registry, signer loading, and the
5
+ * address grammar are reused verbatim. A "current directory" (`cd`/`use`) makes
6
+ * paths relative via the `setWasAddressBase` seam, and the `setRunAndExitReporter`
7
+ * seam keeps a failing command from exiting the process.
8
+ *
9
+ * Session server/DID defaults ride the `WAS_SERVER_URL` / `WAS_DID` environment
10
+ * channel that `resolveWasTarget`/`buildWasClient` already read at the right
11
+ * precedence; the shell snapshots both at startup and restores them on exit.
12
+ *
13
+ * The prompt and diagnostics go to stderr (the readline `output`); command data
14
+ * stays on stdout via the commands' own `console.log`, so `di was shell < script`
15
+ * keeps a pipe-clean stdout.
16
+ */
17
+ import { createInterface } from 'node:readline/promises';
18
+ import { Command } from 'commander';
19
+ import { setWasAddressBase } from '../../was/address.js';
20
+ import { didOption, serverOption, setRunAndExitReporter } from './shared.js';
21
+ import { makeWasShellDispatcher } from './shell/dispatcher.js';
22
+ import { makeShellCompleter } from './shell/completer.js';
23
+ import { formatCwd, resolveCwdChange } from './shell/session.js';
24
+ /**
25
+ * Builds the `shell [path]` command. `[path]` is the initial working directory
26
+ * and `--server`/`--did` seed the session defaults.
27
+ *
28
+ * @returns {Command}
29
+ */
30
+ export function makeWasShellCommand() {
31
+ return new Command('shell')
32
+ .argument('[path]', 'initial working directory (SPACE[/COLLECTION])')
33
+ .description('Start an interactive WAS shell (REPL) for exploring spaces')
34
+ .addOption(serverOption())
35
+ .addOption(didOption())
36
+ .action(async (path, options) => {
37
+ const code = await runWasShell({ path, ...options });
38
+ if (code !== 0) {
39
+ process.exit(code);
40
+ }
41
+ });
42
+ }
43
+ /**
44
+ * Recursively applies `exitOverride()` (throw instead of `process.exit`) and
45
+ * routes commander's own output to the shell's stream, across the whole tree.
46
+ * `addCommand()` does not inherit these settings, so every subcommand must be
47
+ * configured explicitly.
48
+ *
49
+ * @param options {object}
50
+ * @param options.command {Command}
51
+ * @param options.output {NodeJS.WritableStream}
52
+ * @returns {void}
53
+ */
54
+ function configureTreeForShell({ command, output }) {
55
+ command.exitOverride();
56
+ command.configureOutput({
57
+ writeOut: str => output.write(str),
58
+ writeErr: str => output.write(str)
59
+ });
60
+ for (const sub of command.commands) {
61
+ configureTreeForShell({ command: sub, output });
62
+ }
63
+ }
64
+ /**
65
+ * Sets or clears a process environment variable, deleting it when the value is
66
+ * undefined (so a snapshot restore removes vars that were unset at startup).
67
+ *
68
+ * @param options {object}
69
+ * @param options.key {string}
70
+ * @param [options.value] {string}
71
+ * @returns {void}
72
+ */
73
+ function assignEnv({ key, value }) {
74
+ if (value === undefined) {
75
+ delete process.env[key];
76
+ }
77
+ else {
78
+ process.env[key] = value;
79
+ }
80
+ }
81
+ /**
82
+ * Runs the interactive WAS shell: snapshots the env defaults, builds and
83
+ * shell-configures the command tree, and drives a readline question loop until
84
+ * `exit`/`quit` or end-of-input. Server/DID env defaults and the address base
85
+ * are restored on exit.
86
+ *
87
+ * @param options {object}
88
+ * @param [options.path] {string} Initial working directory.
89
+ * @param [options.server] {string} Initial `WAS_SERVER_URL` default.
90
+ * @param [options.did] {string} Initial `WAS_DID` default.
91
+ * @param [options.input] {NodeJS.ReadableStream} REPL input (defaults to stdin).
92
+ * @param [options.output] {NodeJS.WritableStream} REPL output (defaults to stderr).
93
+ * @returns {Promise<number>} The process exit code (always 0).
94
+ */
95
+ export async function runWasShell({ path, server, did, input = process.stdin, output = process.stderr } = {}) {
96
+ // `makeWasCommand` is imported lazily to break the module cycle with was.ts
97
+ // (which wires this shell command into the tree).
98
+ const { makeWasCommand } = await import('../was.js');
99
+ const tree = makeWasCommand();
100
+ configureTreeForShell({ command: tree, output });
101
+ const savedServer = process.env.WAS_SERVER_URL;
102
+ const savedDid = process.env.WAS_DID;
103
+ if (server !== undefined) {
104
+ process.env.WAS_SERVER_URL = server;
105
+ }
106
+ if (did !== undefined) {
107
+ process.env.WAS_DID = did;
108
+ }
109
+ const session = { cwd: [] };
110
+ if (path) {
111
+ try {
112
+ const change = resolveCwdChange({ cwd: [], arg: path });
113
+ session.cwd = change.cwd;
114
+ if (change.server) {
115
+ process.env.WAS_SERVER_URL = change.server;
116
+ }
117
+ }
118
+ catch (err) {
119
+ output.write(`${err.message}\n`);
120
+ }
121
+ }
122
+ // Keep failing commands from exiting the process.
123
+ setRunAndExitReporter(() => { });
124
+ const terminal = Boolean(input.isTTY);
125
+ const rl = createInterface({
126
+ input,
127
+ output,
128
+ terminal,
129
+ completer: makeShellCompleter({ tree, session })
130
+ });
131
+ const dispatch = makeWasShellDispatcher({ tree });
132
+ // Ctrl+C clears the current line and re-prompts (best effort) rather than
133
+ // exiting; Ctrl+D / end-of-input ends the readline async iterator below.
134
+ let currentPrompt = '';
135
+ rl.on('SIGINT', () => {
136
+ output.write(`\n${currentPrompt}`);
137
+ });
138
+ if (terminal) {
139
+ output.write('Interactive WAS shell. Type "help" for builtins, "exit" to quit.\n');
140
+ }
141
+ // The readline async iterator (unlike a `question` loop) buffers input lines
142
+ // instead of dropping any that arrive between prompts -- essential for
143
+ // scripted input (`di was shell < script`).
144
+ const lines = rl[Symbol.asyncIterator]();
145
+ try {
146
+ for (;;) {
147
+ setWasAddressBase(session.cwd);
148
+ currentPrompt = `was:${formatCwd(session.cwd)}> `;
149
+ output.write(currentPrompt);
150
+ const next = await lines.next();
151
+ if (next.done) {
152
+ output.write('\n');
153
+ break;
154
+ }
155
+ const outcome = await dispatch({ line: next.value, session, output });
156
+ if (outcome === 'exit') {
157
+ break;
158
+ }
159
+ }
160
+ }
161
+ finally {
162
+ setWasAddressBase([]);
163
+ setRunAndExitReporter();
164
+ rl.close();
165
+ assignEnv({ key: 'WAS_SERVER_URL', value: savedServer });
166
+ assignEnv({ key: 'WAS_DID', value: savedDid });
167
+ }
168
+ return 0;
169
+ }
170
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../src/commands/was/shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EACL,SAAS,EACT,gBAAgB,EAEjB,MAAM,oBAAoB,CAAA;AAE3B;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;SACxB,QAAQ,CAAC,QAAQ,EAAE,gDAAgD,CAAC;SACpE,WAAW,CAAC,4DAA4D,CAAC;SACzE,SAAS,CAAC,YAAY,EAAE,CAAC;SACzB,SAAS,CAAC,SAAS,EAAE,CAAC;SACtB,MAAM,CACL,KAAK,EACH,IAAwB,EACxB,OAA0C,EAC1C,EAAE;QACF,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO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AAgB,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;QACxD,SAAS,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;IAChD,CAAC;IAED,OAAO,CAAC,CAAA;AACV,CAAC"}
@@ -24,13 +24,17 @@ export declare function runLs(options: {
24
24
  /**
25
25
  * The `was rm` shorthand: deletes whatever the path (or a `--capability`'s
26
26
  * invocation target) points at -- a space, a collection, or a resource (the
27
- * client's uniform `delete()` design).
27
+ * client's uniform `delete()` design). A collection capability deletes one
28
+ * resource inside it with `--resource <id>`, the counterpart of writing at a
29
+ * chosen id through the same grant.
28
30
  *
29
31
  * @param options {object}
30
32
  * @param [options.address] {string} A space, collection, or resource
31
33
  * address.
32
34
  * @param [options.capability] {string} A capability reference instead of
33
35
  * a path.
36
+ * @param [options.resource] {string} The resource id beneath a collection
37
+ * capability.
34
38
  * @param [options.server] {string} The server base URL.
35
39
  * @param [options.did] {string} The signing DID or stored-DID handle.
36
40
  * @returns {Promise<number>} The process exit code.
@@ -38,6 +42,7 @@ export declare function runLs(options: {
38
42
  export declare function runRm(options: {
39
43
  address?: string;
40
44
  capability?: string;
45
+ resource?: string;
41
46
  server?: string;
42
47
  did?: string;
43
48
  }): Promise<number>;
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../src/commands/was/tree.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CA0DlB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BlB"}
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../src/commands/was/tree.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CA0DlB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,MAAM,CAAC,CAiClB"}
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { parseWasAddress } from '../../was/address.js';
8
8
  import { resolveCapabilityTarget } from '../../was/capability.js';
9
- import { assertOneAddressing, printCollectionListing, printResourceListing, reportDeleted, reportError, reportNotFound } from './shared.js';
9
+ import { assertOneAddressing, printCollectionListing, printResourceListing, reportDeleted, reportError, reportNotFound, withResourceId } from './shared.js';
10
10
  import { runCollectionDelete, runCollectionList } from './collection.js';
11
11
  import { runResourceDelete, runResourceList } from './resource.js';
12
12
  import { runSpaceDelete } from './space.js';
@@ -86,13 +86,17 @@ export async function runLs(options) {
86
86
  /**
87
87
  * The `was rm` shorthand: deletes whatever the path (or a `--capability`'s
88
88
  * invocation target) points at -- a space, a collection, or a resource (the
89
- * client's uniform `delete()` design).
89
+ * client's uniform `delete()` design). A collection capability deletes one
90
+ * resource inside it with `--resource <id>`, the counterpart of writing at a
91
+ * chosen id through the same grant.
90
92
  *
91
93
  * @param options {object}
92
94
  * @param [options.address] {string} A space, collection, or resource
93
95
  * address.
94
96
  * @param [options.capability] {string} A capability reference instead of
95
97
  * a path.
98
+ * @param [options.resource] {string} The resource id beneath a collection
99
+ * capability.
96
100
  * @param [options.server] {string} The server base URL.
97
101
  * @param [options.did] {string} The signing DID or stored-DID handle.
98
102
  * @returns {Promise<number>} The process exit code.
@@ -101,9 +105,12 @@ export async function runRm(options) {
101
105
  if (options.capability) {
102
106
  try {
103
107
  assertOneAddressing(options);
104
- const resolved = await resolveCapabilityTarget({
105
- ref: options.capability,
106
- did: options.did
108
+ const resolved = withResourceId({
109
+ resolved: await resolveCapabilityTarget({
110
+ ref: options.capability,
111
+ did: options.did
112
+ }),
113
+ resourceId: options.resource
107
114
  });
108
115
  await resolved.handle.delete();
109
116
  reportDeleted(resolved.url);
@@ -1 +1 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../src/commands/was/tree.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,cAAc,EACf,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AA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AO,CA+rBxC"}
1
+ {"version":3,"file":"was.d.ts","sourceRoot":"","sources":["../../src/commands/was.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA0HnC,wBAAgB,cAAc,IAAI,OAAO,CAuxBxC"}
@@ -29,13 +29,15 @@
29
29
  * this module wires them onto the commander command tree.
30
30
  */
31
31
  import { Command } from 'commander';
32
- import { capabilityOption, contentTypeOption, didOption, disambiguatePayloadArgs, runAndExit, serverOption } from './was/shared.js';
32
+ import { capabilityOption, contentTypeOption, didOption, disambiguatePayloadArgs, resourceIdOption, runAndExit, serverOption } from './was/shared.js';
33
33
  import { runSpaceAdd, runSpaceBackends, runSpaceCreate, runSpaceDelete, runSpaceExport, runSpaceForget, runSpaceImport, runSpaceList, runSpaceMeta, runSpaceQuotas, runSpaceShow, runSpaceUpdate } from './was/space.js';
34
34
  import { runCollectionBackend, runCollectionCreate, runCollectionDelete, runCollectionList, runCollectionQuota, runCollectionShow, runCollectionUpdate } from './was/collection.js';
35
35
  import { runResourceAdd, runResourceDelete, runResourceGet, runResourceList, runResourceMetaGet, runResourceMetaPut, runResourcePut } from './was/resource.js';
36
36
  import { runLs, runRm } from './was/tree.js';
37
37
  import { runPolicyClear, runPolicySet, runPolicyShow } from './was/policy.js';
38
38
  import { runGrant, runPublish, runUnpublish } from './was/publish.js';
39
+ import { runRequestGrant } from './was/request-grant.js';
40
+ import { makeWasShellCommand } from './was/shell.js';
39
41
  /**
40
42
  * Adds a resource `get [path]` verb to a parent command. Shared by
41
43
  * `was resource get` and the top-level `was get` shorthand, which differ only
@@ -51,6 +53,7 @@ function addGetCommand(parent, description) {
51
53
  .description(description)
52
54
  .option('--output <file>', 'write the resource content to a file')
53
55
  .addOption(capabilityOption())
56
+ .addOption(resourceIdOption())
54
57
  .addOption(serverOption())
55
58
  .addOption(didOption())
56
59
  .action(async (address, options) => {
@@ -72,6 +75,7 @@ function addPutCommand(parent, description) {
72
75
  .description(description)
73
76
  .addOption(contentTypeOption())
74
77
  .addOption(capabilityOption())
78
+ .addOption(resourceIdOption())
75
79
  .addOption(serverOption())
76
80
  .addOption(didOption())
77
81
  .action(async (address, file, options) => {
@@ -326,6 +330,7 @@ export function makeWasCommand() {
326
330
  .description("Show a resource's metadata: content type, size, timestamps, and " +
327
331
  'custom name/tags')
328
332
  .addOption(capabilityOption())
333
+ .addOption(resourceIdOption())
329
334
  .addOption(serverOption())
330
335
  .addOption(didOption())
331
336
  .action(async (address, options) => {
@@ -341,6 +346,7 @@ export function makeWasCommand() {
341
346
  .option('--json <jsonOrFile>', 'full custom-metadata replacement as inline JSON or a JSON file path ' +
342
347
  '(clears any omitted field)')
343
348
  .addOption(capabilityOption())
349
+ .addOption(resourceIdOption())
344
350
  .addOption(serverOption())
345
351
  .addOption(didOption())
346
352
  .action(async (address, options) => {
@@ -365,6 +371,7 @@ export function makeWasCommand() {
365
371
  .description('Delete whatever the path points at: a space, a collection, or a ' +
366
372
  'resource')
367
373
  .addOption(capabilityOption())
374
+ .addOption(resourceIdOption())
368
375
  .addOption(serverOption())
369
376
  .addOption(didOption())
370
377
  .action(async (address, options) => {
@@ -434,6 +441,32 @@ export function makeWasCommand() {
434
441
  .action(async (address, options) => {
435
442
  await runAndExit(runGrant({ address, ...options }));
436
443
  });
444
+ was
445
+ .command('request-grant')
446
+ .description('Ask a wallet for a capability on one of its public collections ' +
447
+ '(the inverse of grant: mints a key, prints a link for the user to ' +
448
+ 'approve, and stores what comes back)')
449
+ .option('--collection <name>', 'the public collection to request access to (default web)')
450
+ .option('--action <verb...>', 'requested action(s): GET, HEAD, PUT, POST, DELETE (lowercase accepted)')
451
+ .option('--reason <text>', 'why access is wanted, shown to the user')
452
+ .option('--name <name>', 'what the agent calls itself, shown to the user beside its key ' +
453
+ '(self-declared; at most 64 characters)')
454
+ .option('--wallet <url>', "the user's wallet base URL, to also print a link that opens it " +
455
+ 'straight onto the approval page')
456
+ .option('--save', 'store the minted key and the received capabilities (the default; ' +
457
+ 'accepted so scripts can say it explicitly)')
458
+ .option('--no-save', 'do not store the minted key or the received capabilities (they cannot ' +
459
+ 'then be invoked by a later command)')
460
+ .option('--handle <handle>', 'short tag for the minted key and received capabilities (default agent)')
461
+ .option('--description <description>', 'longer description for the saved items (requires --save)')
462
+ .option('--timeout <seconds>', 'how long to wait for approval (default 600, the server exchange TTL)')
463
+ .option('--json', 'print the DID, handle, and capabilities as JSON')
464
+ .option('--exchange <url>', 'base URL of the WAS server that hosts the ephemeral exchange (or ' +
465
+ 'WAS_SERVER_URL)')
466
+ .action(async (options) => {
467
+ await runAndExit(runRequestGrant(options));
468
+ });
469
+ was.addCommand(makeWasShellCommand());
437
470
  return was;
438
471
  }
439
472
  //# sourceMappingURL=was.js.map