@twin.org/identity-cli 0.0.1-next.20 → 0.0.1-next.22

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 (31) hide show
  1. package/dist/cjs/index.cjs +249 -226
  2. package/dist/esm/index.mjs +250 -230
  3. package/dist/locales/en.json +73 -9
  4. package/dist/types/commands/identityCreate.d.ts +6 -0
  5. package/dist/types/commands/identityResolve.d.ts +5 -0
  6. package/dist/types/commands/proofCreate.d.ts +5 -0
  7. package/dist/types/commands/proofVerify.d.ts +5 -0
  8. package/dist/types/commands/serviceAdd.d.ts +4 -0
  9. package/dist/types/commands/serviceRemove.d.ts +5 -0
  10. package/dist/types/commands/setupCommands.d.ts +18 -0
  11. package/dist/types/commands/verifiableCredentialCreate.d.ts +4 -0
  12. package/dist/types/commands/verifiableCredentialRevoke.d.ts +5 -0
  13. package/dist/types/commands/verifiableCredentialUnrevoke.d.ts +5 -0
  14. package/dist/types/commands/verifiableCredentialVerify.d.ts +4 -0
  15. package/dist/types/commands/verificationMethodAdd.d.ts +4 -0
  16. package/dist/types/commands/verificationMethodRemove.d.ts +5 -0
  17. package/dist/types/index.d.ts +2 -0
  18. package/dist/types/models/identityConnectorTypes.d.ts +17 -0
  19. package/docs/changelog.md +1 -1
  20. package/docs/examples.md +5 -5
  21. package/docs/reference/functions/actionCommandServiceRemove.md +12 -0
  22. package/docs/reference/functions/actionCommandVerifiableCredentialRevoke.md +12 -0
  23. package/docs/reference/functions/actionCommandVerifiableCredentialUnrevoke.md +12 -0
  24. package/docs/reference/functions/actionCommandVerificationMethodRemove.md +12 -0
  25. package/docs/reference/functions/setupIdentityConnector.md +47 -0
  26. package/docs/reference/functions/setupVault.md +9 -0
  27. package/docs/reference/index.md +10 -0
  28. package/docs/reference/type-aliases/IdentityConnectorTypes.md +5 -0
  29. package/docs/reference/variables/IdentityConnectorTypes.md +19 -0
  30. package/locales/en.json +17 -2
  31. package/package.json +7 -5
@@ -2,19 +2,36 @@ import path from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import { CLIOptions, CLIParam, CLIDisplay, CLIUtils, CLIBase } from '@twin.org/cli-core';
4
4
  import { buildCommandMnemonic, buildCommandAddress } from '@twin.org/crypto-cli';
5
- import { buildCommandFaucet, buildCommandTransfer } from '@twin.org/wallet-cli';
6
- import { I18n, Converter, Is, StringHelper, Coerce, GeneralError } from '@twin.org/core';
7
- import { IotaIdentityConnector, IotaIdentityUtils } from '@twin.org/identity-connector-iota';
5
+ import { setupWalletConnector, buildCommandFaucet, buildCommandTransfer } from '@twin.org/wallet-cli';
6
+ import { I18n, Is, Converter, StringHelper, Coerce, GeneralError } from '@twin.org/core';
7
+ import { IotaIdentityConnector, IotaIdentityUtils, IotaIdentityResolverConnector } from '@twin.org/identity-connector-iota';
8
8
  import { VaultConnectorFactory, VaultKeyType } from '@twin.org/vault-models';
9
- import { IotaWalletConnector } from '@twin.org/wallet-connector-iota';
10
9
  import { WalletConnectorFactory } from '@twin.org/wallet-models';
11
10
  import { Command, Option } from 'commander';
12
11
  import { MemoryEntityStorageConnector } from '@twin.org/entity-storage-connector-memory';
13
12
  import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
13
+ import { IotaRebasedIdentityConnector } from '@twin.org/identity-connector-iota-rebased';
14
14
  import { initSchema, EntityStorageVaultConnector } from '@twin.org/vault-connector-entity-storage';
15
15
  import { DidContexts, DidTypes, DidVerificationMethodType } from '@twin.org/standards-w3c-did';
16
16
  import { DocumentHelper } from '@twin.org/identity-models';
17
17
 
18
+ // Copyright 2024 IOTA Stiftung.
19
+ // SPDX-License-Identifier: Apache-2.0.
20
+ /**
21
+ * The identity connector types.
22
+ */
23
+ // eslint-disable-next-line @typescript-eslint/naming-convention
24
+ const IdentityConnectorTypes = {
25
+ /**
26
+ * IOTA.
27
+ */
28
+ Iota: "iota",
29
+ /**
30
+ * IOTA Rebased.
31
+ */
32
+ IotaRebased: "iota-rebased"
33
+ };
34
+
18
35
  // Copyright 2024 IOTA Stiftung.
19
36
  // SPDX-License-Identifier: Apache-2.0.
20
37
  /**
@@ -31,6 +48,41 @@ function setupVault() {
31
48
  const vaultConnector = new EntityStorageVaultConnector();
32
49
  VaultConnectorFactory.register("vault", () => vaultConnector);
33
50
  }
51
+ /**
52
+ * Setup the identity connector for use in the CLI commands.
53
+ * @param options The options for the identity connector.
54
+ * @param options.nodeEndpoint The node endpoint.
55
+ * @param options.network The network.
56
+ * @param options.addressIndex The wallet index.
57
+ * @param options.vaultSeedId The vault seed ID.
58
+ * @param connector The connector to use.
59
+ * @returns The identity connector.
60
+ */
61
+ function setupIdentityConnector(options, connector) {
62
+ connector ??= IdentityConnectorTypes.Iota;
63
+ if (connector === IdentityConnectorTypes.IotaRebased) {
64
+ return new IotaRebasedIdentityConnector({
65
+ config: {
66
+ clientOptions: {
67
+ url: options.nodeEndpoint
68
+ },
69
+ network: options.network ?? "",
70
+ vaultSeedId: options.vaultSeedId,
71
+ walletAddressIndex: options.addressIndex
72
+ }
73
+ });
74
+ }
75
+ return new IotaIdentityConnector({
76
+ config: {
77
+ clientOptions: {
78
+ nodes: [options.nodeEndpoint],
79
+ localPow: true
80
+ },
81
+ vaultSeedId: options.vaultSeedId,
82
+ walletAddressIndex: options.addressIndex
83
+ }
84
+ });
85
+ }
34
86
 
35
87
  // Copyright 2024 IOTA Stiftung.
36
88
  // SPDX-License-Identifier: Apache-2.0.
@@ -44,7 +96,8 @@ function buildCommandIdentityCreate() {
44
96
  .name("identity-create")
45
97
  .summary(I18n.formatMessage("commands.identity-create.summary"))
46
98
  .description(I18n.formatMessage("commands.identity-create.description"))
47
- .requiredOption(I18n.formatMessage("commands.identity-create.options.seed.param"), I18n.formatMessage("commands.identity-create.options.seed.description"));
99
+ .requiredOption(I18n.formatMessage("commands.identity-create.options.seed.param"), I18n.formatMessage("commands.identity-create.options.seed.description"))
100
+ .option(I18n.formatMessage("commands.identity-create.options.addressIndex.param"), I18n.formatMessage("commands.identity-create.options.addressIndex.description"), "0");
48
101
  CLIOptions.output(command, {
49
102
  noConsole: true,
50
103
  json: true,
@@ -53,7 +106,11 @@ function buildCommandIdentityCreate() {
53
106
  mergeEnv: true
54
107
  });
55
108
  command
109
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
110
+ .choices(Object.values(IdentityConnectorTypes))
111
+ .default(IdentityConnectorTypes.Iota))
56
112
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
113
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
57
114
  .option(I18n.formatMessage("commands.common.options.explorer.param"), I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
58
115
  .action(actionCommandIdentityCreate);
59
116
  return command;
@@ -62,44 +119,38 @@ function buildCommandIdentityCreate() {
62
119
  * Action the identity create command.
63
120
  * @param opts The options for the command.
64
121
  * @param opts.seed The private key for the controller.
122
+ * @param opts.connector The connector to perform the operations with.
65
123
  * @param opts.node The node URL.
124
+ * @param opts.network The network to use for rebased connector.
66
125
  * @param opts.explorer The explorer URL.
67
126
  */
68
127
  async function actionCommandIdentityCreate(opts) {
69
128
  const seed = CLIParam.hexBase64("seed", opts.seed);
70
129
  const nodeEndpoint = CLIParam.url("node", opts.node);
130
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
131
+ ? CLIParam.stringValue("network", opts.network)
132
+ : undefined;
71
133
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
134
+ const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
72
135
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
136
+ if (Is.stringValue(network)) {
137
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
138
+ }
73
139
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
140
+ CLIDisplay.value(I18n.formatMessage("commands.identity-create.labels.addressIndex"), addressIndex);
74
141
  CLIDisplay.break();
75
142
  setupVault();
76
143
  const vaultSeedId = "local-seed";
77
144
  const localIdentity = "local";
78
145
  const vaultConnector = VaultConnectorFactory.get("vault");
79
146
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
80
- const iotaWalletConnector = new IotaWalletConnector({
81
- config: {
82
- clientOptions: {
83
- nodes: [nodeEndpoint],
84
- localPow: true
85
- },
86
- vaultSeedId
87
- }
88
- });
89
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
90
- const iotaIdentityConnector = new IotaIdentityConnector({
91
- config: {
92
- clientOptions: {
93
- nodes: [nodeEndpoint],
94
- localPow: true
95
- },
96
- vaultSeedId
97
- }
98
- });
147
+ const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
148
+ WalletConnectorFactory.register("wallet", () => walletConnector);
149
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, vaultSeedId, network, addressIndex }, opts.connector);
99
150
  CLIDisplay.task(I18n.formatMessage("commands.identity-create.progress.creatingIdentity"));
100
151
  CLIDisplay.break();
101
152
  CLIDisplay.spinnerStart();
102
- const document = await iotaIdentityConnector.createDocument(localIdentity);
153
+ const document = await identityConnector.createDocument(localIdentity);
103
154
  CLIDisplay.spinnerStop();
104
155
  if (opts.console) {
105
156
  CLIDisplay.value(I18n.formatMessage("commands.identity-create.labels.identity"), document.id);
@@ -137,8 +188,12 @@ function buildCommandIdentityResolve() {
137
188
  mergeEnv: false
138
189
  });
139
190
  command
191
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
192
+ .choices(Object.values(IdentityConnectorTypes))
193
+ .default(IdentityConnectorTypes.Iota))
140
194
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
141
195
  .option(I18n.formatMessage("commands.common.options.explorer.param"), I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
196
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
142
197
  .action(actionCommandIdentityResolve);
143
198
  return command;
144
199
  }
@@ -146,28 +201,29 @@ function buildCommandIdentityResolve() {
146
201
  * Action the identity resolve command.
147
202
  * @param opts The options for the command.
148
203
  * @param opts.did The identity to resolve.
204
+ * @param opts.connector The connector to perform the operations with.
149
205
  * @param opts.node The node URL.
206
+ * @param opts.network The network to use for rebased connector.
150
207
  * @param opts.explorer The explorer URL.
151
208
  */
152
209
  async function actionCommandIdentityResolve(opts) {
153
210
  const did = CLIParam.stringValue("did", opts.did);
154
211
  const nodeEndpoint = CLIParam.url("node", opts.node);
212
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
213
+ ? CLIParam.stringValue("network", opts.network)
214
+ : undefined;
155
215
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
156
216
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
157
217
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
218
+ if (Is.stringValue(network)) {
219
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
220
+ }
158
221
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
159
222
  CLIDisplay.break();
160
223
  setupVault();
161
- const iotaWalletConnector = new IotaWalletConnector({
162
- config: {
163
- clientOptions: {
164
- nodes: [nodeEndpoint],
165
- localPow: true
166
- }
167
- }
168
- });
169
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
170
- const iotaIdentityConnector = new IotaIdentityConnector({
224
+ const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
225
+ WalletConnectorFactory.register("wallet", () => walletConnector);
226
+ const iotaIdentityResolverConnector = new IotaIdentityResolverConnector({
171
227
  config: {
172
228
  clientOptions: {
173
229
  nodes: [nodeEndpoint],
@@ -178,7 +234,7 @@ async function actionCommandIdentityResolve(opts) {
178
234
  CLIDisplay.task(I18n.formatMessage("commands.identity-resolve.progress.resolvingIdentity"));
179
235
  CLIDisplay.break();
180
236
  CLIDisplay.spinnerStart();
181
- const document = await iotaIdentityConnector.resolveDocument(did);
237
+ const document = await iotaIdentityResolverConnector.resolveDocument(did);
182
238
  CLIDisplay.spinnerStop();
183
239
  if (opts.console) {
184
240
  CLIDisplay.section(I18n.formatMessage("commands.identity-resolve.labels.didDocument"));
@@ -216,7 +272,11 @@ function buildCommandProofCreate() {
216
272
  mergeEnv: true
217
273
  });
218
274
  command
275
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
276
+ .choices(Object.values(IdentityConnectorTypes))
277
+ .default(IdentityConnectorTypes.Iota))
219
278
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
279
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
220
280
  .action(actionCommandProofCreate);
221
281
  return command;
222
282
  }
@@ -226,41 +286,35 @@ function buildCommandProofCreate() {
226
286
  * @param opts.id The id of the verification method to use for the credential.
227
287
  * @param opts.privateKey The private key for the verification method.
228
288
  * @param opts.data The data to create the proof for.
289
+ * @param opts.connector The connector to perform the operations with.
229
290
  * @param opts.node The node URL.
291
+ * @param opts.network The network to use for rebased connector.
230
292
  */
231
293
  async function actionCommandProofCreate(opts) {
232
294
  const id = CLIParam.stringValue("id", opts.id);
233
295
  const privateKey = CLIParam.hexBase64("private-key", opts.privateKey);
234
296
  const data = CLIParam.hexBase64("data", opts.data);
235
297
  const nodeEndpoint = CLIParam.url("node", opts.node);
298
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
299
+ ? CLIParam.stringValue("network", opts.network)
300
+ : undefined;
236
301
  CLIDisplay.value(I18n.formatMessage("commands.proof-create.labels.verificationMethodId"), id);
237
302
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
303
+ if (Is.stringValue(network)) {
304
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
305
+ }
238
306
  CLIDisplay.break();
239
307
  setupVault();
240
308
  const localIdentity = "local";
241
309
  const vaultConnector = VaultConnectorFactory.get("vault");
242
310
  await vaultConnector.addKey(`${localIdentity}/${id}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
243
- const iotaWalletConnector = new IotaWalletConnector({
244
- config: {
245
- clientOptions: {
246
- nodes: [nodeEndpoint],
247
- localPow: true
248
- }
249
- }
250
- });
251
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
252
- const iotaIdentityConnector = new IotaIdentityConnector({
253
- config: {
254
- clientOptions: {
255
- nodes: [nodeEndpoint],
256
- localPow: true
257
- }
258
- }
259
- });
311
+ const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
312
+ WalletConnectorFactory.register("wallet", () => walletConnector);
313
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
260
314
  CLIDisplay.task(I18n.formatMessage("commands.proof-create.progress.creatingProof"));
261
315
  CLIDisplay.break();
262
316
  CLIDisplay.spinnerStart();
263
- const proof = await iotaIdentityConnector.createProof(localIdentity, id, data);
317
+ const proof = await identityConnector.createProof(localIdentity, id, data);
264
318
  CLIDisplay.spinnerStop();
265
319
  if (opts.console) {
266
320
  CLIDisplay.json(proof);
@@ -299,7 +353,11 @@ function buildCommandProofVerify() {
299
353
  mergeEnv: true
300
354
  });
301
355
  command
356
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
357
+ .choices(Object.values(IdentityConnectorTypes))
358
+ .default(IdentityConnectorTypes.Iota))
302
359
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
360
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
303
361
  .action(actionCommandProofVerify);
304
362
  return command;
305
363
  }
@@ -310,7 +368,9 @@ function buildCommandProofVerify() {
310
368
  * @param opts.data The data to verify the proof for.
311
369
  * @param opts.cryptosuite The cryptosuite of the proof.
312
370
  * @param opts.value The proof value.
371
+ * @param opts.connector The connector to perform the operations with.
313
372
  * @param opts.node The node URL.
373
+ * @param opts.network The network to use for rebased connector.
314
374
  */
315
375
  async function actionCommandProofVerify(opts) {
316
376
  const id = CLIParam.stringValue("id", opts.id);
@@ -318,29 +378,21 @@ async function actionCommandProofVerify(opts) {
318
378
  const cryptosuite = CLIParam.stringValue("cryptosuite", opts.cryptosuite);
319
379
  const value = CLIParam.stringValue("value", opts.value);
320
380
  const nodeEndpoint = CLIParam.url("node", opts.node);
381
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
382
+ ? CLIParam.stringValue("network", opts.network)
383
+ : undefined;
321
384
  CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.verificationMethodId"), id);
322
385
  CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.cryptosuite"), cryptosuite);
323
386
  CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.value"), value);
324
387
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
388
+ if (Is.stringValue(network)) {
389
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
390
+ }
325
391
  CLIDisplay.break();
326
392
  setupVault();
327
- const iotaWalletConnector = new IotaWalletConnector({
328
- config: {
329
- clientOptions: {
330
- nodes: [nodeEndpoint],
331
- localPow: true
332
- }
333
- }
334
- });
335
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
336
- const iotaIdentityConnector = new IotaIdentityConnector({
337
- config: {
338
- clientOptions: {
339
- nodes: [nodeEndpoint],
340
- localPow: true
341
- }
342
- }
343
- });
393
+ const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
394
+ WalletConnectorFactory.register("wallet", () => walletConnector);
395
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
344
396
  CLIDisplay.task(I18n.formatMessage("commands.proof-verify.progress.verifyingProof"));
345
397
  CLIDisplay.break();
346
398
  CLIDisplay.spinnerStart();
@@ -352,7 +404,7 @@ async function actionCommandProofVerify(opts) {
352
404
  proofPurpose: "assertionMethod",
353
405
  proofValue: value
354
406
  };
355
- const isVerified = await iotaIdentityConnector.verifyProof(data, proof);
407
+ const isVerified = await identityConnector.verifyProof(data, proof);
356
408
  CLIDisplay.spinnerStop();
357
409
  if (opts.console) {
358
410
  CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.isVerified"), isVerified);
@@ -392,7 +444,11 @@ function buildCommandServiceAdd() {
392
444
  mergeEnv: true
393
445
  });
394
446
  command
447
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
448
+ .choices(Object.values(IdentityConnectorTypes))
449
+ .default(IdentityConnectorTypes.Iota))
395
450
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
451
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
396
452
  .option(I18n.formatMessage("commands.common.options.explorer.param"), I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
397
453
  .action(actionCommandServiceAdd);
398
454
  return command;
@@ -405,6 +461,7 @@ function buildCommandServiceAdd() {
405
461
  * @param opts.id The id of the service to add.
406
462
  * @param opts.type The type of the service to add.
407
463
  * @param opts.endpoint The service endpoint.
464
+ * @param opts.connector The connector to perform the operations with.
408
465
  * @param opts.node The node URL.
409
466
  * @param opts.explorer The explorer URL.
410
467
  */
@@ -415,12 +472,18 @@ async function actionCommandServiceAdd(opts) {
415
472
  const type = CLIParam.stringValue("type", opts.type);
416
473
  const endpoint = CLIParam.url("endpoint", opts.endpoint);
417
474
  const nodeEndpoint = CLIParam.url("node", opts.node);
475
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
476
+ ? CLIParam.stringValue("network", opts.network)
477
+ : undefined;
418
478
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
419
479
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
420
480
  CLIDisplay.value(I18n.formatMessage("commands.service-add.labels.serviceId"), id);
421
481
  CLIDisplay.value(I18n.formatMessage("commands.service-add.labels.serviceType"), type);
422
482
  CLIDisplay.value(I18n.formatMessage("commands.service-add.labels.serviceEndpoint"), endpoint);
423
483
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
484
+ if (Is.stringValue(network)) {
485
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
486
+ }
424
487
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
425
488
  CLIDisplay.break();
426
489
  setupVault();
@@ -428,29 +491,13 @@ async function actionCommandServiceAdd(opts) {
428
491
  const localIdentity = "local";
429
492
  const vaultConnector = VaultConnectorFactory.get("vault");
430
493
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
431
- const iotaWalletConnector = new IotaWalletConnector({
432
- config: {
433
- clientOptions: {
434
- nodes: [nodeEndpoint],
435
- localPow: true
436
- },
437
- vaultSeedId
438
- }
439
- });
440
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
441
- const iotaIdentityConnector = new IotaIdentityConnector({
442
- config: {
443
- clientOptions: {
444
- nodes: [nodeEndpoint],
445
- localPow: true
446
- },
447
- vaultSeedId
448
- }
449
- });
494
+ const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
495
+ WalletConnectorFactory.register("wallet", () => walletConnector);
496
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
450
497
  CLIDisplay.task(I18n.formatMessage("commands.service-add.progress.addingService"));
451
498
  CLIDisplay.break();
452
499
  CLIDisplay.spinnerStart();
453
- const service = await iotaIdentityConnector.addService(localIdentity, did, id, type, endpoint);
500
+ const service = await identityConnector.addService(localIdentity, did, id, type, endpoint);
454
501
  CLIDisplay.spinnerStop();
455
502
  if (Is.stringValue(opts?.json)) {
456
503
  await CLIUtils.writeJsonFile(opts.json, service, opts.mergeJson);
@@ -489,7 +536,11 @@ function buildCommandServiceRemove() {
489
536
  mergeEnv: true
490
537
  });
491
538
  command
539
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
540
+ .choices(Object.values(IdentityConnectorTypes))
541
+ .default(IdentityConnectorTypes.Iota))
492
542
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
543
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
493
544
  .option(I18n.formatMessage("commands.common.options.explorer.param"), I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
494
545
  .action(actionCommandServiceRemove);
495
546
  return command;
@@ -499,16 +550,24 @@ function buildCommandServiceRemove() {
499
550
  * @param opts The options for the command.
500
551
  * @param opts.seed The private key for the controller.
501
552
  * @param opts.id The id of the service to remove.
553
+ * @param opts.connector The connector to perform the operations with.
502
554
  * @param opts.node The node URL.
555
+ * @param opts.network The network to use for rebased connector.
503
556
  * @param opts.explorer The explorer URL.
504
557
  */
505
558
  async function actionCommandServiceRemove(opts) {
506
559
  const seed = CLIParam.hexBase64("seed", opts.seed);
507
560
  const id = CLIParam.stringValue("id", opts.id);
508
561
  const nodeEndpoint = CLIParam.url("node", opts.node);
562
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
563
+ ? CLIParam.stringValue("network", opts.network)
564
+ : undefined;
509
565
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
510
566
  CLIDisplay.value(I18n.formatMessage("commands.service-remove.labels.serviceId"), id);
511
567
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
568
+ if (Is.stringValue(network)) {
569
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
570
+ }
512
571
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
513
572
  CLIDisplay.break();
514
573
  setupVault();
@@ -516,29 +575,13 @@ async function actionCommandServiceRemove(opts) {
516
575
  const localIdentity = "local";
517
576
  const vaultConnector = VaultConnectorFactory.get("vault");
518
577
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
519
- const iotaWalletConnector = new IotaWalletConnector({
520
- config: {
521
- clientOptions: {
522
- nodes: [nodeEndpoint],
523
- localPow: true
524
- },
525
- vaultSeedId
526
- }
527
- });
528
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
529
- const iotaIdentityConnector = new IotaIdentityConnector({
530
- config: {
531
- clientOptions: {
532
- nodes: [nodeEndpoint],
533
- localPow: true
534
- },
535
- vaultSeedId
536
- }
537
- });
578
+ const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
579
+ WalletConnectorFactory.register("wallet", () => walletConnector);
580
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
538
581
  CLIDisplay.task(I18n.formatMessage("commands.service-remove.progress.removingService"));
539
582
  CLIDisplay.break();
540
583
  CLIDisplay.spinnerStart();
541
- await iotaIdentityConnector.removeService(localIdentity, id);
584
+ await identityConnector.removeService(localIdentity, id);
542
585
  CLIDisplay.spinnerStop();
543
586
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaIdentityUtils.didToAddress(DocumentHelper.parse(id).id)}?tab=DID`);
544
587
  CLIDisplay.break();
@@ -570,7 +613,11 @@ function buildCommandVerifiableCredentialCreate() {
570
613
  mergeEnv: true
571
614
  });
572
615
  command
616
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
617
+ .choices(Object.values(IdentityConnectorTypes))
618
+ .default(IdentityConnectorTypes.Iota))
573
619
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
620
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
574
621
  .action(actionCommandVerifiableCredentialCreate);
575
622
  return command;
576
623
  }
@@ -582,6 +629,7 @@ function buildCommandVerifiableCredentialCreate() {
582
629
  * @param opts.credentialId The id of the credential.
583
630
  * @param opts.subjectJson The JSON data for the subject.
584
631
  * @param opts.revocationIndex The revocation index for the credential.
632
+ * @param opts.connector The connector to perform the operations with.
585
633
  * @param opts.node The node URL.
586
634
  */
587
635
  async function actionCommandVerifiableCredentialCreate(opts) {
@@ -591,33 +639,25 @@ async function actionCommandVerifiableCredentialCreate(opts) {
591
639
  const subjectJson = path.resolve(CLIParam.stringValue("subject-json", opts.subjectJson));
592
640
  const revocationIndex = Coerce.number(opts.revocationIndex);
593
641
  const nodeEndpoint = CLIParam.url("node", opts.node);
642
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
643
+ ? CLIParam.stringValue("network", opts.network)
644
+ : undefined;
594
645
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.verificationMethodId"), id);
595
646
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.credentialId"), credentialId);
596
647
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.subjectJson"), subjectJson);
597
648
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.revocationIndex"), revocationIndex);
598
649
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
650
+ if (Is.stringValue(network)) {
651
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
652
+ }
599
653
  CLIDisplay.break();
600
654
  setupVault();
601
655
  const localIdentity = "local";
602
656
  const vaultConnector = VaultConnectorFactory.get("vault");
603
657
  await vaultConnector.addKey(`${localIdentity}/${id}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
604
- const iotaWalletConnector = new IotaWalletConnector({
605
- config: {
606
- clientOptions: {
607
- nodes: [nodeEndpoint],
608
- localPow: true
609
- }
610
- }
611
- });
612
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
613
- const iotaIdentityConnector = new IotaIdentityConnector({
614
- config: {
615
- clientOptions: {
616
- nodes: [nodeEndpoint],
617
- localPow: true
618
- }
619
- }
620
- });
658
+ const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
659
+ WalletConnectorFactory.register("wallet", () => walletConnector);
660
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
621
661
  CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-create.progress.loadingSubjectData"));
622
662
  CLIDisplay.break();
623
663
  const jsonData = await CLIUtils.readJsonFile(subjectJson);
@@ -627,7 +667,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
627
667
  CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-create.progress.creatingVerifiableCredential"));
628
668
  CLIDisplay.break();
629
669
  CLIDisplay.spinnerStart();
630
- const verifiableCredential = await iotaIdentityConnector.createVerifiableCredential(localIdentity, id, credentialId, jsonData, revocationIndex);
670
+ const verifiableCredential = await identityConnector.createVerifiableCredential(localIdentity, id, credentialId, jsonData, revocationIndex);
631
671
  CLIDisplay.spinnerStop();
632
672
  if (opts.console) {
633
673
  CLIDisplay.section(I18n.formatMessage("commands.verifiable-credential-create.labels.verifiableCredential"));
@@ -660,7 +700,11 @@ function buildCommandVerifiableCredentialRevoke() {
660
700
  .requiredOption(I18n.formatMessage("commands.verifiable-credential-revoke.options.did.param"), I18n.formatMessage("commands.verifiable-credential-revoke.options.did.description"))
661
701
  .requiredOption(I18n.formatMessage("commands.verifiable-credential-revoke.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-revoke.options.revocation-index.description"));
662
702
  command
703
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
704
+ .choices(Object.values(IdentityConnectorTypes))
705
+ .default(IdentityConnectorTypes.Iota))
663
706
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
707
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
664
708
  .action(actionCommandVerifiableCredentialRevoke);
665
709
  return command;
666
710
  }
@@ -670,45 +714,37 @@ function buildCommandVerifiableCredentialRevoke() {
670
714
  * @param opts.seed The seed to generate the private key for the controller.
671
715
  * @param opts.did The id of the document to revoke the index.
672
716
  * @param opts.revocationIndex The revocation index for the credential.
717
+ * @param opts.connector The connector to perform the operations with.
673
718
  * @param opts.node The node URL.
719
+ * @param opts.network The network to use for rebased connector.
674
720
  */
675
721
  async function actionCommandVerifiableCredentialRevoke(opts) {
676
722
  const seed = CLIParam.hexBase64("seed", opts.seed);
677
723
  const did = CLIParam.stringValue("did", opts.did);
678
724
  const revocationIndex = CLIParam.integer("revocation-index", opts.revocationIndex);
679
725
  const nodeEndpoint = CLIParam.url("node", opts.node);
726
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
727
+ ? CLIParam.stringValue("network", opts.network)
728
+ : undefined;
680
729
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
681
730
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-revoke.labels.revocationIndex"), revocationIndex);
682
731
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
732
+ if (Is.stringValue(network)) {
733
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
734
+ }
683
735
  CLIDisplay.break();
684
736
  setupVault();
685
737
  const vaultSeedId = "local-seed";
686
738
  const localIdentity = "local";
687
739
  const vaultConnector = VaultConnectorFactory.get("vault");
688
740
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
689
- const iotaWalletConnector = new IotaWalletConnector({
690
- config: {
691
- clientOptions: {
692
- nodes: [nodeEndpoint],
693
- localPow: true
694
- },
695
- vaultSeedId
696
- }
697
- });
698
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
699
- const iotaIdentityConnector = new IotaIdentityConnector({
700
- config: {
701
- clientOptions: {
702
- nodes: [nodeEndpoint],
703
- localPow: true
704
- },
705
- vaultSeedId
706
- }
707
- });
741
+ const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
742
+ WalletConnectorFactory.register("wallet", () => walletConnector);
743
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
708
744
  CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-revoke.progress.revokingCredential"));
709
745
  CLIDisplay.break();
710
746
  CLIDisplay.spinnerStart();
711
- await iotaIdentityConnector.revokeVerifiableCredentials(localIdentity, did, [revocationIndex]);
747
+ await identityConnector.revokeVerifiableCredentials(localIdentity, did, [revocationIndex]);
712
748
  CLIDisplay.spinnerStop();
713
749
  CLIDisplay.done();
714
750
  }
@@ -729,7 +765,11 @@ function buildCommandVerifiableCredentialUnrevoke() {
729
765
  .requiredOption(I18n.formatMessage("commands.verifiable-credential-unrevoke.options.did.param"), I18n.formatMessage("commands.verifiable-credential-unrevoke.options.did.description"))
730
766
  .requiredOption(I18n.formatMessage("commands.verifiable-credential-unrevoke.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-unrevoke.options.revocation-index.description"));
731
767
  command
768
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
769
+ .choices(Object.values(IdentityConnectorTypes))
770
+ .default(IdentityConnectorTypes.Iota))
732
771
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
772
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
733
773
  .action(actionCommandVerifiableCredentialUnrevoke);
734
774
  return command;
735
775
  }
@@ -739,45 +779,37 @@ function buildCommandVerifiableCredentialUnrevoke() {
739
779
  * @param opts.seed The seed to generate the private key for the controller.
740
780
  * @param opts.did The id of the document to unrevoke the index.
741
781
  * @param opts.revocationIndex The revocation index for the credential.
782
+ * @param opts.connector The connector to perform the operations with.
742
783
  * @param opts.node The node URL.
784
+ * @param opts.network The network to use for rebased connector.
743
785
  */
744
786
  async function actionCommandVerifiableCredentialUnrevoke(opts) {
745
787
  const seed = CLIParam.hexBase64("seed", opts.seed);
746
788
  const did = CLIParam.stringValue("did", opts.did);
747
789
  const revocationIndex = CLIParam.integer("revocation-index", opts.revocationIndex);
748
790
  const nodeEndpoint = CLIParam.url("node", opts.node);
791
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
792
+ ? CLIParam.stringValue("network", opts.network)
793
+ : undefined;
749
794
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
750
795
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-unrevoke.labels.revocationIndex"), revocationIndex);
751
796
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
797
+ if (Is.stringValue(network)) {
798
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
799
+ }
752
800
  CLIDisplay.break();
753
801
  setupVault();
754
802
  const vaultSeedId = "local-seed";
755
803
  const localIdentity = "local";
756
804
  const vaultConnector = VaultConnectorFactory.get("vault");
757
805
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
758
- const iotaWalletConnector = new IotaWalletConnector({
759
- config: {
760
- clientOptions: {
761
- nodes: [nodeEndpoint],
762
- localPow: true
763
- },
764
- vaultSeedId
765
- }
766
- });
767
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
768
- const iotaIdentityConnector = new IotaIdentityConnector({
769
- config: {
770
- clientOptions: {
771
- nodes: [nodeEndpoint],
772
- localPow: true
773
- },
774
- vaultSeedId
775
- }
776
- });
806
+ const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
807
+ WalletConnectorFactory.register("wallet", () => walletConnector);
808
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
777
809
  CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-unrevoke.progress.unrevokingCredential"));
778
810
  CLIDisplay.break();
779
811
  CLIDisplay.spinnerStart();
780
- await iotaIdentityConnector.unrevokeVerifiableCredentials(localIdentity, did, [revocationIndex]);
812
+ await identityConnector.unrevokeVerifiableCredentials(localIdentity, did, [revocationIndex]);
781
813
  CLIDisplay.spinnerStop();
782
814
  CLIDisplay.done();
783
815
  }
@@ -803,7 +835,11 @@ function buildCommandVerifiableCredentialVerify() {
803
835
  mergeEnv: true
804
836
  });
805
837
  command
838
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
839
+ .choices(Object.values(IdentityConnectorTypes))
840
+ .default(IdentityConnectorTypes.Iota))
806
841
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
842
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
807
843
  .action(actionCommandVerifiableCredentialVerify);
808
844
  return command;
809
845
  }
@@ -811,36 +847,29 @@ function buildCommandVerifiableCredentialVerify() {
811
847
  * Action the verifiable credential verify command.
812
848
  * @param opts The options for the command.
813
849
  * @param opts.jwt The JSON web token for the verifiable credential.
850
+ * @param opts.connector The connector to perform the operations with.
814
851
  * @param opts.node The node URL.
815
852
  */
816
853
  async function actionCommandVerifiableCredentialVerify(opts) {
817
854
  const jwt = CLIParam.stringValue("jwt", opts.jwt);
818
855
  const nodeEndpoint = CLIParam.url("node", opts.node);
856
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
857
+ ? CLIParam.stringValue("network", opts.network)
858
+ : undefined;
819
859
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-verify.labels.jwt"), jwt);
820
860
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
861
+ if (Is.stringValue(network)) {
862
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
863
+ }
821
864
  CLIDisplay.break();
822
865
  setupVault();
823
- const iotaWalletConnector = new IotaWalletConnector({
824
- config: {
825
- clientOptions: {
826
- nodes: [nodeEndpoint],
827
- localPow: true
828
- }
829
- }
830
- });
831
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
832
- const iotaIdentityConnector = new IotaIdentityConnector({
833
- config: {
834
- clientOptions: {
835
- nodes: [nodeEndpoint],
836
- localPow: true
837
- }
838
- }
839
- });
866
+ const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
867
+ WalletConnectorFactory.register("wallet", () => walletConnector);
868
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
840
869
  CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-verify.progress.verifyingCredential"));
841
870
  CLIDisplay.break();
842
871
  CLIDisplay.spinnerStart();
843
- const verification = await iotaIdentityConnector.checkVerifiableCredential(jwt);
872
+ const verification = await identityConnector.checkVerifiableCredential(jwt);
844
873
  const isVerified = Is.notEmpty(verification.verifiableCredential);
845
874
  const isRevoked = verification.revoked;
846
875
  CLIDisplay.spinnerStop();
@@ -887,7 +916,11 @@ function buildCommandVerificationMethodAdd() {
887
916
  mergeEnv: true
888
917
  });
889
918
  command
919
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
920
+ .choices(Object.values(IdentityConnectorTypes))
921
+ .default(IdentityConnectorTypes.Iota))
890
922
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
923
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
891
924
  .option(I18n.formatMessage("commands.common.options.explorer.param"), I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
892
925
  .action(actionCommandVerificationMethodAdd);
893
926
  return command;
@@ -899,6 +932,7 @@ function buildCommandVerificationMethodAdd() {
899
932
  * @param opts.did The identity of the document to add to.
900
933
  * @param opts.type The type of the verification method to add.
901
934
  * @param opts.id The id of the verification method to add.
935
+ * @param opts.connector The connector to perform the operations with.
902
936
  * @param opts.node The node URL.
903
937
  * @param opts.explorer The explorer URL.
904
938
  */
@@ -907,6 +941,9 @@ async function actionCommandVerificationMethodAdd(opts) {
907
941
  const did = CLIParam.stringValue("did", opts.did);
908
942
  const type = CLIParam.stringValue("type", opts.type);
909
943
  const nodeEndpoint = CLIParam.url("node", opts.node);
944
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
945
+ ? CLIParam.stringValue("network", opts.network)
946
+ : undefined;
910
947
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
911
948
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
912
949
  CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.verificationMethodType"), type);
@@ -914,6 +951,9 @@ async function actionCommandVerificationMethodAdd(opts) {
914
951
  CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.verificationMethodId"), opts?.id);
915
952
  }
916
953
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
954
+ if (Is.stringValue(network)) {
955
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
956
+ }
917
957
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
918
958
  CLIDisplay.break();
919
959
  setupVault();
@@ -921,29 +961,13 @@ async function actionCommandVerificationMethodAdd(opts) {
921
961
  const localIdentity = "local";
922
962
  const vaultConnector = VaultConnectorFactory.get("vault");
923
963
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
924
- const iotaWalletConnector = new IotaWalletConnector({
925
- config: {
926
- clientOptions: {
927
- nodes: [nodeEndpoint],
928
- localPow: true
929
- },
930
- vaultSeedId
931
- }
932
- });
933
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
934
- const iotaIdentityConnector = new IotaIdentityConnector({
935
- config: {
936
- clientOptions: {
937
- nodes: [nodeEndpoint],
938
- localPow: true
939
- },
940
- vaultSeedId
941
- }
942
- });
964
+ const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
965
+ WalletConnectorFactory.register("wallet", () => walletConnector);
966
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
943
967
  CLIDisplay.task(I18n.formatMessage("commands.verification-method-add.progress.addingVerificationMethod"));
944
968
  CLIDisplay.break();
945
969
  CLIDisplay.spinnerStart();
946
- const verificationMethod = await iotaIdentityConnector.addVerificationMethod(localIdentity, did, type, opts?.id);
970
+ const verificationMethod = await identityConnector.addVerificationMethod(localIdentity, did, type, opts?.id);
947
971
  CLIDisplay.spinnerStop();
948
972
  const keyPair = await vaultConnector.getKey(`${localIdentity}/${verificationMethod.id}`);
949
973
  const privateKey = Converter.bytesToBase64(keyPair.privateKey);
@@ -993,7 +1017,11 @@ function buildCommandVerificationMethodRemove() {
993
1017
  mergeEnv: true
994
1018
  });
995
1019
  command
1020
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
1021
+ .choices(Object.values(IdentityConnectorTypes))
1022
+ .default(IdentityConnectorTypes.Iota))
996
1023
  .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
1024
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
997
1025
  .option(I18n.formatMessage("commands.common.options.explorer.param"), I18n.formatMessage("commands.common.options.explorer.description"), "!EXPLORER_URL")
998
1026
  .action(actionCommandVerificationMethodRemove);
999
1027
  return command;
@@ -1003,16 +1031,24 @@ function buildCommandVerificationMethodRemove() {
1003
1031
  * @param opts The options for the command.
1004
1032
  * @param opts.seed The private key for the controller.
1005
1033
  * @param opts.id The id of the verification method to remove.
1034
+ * @param opts.connector The connector to perform the operations with.
1006
1035
  * @param opts.node The node URL.
1007
1036
  * @param opts.explorer The explorer URL.
1037
+ * @param opts.network The network to use for rebased connector.
1008
1038
  */
1009
1039
  async function actionCommandVerificationMethodRemove(opts) {
1010
1040
  const seed = CLIParam.hexBase64("seed", opts.seed);
1011
1041
  const id = CLIParam.stringValue("id", opts.id);
1012
1042
  const nodeEndpoint = CLIParam.url("node", opts.node);
1043
+ const network = opts.connector === IdentityConnectorTypes.IotaRebased
1044
+ ? CLIParam.stringValue("network", opts.network)
1045
+ : undefined;
1013
1046
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
1014
1047
  CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.verificationMethodId"), id);
1015
1048
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
1049
+ if (Is.stringValue(network)) {
1050
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
1051
+ }
1016
1052
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.explorer"), explorerEndpoint);
1017
1053
  CLIDisplay.break();
1018
1054
  setupVault();
@@ -1020,29 +1056,13 @@ async function actionCommandVerificationMethodRemove(opts) {
1020
1056
  const localIdentity = "local";
1021
1057
  const vaultConnector = VaultConnectorFactory.get("vault");
1022
1058
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
1023
- const iotaWalletConnector = new IotaWalletConnector({
1024
- config: {
1025
- clientOptions: {
1026
- nodes: [nodeEndpoint],
1027
- localPow: true
1028
- },
1029
- vaultSeedId
1030
- }
1031
- });
1032
- WalletConnectorFactory.register("wallet", () => iotaWalletConnector);
1033
- const iotaIdentityConnector = new IotaIdentityConnector({
1034
- config: {
1035
- clientOptions: {
1036
- nodes: [nodeEndpoint],
1037
- localPow: true
1038
- },
1039
- vaultSeedId
1040
- }
1041
- });
1059
+ const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
1060
+ WalletConnectorFactory.register("wallet", () => walletConnector);
1061
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
1042
1062
  CLIDisplay.task(I18n.formatMessage("commands.verification-method-remove.progress.removingVerificationMethod"));
1043
1063
  CLIDisplay.break();
1044
1064
  CLIDisplay.spinnerStart();
1045
- await iotaIdentityConnector.removeVerificationMethod(localIdentity, id);
1065
+ await identityConnector.removeVerificationMethod(localIdentity, id);
1046
1066
  CLIDisplay.spinnerStop();
1047
1067
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaIdentityUtils.didToAddress(DocumentHelper.parse(id).id)}?tab=DID`);
1048
1068
  CLIDisplay.break();
@@ -1067,7 +1087,7 @@ class CLI extends CLIBase {
1067
1087
  return this.execute({
1068
1088
  title: "TWIN Identity",
1069
1089
  appName: "twin-identity",
1070
- version: "0.0.3-next.18",
1090
+ version: "0.0.1-next.22",
1071
1091
  icon: "🌍",
1072
1092
  supportsEnvFiles: true,
1073
1093
  overrideOutputWidth: options?.overrideOutputWidth
@@ -1100,4 +1120,4 @@ class CLI extends CLIBase {
1100
1120
  }
1101
1121
  }
1102
1122
 
1103
- export { CLI, actionCommandIdentityCreate, actionCommandIdentityResolve, actionCommandProofCreate, actionCommandProofVerify, actionCommandServiceAdd, actionCommandServiceRemove, actionCommandVerifiableCredentialCreate, actionCommandVerifiableCredentialRevoke, actionCommandVerifiableCredentialUnrevoke, actionCommandVerifiableCredentialVerify, actionCommandVerificationMethodAdd, actionCommandVerificationMethodRemove, buildCommandIdentityCreate, buildCommandIdentityResolve, buildCommandProofCreate, buildCommandProofVerify, buildCommandServiceAdd, buildCommandServiceRemove, buildCommandVerifiableCredentialCreate, buildCommandVerifiableCredentialRevoke, buildCommandVerifiableCredentialUnrevoke, buildCommandVerifiableCredentialVerify, buildCommandVerificationMethodAdd, buildCommandVerificationMethodRemove };
1123
+ export { CLI, IdentityConnectorTypes, actionCommandIdentityCreate, actionCommandIdentityResolve, actionCommandProofCreate, actionCommandProofVerify, actionCommandServiceAdd, actionCommandServiceRemove, actionCommandVerifiableCredentialCreate, actionCommandVerifiableCredentialRevoke, actionCommandVerifiableCredentialUnrevoke, actionCommandVerifiableCredentialVerify, actionCommandVerificationMethodAdd, actionCommandVerificationMethodRemove, buildCommandIdentityCreate, buildCommandIdentityResolve, buildCommandProofCreate, buildCommandProofVerify, buildCommandServiceAdd, buildCommandServiceRemove, buildCommandVerifiableCredentialCreate, buildCommandVerifiableCredentialRevoke, buildCommandVerifiableCredentialUnrevoke, buildCommandVerifiableCredentialVerify, buildCommandVerificationMethodAdd, buildCommandVerificationMethodRemove, setupIdentityConnector, setupVault };