@did-btcr2/cli 0.20.0 → 0.22.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.
- package/README.md +44 -27
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +237 -175
- package/dist/esm/src/cli.js +3 -2
- package/dist/esm/src/cli.js.map +1 -1
- package/dist/esm/src/commands/completion.js +1 -1
- package/dist/esm/src/commands/completion.js.map +1 -1
- package/dist/esm/src/commands/deactivate.js +11 -88
- package/dist/esm/src/commands/deactivate.js.map +1 -1
- package/dist/esm/src/commands/identifier.js +110 -0
- package/dist/esm/src/commands/identifier.js.map +1 -0
- package/dist/esm/src/commands/index.js +1 -0
- package/dist/esm/src/commands/index.js.map +1 -1
- package/dist/esm/src/commands/resolve.js +4 -37
- package/dist/esm/src/commands/resolve.js.map +1 -1
- package/dist/esm/src/commands/update.js +15 -85
- package/dist/esm/src/commands/update.js.map +1 -1
- package/dist/esm/src/commands/write.js +119 -0
- package/dist/esm/src/commands/write.js.map +1 -0
- package/dist/esm/src/resolution-options.js +47 -0
- package/dist/esm/src/resolution-options.js.map +1 -0
- package/dist/esm/src/types.js.map +1 -1
- package/dist/types/src/cli.d.ts +1 -1
- package/dist/types/src/cli.d.ts.map +1 -1
- package/dist/types/src/commands/deactivate.d.ts +1 -1
- package/dist/types/src/commands/deactivate.d.ts.map +1 -1
- package/dist/types/src/commands/identifier.d.ts +12 -0
- package/dist/types/src/commands/identifier.d.ts.map +1 -0
- package/dist/types/src/commands/index.d.ts +1 -0
- package/dist/types/src/commands/index.d.ts.map +1 -1
- package/dist/types/src/commands/resolve.d.ts.map +1 -1
- package/dist/types/src/commands/update.d.ts +1 -1
- package/dist/types/src/commands/update.d.ts.map +1 -1
- package/dist/types/src/commands/write.d.ts +47 -0
- package/dist/types/src/commands/write.d.ts.map +1 -0
- package/dist/types/src/resolution-options.d.ts +21 -0
- package/dist/types/src/resolution-options.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +37 -7
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/cli.ts +3 -1
- package/src/commands/completion.ts +1 -1
- package/src/commands/deactivate.ts +14 -142
- package/src/commands/identifier.ts +156 -0
- package/src/commands/index.ts +1 -0
- package/src/commands/resolve.ts +8 -64
- package/src/commands/update.ts +19 -139
- package/src/commands/write.ts +198 -0
- package/src/resolution-options.ts +67 -0
- package/src/types.ts +34 -7
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DEFAULT_MIN_CONF } from '@did-btcr2/api';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { CLIError } from './error.js';
|
|
4
|
+
/** The help text of `--min-conf`. `resolve`, `update`, and `deactivate` share it. */
|
|
5
|
+
export const MIN_CONF_HELP = 'Minimum block confirmations a beacon signal needs before resolution applies it '
|
|
6
|
+
+ `(positive integer, default: ${DEFAULT_MIN_CONF}). Overrides a minConf inside the JSON resolution options`;
|
|
7
|
+
/**
|
|
8
|
+
* Builds the resolution options from the flags. The inline JSON wins over
|
|
9
|
+
* the file. The `--min-conf` flag wins over a `minConf` inside the JSON.
|
|
10
|
+
* Returns `undefined` if no flag is set.
|
|
11
|
+
*/
|
|
12
|
+
export async function readResolutionOptions(flags) {
|
|
13
|
+
let resolutionOptions;
|
|
14
|
+
if (flags.resolutionOptions) {
|
|
15
|
+
try {
|
|
16
|
+
resolutionOptions = JSON.parse(flags.resolutionOptions);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
throw new CLIError('Invalid resolution options. Must be a valid JSON string.', 'INVALID_ARGUMENT_ERROR', { resolutionOptions: flags.resolutionOptions });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else if (flags.resolutionOptionsPath) {
|
|
23
|
+
try {
|
|
24
|
+
const content = await readFile(flags.resolutionOptionsPath, 'utf-8');
|
|
25
|
+
resolutionOptions = JSON.parse(content);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
throw new CLIError('Invalid resolution options path. Must be a valid path to a JSON file.', 'INVALID_ARGUMENT_ERROR', { resolutionOptionsPath: flags.resolutionOptionsPath });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// The flag wins over a minConf inside the JSON options.
|
|
32
|
+
if (flags.minConf !== undefined) {
|
|
33
|
+
resolutionOptions = { ...(resolutionOptions ?? {}), minConf: flags.minConf };
|
|
34
|
+
}
|
|
35
|
+
return resolutionOptions;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Commander argParser for `--min-conf`. Accepts a positive integer (minimum 1),
|
|
39
|
+
* the domain the specification gives `minConf`. Errors at parse time otherwise.
|
|
40
|
+
*/
|
|
41
|
+
export function parseMinConf(value) {
|
|
42
|
+
if (!/^[1-9]\d*$/.test(value)) {
|
|
43
|
+
throw new CLIError('--min-conf must be a positive integer (minimum 1).', 'INVALID_ARGUMENT_ERROR', { value });
|
|
44
|
+
}
|
|
45
|
+
return Number(value);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=resolution-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution-options.js","sourceRoot":"","sources":["../../../src/resolution-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,qFAAqF;AACrF,MAAM,CAAC,MAAM,aAAa,GACxB,iFAAiF;MAC/E,+BAA+B,gBAAgB,2DAA2D,CAAC;AAE/G;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAA4B;IACtE,IAAI,iBAAgD,CAAC;IACrD,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC5B,IAAI,CAAC;YACH,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAC1D,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,QAAQ,CAChB,0DAA0D,EAC1D,wBAAwB,EACxB,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE,CAC/C,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,IAAI,KAAK,CAAC,qBAAqB,EAAE,CAAC;QACvC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;YACrE,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,QAAQ,CAChB,uEAAuE,EACvE,wBAAwB,EACxB,EAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAAE,CACvD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,wDAAwD;IACxD,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAChC,iBAAiB,GAAG,EAAE,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAC/E,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,QAAQ,CAChB,oDAAoD,EACpD,wBAAwB,EACxB,EAAE,KAAK,EAAE,CACV,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/types/src/cli.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class DidBtcr2Cli {
|
|
|
14
14
|
* for known networks and localhost Polar for regtest.
|
|
15
15
|
*
|
|
16
16
|
* @param factory - Optional API factory for keystore-free commands (create,
|
|
17
|
-
* resolve). Defaults to {@link defaultApiFactory}.
|
|
17
|
+
* resolve, identifier). Defaults to {@link defaultApiFactory}.
|
|
18
18
|
* @param keystoreFactory - Optional keystore-aware API factory for commands
|
|
19
19
|
* that need a signing identity (key, update, deactivate). Defaults to
|
|
20
20
|
* {@link keystoreApiFactory}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAkB,MAAM,WAAW,CAAC;AAepD,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;IA0DlD;;;;OAIG;IACU,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CASjD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
|
-
import {
|
|
2
|
+
import type { ApiFactory } from '../config.js';
|
|
3
3
|
import type { GlobalOptions } from '../types.js';
|
|
4
4
|
export declare function registerDeactivateCommand(program: Command, factory: ApiFactory, globals: () => GlobalOptions): void;
|
|
5
5
|
//# sourceMappingURL=deactivate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deactivate.d.ts","sourceRoot":"","sources":["../../../../src/commands/deactivate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deactivate.d.ts","sourceRoot":"","sources":["../../../../src/commands/deactivate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,wBAAgB,yBAAyB,CACvC,OAAO,EAAG,OAAO,EACjB,OAAO,EAAG,UAAU,EACpB,OAAO,EAAG,MAAM,aAAa,GAC5B,IAAI,CAgBN"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import type { ApiFactory } from '../config.js';
|
|
3
|
+
import type { GlobalOptions } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Registers the `identifier` command group. `decode` prints the components of
|
|
6
|
+
* a did:btcr2 identifier. `validate` checks that an identifier conforms to the
|
|
7
|
+
* specification and prints a report. Both commands are offline and
|
|
8
|
+
* keystore-free: they use the api with no Bitcoin connection, no CAS, and no
|
|
9
|
+
* key material.
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerIdentifierCommand(program: Command, factory: ApiFactory, globals: () => GlobalOptions): void;
|
|
12
|
+
//# sourceMappingURL=identifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../../../src/commands/identifier.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,KAAK,EAAiB,aAAa,EAAwB,MAAM,aAAa,CAAC;AAEtF;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAG,OAAO,EACjB,OAAO,EAAG,UAAU,EACpB,OAAO,EAAG,MAAM,aAAa,GAC5B,IAAI,CAuFN"}
|
|
@@ -4,6 +4,7 @@ export { registerCreateCommand } from './create.js';
|
|
|
4
4
|
export { registerResolveCommand } from './resolve.js';
|
|
5
5
|
export { registerUpdateCommand } from './update.js';
|
|
6
6
|
export { registerDeactivateCommand } from './deactivate.js';
|
|
7
|
+
export { registerIdentifierCommand } from './identifier.js';
|
|
7
8
|
export { registerKeyCommand } from './key.js';
|
|
8
9
|
export { registerKeystoreCommand } from './keystore.js';
|
|
9
10
|
export { registerConfigCommand } from './config.js';
|
|
@@ -1 +1 @@
|
|
|
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,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,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"}
|
|
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,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,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,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../src/commands/resolve.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../src/commands/resolve.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,KAAK,EAAE,aAAa,EAAyB,MAAM,aAAa,CAAC;AAExE,wBAAgB,sBAAsB,CACpC,OAAO,EAAG,OAAO,EACjB,OAAO,EAAG,UAAU,EACpB,OAAO,EAAG,MAAM,aAAa,GAC5B,IAAI,CAiBN"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
|
-
import {
|
|
2
|
+
import type { ApiFactory } from '../config.js';
|
|
3
3
|
import type { GlobalOptions } from '../types.js';
|
|
4
4
|
export declare function registerUpdateCommand(program: Command, factory: ApiFactory, globals: () => GlobalOptions): void;
|
|
5
5
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/commands/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/commands/update.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,wBAAgB,qBAAqB,CACnC,OAAO,EAAG,OAAO,EACjB,OAAO,EAAG,UAAU,EACpB,OAAO,EAAG,MAAM,aAAa,GAC5B,IAAI,CAuBN"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DidBtcr2Api, PublishToCasMode } from '@did-btcr2/api';
|
|
2
|
+
import type { Command } from 'commander';
|
|
3
|
+
import { type ApiFactory } from '../config.js';
|
|
4
|
+
import { type ResolutionOptionFlags } from '../resolution-options.js';
|
|
5
|
+
import type { GlobalOptions, NetworkOption, UpdateCommandOptions } from '../types.js';
|
|
6
|
+
/** The parsed flags that `update` and `deactivate` share. */
|
|
7
|
+
export type WriteFlags = ResolutionOptionFlags & {
|
|
8
|
+
identifier: string;
|
|
9
|
+
sourceDocument?: unknown;
|
|
10
|
+
sourceVersionId?: number;
|
|
11
|
+
verificationMethodId?: string;
|
|
12
|
+
beaconId?: string;
|
|
13
|
+
publishToCas: PublishToCasMode;
|
|
14
|
+
feeRate?: string;
|
|
15
|
+
changeAddress?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Registers the flags that `update` and `deactivate` share. Each command
|
|
19
|
+
* registers `-i/--identifier` (and `update` its `-p/--patches`) before it
|
|
20
|
+
* calls this function, so those flags lead the help output.
|
|
21
|
+
*/
|
|
22
|
+
export declare function registerWriteOptions(command: Command): Command;
|
|
23
|
+
/**
|
|
24
|
+
* Validates the shared write flags, derives the network from the identifier,
|
|
25
|
+
* applies the mainnet keystore guard, builds the signer, and returns the
|
|
26
|
+
* parameters for `updateDid` and `deactivateDid`.
|
|
27
|
+
*
|
|
28
|
+
* The checks run in this order, before any key material is read:
|
|
29
|
+
* 1. The identifier decodes and names a supported network.
|
|
30
|
+
* 2. `--source-document` and `--source-version-id` come together or not at
|
|
31
|
+
* all (ADR 101). The api refuses a half pair too; the cli names the flags.
|
|
32
|
+
* 3. The resolution flags come only without the source pair. The api ignores
|
|
33
|
+
* `resolutionOptions` when the pair is supplied (ADR 098). A silent ignore
|
|
34
|
+
* of `--min-conf` would mislead.
|
|
35
|
+
* 4. A mainnet write is refused with an unencrypted dev keystore (ADR 080).
|
|
36
|
+
*/
|
|
37
|
+
export declare function prepareWrite(options: WriteFlags, factory: ApiFactory, g: GlobalOptions): Promise<{
|
|
38
|
+
network: NetworkOption;
|
|
39
|
+
api: DidBtcr2Api;
|
|
40
|
+
params: UpdateCommandOptions;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns a commander argParser that validates JSON.
|
|
44
|
+
* Errors at parse time with a clear flag reference.
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseJsonArg(flagName: string): (value: string) => unknown;
|
|
47
|
+
//# sourceMappingURL=write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AO,CAYzE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ResolutionOptions } from '@did-btcr2/method';
|
|
2
|
+
/** The flags that select the resolution options of a command. */
|
|
3
|
+
export type ResolutionOptionFlags = {
|
|
4
|
+
resolutionOptions?: string;
|
|
5
|
+
resolutionOptionsPath?: string;
|
|
6
|
+
minConf?: number;
|
|
7
|
+
};
|
|
8
|
+
/** The help text of `--min-conf`. `resolve`, `update`, and `deactivate` share it. */
|
|
9
|
+
export declare const MIN_CONF_HELP: string;
|
|
10
|
+
/**
|
|
11
|
+
* Builds the resolution options from the flags. The inline JSON wins over
|
|
12
|
+
* the file. The `--min-conf` flag wins over a `minConf` inside the JSON.
|
|
13
|
+
* Returns `undefined` if no flag is set.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readResolutionOptions(flags: ResolutionOptionFlags): Promise<ResolutionOptions | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Commander argParser for `--min-conf`. Accepts a positive integer (minimum 1),
|
|
18
|
+
* the domain the specification gives `minConf`. Errors at parse time otherwise.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseMinConf(value: string): number;
|
|
21
|
+
//# sourceMappingURL=resolution-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution-options.d.ts","sourceRoot":"","sources":["../../../src/resolution-options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI3D,iEAAiE;AACjE,MAAM,MAAM,qBAAqB,GAAG;IAClC,iBAAiB,CAAC,EAAO,MAAM,CAAC;IAChC,qBAAqB,CAAC,EAAG,MAAM,CAAC;IAChC,OAAO,CAAC,EAAiB,MAAM,CAAC;CACjC,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,aAAa,QAEoF,CAAC;AAE/G;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CA6BhH;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CASlD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { DidUpdateResult } from '@did-btcr2/api';
|
|
2
|
-
import type { PatchOperation } from '@did-btcr2/common';
|
|
1
|
+
import type { BroadcastOptions, DidUpdateResult, IdentifierReport, PublishToCasMode, Signer } from '@did-btcr2/api';
|
|
3
2
|
import type { Btcr2DidDocument, ResolutionOptions } from '@did-btcr2/method';
|
|
4
3
|
import type { DidResolutionResult } from '@web5/dids';
|
|
5
4
|
import type { DoctorReport, EffectiveConfig } from './config.js';
|
|
@@ -25,12 +24,37 @@ export interface ResolveCommandOptions {
|
|
|
25
24
|
identifier: string;
|
|
26
25
|
options?: ResolutionOptions;
|
|
27
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* The parameters that `update` and `deactivate` hand to the api's `updateDid`
|
|
29
|
+
* and `deactivateDid`. `update` adds `patches`. An absent source pair lets the
|
|
30
|
+
* api resolve the current document with `resolutionOptions` (ADR 098, ADR
|
|
31
|
+
* 101). An absent `verificationMethodId` or `beaconId` lets the api derive it
|
|
32
|
+
* (ADR 104).
|
|
33
|
+
*/
|
|
28
34
|
export interface UpdateCommandOptions {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
did: string;
|
|
36
|
+
signer: Signer;
|
|
37
|
+
sourceDocument?: Btcr2DidDocument;
|
|
38
|
+
sourceVersionId?: number;
|
|
39
|
+
verificationMethodId?: string;
|
|
40
|
+
beaconId?: string;
|
|
41
|
+
resolutionOptions?: ResolutionOptions;
|
|
42
|
+
publishToCas: PublishToCasMode;
|
|
43
|
+
broadcastOptions?: BroadcastOptions;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The data that `identifier decode` prints: the decoded components of the
|
|
47
|
+
* identifier with the genesis bytes as hex, plus the initial DID document
|
|
48
|
+
* if the caller asked for it.
|
|
49
|
+
*/
|
|
50
|
+
export interface IdentifierDecodeData {
|
|
51
|
+
did: string;
|
|
52
|
+
idType: string;
|
|
53
|
+
hrp: string;
|
|
54
|
+
version: number;
|
|
55
|
+
network: string;
|
|
56
|
+
genesisBytes: string;
|
|
57
|
+
initialDocument?: Btcr2DidDocument;
|
|
34
58
|
}
|
|
35
59
|
export type CommandResult = {
|
|
36
60
|
action: 'create';
|
|
@@ -46,6 +70,12 @@ export type CommandResult = {
|
|
|
46
70
|
} | {
|
|
47
71
|
action: 'deactivate';
|
|
48
72
|
data: DidUpdateResult;
|
|
73
|
+
} | {
|
|
74
|
+
action: 'identifier-decode';
|
|
75
|
+
data: IdentifierDecodeData;
|
|
76
|
+
} | {
|
|
77
|
+
action: 'identifier-validate';
|
|
78
|
+
data: IdentifierReport;
|
|
49
79
|
} | {
|
|
50
80
|
action: 'key-generate';
|
|
51
81
|
data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3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AAC;IAC7B,UAAU,CAAC,EAAW,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAW,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAQ,MAAM,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAS,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAS,MAAM,EAAE,CAAC;IAC/B,kBAAkB,CAAC,EAAG,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAa,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAO,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAW,MAAM,CAAC;CAC9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@did-btcr2/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for interacting with did-btcr2-js, the JavaScript/TypeScript reference implementation of the did:btcr2 method. Exposes various parts of multiple packages in the did-btcr2-js monorepo.",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"@web5/dids": "^1.2.0",
|
|
63
63
|
"commander": "^13.1.0",
|
|
64
64
|
"@did-btcr2/key-manager": "^0.7.0",
|
|
65
|
+
"@did-btcr2/api": "^0.22.0",
|
|
66
|
+
"@did-btcr2/common": "^9.4.0",
|
|
65
67
|
"@did-btcr2/keypair": "^0.13.1",
|
|
66
|
-
"@did-btcr2/
|
|
67
|
-
"@did-btcr2/method": "^0.59.0",
|
|
68
|
-
"@did-btcr2/common": "^9.4.0"
|
|
68
|
+
"@did-btcr2/method": "^0.60.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@eslint/js": "^9.21.0",
|
package/src/cli.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
registerConfigCommand,
|
|
6
6
|
registerCreateCommand,
|
|
7
7
|
registerDeactivateCommand,
|
|
8
|
+
registerIdentifierCommand,
|
|
8
9
|
registerInitCommand,
|
|
9
10
|
registerKeyCommand,
|
|
10
11
|
registerKeystoreCommand,
|
|
@@ -32,7 +33,7 @@ export class DidBtcr2Cli {
|
|
|
32
33
|
* for known networks and localhost Polar for regtest.
|
|
33
34
|
*
|
|
34
35
|
* @param factory - Optional API factory for keystore-free commands (create,
|
|
35
|
-
* resolve). Defaults to {@link defaultApiFactory}.
|
|
36
|
+
* resolve, identifier). Defaults to {@link defaultApiFactory}.
|
|
36
37
|
* @param keystoreFactory - Optional keystore-aware API factory for commands
|
|
37
38
|
* that need a signing identity (key, update, deactivate). Defaults to
|
|
38
39
|
* {@link keystoreApiFactory}.
|
|
@@ -89,6 +90,7 @@ export class DidBtcr2Cli {
|
|
|
89
90
|
registerResolveCommand(this.program, factory, globals);
|
|
90
91
|
registerUpdateCommand(this.program, keystoreFactory, globals);
|
|
91
92
|
registerDeactivateCommand(this.program, keystoreFactory, globals);
|
|
93
|
+
registerIdentifierCommand(this.program, factory, globals);
|
|
92
94
|
registerKeyCommand(this.program, keystoreFactory, globals);
|
|
93
95
|
registerKeystoreCommand(this.program, globals);
|
|
94
96
|
registerConfigCommand(this.program, globals);
|
|
@@ -2,7 +2,7 @@ import type { Command } from 'commander';
|
|
|
2
2
|
import { CLIError } from '../error.js';
|
|
3
3
|
import type { GlobalOptions } from '../types.js';
|
|
4
4
|
|
|
5
|
-
const COMMANDS = 'create resolve read update deactivate delete key config profile completion';
|
|
5
|
+
const COMMANDS = 'create resolve read update deactivate delete identifier key config profile completion';
|
|
6
6
|
|
|
7
7
|
/** Registers the `completion` command, which prints a shell completion script to stdout. */
|
|
8
8
|
export function registerCompletionCommand(program: Command, _globals: () => GlobalOptions): void {
|
|
@@ -1,156 +1,28 @@
|
|
|
1
|
-
import type { PublishToCasMode } from '@did-btcr2/api';
|
|
2
|
-
import { KeyManagerSigner } from '@did-btcr2/key-manager';
|
|
3
1
|
import type { Command } from 'commander';
|
|
4
|
-
import {
|
|
5
|
-
import { CLIError } from '../error.js';
|
|
2
|
+
import type { ApiFactory } from '../config.js';
|
|
6
3
|
import { printWatchHint } from '../hints.js';
|
|
7
|
-
import { resolveKeyRef } from '../keystore/resolve-key-ref.js';
|
|
8
4
|
import { formatResult } from '../output.js';
|
|
9
|
-
import type { GlobalOptions
|
|
10
|
-
|
|
11
|
-
/** The JSON Patch that marks a DID document as permanently deactivated. */
|
|
12
|
-
const DEACTIVATION_PATCH = [{ op: 'add' as const, path: '/deactivated', value: true }];
|
|
5
|
+
import type { GlobalOptions } from '../types.js';
|
|
6
|
+
import { prepareWrite, registerWriteOptions, type WriteFlags } from './write.js';
|
|
13
7
|
|
|
14
8
|
export function registerDeactivateCommand(
|
|
15
9
|
program : Command,
|
|
16
10
|
factory : ApiFactory,
|
|
17
11
|
globals : () => GlobalOptions,
|
|
18
12
|
): void {
|
|
19
|
-
program
|
|
13
|
+
const command = program
|
|
20
14
|
.command('deactivate')
|
|
21
15
|
.alias('delete')
|
|
22
16
|
.description('Deactivate the did:btcr2 identifier permanently. This is irreversible.')
|
|
23
|
-
.requiredOption(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
'-m, --verification-method-id <id>',
|
|
34
|
-
'DID document verification method ID used to sign the deactivation'
|
|
35
|
-
)
|
|
36
|
-
.requiredOption(
|
|
37
|
-
'-b, --beacon-id <json>',
|
|
38
|
-
'Beacon ID as a JSON string',
|
|
39
|
-
parseJsonArg('--beacon-id'),
|
|
40
|
-
)
|
|
41
|
-
.option(
|
|
42
|
-
'--publish-to-cas <mode>',
|
|
43
|
-
'Publish update artifacts to a writable CAS before broadcast: auto|always|never. '
|
|
44
|
-
+ 'CAS publication is optional; the default distributes the returned artifacts via sidecar.',
|
|
45
|
-
parsePublishToCasMode,
|
|
46
|
-
'never',
|
|
47
|
-
)
|
|
48
|
-
.option(
|
|
49
|
-
'--fee-rate <satsPerVByte>',
|
|
50
|
-
'Fee rate in sats/vByte for the beacon transaction (default: 5). '
|
|
51
|
-
+ 'Raise it under congestion so the transaction confirms.',
|
|
52
|
-
)
|
|
53
|
-
.option(
|
|
54
|
-
'--change-address <address>',
|
|
55
|
-
'Send transaction change to this address instead of the beacon address, '
|
|
56
|
-
+ 'so a DID\'s announcements are not linked on-chain (ADR 044).',
|
|
57
|
-
)
|
|
58
|
-
.action(async (options: {
|
|
59
|
-
sourceDocument : unknown;
|
|
60
|
-
sourceVersionId : string;
|
|
61
|
-
verificationMethodId : string;
|
|
62
|
-
beaconId : unknown;
|
|
63
|
-
publishToCas : PublishToCasMode;
|
|
64
|
-
feeRate? : string;
|
|
65
|
-
changeAddress? : string;
|
|
66
|
-
}) => {
|
|
67
|
-
if (!/^\d+$/.test(options.sourceVersionId)) {
|
|
68
|
-
throw new CLIError(
|
|
69
|
-
'--source-version-id must be a non-negative integer.',
|
|
70
|
-
'INVALID_ARGUMENT_ERROR',
|
|
71
|
-
{ value: options.sourceVersionId },
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
const parsed: UpdateCommandOptions = {
|
|
75
|
-
sourceDocument : options.sourceDocument as UpdateCommandOptions['sourceDocument'],
|
|
76
|
-
patches : DEACTIVATION_PATCH,
|
|
77
|
-
sourceVersionId : Number(options.sourceVersionId),
|
|
78
|
-
verificationMethodId : options.verificationMethodId,
|
|
79
|
-
beaconId : options.beaconId as UpdateCommandOptions['beaconId'],
|
|
80
|
-
};
|
|
81
|
-
const did = parsed.sourceDocument?.id;
|
|
82
|
-
if (!did) {
|
|
83
|
-
throw new CLIError(
|
|
84
|
-
'Source document must contain an "id" field.',
|
|
85
|
-
'INVALID_ARGUMENT_ERROR',
|
|
86
|
-
options
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
// Deactivation is an update that applies the deactivation patch. The core
|
|
90
|
-
// method has no separate deactivate path, so this routes through update.
|
|
91
|
-
const network = deriveNetwork(did);
|
|
92
|
-
// Refuse to sign a mainnet deactivation with an unencrypted dev keystore (ADR 080).
|
|
93
|
-
assertKeystoreAllowedForNetwork(network, globals());
|
|
94
|
-
const api = factory(network, globals());
|
|
95
|
-
const keyId = resolveKeyRef(api.kms.kms, resolveSigningKeyRef(globals()));
|
|
96
|
-
const signer = new KeyManagerSigner(api.kms.kms, keyId);
|
|
97
|
-
// Resolve fee-rate/change-address through the flag -> env -> profile chain
|
|
98
|
-
// into beacon broadcast options. Undefined when neither is set, so the
|
|
99
|
-
// SDK defaults (5 sat/vB, change back to the beacon address) still apply.
|
|
100
|
-
const broadcastOptions = resolveBroadcastOptions(network, globals(), {
|
|
101
|
-
feeRate : options.feeRate,
|
|
102
|
-
changeAddress : options.changeAddress,
|
|
103
|
-
});
|
|
104
|
-
// CAS publication is optional and never required: every beacon update can
|
|
105
|
-
// be completed and shared via sidecar alone. It is opt-in and defaults to
|
|
106
|
-
// 'never'; pass --publish-to-cas auto|always to publish the signed update
|
|
107
|
-
// (and, for CAS beacons, the announcement) to a writable CAS configured
|
|
108
|
-
// via --cas-rpc-url. The returned artifacts (txid, announcement, proof)
|
|
109
|
-
// are always printed for sidecar distribution regardless.
|
|
110
|
-
const data = await api.btcr2.update({
|
|
111
|
-
sourceDocument : parsed.sourceDocument,
|
|
112
|
-
patches : parsed.patches,
|
|
113
|
-
sourceVersionId : parsed.sourceVersionId,
|
|
114
|
-
verificationMethodId : parsed.verificationMethodId,
|
|
115
|
-
beaconId : parsed.beaconId,
|
|
116
|
-
signer,
|
|
117
|
-
publishToCas : options.publishToCas,
|
|
118
|
-
...(broadcastOptions ? { broadcastOptions } : {}),
|
|
119
|
-
});
|
|
120
|
-
console.log(formatResult({ action: 'deactivate', data }, globals()));
|
|
121
|
-
printWatchHint(globals(), network, data.txid);
|
|
17
|
+
.requiredOption('-i, --identifier <identifier>', 'did:btcr2 identifier to deactivate');
|
|
18
|
+
registerWriteOptions(command)
|
|
19
|
+
.action(async (options: WriteFlags) => {
|
|
20
|
+
const g = globals();
|
|
21
|
+
const { network, api, params } = await prepareWrite(options, factory, g);
|
|
22
|
+
// The api supplies the deactivation patch (ADR 094) and refuses a
|
|
23
|
+
// document that is deactivated already (ADR 100).
|
|
24
|
+
const data = await api.deactivateDid(params);
|
|
25
|
+
console.log(formatResult({ action: 'deactivate', data }, g));
|
|
26
|
+
printWatchHint(g, network, data.txid);
|
|
122
27
|
});
|
|
123
28
|
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Commander argParser for `--publish-to-cas`. Validates the value is one of the
|
|
127
|
-
* three {@link PublishToCasMode} policies, erroring at parse time otherwise.
|
|
128
|
-
*/
|
|
129
|
-
function parsePublishToCasMode(value: string): PublishToCasMode {
|
|
130
|
-
if (value !== 'auto' && value !== 'always' && value !== 'never') {
|
|
131
|
-
throw new CLIError(
|
|
132
|
-
'--publish-to-cas must be one of "auto", "always", or "never".',
|
|
133
|
-
'INVALID_ARGUMENT_ERROR',
|
|
134
|
-
{ value },
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
return value;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Returns a commander argParser that validates JSON.
|
|
142
|
-
* Errors at parse time with a clear flag reference.
|
|
143
|
-
*/
|
|
144
|
-
function parseJsonArg(flagName: string): (value: string) => unknown {
|
|
145
|
-
return (value: string): unknown => {
|
|
146
|
-
try {
|
|
147
|
-
return JSON.parse(value);
|
|
148
|
-
} catch {
|
|
149
|
-
throw new CLIError(
|
|
150
|
-
`Invalid JSON for ${flagName}. Must be a valid JSON string.`,
|
|
151
|
-
'INVALID_ARGUMENT_ERROR',
|
|
152
|
-
{ flagName, value }
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
}
|