@did-btcr2/cli 0.1.0 → 0.2.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 (46) hide show
  1. package/dist/cjs/cli.js +233 -115
  2. package/dist/cjs/cli.js.map +1 -1
  3. package/dist/cjs/command.js +27 -33
  4. package/dist/cjs/command.js.map +1 -1
  5. package/dist/cjs/error.js +10 -0
  6. package/dist/cjs/error.js.map +1 -0
  7. package/dist/cjs/index.js +1 -0
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/esm/bin/btcr2.js +5 -0
  10. package/dist/esm/bin/btcr2.js.map +1 -0
  11. package/dist/esm/src/cli.js +294 -0
  12. package/dist/esm/src/cli.js.map +1 -0
  13. package/dist/esm/src/command.js +35 -0
  14. package/dist/esm/src/command.js.map +1 -0
  15. package/dist/esm/src/error.js +10 -0
  16. package/dist/esm/src/error.js.map +1 -0
  17. package/dist/esm/src/index.js +4 -0
  18. package/dist/esm/src/index.js.map +1 -0
  19. package/dist/types/bin/btcr2.d.ts +3 -0
  20. package/dist/types/bin/btcr2.d.ts.map +1 -0
  21. package/dist/types/cli.d.ts +99 -18
  22. package/dist/types/command.d.ts +50 -9
  23. package/dist/types/error.d.ts +7 -0
  24. package/dist/types/index.d.ts +1 -0
  25. package/dist/types/src/cli.d.ts +113 -0
  26. package/dist/types/src/cli.d.ts.map +1 -0
  27. package/dist/types/src/command.d.ts +56 -0
  28. package/dist/types/src/command.d.ts.map +1 -0
  29. package/dist/types/src/error.d.ts +8 -0
  30. package/dist/types/src/error.d.ts.map +1 -0
  31. package/dist/types/src/index.d.ts +4 -0
  32. package/dist/types/src/index.d.ts.map +1 -0
  33. package/package.json +16 -20
  34. package/src/cli.ts +302 -161
  35. package/src/command.ts +67 -38
  36. package/src/error.ts +10 -0
  37. package/src/index.ts +2 -1
  38. package/dist/esm/cli.js +0 -176
  39. package/dist/esm/cli.js.map +0 -1
  40. package/dist/esm/command.js +0 -41
  41. package/dist/esm/command.js.map +0 -1
  42. package/dist/esm/index.js +0 -3
  43. package/dist/esm/index.js.map +0 -1
  44. package/dist/types/cli.d.ts.map +0 -1
  45. package/dist/types/command.d.ts.map +0 -1
  46. package/dist/types/index.d.ts.map +0 -1
package/dist/cjs/cli.js CHANGED
@@ -1,39 +1,29 @@
1
- import { DidMethodError } from '@did-btcr2/common';
2
1
  import { Identifier } from '@did-btcr2/method';
3
- import { Command } from 'commander';
2
+ import { Command, CommanderError } from 'commander';
4
3
  import { readFile } from 'fs/promises';
5
4
  import Btcr2Command from './command.js';
5
+ import { CLIError } from './error.js';
6
+ const SUPPORTED_NETWORKS = ['bitcoin', 'testnet3', 'testnet4', 'signet', 'mutinynet', 'regtest'];
6
7
  /**
7
- * Custom CLI Error class extending DidMethodError.
8
- */
9
- export class CLIError extends DidMethodError {
10
- constructor(message, type = 'CLIError', data) {
11
- super(message, { type, name: type, data });
12
- }
13
- }
14
- /**
15
- * A class-based CLI using Commander.
16
- * - No forced process.exit().
17
- * - Configurable by calling `run(argv?)`.
8
+ * CLI tool for the did:btcr2 method.
9
+ * @type {DidBtcr2Cli}
10
+ * @class DidBtcr2Cli
18
11
  */
19
12
  export class DidBtcr2Cli {
20
- CLI;
13
+ program;
21
14
  constructor() {
22
- // Create the main Commander program
23
- this.CLI = new Command()
24
- .name('btcr2')
15
+ this.program = new Command('btcr2')
25
16
  .version('btcr2 0.1.0', '-v, --version', 'Output the current version')
26
17
  .description('CLI tool for the did:btcr2 method');
27
- // Configure top-level options and subcommands
28
18
  this.configureCommands();
29
19
  }
30
20
  /**
31
- * Configure the CLI commands and options.
32
- * @private
21
+ * Configures the CLI commands.
22
+ * @returns {void}
33
23
  */
34
24
  configureCommands() {
35
- /* CREATE */
36
- this.CLI
25
+ // Create command
26
+ this.program
37
27
  .command('create')
38
28
  .description('Create an identifier and initial DID document')
39
29
  .requiredOption('-t, --type <type>', 'Identifier type <k|x>', 'k')
@@ -42,20 +32,12 @@ export class DidBtcr2Cli {
42
32
  'If type=k, MUST be secp256k1 public key. ' +
43
33
  'If type=x, MUST be SHA-256 hash of a genesis document')
44
34
  .action(async (options) => {
45
- if (!['k', 'x'].includes(options.type)) {
46
- throw new CLIError('Invalid type. Must be "k" or "x".', 'INVALID_ARGUMENT_ERROR', options);
47
- }
48
- if (!['bitcoin', 'testnet3', 'testnet4', 'signet', 'mutinynet', 'regtest'].includes(options.network)) {
49
- throw new CLIError('Invalid network. Must be one of "bitcoin", "testnet3", ' +
50
- '"testnet4", "signet", "mutinynet", or "regtest".', 'INVALID_ARGUMENT_ERROR', options);
51
- }
52
- if (Buffer.from(options.bytes, 'hex').length === 0) {
53
- throw new CLIError('Invalid bytes. Must be a non-empty hex string.', 'INVALID_ARGUMENT_ERROR', options);
54
- }
55
- await this.invokeCommand({ options, action: 'create', command: new Btcr2Command() });
35
+ const parsedOptions = this.parseCreateOptions(options);
36
+ const result = await this.invokeCommand({ options: parsedOptions, action: 'create', command: new Btcr2Command() });
37
+ this.printResult(result);
56
38
  });
57
- /* READ / RESOLVE */
58
- this.CLI
39
+ // Resolve command
40
+ this.program
59
41
  .command('resolve')
60
42
  .alias('read')
61
43
  .description('Resolve the DID document of the identifier.')
@@ -63,33 +45,12 @@ export class DidBtcr2Cli {
63
45
  .option('-r, --resolutionOptions <resolutionOptions>', 'JSON string containing resolution options')
64
46
  .option('-p, --resolutionOptionsPath <resolutionOptionsPath>', 'Path to a JSON file containing resolution options')
65
47
  .action(async (options) => {
66
- try {
67
- Identifier.decode(options.identifier);
68
- }
69
- catch {
70
- throw new CLIError('Invalid identifier. Must be a valid did:btcr2 identifier.', 'INVALID_ARGUMENT_ERROR', options);
71
- }
72
- if (options.resolutionOptions) {
73
- try {
74
- options.resolutionOptions = JSON.parse(options.resolutionOptions);
75
- }
76
- catch {
77
- throw new CLIError('Invalid options. Must be a valid JSON string.', 'INVALID_ARGUMENT_ERROR', options);
78
- }
79
- }
80
- if (options.resolutionOptionsPath) {
81
- try {
82
- const data = await readFile(options.resolutionOptionsPath, 'utf-8');
83
- options.resolutionOptions = JSON.parse(data);
84
- }
85
- catch {
86
- throw new CLIError('Invalid options path. Must be a valid path to a JSON file.', 'INVALID_ARGUMENT_ERROR', options);
87
- }
88
- }
89
- await this.invokeCommand({ options, action: 'resolve', command: new Btcr2Command() });
48
+ const parsedOptions = await this.parseResolveOptions(options);
49
+ const result = await this.invokeCommand({ options: parsedOptions, action: 'resolve', command: new Btcr2Command() });
50
+ this.printResult(result);
90
51
  });
91
- /* UPDATE */
92
- this.CLI
52
+ // Update command
53
+ this.program
93
54
  .command('update')
94
55
  .description('Update a did:btcr2 document.')
95
56
  .requiredOption('-i, --identifier <identifier>', 'did:btcr2 identifier')
@@ -99,78 +60,235 @@ export class DidBtcr2Cli {
99
60
  .requiredOption('-m, --verificationMethodId <verificationMethodId>', 'Did document verification method ID as a string')
100
61
  .requiredOption('-b, --beaconIds <beaconIds>', 'Beacon IDs as a JSON string array')
101
62
  .action(async (options) => {
102
- // Validate identifier by decoding
103
- try {
104
- Identifier.decode(options.identifier);
105
- }
106
- catch {
107
- throw new CLIError('Invalid identifier. Must be a valid did:btcr2 identifier.', 'INVALID_ARGUMENT_ERROR', options);
108
- }
109
- // Validate source document JSON
110
- if (options.sourceDocument) {
111
- try {
112
- options.sourceDocument = JSON.parse(options.sourceDocument);
113
- }
114
- catch {
115
- throw new CLIError('Invalid options. Must be a valid JSON string.', 'INVALID_ARGUMENT_ERROR', options);
116
- }
117
- }
118
- // Validate patch JSON
119
- if (options.patch) {
120
- try {
121
- options.patch = JSON.parse(options.patch);
122
- }
123
- catch {
124
- throw new CLIError('Invalid options. Must be a valid JSON string.', 'INVALID_ARGUMENT_ERROR', options);
125
- }
126
- }
127
- // Validate beacon IDs JSON
128
- if (options.beaconIds) {
129
- try {
130
- options.beaconIds = JSON.parse(options.beaconIds);
131
- }
132
- catch {
133
- throw new CLIError('Invalid options. Must be a valid JSON string.', 'INVALID_ARGUMENT_ERROR', options);
134
- }
135
- }
136
- await this.invokeCommand({ options, action: 'update', command: new Btcr2Command() });
63
+ const parsedOptions = this.parseUpdateOptions(options);
64
+ const result = await this.invokeCommand({ options: parsedOptions, action: 'update', command: new Btcr2Command() });
65
+ this.printResult(result);
137
66
  });
138
- /* DEACTIVATE / DELETE */
139
- this.CLI
67
+ // Deactivate command
68
+ this.program
140
69
  .command('deactivate')
141
70
  .alias('delete')
142
71
  .description('Deactivate the did:btcr2 identifier permanently.')
143
- .action(async (options) => {
144
- await this.invokeCommand({ options, action: 'deactivate', command: new Btcr2Command() });
72
+ .action(async () => {
73
+ const result = await this.invokeCommand({ options: {}, action: 'deactivate', command: new Btcr2Command() });
74
+ this.printResult(result);
145
75
  });
146
76
  }
147
77
  /**
148
- * A helper to invoke the command logic without forcibly exiting.
78
+ * Invokes a command with the provided request.
79
+ * @param {object} request The command request
80
+ * @param {any} request.options The command options
81
+ * @param {CommandRequest['action']} request.action The command action
82
+ * @param {Btcr2Command} request.command The command instance
83
+ * @returns {Promise<CommandResult>} The command result
149
84
  */
150
- async invokeCommand({ options, action, command }) {
85
+ async invokeCommand(request) {
86
+ return await request.command.execute({ action: request.action, options: request.options });
87
+ }
88
+ /**
89
+ * Runs the CLI with the provided argv or process.argv.
90
+ * @param {string[]} [argv] The argv array to use. Defaults to process.argv.
91
+ */
92
+ async run(argv) {
151
93
  try {
152
- await command.execute({ options, action });
94
+ const normalized = this.normalizeArgv(argv ?? process.argv);
95
+ await this.program.parseAsync(normalized, { from: 'node' });
96
+ if (!this.program.args.length)
97
+ this.program.outputHelp();
153
98
  }
154
99
  catch (error) {
155
- console.error('Error executing command:', error);
100
+ this.handleError(error);
101
+ }
102
+ }
103
+ /**
104
+ * Normalizes argv to ensure it has at least two elements.
105
+ * @param {string[]} argv The argv array to normalize
106
+ * @returns {string[]} Normalized argv array
107
+ */
108
+ normalizeArgv(argv) {
109
+ if (argv.length >= 2)
110
+ return argv;
111
+ if (argv.length === 1)
112
+ return ['node', argv[0]];
113
+ return ['node', 'btcr2'];
114
+ }
115
+ /**
116
+ * Handles errors thrown during CLI execution.
117
+ * @param {unknown} error The error to handle
118
+ * @returns {void}
119
+ */
120
+ handleError(error) {
121
+ if (error instanceof CommanderError && (error.code === 'commander.helpDisplayed' || error.code === 'commander.help')) {
122
+ return;
123
+ }
124
+ if (error instanceof CLIError) {
125
+ console.error(error.message);
126
+ process.exitCode ??= 1;
127
+ return;
128
+ }
129
+ console.error(error);
130
+ process.exitCode ??= 1;
131
+ }
132
+ /**
133
+ * Parses create command options and throws CLIError on invalid input.
134
+ * @param {object} options The create command options
135
+ * @param {string} options.type The identifier type
136
+ * @param {string} options.network The bitcoin network
137
+ * @param {string} options.bytes The genesis bytes as a hex string
138
+ * @returns {CreateCommandOptions} The parsed create command options
139
+ */
140
+ parseCreateOptions(options) {
141
+ if (!['k', 'x'].includes(options.type)) {
142
+ throw new CLIError('Invalid type. Must be "k" or "x".', 'INVALID_ARGUMENT_ERROR', options);
143
+ }
144
+ if (!this.isNetworkValid(options.network)) {
145
+ throw new CLIError('Invalid network. Must be one of "bitcoin", "testnet3", "testnet4", "signet", "mutinynet", or "regtest".', 'INVALID_ARGUMENT_ERROR', options);
146
+ }
147
+ if (Buffer.from(options.bytes, 'hex').length === 0) {
148
+ throw new CLIError('Invalid bytes. Must be a non-empty hex string.', 'INVALID_ARGUMENT_ERROR', options);
156
149
  }
150
+ return {
151
+ type: options.type,
152
+ network: options.network,
153
+ bytes: options.bytes,
154
+ };
155
+ }
156
+ /**
157
+ * Parses resolve command options and throws CLIError on invalid input.
158
+ * @param {object} options The resolve command options
159
+ * @param {string} options.identifier The did:btcr2 identifier
160
+ * @param {string} [options.resolutionOptions] JSON string of resolution options
161
+ * @param {string} [options.resolutionOptionsPath] Path to a JSON file of resolution options
162
+ * @returns {Promise<ResolveCommandOptions>} The parsed resolve command options
163
+ */
164
+ async parseResolveOptions(options) {
165
+ this.validateIdentifier(options.identifier, options);
166
+ const resolutionOptions = await this.parseResolutionOptions(options);
167
+ return {
168
+ identifier: options.identifier,
169
+ ...(resolutionOptions && { options: resolutionOptions }),
170
+ };
171
+ }
172
+ /**
173
+ * Parses update command options and throws CLIError on invalid input.
174
+ * @param {object} options The update command options
175
+ * @param {string} options.identifier The did:btcr2 identifier
176
+ * @param {string} options.sourceDocument The source DID document as a JSON string
177
+ * @param {number} options.sourceVersionId The source version ID as a number
178
+ * @param {string} options.patch The JSON Patch operations as a JSON string array
179
+ * @param {string} options.verificationMethodId The DID document verification method ID as a string
180
+ * @param {string} options.beaconIds The beacon IDs as a JSON string array
181
+ * @returns {UpdateCommandOptions} The parsed update command options
182
+ */
183
+ parseUpdateOptions(options) {
184
+ this.validateIdentifier(options.identifier, options);
185
+ const sourceDocument = this.parseJsonOption(options.sourceDocument, 'Invalid options. Must be a valid JSON string.', options);
186
+ const patch = this.parseJsonOption(options.patch, 'Invalid options. Must be a valid JSON string.', options);
187
+ const beaconIds = this.parseJsonOption(options.beaconIds, 'Invalid options. Must be a valid JSON string.', options);
188
+ return {
189
+ identifier: options.identifier,
190
+ sourceDocument,
191
+ sourceVersionId: Number(options.sourceVersionId),
192
+ patch,
193
+ verificationMethodId: options.verificationMethodId,
194
+ beaconIds,
195
+ };
157
196
  }
158
197
  /**
159
- * Parse and run the CLI.
198
+ * Parses a JSON option and throws a CLIError on failure.
199
+ * @param {string} value JSON string to parse
200
+ * @param {string} errorMessage Error message to use on failure
201
+ * @param {Record<string, any>} data Additional data to include in the error
202
+ * @returns {T} Parsed JSON object
160
203
  */
161
- run(argv) {
162
- if (argv) {
163
- this.CLI.parse(argv, { from: 'user' });
204
+ parseJsonOption(value, errorMessage, data) {
205
+ try {
206
+ return JSON.parse(value);
207
+ }
208
+ catch {
209
+ throw new CLIError(errorMessage, 'INVALID_ARGUMENT_ERROR', data);
164
210
  }
165
- else {
166
- // parse real process.argv
167
- this.CLI.parse();
211
+ }
212
+ /**
213
+ * Parses resolution options from JSON string or file path.
214
+ * @param {object} options The options containing resolution options
215
+ * @param {string} [options.resolutionOptions] JSON string of resolution options
216
+ * @param {string} [options.resolutionOptionsPath] Path to a JSON file of resolution options
217
+ * @returns {Promise<any>} The parsed resolution options
218
+ */
219
+ async parseResolutionOptions(options) {
220
+ if (options.resolutionOptions) {
221
+ return this.parseJsonOption(options.resolutionOptions, 'Invalid options. Must be a valid JSON string.', options);
168
222
  }
169
- // If no subcommand was given, show help
170
- if (!this.CLI.args.length) {
171
- this.CLI.help();
223
+ if (options.resolutionOptionsPath) {
224
+ try {
225
+ const data = await readFile(options.resolutionOptionsPath, 'utf-8');
226
+ return JSON.parse(data);
227
+ }
228
+ catch {
229
+ throw new CLIError('Invalid options path. Must be a valid path to a JSON file.', 'INVALID_ARGUMENT_ERROR', options);
230
+ }
231
+ }
232
+ return undefined;
233
+ }
234
+ /**
235
+ * Validates the did:btcr2 identifier format.
236
+ * @param {string} identifier The identifier to validate
237
+ * @param {Record<string, any>} data Additional data to include in the error
238
+ * @returns {void}
239
+ */
240
+ validateIdentifier(identifier, data) {
241
+ try {
242
+ Identifier.decode(identifier);
243
+ }
244
+ catch {
245
+ throw new CLIError('Invalid identifier. Must be a valid did:btcr2 identifier.', 'INVALID_ARGUMENT_ERROR', data);
246
+ }
247
+ }
248
+ /**
249
+ * Validates if the provided network is supported.
250
+ * @param {string} network The network to validate
251
+ * @returns {boolean} True if the network is valid
252
+ */
253
+ isNetworkValid(network) {
254
+ return SUPPORTED_NETWORKS.includes(network);
255
+ }
256
+ /**
257
+ * Prints the command result to the console.
258
+ * @param {CommandResult} result The command result to print
259
+ * @returns {void}
260
+ */
261
+ printResult(result) {
262
+ switch (result.action) {
263
+ case 'create':
264
+ this.log(result.did);
265
+ break;
266
+ case 'resolve':
267
+ case 'read':
268
+ this.log(result.resolution);
269
+ break;
270
+ case 'update':
271
+ this.log(result.sidecar);
272
+ break;
273
+ case 'deactivate':
274
+ case 'delete':
275
+ this.log(result.message);
276
+ break;
277
+ default:
278
+ this.log(result);
279
+ }
280
+ }
281
+ /**
282
+ * Logs a payload to the console, formatting objects as JSON.
283
+ * @param {unknown} payload The payload to log
284
+ * @returns {void}
285
+ */
286
+ log(payload) {
287
+ if (typeof payload === 'string') {
288
+ console.log(payload);
289
+ return;
172
290
  }
291
+ console.log(JSON.stringify(payload, null, 2));
173
292
  }
174
293
  }
175
- export default new DidBtcr2Cli().run();
176
294
  //# sourceMappingURL=cli.js.map
@@ -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,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,cAAc;IAC1C,YAAY,OAAe,EAAE,OAAe,UAAU,EAAE,IAA0B;QAChF,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,WAAW;IACd,GAAG,CAAU;IAErB;QACE,oCAAoC;QACpC,IAAI,CAAC,GAAG,GAAG,IAAI,OAAO,EAAE;aACrB,IAAI,CAAC,OAAO,CAAC;aACb,OAAO,CAAC,aAAa,EAAE,eAAe,EAAE,4BAA4B,CAAC;aACrE,WAAW,CAAC,mCAAmC,CAAC,CAAC;QAEpD,8CAA8C;QAC9C,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACK,iBAAiB;QACvB,YAAY;QACZ,IAAI,CAAC,GAAG;aACL,OAAO,CAAC,QAAQ,CAAC;aACjB,WAAW,CAAC,+CAA+C,CAAC;aAC5D,cAAc,CAAC,mBAAmB,EA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did-btcr2/method';
3
3
  export default class Btcr2Command {
4
- async execute({ options, action }) {
5
- try {
6
- switch (action) {
7
- case 'create': {
8
- const { type, bytes } = options;
9
- const idType = type === 'k' ? IdentifierTypes.KEY : IdentifierTypes.EXTERNAL;
10
- const genesisBytes = Buffer.from(bytes, 'hex').toArray().toUint8Array();
11
- const did = await DidBtcr2.create({ idType, genesisBytes });
12
- console.log(did);
13
- break;
14
- }
15
- case 'read':
16
- case 'resolve': {
17
- const { identifier, options: resolutionOptions } = options;
18
- const resolutionResult = await DidBtcr2.resolve(identifier, resolutionOptions);
19
- console.log(JSON.stringify(resolutionResult, null, 2));
20
- break;
21
- }
22
- case 'update': {
23
- const update = await DidBtcr2.update(options);
24
- console.log(JSON.stringify(update, null, 2));
25
- break;
26
- }
27
- case 'delete':
28
- case 'deactivate':
29
- // await DidBtcr2.deactivate(options);
30
- Logger.warn('// TODO: Update once DidBtcr2.deactivate implemented');
31
- break;
32
- default:
33
- throw new MethodError(`Invalid command: ${action}`, 'INVALID_COMMAND');
4
+ async execute(request) {
5
+ const action = request.action;
6
+ switch (action) {
7
+ case 'create': {
8
+ const { type, bytes, network } = request.options;
9
+ const idType = type === 'k' ? IdentifierTypes.KEY : IdentifierTypes.EXTERNAL;
10
+ const genesisBytes = Buffer.from(bytes, 'hex');
11
+ const did = await DidBtcr2.create(genesisBytes, { idType, network });
12
+ return { action: 'create', did };
13
+ }
14
+ case 'read':
15
+ case 'resolve': {
16
+ const { identifier, options } = request.options;
17
+ const resolution = await DidBtcr2.resolve(identifier, options);
18
+ return { action: request.action, resolution };
19
+ }
20
+ case 'update': {
21
+ const sidecar = await DidBtcr2.update(request.options);
22
+ return { action: 'update', sidecar };
23
+ }
24
+ case 'delete':
25
+ case 'deactivate': {
26
+ Logger.warn('// TODO: Update once DidBtcr2.deactivate implemented');
27
+ return { action: 'deactivate', message: 'Deactivate not yet implemented' };
28
+ }
29
+ default: {
30
+ throw new MethodError(`Invalid command: ${action}`, 'INVALID_COMMAND');
34
31
  }
35
- }
36
- catch (error) {
37
- console.error(error);
38
32
  }
39
33
  }
40
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAwB,MAAM,mBAAmB,CAAC;AAWnE,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,EAAiB;QAC9C,IAAI,CAAC;YACH,QAAQ,MAAM,EAAE,CAAC;gBACf,KAAK,QAAQ,CAAC,CAAA,CAAC;oBACb,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAA0C,CAAC;oBACnE,MAAM,MAAM,GAAG,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC;oBAC7E,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,YAAY,EAAE,CAAC;oBACxE,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;oBAC5D,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBACjB,MAAM;gBACR,CAAC;gBACD,KAAK,MAAM,CAAC;gBACZ,KAAK,SAAS,CAAC,CAAC,CAAC;oBACf,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,OAA+B,CAAC;oBACnF,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;oBAC/E,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,I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BAC7E,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;gBAC/C,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;gBACrE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;YACnC,CAAC;YACD,KAAK,MAAM,CAAC;YACZ,KAAK,SAAS,CAAC,CAAC,CAAC;gBACf,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;gBAChD,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;gBAC/D,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;YAChD,CAAC;YACD,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,OAAc,CAAC,CAAC;gBAC9D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;YACvC,CAAC;YACD,KAAK,QAAQ,CAAC;YACd,KAAK,YAAY,CAAC,CAAC,CAAC;gBAClB,MAAM,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;gBACpE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC;YAC7E,CAAC;YACD,OAAO,CAAC,CAAA,CAAC;gBACP,MAAM,IAAI,WAAW,CAAC,oBAAoB,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { DidMethodError } from '@did-btcr2/common';
2
+ /**
3
+ * Custom CLI Error class extending DidMethodError.
4
+ */
5
+ export class CLIError extends DidMethodError {
6
+ constructor(message, type = 'CLIError', data) {
7
+ super(message, { type, name: type, data });
8
+ }
9
+ }
10
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,cAAc;IAC1C,YAAY,OAAe,EAAE,OAAe,UAAU,EAAE,IAA0B;QAChF,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF"}
package/dist/cjs/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './cli.js';
2
2
  export * from './command.js';
3
+ export * from './error.js';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { DidBtcr2Cli } from '../src/cli.js';
3
+ const cli = new DidBtcr2Cli();
4
+ await cli.run(process.argv);
5
+ //# sourceMappingURL=btcr2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"btcr2.js","sourceRoot":"","sources":["../../../bin/btcr2.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAC9B,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}