@did-btcr2/cli 0.21.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 +13 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +123 -9
- 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/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/types/src/cli.d.ts +1 -1
- package/dist/types/src/cli.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/types.d.ts +21 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/cli.ts +3 -1
- package/src/commands/completion.ts +1 -1
- package/src/commands/identifier.ts +156 -0
- package/src/commands/index.ts +1 -0
- package/src/types.ts +18 -1
package/dist/cjs/index.js
CHANGED
|
@@ -51,6 +51,7 @@ __export(index_exports, {
|
|
|
51
51
|
registerConfigCommand: () => registerConfigCommand,
|
|
52
52
|
registerCreateCommand: () => registerCreateCommand,
|
|
53
53
|
registerDeactivateCommand: () => registerDeactivateCommand,
|
|
54
|
+
registerIdentifierCommand: () => registerIdentifierCommand,
|
|
54
55
|
registerInitCommand: () => registerInitCommand,
|
|
55
56
|
registerKeyCommand: () => registerKeyCommand,
|
|
56
57
|
registerKeystoreCommand: () => registerKeystoreCommand,
|
|
@@ -2500,9 +2501,120 @@ function registerDeactivateCommand(program, factory, globals) {
|
|
|
2500
2501
|
});
|
|
2501
2502
|
}
|
|
2502
2503
|
|
|
2504
|
+
// src/commands/identifier.ts
|
|
2505
|
+
var import_api6 = require("@did-btcr2/api");
|
|
2506
|
+
var import_utils5 = require("@noble/hashes/utils.js");
|
|
2507
|
+
var import_promises2 = require("fs/promises");
|
|
2508
|
+
function registerIdentifierCommand(program, factory, globals) {
|
|
2509
|
+
const identifier = program.command("identifier").description("Decode and validate did:btcr2 identifiers (offline).");
|
|
2510
|
+
const print = (result) => console.log(formatResult(result, globals()));
|
|
2511
|
+
identifier.command("decode <did>").description("Print the components of a did:btcr2 identifier.").option(
|
|
2512
|
+
"--initial-document",
|
|
2513
|
+
"Add the initial DID document. An external identifier (x) needs --genesis-document.",
|
|
2514
|
+
false
|
|
2515
|
+
).option(
|
|
2516
|
+
"--genesis-document <path>",
|
|
2517
|
+
"Path to the JSON genesis document of an external identifier (x). Requires --initial-document."
|
|
2518
|
+
).action(async (did, options) => {
|
|
2519
|
+
if (options.genesisDocument !== void 0 && !options.initialDocument) {
|
|
2520
|
+
throw new CLIError("--genesis-document requires --initial-document.", "INVALID_ARGUMENT_ERROR");
|
|
2521
|
+
}
|
|
2522
|
+
assertValidIdentifier(did);
|
|
2523
|
+
const api = factory();
|
|
2524
|
+
const components = api.did.decode(did);
|
|
2525
|
+
if (options.genesisDocument !== void 0 && components.hrp === "k") {
|
|
2526
|
+
throw new CLIError(
|
|
2527
|
+
"--genesis-document applies only to external identifiers (x).",
|
|
2528
|
+
"INVALID_ARGUMENT_ERROR",
|
|
2529
|
+
{ did }
|
|
2530
|
+
);
|
|
2531
|
+
}
|
|
2532
|
+
const data = {
|
|
2533
|
+
did,
|
|
2534
|
+
idType: components.idType,
|
|
2535
|
+
hrp: components.hrp,
|
|
2536
|
+
version: components.version,
|
|
2537
|
+
network: components.network,
|
|
2538
|
+
genesisBytes: (0, import_utils5.bytesToHex)(components.genesisBytes)
|
|
2539
|
+
};
|
|
2540
|
+
if (options.initialDocument) {
|
|
2541
|
+
if (components.hrp === "x" && options.genesisDocument === void 0) {
|
|
2542
|
+
throw new CLIError(
|
|
2543
|
+
"An external identifier (x) needs --genesis-document <path> for --initial-document.",
|
|
2544
|
+
"INVALID_ARGUMENT_ERROR",
|
|
2545
|
+
{ did }
|
|
2546
|
+
);
|
|
2547
|
+
}
|
|
2548
|
+
const genesisDocument = options.genesisDocument === void 0 ? void 0 : await readGenesisDocument(options.genesisDocument);
|
|
2549
|
+
data.initialDocument = api.btcr2.getInitialDocument(did, genesisDocument);
|
|
2550
|
+
}
|
|
2551
|
+
print({ action: "identifier-decode", data });
|
|
2552
|
+
});
|
|
2553
|
+
identifier.command("validate <did>").description("Check that a did:btcr2 identifier conforms to the specification. Exit code 1 if it does not.").option(
|
|
2554
|
+
"-b, --bytes <hex>",
|
|
2555
|
+
"Genesis bytes as a hex string that the identifier must encode: the 33-byte public key (k) or the 32-byte genesis document hash (x). Adds the genesisBytesMatch check."
|
|
2556
|
+
).option(
|
|
2557
|
+
"--genesis-document <path>",
|
|
2558
|
+
"Path to the JSON genesis document of an external identifier (x). Adds the genesisDocument check."
|
|
2559
|
+
).action(async (did, options) => {
|
|
2560
|
+
const genesisBytes = options.bytes === void 0 ? void 0 : parseHexBytes(options.bytes);
|
|
2561
|
+
let genesisDocument;
|
|
2562
|
+
if (options.genesisDocument !== void 0) {
|
|
2563
|
+
if (import_api6.Identifier.isValid(did) && import_api6.Identifier.decode(did).hrp === "k") {
|
|
2564
|
+
throw new CLIError(
|
|
2565
|
+
"--genesis-document applies only to external identifiers (x).",
|
|
2566
|
+
"INVALID_ARGUMENT_ERROR",
|
|
2567
|
+
{ did }
|
|
2568
|
+
);
|
|
2569
|
+
}
|
|
2570
|
+
genesisDocument = await readGenesisDocument(options.genesisDocument);
|
|
2571
|
+
}
|
|
2572
|
+
const report = factory().did.validate(did, { genesisBytes, genesisDocument });
|
|
2573
|
+
print({ action: "identifier-validate", data: report });
|
|
2574
|
+
if (!report.valid) process.exitCode = 1;
|
|
2575
|
+
});
|
|
2576
|
+
}
|
|
2577
|
+
function assertValidIdentifier(did) {
|
|
2578
|
+
const report = import_api6.Identifier.validate(did);
|
|
2579
|
+
if (report.valid) return;
|
|
2580
|
+
const failed = report.checks[report.checks.length - 1];
|
|
2581
|
+
throw new CLIError(
|
|
2582
|
+
`Invalid identifier (${failed.name} check): ${failed.detail ?? "failed"}`,
|
|
2583
|
+
"INVALID_ARGUMENT_ERROR",
|
|
2584
|
+
{ did, check: failed.name }
|
|
2585
|
+
);
|
|
2586
|
+
}
|
|
2587
|
+
function parseHexBytes(value) {
|
|
2588
|
+
try {
|
|
2589
|
+
return (0, import_utils5.hexToBytes)(value.trim());
|
|
2590
|
+
} catch {
|
|
2591
|
+
throw new CLIError("Invalid bytes: not valid hex.", "INVALID_ARGUMENT_ERROR", { bytes: value });
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
async function readGenesisDocument(path) {
|
|
2595
|
+
let parsed;
|
|
2596
|
+
try {
|
|
2597
|
+
parsed = JSON.parse(await (0, import_promises2.readFile)(path, "utf-8"));
|
|
2598
|
+
} catch {
|
|
2599
|
+
throw new CLIError(
|
|
2600
|
+
"Invalid genesis document path. Must be a valid path to a JSON file.",
|
|
2601
|
+
"INVALID_ARGUMENT_ERROR",
|
|
2602
|
+
{ genesisDocument: path }
|
|
2603
|
+
);
|
|
2604
|
+
}
|
|
2605
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
2606
|
+
throw new CLIError(
|
|
2607
|
+
"Invalid genesis document. The file must contain a JSON object.",
|
|
2608
|
+
"INVALID_ARGUMENT_ERROR",
|
|
2609
|
+
{ genesisDocument: path }
|
|
2610
|
+
);
|
|
2611
|
+
}
|
|
2612
|
+
return parsed;
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2503
2615
|
// src/commands/key.ts
|
|
2504
2616
|
var import_keypair = require("@did-btcr2/keypair");
|
|
2505
|
-
var
|
|
2617
|
+
var import_utils6 = require("@noble/hashes/utils.js");
|
|
2506
2618
|
var import_node_fs9 = require("fs");
|
|
2507
2619
|
function registerKeyCommand(program, factory, globals) {
|
|
2508
2620
|
const key = program.command("key").description("Manage keypairs in the encrypted keystore.");
|
|
@@ -2512,7 +2624,7 @@ function registerKeyCommand(program, factory, globals) {
|
|
|
2512
2624
|
assertNameAvailable(api.kms.kms, options.name);
|
|
2513
2625
|
const setActive = options.setActive ?? false;
|
|
2514
2626
|
const id = api.kms.generateKey({ ...options.name && { tags: { name: options.name } }, setActive });
|
|
2515
|
-
print({ action: "key-generate", data: { keyId: id, publicKey: (0,
|
|
2627
|
+
print({ action: "key-generate", data: { keyId: id, publicKey: (0, import_utils6.bytesToHex)(api.kms.getPublicKey(id)), active: setActive } });
|
|
2516
2628
|
});
|
|
2517
2629
|
key.command("list").alias("ls").description("List stored keys.").action(() => {
|
|
2518
2630
|
const kms = factory(void 0, globals()).kms.kms;
|
|
@@ -2532,7 +2644,7 @@ function registerKeyCommand(program, factory, globals) {
|
|
|
2532
2644
|
const kms = factory(void 0, globals()).kms.kms;
|
|
2533
2645
|
const id = resolveKeyRef(kms, ref);
|
|
2534
2646
|
const entry = kms.getEntry(id);
|
|
2535
|
-
print({ action: "key-show", data: { keyId: id, publicKey: (0,
|
|
2647
|
+
print({ action: "key-show", data: { keyId: id, publicKey: (0, import_utils6.bytesToHex)(entry.publicKey), ...entry.tags && { tags: entry.tags } } });
|
|
2536
2648
|
});
|
|
2537
2649
|
key.command("import").description("Import a key: a secret from a hex file, or a public key as watch-only.").option("--secret-file <path>", "Path to a file containing a 32-byte secret key as hex.").option("--public <hex>", "A 33-byte compressed public key as hex (imported watch-only).").option("--name <name>", "A human-friendly name, stored as a tag.").option("--set-active", "Make this the active key.", false).action((options) => {
|
|
2538
2650
|
if (Boolean(options.secretFile) === Boolean(options.public)) {
|
|
@@ -2543,13 +2655,13 @@ function registerKeyCommand(program, factory, globals) {
|
|
|
2543
2655
|
const keyPair = options.secretFile ? new import_keypair.SchnorrKeyPair({ secretKey: readHexFile(options.secretFile, 32, "--secret-file") }) : new import_keypair.SchnorrKeyPair({ publicKey: parseHex(options.public ?? "", 33, "--public") });
|
|
2544
2656
|
const setActive = options.setActive ?? false;
|
|
2545
2657
|
const id = api.kms.import(keyPair, { ...options.name && { tags: { name: options.name } }, setActive });
|
|
2546
|
-
print({ action: "key-import", data: { keyId: id, publicKey: (0,
|
|
2658
|
+
print({ action: "key-import", data: { keyId: id, publicKey: (0, import_utils6.bytesToHex)(api.kms.getPublicKey(id)), watchOnly: !options.secretFile, active: setActive } });
|
|
2547
2659
|
});
|
|
2548
2660
|
key.command("export <ref>").description("Export a key. Public material by default; --secret writes the secret to a file.").option("--secret", "Export the secret key. Requires --out.", false).option("--out <path>", "Write the exported secret to this file (created 0600).").action((ref, options) => {
|
|
2549
2661
|
const api = factory(void 0, globals());
|
|
2550
2662
|
const id = resolveKeyRef(api.kms.kms, ref);
|
|
2551
2663
|
if (!options.secret) {
|
|
2552
|
-
print({ action: "key-export", data: { keyId: id, publicKey: (0,
|
|
2664
|
+
print({ action: "key-export", data: { keyId: id, publicKey: (0, import_utils6.bytesToHex)(api.kms.getPublicKey(id)) } });
|
|
2553
2665
|
return;
|
|
2554
2666
|
}
|
|
2555
2667
|
if (!options.out) {
|
|
@@ -2560,7 +2672,7 @@ function registerKeyCommand(program, factory, globals) {
|
|
|
2560
2672
|
throw new CLIError(`Key ${id} is watch-only and has no secret to export.`, "INVALID_ARGUMENT_ERROR", { keyId: id });
|
|
2561
2673
|
}
|
|
2562
2674
|
process.stderr.write("warning: writing an unencrypted secret key to disk. Protect this file and delete it when done.\n");
|
|
2563
|
-
writeSecretFile(options.out, (0,
|
|
2675
|
+
writeSecretFile(options.out, (0, import_utils6.bytesToHex)(keyPair.secretKey.bytes));
|
|
2564
2676
|
print({ action: "key-export", data: { keyId: id, secretWrittenTo: options.out } });
|
|
2565
2677
|
});
|
|
2566
2678
|
key.command("delete <ref>").alias("rm").description("Delete a key from the keystore.").option("--force", "Delete even if it is the active key.", false).action((ref, options) => {
|
|
@@ -2585,7 +2697,7 @@ function assertNameAvailable(kms, name) {
|
|
|
2585
2697
|
function parseHex(hex, expectedBytes, label) {
|
|
2586
2698
|
let bytes;
|
|
2587
2699
|
try {
|
|
2588
|
-
bytes = (0,
|
|
2700
|
+
bytes = (0, import_utils6.hexToBytes)(hex.trim());
|
|
2589
2701
|
} catch {
|
|
2590
2702
|
throw new CLIError(`Invalid hex for ${label}.`, "INVALID_ARGUMENT_ERROR", { label });
|
|
2591
2703
|
}
|
|
@@ -2912,7 +3024,7 @@ function registerProfileCommand(program, globals) {
|
|
|
2912
3024
|
}
|
|
2913
3025
|
|
|
2914
3026
|
// src/commands/completion.ts
|
|
2915
|
-
var COMMANDS = "create resolve read update deactivate delete key config profile completion";
|
|
3027
|
+
var COMMANDS = "create resolve read update deactivate delete identifier key config profile completion";
|
|
2916
3028
|
function registerCompletionCommand(program, _globals) {
|
|
2917
3029
|
program.command("completion [shell]").description("Print a shell completion script (bash, zsh, or fish) to stdout.").action((shell = "bash") => {
|
|
2918
3030
|
console.log(completionScript(shell));
|
|
@@ -2972,7 +3084,7 @@ var DidBtcr2Cli = class {
|
|
|
2972
3084
|
* for known networks and localhost Polar for regtest.
|
|
2973
3085
|
*
|
|
2974
3086
|
* @param factory - Optional API factory for keystore-free commands (create,
|
|
2975
|
-
* resolve). Defaults to {@link defaultApiFactory}.
|
|
3087
|
+
* resolve, identifier). Defaults to {@link defaultApiFactory}.
|
|
2976
3088
|
* @param keystoreFactory - Optional keystore-aware API factory for commands
|
|
2977
3089
|
* that need a signing identity (key, update, deactivate). Defaults to
|
|
2978
3090
|
* {@link keystoreApiFactory}.
|
|
@@ -2990,6 +3102,7 @@ var DidBtcr2Cli = class {
|
|
|
2990
3102
|
registerResolveCommand(this.program, factory, globals);
|
|
2991
3103
|
registerUpdateCommand(this.program, keystoreFactory, globals);
|
|
2992
3104
|
registerDeactivateCommand(this.program, keystoreFactory, globals);
|
|
3105
|
+
registerIdentifierCommand(this.program, factory, globals);
|
|
2993
3106
|
registerKeyCommand(this.program, keystoreFactory, globals);
|
|
2994
3107
|
registerKeystoreCommand(this.program, globals);
|
|
2995
3108
|
registerConfigCommand(this.program, globals);
|
|
@@ -3064,6 +3177,7 @@ function handleError(error, verbose) {
|
|
|
3064
3177
|
registerConfigCommand,
|
|
3065
3178
|
registerCreateCommand,
|
|
3066
3179
|
registerDeactivateCommand,
|
|
3180
|
+
registerIdentifierCommand,
|
|
3067
3181
|
registerInitCommand,
|
|
3068
3182
|
registerKeyCommand,
|
|
3069
3183
|
registerKeystoreCommand,
|
package/dist/esm/src/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DidMethodError } from '@did-btcr2/common';
|
|
2
2
|
import { Command, CommanderError } from 'commander';
|
|
3
|
-
import { registerCompletionCommand, registerConfigCommand, registerCreateCommand, registerDeactivateCommand, registerInitCommand, registerKeyCommand, registerKeystoreCommand, registerProfileCommand, registerQuickstartCommand, registerResolveCommand, registerUpdateCommand, } from './commands/index.js';
|
|
3
|
+
import { registerCompletionCommand, registerConfigCommand, registerCreateCommand, registerDeactivateCommand, registerIdentifierCommand, registerInitCommand, registerKeyCommand, registerKeystoreCommand, registerProfileCommand, registerQuickstartCommand, registerResolveCommand, registerUpdateCommand, } from './commands/index.js';
|
|
4
4
|
import { defaultApiFactory, keystoreApiFactory, resolveOutputFormat } from './config.js';
|
|
5
5
|
import { VERSION } from './version.js';
|
|
6
6
|
/**
|
|
@@ -17,7 +17,7 @@ export class DidBtcr2Cli {
|
|
|
17
17
|
* for known networks and localhost Polar for regtest.
|
|
18
18
|
*
|
|
19
19
|
* @param factory - Optional API factory for keystore-free commands (create,
|
|
20
|
-
* resolve). Defaults to {@link defaultApiFactory}.
|
|
20
|
+
* resolve, identifier). Defaults to {@link defaultApiFactory}.
|
|
21
21
|
* @param keystoreFactory - Optional keystore-aware API factory for commands
|
|
22
22
|
* that need a signing identity (key, update, deactivate). Defaults to
|
|
23
23
|
* {@link keystoreApiFactory}.
|
|
@@ -68,6 +68,7 @@ export class DidBtcr2Cli {
|
|
|
68
68
|
registerResolveCommand(this.program, factory, globals);
|
|
69
69
|
registerUpdateCommand(this.program, keystoreFactory, globals);
|
|
70
70
|
registerDeactivateCommand(this.program, keystoreFactory, globals);
|
|
71
|
+
registerIdentifierCommand(this.program, factory, globals);
|
|
71
72
|
registerKeyCommand(this.program, keystoreFactory, globals);
|
|
72
73
|
registerKeystoreCommand(this.program, globals);
|
|
73
74
|
registerConfigCommand(this.program, globals);
|
package/dist/esm/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAmB,MAAM,aAAa,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;GAEG;AACH,MAAM,OAAO,WAAW;IACN,OAAO,CAAU;IAEjC;;;;;;;;;;;;;OAaG;IACH,YACE,UAAsB,iBAAiB,EACvC,kBAA8B,kBAAkB;QAEhD,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;aAChC,OAAO,CAAC,SAAS,OAAO,EAAE,EAAE,eAAe,EAAE,4BAA4B,CAAC;aAC1E,WAAW,CAAC,mCAAmC,CAAC;aAChD,MAAM,CAAC,uBAAuB,EAAE,wEAAwE,CAAC;aACzG,MAAM,CAAC,WAAW,EAAE,gBAAgB,EAAE,KAA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delete key config profile completion';
|
|
2
|
+
const COMMANDS = 'create resolve read update deactivate delete identifier key config profile completion';
|
|
3
3
|
/** Registers the `completion` command, which prints a shell completion script to stdout. */
|
|
4
4
|
export function registerCompletionCommand(program, _globals) {
|
|
5
5
|
program
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../../../../src/commands/completion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,MAAM,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../../../../src/commands/completion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,MAAM,QAAQ,GAAG,uFAAuF,CAAC;AAEzG,4FAA4F;AAC5F,MAAM,UAAU,yBAAyB,CAAC,OAAgB,EAAE,QAA6B;IACvF,OAAO;SACJ,OAAO,CAAC,oBAAoB,CAAC;SAC7B,WAAW,CAAC,iEAAiE,CAAC;SAC9E,MAAM,CAAC,CAAC,KAAK,GAAG,MAAM,EAAE,EAAE;QACzB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC;AAED,uDAAuD;AACvD,SAAS,gBAAgB,CAAC,KAAa;IACrC,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,MAAM;YACT,OAAO;gBACL,wEAAwE;gBACxE,uCAAuC,GAAG,QAAQ,GAAG,wCAAwC;gBAC7F,0BAA0B;aAC3B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,KAAK,KAAK;YACR,OAAO;gBACL,sEAAsE;gBACtE,qBAAqB,GAAG,QAAQ,GAAG,IAAI;gBACvC,sBAAsB;aACvB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,KAAK,MAAM;YACT,OAAO;gBACL,wEAAwE;gBACxE,2BAA2B,GAAG,QAAQ,GAAG,GAAG;aAC7C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf;YACE,MAAM,IAAI,QAAQ,CAAC,sBAAsB,KAAK,4BAA4B,EAAE,wBAAwB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACrH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Identifier } from '@did-btcr2/api';
|
|
2
|
+
import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { CLIError } from '../error.js';
|
|
5
|
+
import { formatResult } from '../output.js';
|
|
6
|
+
/**
|
|
7
|
+
* Registers the `identifier` command group. `decode` prints the components of
|
|
8
|
+
* a did:btcr2 identifier. `validate` checks that an identifier conforms to the
|
|
9
|
+
* specification and prints a report. Both commands are offline and
|
|
10
|
+
* keystore-free: they use the api with no Bitcoin connection, no CAS, and no
|
|
11
|
+
* key material.
|
|
12
|
+
*/
|
|
13
|
+
export function registerIdentifierCommand(program, factory, globals) {
|
|
14
|
+
const identifier = program
|
|
15
|
+
.command('identifier')
|
|
16
|
+
.description('Decode and validate did:btcr2 identifiers (offline).');
|
|
17
|
+
const print = (result) => console.log(formatResult(result, globals()));
|
|
18
|
+
identifier
|
|
19
|
+
.command('decode <did>')
|
|
20
|
+
.description('Print the components of a did:btcr2 identifier.')
|
|
21
|
+
.option('--initial-document', 'Add the initial DID document. An external identifier (x) needs --genesis-document.', false)
|
|
22
|
+
.option('--genesis-document <path>', 'Path to the JSON genesis document of an external identifier (x). Requires --initial-document.')
|
|
23
|
+
.action(async (did, options) => {
|
|
24
|
+
if (options.genesisDocument !== undefined && !options.initialDocument) {
|
|
25
|
+
throw new CLIError('--genesis-document requires --initial-document.', 'INVALID_ARGUMENT_ERROR');
|
|
26
|
+
}
|
|
27
|
+
assertValidIdentifier(did);
|
|
28
|
+
const api = factory();
|
|
29
|
+
const components = api.did.decode(did);
|
|
30
|
+
if (options.genesisDocument !== undefined && components.hrp === 'k') {
|
|
31
|
+
throw new CLIError('--genesis-document applies only to external identifiers (x).', 'INVALID_ARGUMENT_ERROR', { did });
|
|
32
|
+
}
|
|
33
|
+
const data = {
|
|
34
|
+
did,
|
|
35
|
+
idType: components.idType,
|
|
36
|
+
hrp: components.hrp,
|
|
37
|
+
version: components.version,
|
|
38
|
+
network: components.network,
|
|
39
|
+
genesisBytes: bytesToHex(components.genesisBytes),
|
|
40
|
+
};
|
|
41
|
+
if (options.initialDocument) {
|
|
42
|
+
if (components.hrp === 'x' && options.genesisDocument === undefined) {
|
|
43
|
+
throw new CLIError('An external identifier (x) needs --genesis-document <path> for --initial-document.', 'INVALID_ARGUMENT_ERROR', { did });
|
|
44
|
+
}
|
|
45
|
+
const genesisDocument = options.genesisDocument === undefined
|
|
46
|
+
? undefined
|
|
47
|
+
: await readGenesisDocument(options.genesisDocument);
|
|
48
|
+
data.initialDocument = api.btcr2.getInitialDocument(did, genesisDocument);
|
|
49
|
+
}
|
|
50
|
+
print({ action: 'identifier-decode', data });
|
|
51
|
+
});
|
|
52
|
+
identifier
|
|
53
|
+
.command('validate <did>')
|
|
54
|
+
.description('Check that a did:btcr2 identifier conforms to the specification. Exit code 1 if it does not.')
|
|
55
|
+
.option('-b, --bytes <hex>', 'Genesis bytes as a hex string that the identifier must encode: the 33-byte public key (k) '
|
|
56
|
+
+ 'or the 32-byte genesis document hash (x). Adds the genesisBytesMatch check.')
|
|
57
|
+
.option('--genesis-document <path>', 'Path to the JSON genesis document of an external identifier (x). Adds the genesisDocument check.')
|
|
58
|
+
.action(async (did, options) => {
|
|
59
|
+
const genesisBytes = options.bytes === undefined ? undefined : parseHexBytes(options.bytes);
|
|
60
|
+
let genesisDocument;
|
|
61
|
+
if (options.genesisDocument !== undefined) {
|
|
62
|
+
// Refuse the flag for a KEY identifier before the file read. An invalid
|
|
63
|
+
// identifier passes through: the report names its failed check.
|
|
64
|
+
if (Identifier.isValid(did) && Identifier.decode(did).hrp === 'k') {
|
|
65
|
+
throw new CLIError('--genesis-document applies only to external identifiers (x).', 'INVALID_ARGUMENT_ERROR', { did });
|
|
66
|
+
}
|
|
67
|
+
genesisDocument = await readGenesisDocument(options.genesisDocument);
|
|
68
|
+
}
|
|
69
|
+
const report = factory().did.validate(did, { genesisBytes, genesisDocument });
|
|
70
|
+
print({ action: 'identifier-validate', data: report });
|
|
71
|
+
if (!report.valid)
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Throws a `CLIError` that names the failed check if the identifier is not
|
|
77
|
+
* valid. The Bech32m decoder alone throws a raw error with a stack; this
|
|
78
|
+
* guard gives `decode` one message shape for every failure.
|
|
79
|
+
*/
|
|
80
|
+
function assertValidIdentifier(did) {
|
|
81
|
+
const report = Identifier.validate(did);
|
|
82
|
+
if (report.valid)
|
|
83
|
+
return;
|
|
84
|
+
const failed = report.checks[report.checks.length - 1];
|
|
85
|
+
throw new CLIError(`Invalid identifier (${failed.name} check): ${failed.detail ?? 'failed'}`, 'INVALID_ARGUMENT_ERROR', { did, check: failed.name });
|
|
86
|
+
}
|
|
87
|
+
/** Parses the `--bytes` hex string. The length is a validation result, not an argument error. */
|
|
88
|
+
function parseHexBytes(value) {
|
|
89
|
+
try {
|
|
90
|
+
return hexToBytes(value.trim());
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
throw new CLIError('Invalid bytes: not valid hex.', 'INVALID_ARGUMENT_ERROR', { bytes: value });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Reads and parses the genesis document file. The content must be a JSON object. */
|
|
97
|
+
async function readGenesisDocument(path) {
|
|
98
|
+
let parsed;
|
|
99
|
+
try {
|
|
100
|
+
parsed = JSON.parse(await readFile(path, 'utf-8'));
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
throw new CLIError('Invalid genesis document path. Must be a valid path to a JSON file.', 'INVALID_ARGUMENT_ERROR', { genesisDocument: path });
|
|
104
|
+
}
|
|
105
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
106
|
+
throw new CLIError('Invalid genesis document. The file must contain a JSON object.', 'INVALID_ARGUMENT_ERROR', { genesisDocument: path });
|
|
107
|
+
}
|
|
108
|
+
return parsed;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=identifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../../src/commands/identifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAiB,EACjB,OAAoB,EACpB,OAA6B;IAE7B,MAAM,UAAU,GAAG,OAAO;SACvB,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,sDAAsD,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,CAAC,MAAqB,EAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAE5F,UAAU;SACP,OAAO,CAAC,cAAc,CAAC;SACvB,WAAW,CAAC,iDAAiD,CAAC;SAC9D,MAAM,CACL,oBAAoB,EACpB,oFAAoF,EACpF,KAAK,CACN;SACA,MAAM,CACL,2BAA2B,EAC3B,+FAA+F,CAChG;SACA,MAAM,CAAC,KAAK,EAAE,GAAW,EAAE,OAAgE,EAAE,EAAE;QAC9F,IAAI,OAAO,CAAC,eAAe,KAAK,SAAS,I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AAE,IAAI,EAAE,CAC1B,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -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.js","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.js","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"}
|
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"}
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import type { BroadcastOptions, DidUpdateResult, PublishToCasMode, Signer } from '@did-btcr2/api';
|
|
1
|
+
import type { BroadcastOptions, DidUpdateResult, IdentifierReport, PublishToCasMode, Signer } from '@did-btcr2/api';
|
|
2
2
|
import type { Btcr2DidDocument, ResolutionOptions } from '@did-btcr2/method';
|
|
3
3
|
import type { DidResolutionResult } from '@web5/dids';
|
|
4
4
|
import type { DoctorReport, EffectiveConfig } from './config.js';
|
|
@@ -42,6 +42,20 @@ export interface UpdateCommandOptions {
|
|
|
42
42
|
publishToCas: PublishToCasMode;
|
|
43
43
|
broadcastOptions?: BroadcastOptions;
|
|
44
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;
|
|
58
|
+
}
|
|
45
59
|
export type CommandResult = {
|
|
46
60
|
action: 'create';
|
|
47
61
|
data: string;
|
|
@@ -56,6 +70,12 @@ export type CommandResult = {
|
|
|
56
70
|
} | {
|
|
57
71
|
action: 'deactivate';
|
|
58
72
|
data: DidUpdateResult;
|
|
73
|
+
} | {
|
|
74
|
+
action: 'identifier-decode';
|
|
75
|
+
data: IdentifierDecodeData;
|
|
76
|
+
} | {
|
|
77
|
+
action: 'identifier-validate';
|
|
78
|
+
data: IdentifierReport;
|
|
59
79
|
} | {
|
|
60
80
|
action: 'key-generate';
|
|
61
81
|
data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
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;AAE3D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AACrG,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3C;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErE,eAAO,MAAM,kBAAkB,EAAE,aAAa,EAE7C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YA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7B,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",
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"@scure/base": "^1.2.6",
|
|
62
62
|
"@web5/dids": "^1.2.0",
|
|
63
63
|
"commander": "^13.1.0",
|
|
64
|
-
"@did-btcr2/api": "^0.21.0",
|
|
65
|
-
"@did-btcr2/common": "^9.4.0",
|
|
66
64
|
"@did-btcr2/key-manager": "^0.7.0",
|
|
67
|
-
"@did-btcr2/
|
|
68
|
-
"@did-btcr2/
|
|
65
|
+
"@did-btcr2/api": "^0.22.0",
|
|
66
|
+
"@did-btcr2/common": "^9.4.0",
|
|
67
|
+
"@did-btcr2/keypair": "^0.13.1",
|
|
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 {
|