@twin.org/identity-cli 0.0.1-next.9 → 0.0.2-next.1

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 (45) hide show
  1. package/bin/index.js +0 -0
  2. package/dist/cjs/index.cjs +360 -271
  3. package/dist/esm/index.mjs +359 -275
  4. package/dist/locales/en.json +883 -779
  5. package/dist/types/commands/identityCreate.d.ts +6 -0
  6. package/dist/types/commands/identityResolve.d.ts +5 -0
  7. package/dist/types/commands/proofCreate.d.ts +6 -1
  8. package/dist/types/commands/proofVerify.d.ts +9 -7
  9. package/dist/types/commands/serviceAdd.d.ts +4 -0
  10. package/dist/types/commands/serviceRemove.d.ts +5 -0
  11. package/dist/types/commands/setupCommands.d.ts +31 -0
  12. package/dist/types/commands/verifiableCredentialCreate.d.ts +4 -0
  13. package/dist/types/commands/verifiableCredentialRevoke.d.ts +5 -0
  14. package/dist/types/commands/verifiableCredentialUnrevoke.d.ts +5 -0
  15. package/dist/types/commands/verifiableCredentialVerify.d.ts +4 -0
  16. package/dist/types/commands/verificationMethodAdd.d.ts +4 -0
  17. package/dist/types/commands/verificationMethodRemove.d.ts +5 -0
  18. package/dist/types/index.d.ts +3 -0
  19. package/dist/types/models/identityConnectorTypes.d.ts +13 -0
  20. package/dist/types/models/identityResolverConnectorTypes.d.ts +13 -0
  21. package/docs/changelog.md +337 -1
  22. package/docs/examples.md +14 -12
  23. package/docs/reference/classes/CLI.md +14 -8
  24. package/docs/reference/functions/actionCommandIdentityCreate.md +3 -1
  25. package/docs/reference/functions/actionCommandIdentityResolve.md +3 -1
  26. package/docs/reference/functions/actionCommandProofCreate.md +3 -1
  27. package/docs/reference/functions/actionCommandProofVerify.md +3 -1
  28. package/docs/reference/functions/actionCommandServiceAdd.md +3 -1
  29. package/docs/reference/functions/actionCommandServiceRemove.md +25 -5
  30. package/docs/reference/functions/actionCommandVerifiableCredentialCreate.md +3 -1
  31. package/docs/reference/functions/actionCommandVerifiableCredentialRevoke.md +25 -5
  32. package/docs/reference/functions/actionCommandVerifiableCredentialUnrevoke.md +25 -5
  33. package/docs/reference/functions/actionCommandVerifiableCredentialVerify.md +3 -1
  34. package/docs/reference/functions/actionCommandVerificationMethodAdd.md +3 -1
  35. package/docs/reference/functions/actionCommandVerificationMethodRemove.md +25 -5
  36. package/docs/reference/functions/setupIdentityConnector.md +47 -0
  37. package/docs/reference/functions/setupIdentityResolverConnector.md +35 -0
  38. package/docs/reference/functions/setupVault.md +9 -0
  39. package/docs/reference/index.md +13 -0
  40. package/docs/reference/type-aliases/IdentityConnectorTypes.md +5 -0
  41. package/docs/reference/type-aliases/IdentityResolverConnectorTypes.md +5 -0
  42. package/docs/reference/variables/IdentityConnectorTypes.md +13 -0
  43. package/docs/reference/variables/IdentityResolverConnectorTypes.md +13 -0
  44. package/locales/en.json +39 -27
  45. package/package.json +7 -7
@@ -6,18 +6,44 @@ var cliCore = require('@twin.org/cli-core');
6
6
  var cryptoCli = require('@twin.org/crypto-cli');
7
7
  var walletCli = require('@twin.org/wallet-cli');
8
8
  var core = require('@twin.org/core');
9
- var identityConnectorIota = require('@twin.org/identity-connector-iota');
10
9
  var vaultModels = require('@twin.org/vault-models');
11
- var walletConnectorIota = require('@twin.org/wallet-connector-iota');
12
10
  var walletModels = require('@twin.org/wallet-models');
13
11
  var commander = require('commander');
14
12
  var entityStorageConnectorMemory = require('@twin.org/entity-storage-connector-memory');
15
13
  var entityStorageModels = require('@twin.org/entity-storage-models');
14
+ var identityConnectorIota = require('@twin.org/identity-connector-iota');
16
15
  var vaultConnectorEntityStorage = require('@twin.org/vault-connector-entity-storage');
17
16
  var identityModels = require('@twin.org/identity-models');
18
17
  var standardsW3cDid = require('@twin.org/standards-w3c-did');
18
+ var web = require('@twin.org/web');
19
19
 
20
20
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
21
+ // Copyright 2024 IOTA Stiftung.
22
+ // SPDX-License-Identifier: Apache-2.0.
23
+ /**
24
+ * The identity connector types.
25
+ */
26
+ // eslint-disable-next-line @typescript-eslint/naming-convention
27
+ const IdentityConnectorTypes = {
28
+ /**
29
+ * IOTA.
30
+ */
31
+ Iota: "iota"
32
+ };
33
+
34
+ // Copyright 2024 IOTA Stiftung.
35
+ // SPDX-License-Identifier: Apache-2.0.
36
+ /**
37
+ * The identity resolver connector types.
38
+ */
39
+ // eslint-disable-next-line @typescript-eslint/naming-convention
40
+ const IdentityResolverConnectorTypes = {
41
+ /**
42
+ * IOTA.
43
+ */
44
+ Iota: "iota"
45
+ };
46
+
21
47
  // Copyright 2024 IOTA Stiftung.
22
48
  // SPDX-License-Identifier: Apache-2.0.
23
49
  /**
@@ -34,6 +60,48 @@ function setupVault() {
34
60
  const vaultConnector = new vaultConnectorEntityStorage.EntityStorageVaultConnector();
35
61
  vaultModels.VaultConnectorFactory.register("vault", () => vaultConnector);
36
62
  }
63
+ /**
64
+ * Setup the identity connector for use in the CLI commands.
65
+ * @param options The options for the identity connector.
66
+ * @param options.nodeEndpoint The node endpoint.
67
+ * @param options.network The network.
68
+ * @param options.addressIndex The wallet index.
69
+ * @param options.vaultSeedId The vault seed ID.
70
+ * @param connector The connector to use.
71
+ * @returns The identity connector.
72
+ */
73
+ function setupIdentityConnector(options, connector) {
74
+ connector ??= IdentityConnectorTypes.Iota;
75
+ return new identityConnectorIota.IotaIdentityConnector({
76
+ config: {
77
+ clientOptions: {
78
+ url: options.nodeEndpoint
79
+ },
80
+ network: options.network ?? "",
81
+ vaultSeedId: options.vaultSeedId,
82
+ walletAddressIndex: options.addressIndex
83
+ }
84
+ });
85
+ }
86
+ /**
87
+ * Setup the identity resolver connector for use in the CLI commands.
88
+ * @param options The options for the identity connector.
89
+ * @param options.nodeEndpoint The node endpoint.
90
+ * @param options.network The network.
91
+ * @param connector The connector to use.
92
+ * @returns The identity connector.
93
+ */
94
+ function setupIdentityResolverConnector(options, connector) {
95
+ connector ??= IdentityResolverConnectorTypes.Iota;
96
+ return new identityConnectorIota.IotaIdentityResolverConnector({
97
+ config: {
98
+ clientOptions: {
99
+ url: options.nodeEndpoint
100
+ },
101
+ network: options.network ?? ""
102
+ }
103
+ });
104
+ }
37
105
 
38
106
  // Copyright 2024 IOTA Stiftung.
39
107
  // SPDX-License-Identifier: Apache-2.0.
@@ -47,7 +115,8 @@ function buildCommandIdentityCreate() {
47
115
  .name("identity-create")
48
116
  .summary(core.I18n.formatMessage("commands.identity-create.summary"))
49
117
  .description(core.I18n.formatMessage("commands.identity-create.description"))
50
- .requiredOption(core.I18n.formatMessage("commands.identity-create.options.seed.param"), core.I18n.formatMessage("commands.identity-create.options.seed.description"));
118
+ .requiredOption(core.I18n.formatMessage("commands.identity-create.options.seed.param"), core.I18n.formatMessage("commands.identity-create.options.seed.description"))
119
+ .option(core.I18n.formatMessage("commands.identity-create.options.addressIndex.param"), core.I18n.formatMessage("commands.identity-create.options.addressIndex.description"), "0");
51
120
  cliCore.CLIOptions.output(command, {
52
121
  noConsole: true,
53
122
  json: true,
@@ -56,7 +125,11 @@ function buildCommandIdentityCreate() {
56
125
  mergeEnv: true
57
126
  });
58
127
  command
128
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
129
+ .choices(Object.values(IdentityConnectorTypes))
130
+ .default(IdentityConnectorTypes.Iota))
59
131
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
132
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
60
133
  .option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
61
134
  .action(actionCommandIdentityCreate);
62
135
  return command;
@@ -65,44 +138,38 @@ function buildCommandIdentityCreate() {
65
138
  * Action the identity create command.
66
139
  * @param opts The options for the command.
67
140
  * @param opts.seed The private key for the controller.
141
+ * @param opts.connector The connector to perform the operations with.
68
142
  * @param opts.node The node URL.
143
+ * @param opts.network The network to use for connector.
69
144
  * @param opts.explorer The explorer URL.
70
145
  */
71
146
  async function actionCommandIdentityCreate(opts) {
72
147
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
73
148
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
149
+ const network = opts.connector === IdentityConnectorTypes.Iota
150
+ ? cliCore.CLIParam.stringValue("network", opts.network)
151
+ : undefined;
74
152
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
153
+ const addressIndex = cliCore.CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
75
154
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
155
+ if (core.Is.stringValue(network)) {
156
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
157
+ }
76
158
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
159
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.identity-create.labels.addressIndex"), addressIndex);
77
160
  cliCore.CLIDisplay.break();
78
161
  setupVault();
79
162
  const vaultSeedId = "local-seed";
80
163
  const localIdentity = "local";
81
164
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
82
165
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
83
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
84
- config: {
85
- clientOptions: {
86
- nodes: [nodeEndpoint],
87
- localPow: true
88
- },
89
- vaultSeedId
90
- }
91
- });
92
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
93
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
94
- config: {
95
- clientOptions: {
96
- nodes: [nodeEndpoint],
97
- localPow: true
98
- },
99
- vaultSeedId
100
- }
101
- });
166
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
167
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
168
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, vaultSeedId, network, addressIndex }, opts.connector);
102
169
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.identity-create.progress.creatingIdentity"));
103
170
  cliCore.CLIDisplay.break();
104
171
  cliCore.CLIDisplay.spinnerStart();
105
- const document = await iotaIdentityConnector.createDocument(localIdentity);
172
+ const document = await identityConnector.createDocument(localIdentity);
106
173
  cliCore.CLIDisplay.spinnerStop();
107
174
  if (opts.console) {
108
175
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.identity-create.labels.identity"), document.id);
@@ -114,7 +181,12 @@ async function actionCommandIdentityCreate(opts) {
114
181
  if (core.Is.stringValue(opts?.env)) {
115
182
  await cliCore.CLIUtils.writeEnvFile(opts.env, [`DID="${document.id}"`], opts.mergeEnv);
116
183
  }
117
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(document.id)}?tab=DID`);
184
+ if (opts.connector === IdentityConnectorTypes.Iota) {
185
+ const didUrn = core.Urn.fromValidString(document.id);
186
+ const didParts = didUrn.parts();
187
+ const objectId = didParts[didParts.length - 1];
188
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
189
+ }
118
190
  cliCore.CLIDisplay.break();
119
191
  cliCore.CLIDisplay.done();
120
192
  }
@@ -140,8 +212,12 @@ function buildCommandIdentityResolve() {
140
212
  mergeEnv: false
141
213
  });
142
214
  command
215
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
216
+ .choices(Object.values(IdentityConnectorTypes))
217
+ .default(IdentityConnectorTypes.Iota))
143
218
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
144
219
  .option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
220
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
145
221
  .action(actionCommandIdentityResolve);
146
222
  return command;
147
223
  }
@@ -149,39 +225,33 @@ function buildCommandIdentityResolve() {
149
225
  * Action the identity resolve command.
150
226
  * @param opts The options for the command.
151
227
  * @param opts.did The identity to resolve.
228
+ * @param opts.connector The connector to perform the operations with.
152
229
  * @param opts.node The node URL.
230
+ * @param opts.network The network to use for connector.
153
231
  * @param opts.explorer The explorer URL.
154
232
  */
155
233
  async function actionCommandIdentityResolve(opts) {
156
234
  const did = cliCore.CLIParam.stringValue("did", opts.did);
157
235
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
236
+ const network = opts.connector === IdentityConnectorTypes.Iota
237
+ ? cliCore.CLIParam.stringValue("network", opts.network)
238
+ : undefined;
158
239
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
159
240
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.did"), did);
160
241
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
242
+ if (core.Is.stringValue(network)) {
243
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
244
+ }
161
245
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
162
246
  cliCore.CLIDisplay.break();
163
247
  setupVault();
164
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
165
- config: {
166
- clientOptions: {
167
- nodes: [nodeEndpoint],
168
- localPow: true
169
- }
170
- }
171
- });
172
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
173
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
174
- config: {
175
- clientOptions: {
176
- nodes: [nodeEndpoint],
177
- localPow: true
178
- }
179
- }
180
- });
248
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
249
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
250
+ const identityResolverConnector = setupIdentityResolverConnector({ nodeEndpoint, network }, opts.connector);
181
251
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.identity-resolve.progress.resolvingIdentity"));
182
252
  cliCore.CLIDisplay.break();
183
253
  cliCore.CLIDisplay.spinnerStart();
184
- const document = await iotaIdentityConnector.resolveDocument(did);
254
+ const document = await identityResolverConnector.resolveDocument(did);
185
255
  cliCore.CLIDisplay.spinnerStop();
186
256
  if (opts.console) {
187
257
  cliCore.CLIDisplay.section(core.I18n.formatMessage("commands.identity-resolve.labels.didDocument"));
@@ -191,7 +261,12 @@ async function actionCommandIdentityResolve(opts) {
191
261
  if (core.Is.stringValue(opts?.json)) {
192
262
  await cliCore.CLIUtils.writeJsonFile(opts.json, document, opts.mergeJson);
193
263
  }
194
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(document.id)}?tab=DID`);
264
+ if (opts.connector === IdentityConnectorTypes.Iota) {
265
+ const didUrn = core.Urn.fromValidString(document.id);
266
+ const didParts = didUrn.parts();
267
+ const objectId = didParts[didParts.length - 1];
268
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
269
+ }
195
270
  cliCore.CLIDisplay.break();
196
271
  cliCore.CLIDisplay.done();
197
272
  }
@@ -210,7 +285,7 @@ function buildCommandProofCreate() {
210
285
  .description(core.I18n.formatMessage("commands.proof-create.description"))
211
286
  .requiredOption(core.I18n.formatMessage("commands.proof-create.options.id.param"), core.I18n.formatMessage("commands.proof-create.options.id.description"))
212
287
  .requiredOption(core.I18n.formatMessage("commands.proof-create.options.private-key.param"), core.I18n.formatMessage("commands.proof-create.options.private-key.description"))
213
- .requiredOption(core.I18n.formatMessage("commands.proof-create.options.data.param"), core.I18n.formatMessage("commands.proof-create.options.data.description"));
288
+ .requiredOption(core.I18n.formatMessage("commands.proof-create.options.document-filename.param"), core.I18n.formatMessage("commands.proof-create.options.document-filename.description"));
214
289
  cliCore.CLIOptions.output(command, {
215
290
  noConsole: true,
216
291
  json: true,
@@ -219,7 +294,11 @@ function buildCommandProofCreate() {
219
294
  mergeEnv: true
220
295
  });
221
296
  command
297
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
298
+ .choices(Object.values(IdentityConnectorTypes))
299
+ .default(IdentityConnectorTypes.Iota))
222
300
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
301
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
223
302
  .action(actionCommandProofCreate);
224
303
  return command;
225
304
  }
@@ -229,53 +308,51 @@ function buildCommandProofCreate() {
229
308
  * @param opts.id The id of the verification method to use for the credential.
230
309
  * @param opts.privateKey The private key for the verification method.
231
310
  * @param opts.data The data to create the proof for.
311
+ * @param opts.connector The connector to perform the operations with.
232
312
  * @param opts.node The node URL.
313
+ * @param opts.network The network to use for connector.
233
314
  */
234
315
  async function actionCommandProofCreate(opts) {
235
316
  const id = cliCore.CLIParam.stringValue("id", opts.id);
236
317
  const privateKey = cliCore.CLIParam.hexBase64("private-key", opts.privateKey);
237
- const data = cliCore.CLIParam.hexBase64("data", opts.data);
318
+ const documentFilename = path.resolve(cliCore.CLIParam.stringValue("document-filename", opts.documentFilename));
238
319
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
320
+ const network = opts.connector === IdentityConnectorTypes.Iota
321
+ ? cliCore.CLIParam.stringValue("network", opts.network)
322
+ : undefined;
239
323
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-create.labels.verificationMethodId"), id);
324
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-create.labels.documentFilename"), documentFilename);
240
325
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
326
+ if (core.Is.stringValue(network)) {
327
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
328
+ }
241
329
  cliCore.CLIDisplay.break();
242
330
  setupVault();
243
331
  const localIdentity = "local";
332
+ const vmParts = identityModels.DocumentHelper.parseId(id);
244
333
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
245
- await vaultConnector.addKey(`${localIdentity}/${id}`, vaultModels.VaultKeyType.Ed25519, privateKey, new Uint8Array());
246
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
247
- config: {
248
- clientOptions: {
249
- nodes: [nodeEndpoint],
250
- localPow: true
251
- }
252
- }
253
- });
254
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
255
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
256
- config: {
257
- clientOptions: {
258
- nodes: [nodeEndpoint],
259
- localPow: true
260
- }
261
- }
262
- });
334
+ await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, vaultModels.VaultKeyType.Ed25519, privateKey, new Uint8Array());
335
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
336
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
337
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
263
338
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.proof-create.progress.creatingProof"));
264
339
  cliCore.CLIDisplay.break();
265
340
  cliCore.CLIDisplay.spinnerStart();
266
- const proof = await iotaIdentityConnector.createProof(localIdentity, id, data);
267
- const proofValue = core.Converter.bytesToBase64(proof.value);
341
+ const document = await cliCore.CLIUtils.readJsonFile(documentFilename);
342
+ if (core.Is.undefined(document)) {
343
+ throw new core.GeneralError("commands", "commands.proof-create.documentJsonFileNotFound");
344
+ }
345
+ const proof = await identityConnector.createProof(localIdentity, id, standardsW3cDid.ProofTypes.DataIntegrityProof, document);
268
346
  cliCore.CLIDisplay.spinnerStop();
269
347
  if (opts.console) {
270
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-create.labels.type"), proof.type);
271
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-create.labels.value"), proofValue);
348
+ cliCore.CLIDisplay.json(proof);
272
349
  cliCore.CLIDisplay.break();
273
350
  }
274
351
  if (core.Is.stringValue(opts?.json)) {
275
- await cliCore.CLIUtils.writeJsonFile(opts.json, { type: proof.type, value: proofValue }, opts.mergeJson);
352
+ await cliCore.CLIUtils.writeJsonFile(opts.json, proof, opts.mergeJson);
276
353
  }
277
354
  if (core.Is.stringValue(opts?.env)) {
278
- await cliCore.CLIUtils.writeEnvFile(opts.env, [`DID_PROOF_TYPE="${proof.type}"`, `DID_PROOF_VALUE="${proofValue}"`], opts.mergeEnv);
355
+ await cliCore.CLIUtils.writeEnvFile(opts.env, [`DID_PROOF='${JSON.stringify(proof)}'`], opts.mergeEnv);
279
356
  }
280
357
  cliCore.CLIDisplay.done();
281
358
  }
@@ -292,10 +369,8 @@ function buildCommandProofVerify() {
292
369
  .name("proof-verify")
293
370
  .summary(core.I18n.formatMessage("commands.proof-verify.summary"))
294
371
  .description(core.I18n.formatMessage("commands.proof-verify.description"))
295
- .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.id.param"), core.I18n.formatMessage("commands.proof-verify.options.id.description"))
296
- .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.data.param"), core.I18n.formatMessage("commands.proof-verify.options.data.description"))
297
- .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.type.param"), core.I18n.formatMessage("commands.proof-verify.options.type.description"))
298
- .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.value.param"), core.I18n.formatMessage("commands.proof-verify.options.value.description"));
372
+ .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.document-filename.param"), core.I18n.formatMessage("commands.proof-verify.options.document-filename.description"))
373
+ .requiredOption(core.I18n.formatMessage("commands.proof-verify.options.proof-filename.param"), core.I18n.formatMessage("commands.proof-verify.options.proof-filename.description"));
299
374
  cliCore.CLIOptions.output(command, {
300
375
  noConsole: true,
301
376
  json: true,
@@ -304,7 +379,11 @@ function buildCommandProofVerify() {
304
379
  mergeEnv: true
305
380
  });
306
381
  command
382
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
383
+ .choices(Object.values(IdentityConnectorTypes))
384
+ .default(IdentityConnectorTypes.Iota))
307
385
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
386
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
308
387
  .action(actionCommandProofVerify);
309
388
  return command;
310
389
  }
@@ -312,44 +391,42 @@ function buildCommandProofVerify() {
312
391
  * Action the proof verify command.
313
392
  * @param opts The options for the command.
314
393
  * @param opts.id The id of the verification method to use for the credential.
315
- * @param opts.data The data to verify the proof for.
316
- * @param opts.type The type of the proof.
317
- * @param opts.value The proof value.
394
+ * @param opts.documentFilename The data to verify the proof for.
395
+ * @param opts.proofFilename The proof value.
396
+ * @param opts.connector The connector to perform the operations with.
318
397
  * @param opts.node The node URL.
398
+ * @param opts.network The network to use for connector.
319
399
  */
320
400
  async function actionCommandProofVerify(opts) {
321
- const id = cliCore.CLIParam.stringValue("id", opts.id);
322
- const data = cliCore.CLIParam.hexBase64("data", opts.data);
323
- const type = cliCore.CLIParam.stringValue("type", opts.type);
324
- const value = cliCore.CLIParam.hexBase64("value", opts.value);
401
+ const documentFilename = path.resolve(cliCore.CLIParam.stringValue("document-filename", opts.documentFilename));
402
+ const proofFilename = path.resolve(cliCore.CLIParam.stringValue("proof-filename", opts.proofFilename));
325
403
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
326
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.verificationMethodId"), id);
327
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.type"), type);
328
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.value"), core.Converter.bytesToBase64(value));
404
+ const network = opts.connector === IdentityConnectorTypes.Iota
405
+ ? cliCore.CLIParam.stringValue("network", opts.network)
406
+ : undefined;
407
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.documentFilename"), documentFilename);
408
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.proofFilename"), proofFilename);
329
409
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
410
+ if (core.Is.stringValue(network)) {
411
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
412
+ }
330
413
  cliCore.CLIDisplay.break();
331
414
  setupVault();
332
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
333
- config: {
334
- clientOptions: {
335
- nodes: [nodeEndpoint],
336
- localPow: true
337
- }
338
- }
339
- });
340
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
341
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
342
- config: {
343
- clientOptions: {
344
- nodes: [nodeEndpoint],
345
- localPow: true
346
- }
347
- }
348
- });
415
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
416
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
417
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
349
418
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.proof-verify.progress.verifyingProof"));
350
419
  cliCore.CLIDisplay.break();
351
420
  cliCore.CLIDisplay.spinnerStart();
352
- const isVerified = await iotaIdentityConnector.verifyProof(id, data, type, value);
421
+ const document = await cliCore.CLIUtils.readJsonFile(documentFilename);
422
+ if (core.Is.undefined(document)) {
423
+ throw new core.GeneralError("commands", "commands.proof-verify.documentJsonFileNotFound");
424
+ }
425
+ const proof = await cliCore.CLIUtils.readJsonFile(proofFilename);
426
+ if (core.Is.undefined(proof)) {
427
+ throw new core.GeneralError("commands", "commands.proof-verify.proofJsonFileNotFound");
428
+ }
429
+ const isVerified = await identityConnector.verifyProof(document, proof);
353
430
  cliCore.CLIDisplay.spinnerStop();
354
431
  if (opts.console) {
355
432
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.isVerified"), isVerified);
@@ -389,7 +466,11 @@ function buildCommandServiceAdd() {
389
466
  mergeEnv: true
390
467
  });
391
468
  command
469
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
470
+ .choices(Object.values(IdentityConnectorTypes))
471
+ .default(IdentityConnectorTypes.Iota))
392
472
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
473
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
393
474
  .option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
394
475
  .action(actionCommandServiceAdd);
395
476
  return command;
@@ -402,6 +483,7 @@ function buildCommandServiceAdd() {
402
483
  * @param opts.id The id of the service to add.
403
484
  * @param opts.type The type of the service to add.
404
485
  * @param opts.endpoint The service endpoint.
486
+ * @param opts.connector The connector to perform the operations with.
405
487
  * @param opts.node The node URL.
406
488
  * @param opts.explorer The explorer URL.
407
489
  */
@@ -412,12 +494,18 @@ async function actionCommandServiceAdd(opts) {
412
494
  const type = cliCore.CLIParam.stringValue("type", opts.type);
413
495
  const endpoint = cliCore.CLIParam.url("endpoint", opts.endpoint);
414
496
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
497
+ const network = opts.connector === IdentityConnectorTypes.Iota
498
+ ? cliCore.CLIParam.stringValue("network", opts.network)
499
+ : undefined;
415
500
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
416
501
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.did"), did);
417
502
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.service-add.labels.serviceId"), id);
418
503
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.service-add.labels.serviceType"), type);
419
504
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.service-add.labels.serviceEndpoint"), endpoint);
420
505
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
506
+ if (core.Is.stringValue(network)) {
507
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
508
+ }
421
509
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
422
510
  cliCore.CLIDisplay.break();
423
511
  setupVault();
@@ -425,29 +513,13 @@ async function actionCommandServiceAdd(opts) {
425
513
  const localIdentity = "local";
426
514
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
427
515
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
428
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
429
- config: {
430
- clientOptions: {
431
- nodes: [nodeEndpoint],
432
- localPow: true
433
- },
434
- vaultSeedId
435
- }
436
- });
437
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
438
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
439
- config: {
440
- clientOptions: {
441
- nodes: [nodeEndpoint],
442
- localPow: true
443
- },
444
- vaultSeedId
445
- }
446
- });
516
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
517
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
518
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
447
519
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.service-add.progress.addingService"));
448
520
  cliCore.CLIDisplay.break();
449
521
  cliCore.CLIDisplay.spinnerStart();
450
- const service = await iotaIdentityConnector.addService(localIdentity, did, id, type, endpoint);
522
+ const service = await identityConnector.addService(localIdentity, did, id, type, endpoint);
451
523
  cliCore.CLIDisplay.spinnerStop();
452
524
  if (core.Is.stringValue(opts?.json)) {
453
525
  await cliCore.CLIUtils.writeJsonFile(opts.json, service, opts.mergeJson);
@@ -459,7 +531,12 @@ async function actionCommandServiceAdd(opts) {
459
531
  `DID_SERVICE_ENDPOINT="${service.serviceEndpoint}"`
460
532
  ], opts.mergeEnv);
461
533
  }
462
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(did)}?tab=DID`);
534
+ if (opts.connector === IdentityConnectorTypes.Iota) {
535
+ const didUrn = core.Urn.fromValidString(did);
536
+ const didParts = didUrn.parts();
537
+ const objectId = didParts[didParts.length - 1];
538
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
539
+ }
463
540
  cliCore.CLIDisplay.break();
464
541
  cliCore.CLIDisplay.done();
465
542
  }
@@ -486,7 +563,11 @@ function buildCommandServiceRemove() {
486
563
  mergeEnv: true
487
564
  });
488
565
  command
566
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
567
+ .choices(Object.values(IdentityConnectorTypes))
568
+ .default(IdentityConnectorTypes.Iota))
489
569
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
570
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
490
571
  .option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
491
572
  .action(actionCommandServiceRemove);
492
573
  return command;
@@ -496,16 +577,24 @@ function buildCommandServiceRemove() {
496
577
  * @param opts The options for the command.
497
578
  * @param opts.seed The private key for the controller.
498
579
  * @param opts.id The id of the service to remove.
580
+ * @param opts.connector The connector to perform the operations with.
499
581
  * @param opts.node The node URL.
582
+ * @param opts.network The network to use for connector.
500
583
  * @param opts.explorer The explorer URL.
501
584
  */
502
585
  async function actionCommandServiceRemove(opts) {
503
586
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
504
587
  const id = cliCore.CLIParam.stringValue("id", opts.id);
505
588
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
589
+ const network = opts.connector === IdentityConnectorTypes.Iota
590
+ ? cliCore.CLIParam.stringValue("network", opts.network)
591
+ : undefined;
506
592
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
507
593
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.service-remove.labels.serviceId"), id);
508
594
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
595
+ if (core.Is.stringValue(network)) {
596
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
597
+ }
509
598
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
510
599
  cliCore.CLIDisplay.break();
511
600
  setupVault();
@@ -513,31 +602,21 @@ async function actionCommandServiceRemove(opts) {
513
602
  const localIdentity = "local";
514
603
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
515
604
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
516
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
517
- config: {
518
- clientOptions: {
519
- nodes: [nodeEndpoint],
520
- localPow: true
521
- },
522
- vaultSeedId
523
- }
524
- });
525
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
526
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
527
- config: {
528
- clientOptions: {
529
- nodes: [nodeEndpoint],
530
- localPow: true
531
- },
532
- vaultSeedId
533
- }
534
- });
605
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
606
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
607
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
535
608
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.service-remove.progress.removingService"));
536
609
  cliCore.CLIDisplay.break();
537
610
  cliCore.CLIDisplay.spinnerStart();
538
- await iotaIdentityConnector.removeService(localIdentity, id);
611
+ await identityConnector.removeService(localIdentity, id);
539
612
  cliCore.CLIDisplay.spinnerStop();
540
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(identityModels.DocumentHelper.parse(id).id)}?tab=DID`);
613
+ const did = identityModels.DocumentHelper.parseId(id).id;
614
+ if (opts.connector === IdentityConnectorTypes.Iota) {
615
+ const didUrn = core.Urn.fromValidString(did);
616
+ const didParts = didUrn.parts();
617
+ const objectId = didParts[didParts.length - 1];
618
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
619
+ }
541
620
  cliCore.CLIDisplay.break();
542
621
  cliCore.CLIDisplay.done();
543
622
  }
@@ -567,7 +646,11 @@ function buildCommandVerifiableCredentialCreate() {
567
646
  mergeEnv: true
568
647
  });
569
648
  command
649
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
650
+ .choices(Object.values(IdentityConnectorTypes))
651
+ .default(IdentityConnectorTypes.Iota))
570
652
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
653
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
571
654
  .action(actionCommandVerifiableCredentialCreate);
572
655
  return command;
573
656
  }
@@ -579,6 +662,7 @@ function buildCommandVerifiableCredentialCreate() {
579
662
  * @param opts.credentialId The id of the credential.
580
663
  * @param opts.subjectJson The JSON data for the subject.
581
664
  * @param opts.revocationIndex The revocation index for the credential.
665
+ * @param opts.connector The connector to perform the operations with.
582
666
  * @param opts.node The node URL.
583
667
  */
584
668
  async function actionCommandVerifiableCredentialCreate(opts) {
@@ -588,33 +672,26 @@ async function actionCommandVerifiableCredentialCreate(opts) {
588
672
  const subjectJson = path.resolve(cliCore.CLIParam.stringValue("subject-json", opts.subjectJson));
589
673
  const revocationIndex = core.Coerce.number(opts.revocationIndex);
590
674
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
675
+ const network = opts.connector === IdentityConnectorTypes.Iota
676
+ ? cliCore.CLIParam.stringValue("network", opts.network)
677
+ : undefined;
591
678
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.verificationMethodId"), id);
592
679
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.credentialId"), credentialId);
593
680
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.subjectJson"), subjectJson);
594
681
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.revocationIndex"), revocationIndex);
595
682
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
683
+ if (core.Is.stringValue(network)) {
684
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
685
+ }
596
686
  cliCore.CLIDisplay.break();
597
687
  setupVault();
598
688
  const localIdentity = "local";
689
+ const vmParts = identityModels.DocumentHelper.parseId(id);
599
690
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
600
- await vaultConnector.addKey(`${localIdentity}/${id}`, vaultModels.VaultKeyType.Ed25519, privateKey, new Uint8Array());
601
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
602
- config: {
603
- clientOptions: {
604
- nodes: [nodeEndpoint],
605
- localPow: true
606
- }
607
- }
608
- });
609
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
610
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
611
- config: {
612
- clientOptions: {
613
- nodes: [nodeEndpoint],
614
- localPow: true
615
- }
616
- }
617
- });
691
+ await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, vaultModels.VaultKeyType.Ed25519, privateKey, new Uint8Array());
692
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
693
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
694
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
618
695
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.verifiable-credential-create.progress.loadingSubjectData"));
619
696
  cliCore.CLIDisplay.break();
620
697
  const jsonData = await cliCore.CLIUtils.readJsonFile(subjectJson);
@@ -624,7 +701,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
624
701
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.verifiable-credential-create.progress.creatingVerifiableCredential"));
625
702
  cliCore.CLIDisplay.break();
626
703
  cliCore.CLIDisplay.spinnerStart();
627
- const verifiableCredential = await iotaIdentityConnector.createVerifiableCredential(localIdentity, id, credentialId, jsonData, revocationIndex);
704
+ const verifiableCredential = await identityConnector.createVerifiableCredential(localIdentity, id, credentialId, jsonData, revocationIndex);
628
705
  cliCore.CLIDisplay.spinnerStop();
629
706
  if (opts.console) {
630
707
  cliCore.CLIDisplay.section(core.I18n.formatMessage("commands.verifiable-credential-create.labels.verifiableCredential"));
@@ -657,7 +734,11 @@ function buildCommandVerifiableCredentialRevoke() {
657
734
  .requiredOption(core.I18n.formatMessage("commands.verifiable-credential-revoke.options.did.param"), core.I18n.formatMessage("commands.verifiable-credential-revoke.options.did.description"))
658
735
  .requiredOption(core.I18n.formatMessage("commands.verifiable-credential-revoke.options.revocation-index.param"), core.I18n.formatMessage("commands.verifiable-credential-revoke.options.revocation-index.description"));
659
736
  command
737
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
738
+ .choices(Object.values(IdentityConnectorTypes))
739
+ .default(IdentityConnectorTypes.Iota))
660
740
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
741
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
661
742
  .action(actionCommandVerifiableCredentialRevoke);
662
743
  return command;
663
744
  }
@@ -667,45 +748,37 @@ function buildCommandVerifiableCredentialRevoke() {
667
748
  * @param opts.seed The seed to generate the private key for the controller.
668
749
  * @param opts.did The id of the document to revoke the index.
669
750
  * @param opts.revocationIndex The revocation index for the credential.
751
+ * @param opts.connector The connector to perform the operations with.
670
752
  * @param opts.node The node URL.
753
+ * @param opts.network The network to use for connector.
671
754
  */
672
755
  async function actionCommandVerifiableCredentialRevoke(opts) {
673
756
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
674
757
  const did = cliCore.CLIParam.stringValue("did", opts.did);
675
758
  const revocationIndex = cliCore.CLIParam.integer("revocation-index", opts.revocationIndex);
676
759
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
760
+ const network = opts.connector === IdentityConnectorTypes.Iota
761
+ ? cliCore.CLIParam.stringValue("network", opts.network)
762
+ : undefined;
677
763
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.did"), did);
678
764
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-revoke.labels.revocationIndex"), revocationIndex);
679
765
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
766
+ if (core.Is.stringValue(network)) {
767
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
768
+ }
680
769
  cliCore.CLIDisplay.break();
681
770
  setupVault();
682
771
  const vaultSeedId = "local-seed";
683
772
  const localIdentity = "local";
684
773
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
685
774
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
686
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
687
- config: {
688
- clientOptions: {
689
- nodes: [nodeEndpoint],
690
- localPow: true
691
- },
692
- vaultSeedId
693
- }
694
- });
695
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
696
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
697
- config: {
698
- clientOptions: {
699
- nodes: [nodeEndpoint],
700
- localPow: true
701
- },
702
- vaultSeedId
703
- }
704
- });
775
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
776
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
777
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
705
778
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.verifiable-credential-revoke.progress.revokingCredential"));
706
779
  cliCore.CLIDisplay.break();
707
780
  cliCore.CLIDisplay.spinnerStart();
708
- await iotaIdentityConnector.revokeVerifiableCredentials(localIdentity, did, [revocationIndex]);
781
+ await identityConnector.revokeVerifiableCredentials(localIdentity, did, [revocationIndex]);
709
782
  cliCore.CLIDisplay.spinnerStop();
710
783
  cliCore.CLIDisplay.done();
711
784
  }
@@ -726,7 +799,11 @@ function buildCommandVerifiableCredentialUnrevoke() {
726
799
  .requiredOption(core.I18n.formatMessage("commands.verifiable-credential-unrevoke.options.did.param"), core.I18n.formatMessage("commands.verifiable-credential-unrevoke.options.did.description"))
727
800
  .requiredOption(core.I18n.formatMessage("commands.verifiable-credential-unrevoke.options.revocation-index.param"), core.I18n.formatMessage("commands.verifiable-credential-unrevoke.options.revocation-index.description"));
728
801
  command
802
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
803
+ .choices(Object.values(IdentityConnectorTypes))
804
+ .default(IdentityConnectorTypes.Iota))
729
805
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
806
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
730
807
  .action(actionCommandVerifiableCredentialUnrevoke);
731
808
  return command;
732
809
  }
@@ -736,45 +813,37 @@ function buildCommandVerifiableCredentialUnrevoke() {
736
813
  * @param opts.seed The seed to generate the private key for the controller.
737
814
  * @param opts.did The id of the document to unrevoke the index.
738
815
  * @param opts.revocationIndex The revocation index for the credential.
816
+ * @param opts.connector The connector to perform the operations with.
739
817
  * @param opts.node The node URL.
818
+ * @param opts.network The network to use for connector.
740
819
  */
741
820
  async function actionCommandVerifiableCredentialUnrevoke(opts) {
742
821
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
743
822
  const did = cliCore.CLIParam.stringValue("did", opts.did);
744
823
  const revocationIndex = cliCore.CLIParam.integer("revocation-index", opts.revocationIndex);
745
824
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
825
+ const network = opts.connector === IdentityConnectorTypes.Iota
826
+ ? cliCore.CLIParam.stringValue("network", opts.network)
827
+ : undefined;
746
828
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.did"), did);
747
829
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-unrevoke.labels.revocationIndex"), revocationIndex);
748
830
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
831
+ if (core.Is.stringValue(network)) {
832
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
833
+ }
749
834
  cliCore.CLIDisplay.break();
750
835
  setupVault();
751
836
  const vaultSeedId = "local-seed";
752
837
  const localIdentity = "local";
753
838
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
754
839
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
755
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
756
- config: {
757
- clientOptions: {
758
- nodes: [nodeEndpoint],
759
- localPow: true
760
- },
761
- vaultSeedId
762
- }
763
- });
764
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
765
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
766
- config: {
767
- clientOptions: {
768
- nodes: [nodeEndpoint],
769
- localPow: true
770
- },
771
- vaultSeedId
772
- }
773
- });
840
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
841
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
842
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
774
843
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.verifiable-credential-unrevoke.progress.unrevokingCredential"));
775
844
  cliCore.CLIDisplay.break();
776
845
  cliCore.CLIDisplay.spinnerStart();
777
- await iotaIdentityConnector.unrevokeVerifiableCredentials(localIdentity, did, [revocationIndex]);
846
+ await identityConnector.unrevokeVerifiableCredentials(localIdentity, did, [revocationIndex]);
778
847
  cliCore.CLIDisplay.spinnerStop();
779
848
  cliCore.CLIDisplay.done();
780
849
  }
@@ -800,7 +869,11 @@ function buildCommandVerifiableCredentialVerify() {
800
869
  mergeEnv: true
801
870
  });
802
871
  command
872
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
873
+ .choices(Object.values(IdentityConnectorTypes))
874
+ .default(IdentityConnectorTypes.Iota))
803
875
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
876
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
804
877
  .action(actionCommandVerifiableCredentialVerify);
805
878
  return command;
806
879
  }
@@ -808,36 +881,29 @@ function buildCommandVerifiableCredentialVerify() {
808
881
  * Action the verifiable credential verify command.
809
882
  * @param opts The options for the command.
810
883
  * @param opts.jwt The JSON web token for the verifiable credential.
884
+ * @param opts.connector The connector to perform the operations with.
811
885
  * @param opts.node The node URL.
812
886
  */
813
887
  async function actionCommandVerifiableCredentialVerify(opts) {
814
888
  const jwt = cliCore.CLIParam.stringValue("jwt", opts.jwt);
815
889
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
890
+ const network = opts.connector === IdentityConnectorTypes.Iota
891
+ ? cliCore.CLIParam.stringValue("network", opts.network)
892
+ : undefined;
816
893
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-verify.labels.jwt"), jwt);
817
894
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
895
+ if (core.Is.stringValue(network)) {
896
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
897
+ }
818
898
  cliCore.CLIDisplay.break();
819
899
  setupVault();
820
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
821
- config: {
822
- clientOptions: {
823
- nodes: [nodeEndpoint],
824
- localPow: true
825
- }
826
- }
827
- });
828
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
829
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
830
- config: {
831
- clientOptions: {
832
- nodes: [nodeEndpoint],
833
- localPow: true
834
- }
835
- }
836
- });
900
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
901
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
902
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
837
903
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.verifiable-credential-verify.progress.verifyingCredential"));
838
904
  cliCore.CLIDisplay.break();
839
905
  cliCore.CLIDisplay.spinnerStart();
840
- const verification = await iotaIdentityConnector.checkVerifiableCredential(jwt);
906
+ const verification = await identityConnector.checkVerifiableCredential(jwt);
841
907
  const isVerified = core.Is.notEmpty(verification.verifiableCredential);
842
908
  const isRevoked = verification.revoked;
843
909
  cliCore.CLIDisplay.spinnerStop();
@@ -884,7 +950,11 @@ function buildCommandVerificationMethodAdd() {
884
950
  mergeEnv: true
885
951
  });
886
952
  command
953
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
954
+ .choices(Object.values(IdentityConnectorTypes))
955
+ .default(IdentityConnectorTypes.Iota))
887
956
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
957
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
888
958
  .option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
889
959
  .action(actionCommandVerificationMethodAdd);
890
960
  return command;
@@ -896,6 +966,7 @@ function buildCommandVerificationMethodAdd() {
896
966
  * @param opts.did The identity of the document to add to.
897
967
  * @param opts.type The type of the verification method to add.
898
968
  * @param opts.id The id of the verification method to add.
969
+ * @param opts.connector The connector to perform the operations with.
899
970
  * @param opts.node The node URL.
900
971
  * @param opts.explorer The explorer URL.
901
972
  */
@@ -904,6 +975,9 @@ async function actionCommandVerificationMethodAdd(opts) {
904
975
  const did = cliCore.CLIParam.stringValue("did", opts.did);
905
976
  const type = cliCore.CLIParam.stringValue("type", opts.type);
906
977
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
978
+ const network = opts.connector === IdentityConnectorTypes.Iota
979
+ ? cliCore.CLIParam.stringValue("network", opts.network)
980
+ : undefined;
907
981
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
908
982
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.did"), did);
909
983
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.verificationMethodType"), type);
@@ -911,6 +985,9 @@ async function actionCommandVerificationMethodAdd(opts) {
911
985
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.verificationMethodId"), opts?.id);
912
986
  }
913
987
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
988
+ if (core.Is.stringValue(network)) {
989
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
990
+ }
914
991
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
915
992
  cliCore.CLIDisplay.break();
916
993
  setupVault();
@@ -918,50 +995,55 @@ async function actionCommandVerificationMethodAdd(opts) {
918
995
  const localIdentity = "local";
919
996
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
920
997
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
921
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
922
- config: {
923
- clientOptions: {
924
- nodes: [nodeEndpoint],
925
- localPow: true
926
- },
927
- vaultSeedId
928
- }
929
- });
930
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
931
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
932
- config: {
933
- clientOptions: {
934
- nodes: [nodeEndpoint],
935
- localPow: true
936
- },
937
- vaultSeedId
938
- }
939
- });
998
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
999
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
1000
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
940
1001
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.verification-method-add.progress.addingVerificationMethod"));
941
1002
  cliCore.CLIDisplay.break();
942
1003
  cliCore.CLIDisplay.spinnerStart();
943
- const verificationMethod = await iotaIdentityConnector.addVerificationMethod(localIdentity, did, type, opts?.id);
1004
+ const verificationMethod = await identityConnector.addVerificationMethod(localIdentity, did, type, opts?.id);
944
1005
  cliCore.CLIDisplay.spinnerStop();
945
- const keyPair = await vaultConnector.getKey(`${localIdentity}/${verificationMethod.id}`);
946
- const privateKey = core.Converter.bytesToBase64(keyPair.privateKey);
947
- const publicKey = core.Converter.bytesToBase64(keyPair.publicKey);
1006
+ const keyParts = identityModels.DocumentHelper.parseId(verificationMethod.id);
1007
+ const keyPair = await vaultConnector.getKey(`${localIdentity}/${keyParts.fragment}`);
1008
+ const privateKeyBase64 = core.Converter.bytesToBase64Url(keyPair.privateKey);
1009
+ const publicKeyBase64 = core.Is.uint8Array(keyPair.publicKey)
1010
+ ? core.Converter.bytesToBase64Url(keyPair.publicKey)
1011
+ : "";
1012
+ const privateKeyHex = core.Converter.bytesToHex(keyPair.privateKey, true);
1013
+ const publicKeyHex = core.Is.uint8Array(keyPair.publicKey)
1014
+ ? core.Converter.bytesToHex(keyPair.publicKey, true)
1015
+ : "";
1016
+ const jwk = await web.Jwk.fromEd25519Private(keyPair.privateKey);
1017
+ const kid = await web.Jwk.generateKid(jwk);
948
1018
  if (opts.console) {
949
1019
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.verificationMethodId"), verificationMethod.id);
950
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.privateKey"), privateKey);
951
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.publicKey"), publicKey);
1020
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.kid"), kid);
1021
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.privateKeyBase64"), privateKeyBase64);
1022
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.publicKeyBase64"), publicKeyBase64);
1023
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.privateKeyHex"), privateKeyHex);
1024
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.publicKeyHex"), publicKeyHex);
952
1025
  cliCore.CLIDisplay.break();
953
1026
  }
954
1027
  if (core.Is.stringValue(opts?.json)) {
955
- await cliCore.CLIUtils.writeJsonFile(opts.json, { verificationMethodId: verificationMethod.id, privateKey, publicKey }, opts.mergeJson);
1028
+ await cliCore.CLIUtils.writeJsonFile(opts.json, {
1029
+ kid,
1030
+ ...jwk
1031
+ }, opts.mergeJson);
956
1032
  }
957
1033
  if (core.Is.stringValue(opts?.env)) {
958
1034
  await cliCore.CLIUtils.writeEnvFile(opts.env, [
959
1035
  `DID_VERIFICATION_METHOD_ID="${verificationMethod.id}"`,
960
- `DID_VERIFICATION_METHOD_PRIVATE_KEY="${privateKey}"`,
961
- `DID_VERIFICATION_METHOD_PUBLIC_KEY="${publicKey}"`
1036
+ `DID_VERIFICATION_METHOD_KID="${kid}"`,
1037
+ `DID_VERIFICATION_METHOD_PRIVATE_KEY="${privateKeyHex}"`,
1038
+ `DID_VERIFICATION_METHOD_PUBLIC_KEY="${publicKeyHex}"`
962
1039
  ], opts.mergeEnv);
963
1040
  }
964
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(did)}?tab=DID`);
1041
+ if (opts.connector === IdentityConnectorTypes.Iota) {
1042
+ const didUrn = core.Urn.fromValidString(did);
1043
+ const didParts = didUrn.parts();
1044
+ const objectId = didParts[didParts.length - 1];
1045
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
1046
+ }
965
1047
  cliCore.CLIDisplay.break();
966
1048
  cliCore.CLIDisplay.done();
967
1049
  }
@@ -988,7 +1070,11 @@ function buildCommandVerificationMethodRemove() {
988
1070
  mergeEnv: true
989
1071
  });
990
1072
  command
1073
+ .addOption(new commander.Option(core.I18n.formatMessage("commands.common.options.connector.param"), core.I18n.formatMessage("commands.common.options.connector.description"))
1074
+ .choices(Object.values(IdentityConnectorTypes))
1075
+ .default(IdentityConnectorTypes.Iota))
991
1076
  .option(core.I18n.formatMessage("commands.common.options.node.param"), core.I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
1077
+ .option(core.I18n.formatMessage("commands.common.options.network.param"), core.I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
992
1078
  .option(core.I18n.formatMessage("commands.common.options.explorer.param"), core.I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
993
1079
  .action(actionCommandVerificationMethodRemove);
994
1080
  return command;
@@ -998,16 +1084,24 @@ function buildCommandVerificationMethodRemove() {
998
1084
  * @param opts The options for the command.
999
1085
  * @param opts.seed The private key for the controller.
1000
1086
  * @param opts.id The id of the verification method to remove.
1087
+ * @param opts.connector The connector to perform the operations with.
1001
1088
  * @param opts.node The node URL.
1002
1089
  * @param opts.explorer The explorer URL.
1090
+ * @param opts.network The network to use for connector.
1003
1091
  */
1004
1092
  async function actionCommandVerificationMethodRemove(opts) {
1005
1093
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
1006
1094
  const id = cliCore.CLIParam.stringValue("id", opts.id);
1007
1095
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
1096
+ const network = opts.connector === IdentityConnectorTypes.Iota
1097
+ ? cliCore.CLIParam.stringValue("network", opts.network)
1098
+ : undefined;
1008
1099
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
1009
1100
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verification-method-add.labels.verificationMethodId"), id);
1010
1101
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
1102
+ if (core.Is.stringValue(network)) {
1103
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.network"), network);
1104
+ }
1011
1105
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
1012
1106
  cliCore.CLIDisplay.break();
1013
1107
  setupVault();
@@ -1015,31 +1109,21 @@ async function actionCommandVerificationMethodRemove(opts) {
1015
1109
  const localIdentity = "local";
1016
1110
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
1017
1111
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, core.Converter.bytesToBase64(seed));
1018
- const iotaWalletConnector = new walletConnectorIota.IotaWalletConnector({
1019
- config: {
1020
- clientOptions: {
1021
- nodes: [nodeEndpoint],
1022
- localPow: true
1023
- },
1024
- vaultSeedId
1025
- }
1026
- });
1027
- walletModels.WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
1028
- const iotaIdentityConnector = new identityConnectorIota.IotaIdentityConnector({
1029
- config: {
1030
- clientOptions: {
1031
- nodes: [nodeEndpoint],
1032
- localPow: true
1033
- },
1034
- vaultSeedId
1035
- }
1036
- });
1112
+ const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
1113
+ walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
1114
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
1037
1115
  cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.verification-method-remove.progress.removingVerificationMethod"));
1038
1116
  cliCore.CLIDisplay.break();
1039
1117
  cliCore.CLIDisplay.spinnerStart();
1040
- await iotaIdentityConnector.removeVerificationMethod(localIdentity, id);
1118
+ await identityConnector.removeVerificationMethod(localIdentity, id);
1041
1119
  cliCore.CLIDisplay.spinnerStop();
1042
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(identityModels.DocumentHelper.parse(id).id)}?tab=DID`);
1120
+ const did = identityModels.DocumentHelper.parseId(id).id;
1121
+ if (opts.connector === IdentityConnectorTypes.Iota) {
1122
+ const didUrn = core.Urn.fromValidString(did);
1123
+ const didParts = didUrn.parts();
1124
+ const objectId = didParts[didParts.length - 1];
1125
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
1126
+ }
1043
1127
  cliCore.CLIDisplay.break();
1044
1128
  cliCore.CLIDisplay.done();
1045
1129
  }
@@ -1062,7 +1146,7 @@ class CLI extends cliCore.CLIBase {
1062
1146
  return this.execute({
1063
1147
  title: "TWIN Identity",
1064
1148
  appName: "twin-identity",
1065
- version: "0.0.3-next.18",
1149
+ version: "0.0.2-next.1", // x-release-please-version
1066
1150
  icon: "🌍",
1067
1151
  supportsEnvFiles: true,
1068
1152
  overrideOutputWidth: options?.overrideOutputWidth
@@ -1096,6 +1180,8 @@ class CLI extends cliCore.CLIBase {
1096
1180
  }
1097
1181
 
1098
1182
  exports.CLI = CLI;
1183
+ exports.IdentityConnectorTypes = IdentityConnectorTypes;
1184
+ exports.IdentityResolverConnectorTypes = IdentityResolverConnectorTypes;
1099
1185
  exports.actionCommandIdentityCreate = actionCommandIdentityCreate;
1100
1186
  exports.actionCommandIdentityResolve = actionCommandIdentityResolve;
1101
1187
  exports.actionCommandProofCreate = actionCommandProofCreate;
@@ -1120,3 +1206,6 @@ exports.buildCommandVerifiableCredentialUnrevoke = buildCommandVerifiableCredent
1120
1206
  exports.buildCommandVerifiableCredentialVerify = buildCommandVerifiableCredentialVerify;
1121
1207
  exports.buildCommandVerificationMethodAdd = buildCommandVerificationMethodAdd;
1122
1208
  exports.buildCommandVerificationMethodRemove = buildCommandVerificationMethodRemove;
1209
+ exports.setupIdentityConnector = setupIdentityConnector;
1210
+ exports.setupIdentityResolverConnector = setupIdentityResolverConnector;
1211
+ exports.setupVault = setupVault;