@did-btcr2/cli 0.5.3 → 0.8.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 +137 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +163 -30
- package/dist/esm/src/cli.js +22 -11
- package/dist/esm/src/cli.js.map +1 -1
- package/dist/esm/src/commands/create.js +2 -1
- package/dist/esm/src/commands/create.js.map +1 -1
- package/dist/esm/src/commands/deactivate.js +14 -5
- package/dist/esm/src/commands/deactivate.js.map +1 -1
- package/dist/esm/src/commands/resolve.js +4 -3
- package/dist/esm/src/commands/resolve.js.map +1 -1
- package/dist/esm/src/commands/update.js +15 -5
- package/dist/esm/src/commands/update.js.map +1 -1
- package/dist/esm/src/config.js +142 -0
- package/dist/esm/src/config.js.map +1 -0
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/index.js.map +1 -1
- package/dist/types/src/cli.d.ts +10 -5
- package/dist/types/src/cli.d.ts.map +1 -1
- package/dist/types/src/commands/create.d.ts +2 -2
- package/dist/types/src/commands/create.d.ts.map +1 -1
- package/dist/types/src/commands/deactivate.d.ts +2 -2
- package/dist/types/src/commands/deactivate.d.ts.map +1 -1
- package/dist/types/src/commands/resolve.d.ts +2 -2
- package/dist/types/src/commands/resolve.d.ts.map +1 -1
- package/dist/types/src/commands/update.d.ts +2 -2
- package/dist/types/src/commands/update.d.ts.map +1 -1
- package/dist/types/src/config.d.ts +131 -0
- package/dist/types/src/config.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +7 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/cli.ts +22 -12
- package/src/commands/create.ts +3 -2
- package/src/commands/deactivate.ts +22 -6
- package/src/commands/resolve.ts +4 -4
- package/src/commands/update.ts +23 -6
- package/src/config.ts +226 -0
- package/src/index.ts +1 -0
- package/src/types.ts +10 -3
package/dist/cjs/index.js
CHANGED
|
@@ -22,9 +22,16 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
CLIError: () => CLIError,
|
|
24
24
|
DidBtcr2Cli: () => DidBtcr2Cli,
|
|
25
|
+
ENV_VARS: () => ENV_VARS,
|
|
25
26
|
SUPPORTED_NETWORKS: () => SUPPORTED_NETWORKS,
|
|
26
27
|
VERSION: () => VERSION,
|
|
28
|
+
defaultApiFactory: () => defaultApiFactory,
|
|
29
|
+
defaultConfigPath: () => defaultConfigPath,
|
|
30
|
+
deriveNetwork: () => deriveNetwork,
|
|
27
31
|
formatResult: () => formatResult,
|
|
32
|
+
profileToOverrides: () => profileToOverrides,
|
|
33
|
+
readConfigFile: () => readConfigFile,
|
|
34
|
+
readEnvOverrides: () => readEnvOverrides,
|
|
28
35
|
registerCreateCommand: () => registerCreateCommand,
|
|
29
36
|
registerDeactivateCommand: () => registerDeactivateCommand,
|
|
30
37
|
registerResolveCommand: () => registerResolveCommand,
|
|
@@ -38,7 +45,6 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
|
38
45
|
|
|
39
46
|
// src/cli.ts
|
|
40
47
|
var import_commander = require("commander");
|
|
41
|
-
var import_api2 = require("@did-btcr2/api");
|
|
42
48
|
|
|
43
49
|
// src/error.ts
|
|
44
50
|
var import_common = require("@did-btcr2/common");
|
|
@@ -72,7 +78,7 @@ var EXPECTED_BYTES = {
|
|
|
72
78
|
k: { length: 33, label: "secp256k1 compressed public key (33 bytes)" },
|
|
73
79
|
x: { length: 32, label: "SHA-256 hash (32 bytes)" }
|
|
74
80
|
};
|
|
75
|
-
function registerCreateCommand(program,
|
|
81
|
+
function registerCreateCommand(program, factory, globals) {
|
|
76
82
|
program.command("create").description("Create an identifier and initial DID document").requiredOption("-t, --type <type>", "Identifier type <k|x>", "k").requiredOption(
|
|
77
83
|
"-n, --network <network>",
|
|
78
84
|
"Identifier bitcoin network <bitcoin|testnet3|testnet4|signet|mutinynet|regtest>"
|
|
@@ -81,6 +87,7 @@ function registerCreateCommand(program, api, globals) {
|
|
|
81
87
|
"Genesis bytes as a hex string. If type=k, MUST be secp256k1 public key. If type=x, MUST be SHA-256 hash of a genesis document"
|
|
82
88
|
).action(async (options) => {
|
|
83
89
|
const parsed = validateCreateOptions(options);
|
|
90
|
+
const api = factory();
|
|
84
91
|
const type = parsed.type === "k" ? "deterministic" : "external";
|
|
85
92
|
const genesisBytes = Buffer.from(parsed.bytes, "hex");
|
|
86
93
|
const data = api.createDid(type, genesisBytes, { network: parsed.network });
|
|
@@ -127,20 +134,107 @@ function validateCreateOptions(options) {
|
|
|
127
134
|
}
|
|
128
135
|
|
|
129
136
|
// src/commands/resolve.ts
|
|
130
|
-
var
|
|
137
|
+
var import_api2 = require("@did-btcr2/api");
|
|
131
138
|
var import_promises = require("fs/promises");
|
|
132
|
-
|
|
139
|
+
|
|
140
|
+
// src/config.ts
|
|
141
|
+
var import_api = require("@did-btcr2/api");
|
|
142
|
+
var import_node_fs = require("fs");
|
|
143
|
+
var import_node_os = require("os");
|
|
144
|
+
var import_node_path = require("path");
|
|
145
|
+
var ENV_VARS = {
|
|
146
|
+
BTC_REST: "BTCR2_BTC_REST",
|
|
147
|
+
BTC_RPC_URL: "BTCR2_BTC_RPC_URL",
|
|
148
|
+
BTC_RPC_USER: "BTCR2_BTC_RPC_USER",
|
|
149
|
+
BTC_RPC_PASS: "BTCR2_BTC_RPC_PASS",
|
|
150
|
+
CAS_GATEWAY: "BTCR2_CAS_GATEWAY"
|
|
151
|
+
};
|
|
152
|
+
function readEnvOverrides() {
|
|
153
|
+
const env = (key) => process.env[key] || void 0;
|
|
154
|
+
return {
|
|
155
|
+
btcRest: env(ENV_VARS.BTC_REST),
|
|
156
|
+
btcRpcUrl: env(ENV_VARS.BTC_RPC_URL),
|
|
157
|
+
btcRpcUser: env(ENV_VARS.BTC_RPC_USER),
|
|
158
|
+
btcRpcPass: env(ENV_VARS.BTC_RPC_PASS),
|
|
159
|
+
casGateway: env(ENV_VARS.CAS_GATEWAY)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function defaultConfigPath() {
|
|
163
|
+
const base = process.env.XDG_CONFIG_HOME ?? process.env.APPDATA ?? (0, import_node_path.join)((0, import_node_os.homedir)(), ".config");
|
|
164
|
+
return (0, import_node_path.join)(base, "btcr2", "config.json");
|
|
165
|
+
}
|
|
166
|
+
function readConfigFile(path) {
|
|
167
|
+
try {
|
|
168
|
+
const content = (0, import_node_fs.readFileSync)(path, "utf-8");
|
|
169
|
+
return JSON.parse(content);
|
|
170
|
+
} catch {
|
|
171
|
+
return void 0;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function profileToOverrides(config, profileName) {
|
|
175
|
+
const profile = config.profiles?.[profileName];
|
|
176
|
+
if (!profile) return {};
|
|
177
|
+
return {
|
|
178
|
+
btcRest: profile.btc?.rest,
|
|
179
|
+
btcRpcUrl: profile.btc?.rpcUrl,
|
|
180
|
+
btcRpcUser: profile.btc?.rpcUser,
|
|
181
|
+
btcRpcPass: profile.btc?.rpcPass,
|
|
182
|
+
casGateway: profile.cas?.gateway
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function defaultApiFactory(network, overrides) {
|
|
186
|
+
if (!network) return (0, import_api.createApi)();
|
|
187
|
+
const configPath = overrides?.config ?? defaultConfigPath();
|
|
188
|
+
const profileName = overrides?.profile ?? network;
|
|
189
|
+
const file = readConfigFile(configPath);
|
|
190
|
+
const fileOverrides = file ? profileToOverrides(file, profileName) : {};
|
|
191
|
+
const env = readEnvOverrides();
|
|
192
|
+
const merged = {
|
|
193
|
+
btcRest: overrides?.btcRest ?? env.btcRest ?? fileOverrides.btcRest,
|
|
194
|
+
btcRpcUrl: overrides?.btcRpcUrl ?? env.btcRpcUrl ?? fileOverrides.btcRpcUrl,
|
|
195
|
+
btcRpcUser: overrides?.btcRpcUser ?? env.btcRpcUser ?? fileOverrides.btcRpcUser,
|
|
196
|
+
btcRpcPass: overrides?.btcRpcPass ?? env.btcRpcPass ?? fileOverrides.btcRpcPass,
|
|
197
|
+
casGateway: overrides?.casGateway ?? env.casGateway ?? fileOverrides.casGateway
|
|
198
|
+
};
|
|
199
|
+
const btc = { network };
|
|
200
|
+
if (merged.btcRest) {
|
|
201
|
+
btc.rest = { host: merged.btcRest };
|
|
202
|
+
}
|
|
203
|
+
if (merged.btcRpcUrl) {
|
|
204
|
+
btc.rpc = {
|
|
205
|
+
host: merged.btcRpcUrl,
|
|
206
|
+
username: merged.btcRpcUser,
|
|
207
|
+
password: merged.btcRpcPass
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const cas = merged.casGateway ? { gateway: merged.casGateway } : void 0;
|
|
211
|
+
return (0, import_api.createApi)({ btc, ...cas && { cas } });
|
|
212
|
+
}
|
|
213
|
+
function deriveNetwork(did) {
|
|
214
|
+
const { network } = import_api.Identifier.decode(did);
|
|
215
|
+
if (!SUPPORTED_NETWORKS.includes(network)) {
|
|
216
|
+
throw new CLIError(
|
|
217
|
+
`Unsupported network "${network}" in DID.`,
|
|
218
|
+
"INVALID_ARGUMENT_ERROR",
|
|
219
|
+
{ did, network }
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
return network;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/commands/resolve.ts
|
|
226
|
+
function registerResolveCommand(program, factory, globals) {
|
|
133
227
|
program.command("resolve").alias("read").description("Resolve the DID document of the identifier.").requiredOption("-i, --identifier <identifier>", "did:btcr2 identifier").option("-r, --resolution-options <json>", "JSON string containing resolution options").option("-p, --resolution-options-path <path>", "Path to a JSON file containing resolution options").action(async (options) => {
|
|
134
|
-
console.log("resolve command options prevalidation", options);
|
|
135
228
|
const parsed = await validateResolveOptions(options);
|
|
136
|
-
|
|
229
|
+
const network = deriveNetwork(parsed.identifier);
|
|
230
|
+
const api = factory(network, globals());
|
|
137
231
|
const data = await api.resolveDid(parsed.identifier, parsed.options);
|
|
138
232
|
const result = { action: "resolve", data };
|
|
139
233
|
console.log(formatResult(result, globals()));
|
|
140
234
|
});
|
|
141
235
|
}
|
|
142
236
|
async function validateResolveOptions(options) {
|
|
143
|
-
|
|
237
|
+
import_api2.Identifier.decode(options.identifier);
|
|
144
238
|
let resolutionOptions = void 0;
|
|
145
239
|
if (options.resolutionOptions) {
|
|
146
240
|
try {
|
|
@@ -168,7 +262,7 @@ async function validateResolveOptions(options) {
|
|
|
168
262
|
}
|
|
169
263
|
|
|
170
264
|
// src/commands/update.ts
|
|
171
|
-
function registerUpdateCommand(program,
|
|
265
|
+
function registerUpdateCommand(program, factory, globals) {
|
|
172
266
|
program.command("update").description("Update a did:btcr2 document.").requiredOption(
|
|
173
267
|
"-s, --source-document <json>",
|
|
174
268
|
"Source DID document as JSON string",
|
|
@@ -195,9 +289,23 @@ function registerUpdateCommand(program, api, globals) {
|
|
|
195
289
|
verificationMethodId: options.verificationMethodId,
|
|
196
290
|
beaconId: options.beaconId
|
|
197
291
|
};
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
292
|
+
const did = parsed.sourceDocument?.id;
|
|
293
|
+
if (!did) {
|
|
294
|
+
throw new CLIError(
|
|
295
|
+
'Source document must contain an "id" field.',
|
|
296
|
+
"INVALID_ARGUMENT_ERROR",
|
|
297
|
+
options
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
void deriveNetwork(did);
|
|
301
|
+
void factory;
|
|
302
|
+
void globals;
|
|
303
|
+
void parsed;
|
|
304
|
+
throw new CLIError(
|
|
305
|
+
"CLI signing is not yet implemented. Use @did-btcr2/api with a Signer directly.",
|
|
306
|
+
"NOT_IMPLEMENTED_ERROR",
|
|
307
|
+
{ command: "update" }
|
|
308
|
+
);
|
|
201
309
|
});
|
|
202
310
|
}
|
|
203
311
|
function parseJsonArg(flagName) {
|
|
@@ -216,7 +324,7 @@ function parseJsonArg(flagName) {
|
|
|
216
324
|
|
|
217
325
|
// src/commands/deactivate.ts
|
|
218
326
|
var DEACTIVATION_PATCH = [{ op: "add", path: "/deactivated", value: true }];
|
|
219
|
-
function registerDeactivateCommand(program,
|
|
327
|
+
function registerDeactivateCommand(program, factory, globals) {
|
|
220
328
|
program.command("deactivate").alias("delete").description("Deactivate the did:btcr2 identifier permanently. This is irreversible.").requiredOption(
|
|
221
329
|
"-s, --source-document <json>",
|
|
222
330
|
"Current DID document as JSON string",
|
|
@@ -239,9 +347,23 @@ function registerDeactivateCommand(program, api, globals) {
|
|
|
239
347
|
verificationMethodId: options.verificationMethodId,
|
|
240
348
|
beaconId: options.beaconId
|
|
241
349
|
};
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
350
|
+
const did = parsed.sourceDocument?.id;
|
|
351
|
+
if (!did) {
|
|
352
|
+
throw new CLIError(
|
|
353
|
+
'Source document must contain an "id" field.',
|
|
354
|
+
"INVALID_ARGUMENT_ERROR",
|
|
355
|
+
options
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
void deriveNetwork(did);
|
|
359
|
+
void factory;
|
|
360
|
+
void globals;
|
|
361
|
+
void parsed;
|
|
362
|
+
throw new CLIError(
|
|
363
|
+
"CLI signing is not yet implemented. Use @did-btcr2/api with a Signer directly.",
|
|
364
|
+
"NOT_IMPLEMENTED_ERROR",
|
|
365
|
+
{ command: "deactivate" }
|
|
366
|
+
);
|
|
245
367
|
});
|
|
246
368
|
}
|
|
247
369
|
function parseJsonArg2(flagName) {
|
|
@@ -259,18 +381,18 @@ function parseJsonArg2(flagName) {
|
|
|
259
381
|
}
|
|
260
382
|
|
|
261
383
|
// src/version.ts
|
|
262
|
-
var
|
|
263
|
-
var
|
|
384
|
+
var import_node_fs2 = require("fs");
|
|
385
|
+
var import_node_path2 = require("path");
|
|
264
386
|
var import_node_url = require("url");
|
|
265
387
|
function readVersion() {
|
|
266
|
-
let dir = (0,
|
|
388
|
+
let dir = (0, import_node_path2.dirname)((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
267
389
|
for (let i = 0; i < 5; i++) {
|
|
268
390
|
try {
|
|
269
|
-
const pkg = JSON.parse((0,
|
|
391
|
+
const pkg = JSON.parse((0, import_node_fs2.readFileSync)((0, import_node_path2.join)(dir, "package.json"), "utf-8"));
|
|
270
392
|
if (pkg.name === "@did-btcr2/cli") return pkg.version;
|
|
271
393
|
} catch {
|
|
272
394
|
}
|
|
273
|
-
dir = (0,
|
|
395
|
+
dir = (0, import_node_path2.dirname)(dir);
|
|
274
396
|
}
|
|
275
397
|
return "0.0.0";
|
|
276
398
|
}
|
|
@@ -279,19 +401,23 @@ var VERSION = readVersion();
|
|
|
279
401
|
// src/cli.ts
|
|
280
402
|
var DidBtcr2Cli = class {
|
|
281
403
|
program;
|
|
282
|
-
api;
|
|
283
404
|
/**
|
|
284
|
-
* Initializes the CLI with an optional
|
|
285
|
-
*
|
|
405
|
+
* Initializes the CLI with an optional API factory.
|
|
406
|
+
*
|
|
407
|
+
* The factory is called lazily by each command with the appropriate
|
|
408
|
+
* network derived from the DID being operated on. Defaults to
|
|
409
|
+
* {@link defaultApiFactory} which uses public endpoints (mempool.space)
|
|
410
|
+
* for known networks and localhost Polar for regtest.
|
|
411
|
+
*
|
|
412
|
+
* @param factory - Optional API factory. Defaults to {@link defaultApiFactory}.
|
|
286
413
|
*/
|
|
287
|
-
constructor(
|
|
288
|
-
this.
|
|
289
|
-
this.program = new import_commander.Command("btcr2").version(`btcr2 ${VERSION}`, "-v, --version", "Output the current version").description("CLI tool for the did:btcr2 method").option("-o, --output <format>", "Output format <json|text>", "text").option("--verbose", "Verbose output", false).option("--quiet", "Suppress non-essential output", false);
|
|
414
|
+
constructor(factory = defaultApiFactory) {
|
|
415
|
+
this.program = new import_commander.Command("btcr2").version(`btcr2 ${VERSION}`, "-v, --version", "Output the current version").description("CLI tool for the did:btcr2 method").option("-o, --output <format>", "Output format <json|text>", "text").option("--verbose", "Verbose output", false).option("--quiet", "Suppress non-essential output", false).option("-c, --config <path>", "Path to config file (default: $XDG_CONFIG_HOME/btcr2/config.json)").option("--profile <name>", "Config profile name (default: auto-detected from network)").option("--btc-rest <url>", "Override Bitcoin REST endpoint (Esplora API)").option("--btc-rpc-url <url>", "Override Bitcoin Core RPC endpoint").option("--btc-rpc-user <user>", "Bitcoin Core RPC username").option("--btc-rpc-pass <pass>", "Bitcoin Core RPC password").option("--cas-gateway <url>", "IPFS HTTP gateway for CAS reads");
|
|
290
416
|
const globals = () => this.program.opts();
|
|
291
|
-
registerCreateCommand(this.program,
|
|
292
|
-
registerResolveCommand(this.program,
|
|
293
|
-
registerUpdateCommand(this.program,
|
|
294
|
-
registerDeactivateCommand(this.program,
|
|
417
|
+
registerCreateCommand(this.program, factory, globals);
|
|
418
|
+
registerResolveCommand(this.program, factory, globals);
|
|
419
|
+
registerUpdateCommand(this.program, factory, globals);
|
|
420
|
+
registerDeactivateCommand(this.program, factory, globals);
|
|
295
421
|
}
|
|
296
422
|
/**
|
|
297
423
|
* Runs the CLI with the provided argv or process.argv.
|
|
@@ -329,9 +455,16 @@ function handleError(error) {
|
|
|
329
455
|
0 && (module.exports = {
|
|
330
456
|
CLIError,
|
|
331
457
|
DidBtcr2Cli,
|
|
458
|
+
ENV_VARS,
|
|
332
459
|
SUPPORTED_NETWORKS,
|
|
333
460
|
VERSION,
|
|
461
|
+
defaultApiFactory,
|
|
462
|
+
defaultConfigPath,
|
|
463
|
+
deriveNetwork,
|
|
334
464
|
formatResult,
|
|
465
|
+
profileToOverrides,
|
|
466
|
+
readConfigFile,
|
|
467
|
+
readEnvOverrides,
|
|
335
468
|
registerCreateCommand,
|
|
336
469
|
registerDeactivateCommand,
|
|
337
470
|
registerResolveCommand,
|
package/dist/esm/src/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command, CommanderError } from 'commander';
|
|
2
|
-
import { createApi } from '@did-btcr2/api';
|
|
3
2
|
import { registerCreateCommand, registerDeactivateCommand, registerResolveCommand, registerUpdateCommand, } from './commands/index.js';
|
|
3
|
+
import { defaultApiFactory } from './config.js';
|
|
4
4
|
import { CLIError } from './error.js';
|
|
5
5
|
import { VERSION } from './version.js';
|
|
6
6
|
/**
|
|
@@ -8,24 +8,35 @@ import { VERSION } from './version.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export class DidBtcr2Cli {
|
|
10
10
|
program;
|
|
11
|
-
api;
|
|
12
11
|
/**
|
|
13
|
-
* Initializes the CLI with an optional
|
|
14
|
-
*
|
|
12
|
+
* Initializes the CLI with an optional API factory.
|
|
13
|
+
*
|
|
14
|
+
* The factory is called lazily by each command with the appropriate
|
|
15
|
+
* network derived from the DID being operated on. Defaults to
|
|
16
|
+
* {@link defaultApiFactory} which uses public endpoints (mempool.space)
|
|
17
|
+
* for known networks and localhost Polar for regtest.
|
|
18
|
+
*
|
|
19
|
+
* @param factory - Optional API factory. Defaults to {@link defaultApiFactory}.
|
|
15
20
|
*/
|
|
16
|
-
constructor(
|
|
17
|
-
this.api = api;
|
|
21
|
+
constructor(factory = defaultApiFactory) {
|
|
18
22
|
this.program = new Command('btcr2')
|
|
19
23
|
.version(`btcr2 ${VERSION}`, '-v, --version', 'Output the current version')
|
|
20
24
|
.description('CLI tool for the did:btcr2 method')
|
|
21
25
|
.option('-o, --output <format>', 'Output format <json|text>', 'text')
|
|
22
26
|
.option('--verbose', 'Verbose output', false)
|
|
23
|
-
.option('--quiet', 'Suppress non-essential output', false)
|
|
27
|
+
.option('--quiet', 'Suppress non-essential output', false)
|
|
28
|
+
.option('-c, --config <path>', 'Path to config file (default: $XDG_CONFIG_HOME/btcr2/config.json)')
|
|
29
|
+
.option('--profile <name>', 'Config profile name (default: auto-detected from network)')
|
|
30
|
+
.option('--btc-rest <url>', 'Override Bitcoin REST endpoint (Esplora API)')
|
|
31
|
+
.option('--btc-rpc-url <url>', 'Override Bitcoin Core RPC endpoint')
|
|
32
|
+
.option('--btc-rpc-user <user>', 'Bitcoin Core RPC username')
|
|
33
|
+
.option('--btc-rpc-pass <pass>', 'Bitcoin Core RPC password')
|
|
34
|
+
.option('--cas-gateway <url>', 'IPFS HTTP gateway for CAS reads');
|
|
24
35
|
const globals = () => this.program.opts();
|
|
25
|
-
registerCreateCommand(this.program,
|
|
26
|
-
registerResolveCommand(this.program,
|
|
27
|
-
registerUpdateCommand(this.program,
|
|
28
|
-
registerDeactivateCommand(this.program,
|
|
36
|
+
registerCreateCommand(this.program, factory, globals);
|
|
37
|
+
registerResolveCommand(this.program, factory, globals);
|
|
38
|
+
registerUpdateCommand(this.program, factory, globals);
|
|
39
|
+
registerDeactivateCommand(this.program, factory, globals);
|
|
29
40
|
}
|
|
30
41
|
/**
|
|
31
42
|
* Runs the CLI with the provided argv or process.argv.
|
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,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAmB,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;GAEG;AACH,MAAM,OAAO,WAAW;IACN,OAAO,CAAU;IAEjC;;;;;;;;;OASG;IACH,YAAY,UAAsB,iBAAiB;QACjD,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;aAChC,OAAO,CAAC,SAAS,OAAO,EAAE,EAAE,eAAe,EAAE,4BAA4B,CAAC;aAC1E,W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I,CAAC,MAAM;gBAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC3D,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,IAAc;IACnC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,SAAS,WAAW,CAAC,KAAc;IACjC,IACE,KAAK,YAAY,cAAc;QAC/B,CAAC,KAAK,CAAC,IAAI,KAAK,yBAAyB,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC,EAC7E,CAAC;QACD,OAAO;IACT,CAAC;IACD,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7B,OAAO,CAAC,QAAQ,KAAK,CAAC,CAAC;QACvB,OAAO;IACT,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,KAAK,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -6,7 +6,7 @@ const EXPECTED_BYTES = {
|
|
|
6
6
|
k: { length: 33, label: 'secp256k1 compressed public key (33 bytes)' },
|
|
7
7
|
x: { length: 32, label: 'SHA-256 hash (32 bytes)' },
|
|
8
8
|
};
|
|
9
|
-
export function registerCreateCommand(program,
|
|
9
|
+
export function registerCreateCommand(program, factory, globals) {
|
|
10
10
|
program
|
|
11
11
|
.command('create')
|
|
12
12
|
.description('Create an identifier and initial DID document')
|
|
@@ -17,6 +17,7 @@ export function registerCreateCommand(program, api, globals) {
|
|
|
17
17
|
'If type=x, MUST be SHA-256 hash of a genesis document')
|
|
18
18
|
.action(async (options) => {
|
|
19
19
|
const parsed = validateCreateOptions(options);
|
|
20
|
+
const api = factory();
|
|
20
21
|
const type = parsed.type === 'k' ? 'deterministic' : 'external';
|
|
21
22
|
const genesisBytes = Buffer.from(parsed.bytes, 'hex');
|
|
22
23
|
const data = api.createDid(type, genesisBytes, { network: parsed.network });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/create.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAK5C,OAAO,EACL,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,8FAA8F;AAC9F,MAAM,cAAc,GAAyD;IAC3E,CAAC,EAAG,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,4CAA4C,EAAE;IACvE,CAAC,EAAG,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,yBAAyB,EAAE;CACrD,CAAC;AAEF,MAAM,UAAU,qBAAqB,CACnC,OAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/commands/create.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAK5C,OAAO,EACL,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,8FAA8F;AAC9F,MAAM,cAAc,GAAyD;IAC3E,CAAC,EAAG,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,4CAA4C,EAAE;IACvE,CAAC,EAAG,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,yBAAyB,EAAE;CACrD,CAAC;AAEF,MAAM,UAAU,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,QAAQ,CAAC,OAAO,CAAC,OAAwB,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,QAAQ,CAChB,yGAAyG,EACzG,wBAAwB,EACxB,OAAO,CACR,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,QAAQ,CAChB,gDAAgD,EAChD,wBAAwB,EACxB,OAAO,CACR,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,IAAiB,CAAC,CAAC;IAC3D,IAAI,GAAG,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,IAAI,QAAQ,CAChB,kCAAkC,OAAO,CAAC,IAAI,eAAe,QAAQ,CAAC,KAAK,SAAS,GAAG,CAAC,MAAM,SAAS,EACvG,wBAAwB,EACxB,OAAO,CACR,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAM,OAAO,CAAC,IAAiB;QACnC,OAAO,EAAG,OAAO,CAAC,OAAwB;QAC1C,KAAK,EAAK,OAAO,CAAC,KAAK;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { deriveNetwork } from '../config.js';
|
|
1
2
|
import { CLIError } from '../error.js';
|
|
2
|
-
import { formatResult } from '../output.js';
|
|
3
3
|
/** The JSON Patch that marks a DID document as permanently deactivated. */
|
|
4
4
|
const DEACTIVATION_PATCH = [{ op: 'add', path: '/deactivated', value: true }];
|
|
5
|
-
export function registerDeactivateCommand(program,
|
|
5
|
+
export function registerDeactivateCommand(program, factory, globals) {
|
|
6
6
|
program
|
|
7
7
|
.command('deactivate')
|
|
8
8
|
.alias('delete')
|
|
@@ -19,9 +19,18 @@ export function registerDeactivateCommand(program, api, globals) {
|
|
|
19
19
|
verificationMethodId: options.verificationMethodId,
|
|
20
20
|
beaconId: options.beaconId,
|
|
21
21
|
};
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const did = parsed.sourceDocument?.id;
|
|
23
|
+
if (!did) {
|
|
24
|
+
throw new CLIError('Source document must contain an "id" field.', 'INVALID_ARGUMENT_ERROR', options);
|
|
25
|
+
}
|
|
26
|
+
// CLI signing is not yet wired up; deactivate uses the same update path
|
|
27
|
+
// and inherits the same gap. Drive the SDK directly with a `Signer` for now.
|
|
28
|
+
// Variables above are kept so command parsing + validation still works.
|
|
29
|
+
void deriveNetwork(did);
|
|
30
|
+
void factory;
|
|
31
|
+
void globals;
|
|
32
|
+
void parsed;
|
|
33
|
+
throw new CLIError('CLI signing is not yet implemented. Use @did-btcr2/api with a Signer directly.', 'NOT_IMPLEMENTED_ERROR', { command: 'deactivate' });
|
|
25
34
|
});
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deactivate.js","sourceRoot":"","sources":["../../../../src/commands/deactivate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deactivate.js","sourceRoot":"","sources":["../../../../src/commands/deactivate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAmB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,CAAC,EAAE,EAAE,EAAE,KAAc,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAEvF,MAAM,UAAU,yBAAyB,CACvC,OAAiB,EACjB,OAAoB,EACpB,OAA6B;IAE7B,OAAO;SACJ,OAAO,CAAC,YAAY,CAAC;SACrB,KAAK,CAAC,QAAQ,CAAC;SACf,WAAW,CAAC,wEAAwE,CAAC;SACrF,cAAc,CACb,8BAA8B,EAC9B,q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EAAE,QAAQ,EAAE,KAAK,EAAE,CACpB,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Identifier } from '@did-btcr2/api';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { deriveNetwork } from '../config.js';
|
|
3
4
|
import { CLIError } from '../error.js';
|
|
4
5
|
import { formatResult } from '../output.js';
|
|
5
|
-
export function registerResolveCommand(program,
|
|
6
|
+
export function registerResolveCommand(program, factory, globals) {
|
|
6
7
|
program
|
|
7
8
|
.command('resolve')
|
|
8
9
|
.alias('read')
|
|
@@ -11,9 +12,9 @@ export function registerResolveCommand(program, api, globals) {
|
|
|
11
12
|
.option('-r, --resolution-options <json>', 'JSON string containing resolution options')
|
|
12
13
|
.option('-p, --resolution-options-path <path>', 'Path to a JSON file containing resolution options')
|
|
13
14
|
.action(async (options) => {
|
|
14
|
-
console.log('resolve command options prevalidation', options);
|
|
15
15
|
const parsed = await validateResolveOptions(options);
|
|
16
|
-
|
|
16
|
+
const network = deriveNetwork(parsed.identifier);
|
|
17
|
+
const api = factory(network, globals());
|
|
17
18
|
const data = await api.resolveDid(parsed.identifier, parsed.options);
|
|
18
19
|
const result = { action: 'resolve', data };
|
|
19
20
|
console.log(formatResult(result, globals()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../../src/commands/resolve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../../src/commands/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAmB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,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QAAQ,CAChB,0DAA0D,EAC1D,wBAAwB,EACxB,OAAO,CACR,CAAC;QACJ,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;QACzC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;YACvE,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,QAAQ,CAChB,uEAAuE,EACvE,wBAAwB,EACxB,OAAO,CACR,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { deriveNetwork } from '../config.js';
|
|
1
2
|
import { CLIError } from '../error.js';
|
|
2
|
-
|
|
3
|
-
export function registerUpdateCommand(program, api, globals) {
|
|
3
|
+
export function registerUpdateCommand(program, factory, globals) {
|
|
4
4
|
program
|
|
5
5
|
.command('update')
|
|
6
6
|
.description('Update a did:btcr2 document.')
|
|
@@ -17,9 +17,19 @@ export function registerUpdateCommand(program, api, globals) {
|
|
|
17
17
|
verificationMethodId: options.verificationMethodId,
|
|
18
18
|
beaconId: options.beaconId,
|
|
19
19
|
};
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const did = parsed.sourceDocument?.id;
|
|
21
|
+
if (!did) {
|
|
22
|
+
throw new CLIError('Source document must contain an "id" field.', 'INVALID_ARGUMENT_ERROR', options);
|
|
23
|
+
}
|
|
24
|
+
// The CLI does not yet have a way to load signing material (keystore,
|
|
25
|
+
// KMS config, hardware wallet, etc.), so signed updates from the CLI are
|
|
26
|
+
// not yet wired up. Drive the SDK directly with a `Signer` for now.
|
|
27
|
+
// Variables above are kept so command parsing + validation still works.
|
|
28
|
+
void deriveNetwork(did);
|
|
29
|
+
void factory;
|
|
30
|
+
void globals;
|
|
31
|
+
void parsed;
|
|
32
|
+
throw new CLIError('CLI signing is not yet implemented. Use @did-btcr2/api with a Signer directly.', 'NOT_IMPLEMENTED_ERROR', { command: 'update' });
|
|
23
33
|
});
|
|
24
34
|
}
|
|
25
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/update.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/commands/update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAmB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,MAAM,UAAU,qBAAqB,CACnC,OAAiB,EACjB,OAAoB,EACpB,OAA6B;IAE7B,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,8BAA8B,CAAC;SAC3C,cAAc,CACb,8BAA8B,EAC9B,oCAAoC,EACpC,YAAY,CAAC,mBAAmB,CAAC,CAClC;SACA,cAAc,CACb,8BAA8B,EAC9B,+BAA+B,CAChC;SACA,cAAc,CACb,sBAAsB,EACtB,8CAA8C,EAC9C,YAAY,CAAC,WAAW,CAAC,CAC1B;SACA,cAAc,CACb,mCAAmC,EACnC,qCAAqC,CACtC;SACA,cAAc,CACb,wBAAwB,EACxB,4BAA4B,EAC5B,YAAY,CAAC,aAAa,CAAC,CAC5B;SACA,MAAM,CAAC,KAAK,EAAE,OAMd,EAAE,EAAE;QACH,MAAM,MAAM,GAAyB;YACnC,cAAc,EAAS,OAAO,CAAC,cAAwD;YACvF,OAAO,EAAgB,OAAO,CAAC,OAA0C;YACzE,eAAe,EAAQ,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC;YACtD,oBAAoB,EAAG,OAAO,CAAC,oBAAoB;YACnD,QAAQ,EAA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