@twin.org/identity-cli 0.0.1-next.24 → 0.0.1-next.26

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.
@@ -6,16 +6,16 @@ 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');
9
+ var identityConnectorIotaStardust = require('@twin.org/identity-connector-iota-stardust');
10
10
  var vaultModels = require('@twin.org/vault-models');
11
11
  var walletModels = require('@twin.org/wallet-models');
12
12
  var commander = require('commander');
13
13
  var entityStorageConnectorMemory = require('@twin.org/entity-storage-connector-memory');
14
14
  var entityStorageModels = require('@twin.org/entity-storage-models');
15
- var identityConnectorIotaRebased = require('@twin.org/identity-connector-iota-rebased');
15
+ var identityConnectorIota = require('@twin.org/identity-connector-iota');
16
16
  var vaultConnectorEntityStorage = require('@twin.org/vault-connector-entity-storage');
17
- var standardsW3cDid = require('@twin.org/standards-w3c-did');
18
17
  var identityModels = require('@twin.org/identity-models');
18
+ var standardsW3cDid = require('@twin.org/standards-w3c-did');
19
19
 
20
20
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
21
21
  // Copyright 2024 IOTA Stiftung.
@@ -30,9 +30,9 @@ const IdentityConnectorTypes = {
30
30
  */
31
31
  Iota: "iota",
32
32
  /**
33
- * IOTA Rebased.
33
+ * IOTA Stardust.
34
34
  */
35
- IotaRebased: "iota-rebased"
35
+ IotaStardust: "iota-stardust"
36
36
  };
37
37
 
38
38
  // Copyright 2024 IOTA Stiftung.
@@ -63,8 +63,8 @@ function setupVault() {
63
63
  */
64
64
  function setupIdentityConnector(options, connector) {
65
65
  connector ??= IdentityConnectorTypes.Iota;
66
- if (connector === IdentityConnectorTypes.IotaRebased) {
67
- return new identityConnectorIotaRebased.IotaRebasedIdentityConnector({
66
+ if (connector === IdentityConnectorTypes.Iota) {
67
+ return new identityConnectorIota.IotaIdentityConnector({
68
68
  config: {
69
69
  clientOptions: {
70
70
  url: options.nodeEndpoint
@@ -75,7 +75,7 @@ function setupIdentityConnector(options, connector) {
75
75
  }
76
76
  });
77
77
  }
78
- return new identityConnectorIota.IotaIdentityConnector({
78
+ return new identityConnectorIotaStardust.IotaStardustIdentityConnector({
79
79
  config: {
80
80
  clientOptions: {
81
81
  nodes: [options.nodeEndpoint],
@@ -124,13 +124,13 @@ function buildCommandIdentityCreate() {
124
124
  * @param opts.seed The private key for the controller.
125
125
  * @param opts.connector The connector to perform the operations with.
126
126
  * @param opts.node The node URL.
127
- * @param opts.network The network to use for rebased connector.
127
+ * @param opts.network The network to use for connector.
128
128
  * @param opts.explorer The explorer URL.
129
129
  */
130
130
  async function actionCommandIdentityCreate(opts) {
131
131
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
132
132
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
133
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
133
+ const network = opts.connector === IdentityConnectorTypes.Iota
134
134
  ? cliCore.CLIParam.stringValue("network", opts.network)
135
135
  : undefined;
136
136
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
@@ -165,7 +165,7 @@ async function actionCommandIdentityCreate(opts) {
165
165
  if (core.Is.stringValue(opts?.env)) {
166
166
  await cliCore.CLIUtils.writeEnvFile(opts.env, [`DID="${document.id}"`], opts.mergeEnv);
167
167
  }
168
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(document.id)}?tab=DID`);
168
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(document.id)}?tab=DID`);
169
169
  cliCore.CLIDisplay.break();
170
170
  cliCore.CLIDisplay.done();
171
171
  }
@@ -206,13 +206,13 @@ function buildCommandIdentityResolve() {
206
206
  * @param opts.did The identity to resolve.
207
207
  * @param opts.connector The connector to perform the operations with.
208
208
  * @param opts.node The node URL.
209
- * @param opts.network The network to use for rebased connector.
209
+ * @param opts.network The network to use for connector.
210
210
  * @param opts.explorer The explorer URL.
211
211
  */
212
212
  async function actionCommandIdentityResolve(opts) {
213
213
  const did = cliCore.CLIParam.stringValue("did", opts.did);
214
214
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
215
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
215
+ const network = opts.connector === IdentityConnectorTypes.Iota
216
216
  ? cliCore.CLIParam.stringValue("network", opts.network)
217
217
  : undefined;
218
218
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
@@ -226,7 +226,7 @@ async function actionCommandIdentityResolve(opts) {
226
226
  setupVault();
227
227
  const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
228
228
  walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
229
- const iotaIdentityResolverConnector = new identityConnectorIota.IotaIdentityResolverConnector({
229
+ const iotaIdentityResolverConnector = new identityConnectorIotaStardust.IotaStardustIdentityResolverConnector({
230
230
  config: {
231
231
  clientOptions: {
232
232
  nodes: [nodeEndpoint],
@@ -247,7 +247,7 @@ async function actionCommandIdentityResolve(opts) {
247
247
  if (core.Is.stringValue(opts?.json)) {
248
248
  await cliCore.CLIUtils.writeJsonFile(opts.json, document, opts.mergeJson);
249
249
  }
250
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(document.id)}?tab=DID`);
250
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(document.id)}?tab=DID`);
251
251
  cliCore.CLIDisplay.break();
252
252
  cliCore.CLIDisplay.done();
253
253
  }
@@ -291,14 +291,14 @@ function buildCommandProofCreate() {
291
291
  * @param opts.data The data to create the proof for.
292
292
  * @param opts.connector The connector to perform the operations with.
293
293
  * @param opts.node The node URL.
294
- * @param opts.network The network to use for rebased connector.
294
+ * @param opts.network The network to use for connector.
295
295
  */
296
296
  async function actionCommandProofCreate(opts) {
297
297
  const id = cliCore.CLIParam.stringValue("id", opts.id);
298
298
  const privateKey = cliCore.CLIParam.hexBase64("private-key", opts.privateKey);
299
299
  const data = cliCore.CLIParam.hexBase64("data", opts.data);
300
300
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
301
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
301
+ const network = opts.connector === IdentityConnectorTypes.Iota
302
302
  ? cliCore.CLIParam.stringValue("network", opts.network)
303
303
  : undefined;
304
304
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-create.labels.verificationMethodId"), id);
@@ -309,8 +309,9 @@ async function actionCommandProofCreate(opts) {
309
309
  cliCore.CLIDisplay.break();
310
310
  setupVault();
311
311
  const localIdentity = "local";
312
+ const vmParts = identityModels.DocumentHelper.parseId(id);
312
313
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
313
- await vaultConnector.addKey(`${localIdentity}/${id}`, vaultModels.VaultKeyType.Ed25519, privateKey, new Uint8Array());
314
+ await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, vaultModels.VaultKeyType.Ed25519, privateKey, new Uint8Array());
314
315
  const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
315
316
  walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
316
317
  const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
@@ -373,7 +374,7 @@ function buildCommandProofVerify() {
373
374
  * @param opts.value The proof value.
374
375
  * @param opts.connector The connector to perform the operations with.
375
376
  * @param opts.node The node URL.
376
- * @param opts.network The network to use for rebased connector.
377
+ * @param opts.network The network to use for connector.
377
378
  */
378
379
  async function actionCommandProofVerify(opts) {
379
380
  const id = cliCore.CLIParam.stringValue("id", opts.id);
@@ -381,7 +382,7 @@ async function actionCommandProofVerify(opts) {
381
382
  const cryptosuite = cliCore.CLIParam.stringValue("cryptosuite", opts.cryptosuite);
382
383
  const value = cliCore.CLIParam.stringValue("value", opts.value);
383
384
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
384
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
385
+ const network = opts.connector === IdentityConnectorTypes.Iota
385
386
  ? cliCore.CLIParam.stringValue("network", opts.network)
386
387
  : undefined;
387
388
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.verificationMethodId"), id);
@@ -475,7 +476,7 @@ async function actionCommandServiceAdd(opts) {
475
476
  const type = cliCore.CLIParam.stringValue("type", opts.type);
476
477
  const endpoint = cliCore.CLIParam.url("endpoint", opts.endpoint);
477
478
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
478
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
479
+ const network = opts.connector === IdentityConnectorTypes.Iota
479
480
  ? cliCore.CLIParam.stringValue("network", opts.network)
480
481
  : undefined;
481
482
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
@@ -512,7 +513,7 @@ async function actionCommandServiceAdd(opts) {
512
513
  `DID_SERVICE_ENDPOINT="${service.serviceEndpoint}"`
513
514
  ], opts.mergeEnv);
514
515
  }
515
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(did)}?tab=DID`);
516
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
516
517
  cliCore.CLIDisplay.break();
517
518
  cliCore.CLIDisplay.done();
518
519
  }
@@ -555,14 +556,14 @@ function buildCommandServiceRemove() {
555
556
  * @param opts.id The id of the service to remove.
556
557
  * @param opts.connector The connector to perform the operations with.
557
558
  * @param opts.node The node URL.
558
- * @param opts.network The network to use for rebased connector.
559
+ * @param opts.network The network to use for connector.
559
560
  * @param opts.explorer The explorer URL.
560
561
  */
561
562
  async function actionCommandServiceRemove(opts) {
562
563
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
563
564
  const id = cliCore.CLIParam.stringValue("id", opts.id);
564
565
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
565
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
566
+ const network = opts.connector === IdentityConnectorTypes.Iota
566
567
  ? cliCore.CLIParam.stringValue("network", opts.network)
567
568
  : undefined;
568
569
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
@@ -586,7 +587,7 @@ async function actionCommandServiceRemove(opts) {
586
587
  cliCore.CLIDisplay.spinnerStart();
587
588
  await identityConnector.removeService(localIdentity, id);
588
589
  cliCore.CLIDisplay.spinnerStop();
589
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(identityModels.DocumentHelper.parseId(id).id)}?tab=DID`);
590
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(identityModels.DocumentHelper.parseId(id).id)}?tab=DID`);
590
591
  cliCore.CLIDisplay.break();
591
592
  cliCore.CLIDisplay.done();
592
593
  }
@@ -642,7 +643,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
642
643
  const subjectJson = path.resolve(cliCore.CLIParam.stringValue("subject-json", opts.subjectJson));
643
644
  const revocationIndex = core.Coerce.number(opts.revocationIndex);
644
645
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
645
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
646
+ const network = opts.connector === IdentityConnectorTypes.Iota
646
647
  ? cliCore.CLIParam.stringValue("network", opts.network)
647
648
  : undefined;
648
649
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.verificationMethodId"), id);
@@ -656,8 +657,9 @@ async function actionCommandVerifiableCredentialCreate(opts) {
656
657
  cliCore.CLIDisplay.break();
657
658
  setupVault();
658
659
  const localIdentity = "local";
660
+ const vmParts = identityModels.DocumentHelper.parseId(id);
659
661
  const vaultConnector = vaultModels.VaultConnectorFactory.get("vault");
660
- await vaultConnector.addKey(`${localIdentity}/${id}`, vaultModels.VaultKeyType.Ed25519, privateKey, new Uint8Array());
662
+ await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, vaultModels.VaultKeyType.Ed25519, privateKey, new Uint8Array());
661
663
  const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
662
664
  walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
663
665
  const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
@@ -719,14 +721,14 @@ function buildCommandVerifiableCredentialRevoke() {
719
721
  * @param opts.revocationIndex The revocation index for the credential.
720
722
  * @param opts.connector The connector to perform the operations with.
721
723
  * @param opts.node The node URL.
722
- * @param opts.network The network to use for rebased connector.
724
+ * @param opts.network The network to use for connector.
723
725
  */
724
726
  async function actionCommandVerifiableCredentialRevoke(opts) {
725
727
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
726
728
  const did = cliCore.CLIParam.stringValue("did", opts.did);
727
729
  const revocationIndex = cliCore.CLIParam.integer("revocation-index", opts.revocationIndex);
728
730
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
729
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
731
+ const network = opts.connector === IdentityConnectorTypes.Iota
730
732
  ? cliCore.CLIParam.stringValue("network", opts.network)
731
733
  : undefined;
732
734
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.did"), did);
@@ -784,14 +786,14 @@ function buildCommandVerifiableCredentialUnrevoke() {
784
786
  * @param opts.revocationIndex The revocation index for the credential.
785
787
  * @param opts.connector The connector to perform the operations with.
786
788
  * @param opts.node The node URL.
787
- * @param opts.network The network to use for rebased connector.
789
+ * @param opts.network The network to use for connector.
788
790
  */
789
791
  async function actionCommandVerifiableCredentialUnrevoke(opts) {
790
792
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
791
793
  const did = cliCore.CLIParam.stringValue("did", opts.did);
792
794
  const revocationIndex = cliCore.CLIParam.integer("revocation-index", opts.revocationIndex);
793
795
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
794
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
796
+ const network = opts.connector === IdentityConnectorTypes.Iota
795
797
  ? cliCore.CLIParam.stringValue("network", opts.network)
796
798
  : undefined;
797
799
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.did"), did);
@@ -856,7 +858,7 @@ function buildCommandVerifiableCredentialVerify() {
856
858
  async function actionCommandVerifiableCredentialVerify(opts) {
857
859
  const jwt = cliCore.CLIParam.stringValue("jwt", opts.jwt);
858
860
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
859
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
861
+ const network = opts.connector === IdentityConnectorTypes.Iota
860
862
  ? cliCore.CLIParam.stringValue("network", opts.network)
861
863
  : undefined;
862
864
  cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-verify.labels.jwt"), jwt);
@@ -944,7 +946,7 @@ async function actionCommandVerificationMethodAdd(opts) {
944
946
  const did = cliCore.CLIParam.stringValue("did", opts.did);
945
947
  const type = cliCore.CLIParam.stringValue("type", opts.type);
946
948
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
947
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
949
+ const network = opts.connector === IdentityConnectorTypes.Iota
948
950
  ? cliCore.CLIParam.stringValue("network", opts.network)
949
951
  : undefined;
950
952
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
@@ -972,7 +974,8 @@ async function actionCommandVerificationMethodAdd(opts) {
972
974
  cliCore.CLIDisplay.spinnerStart();
973
975
  const verificationMethod = await identityConnector.addVerificationMethod(localIdentity, did, type, opts?.id);
974
976
  cliCore.CLIDisplay.spinnerStop();
975
- const keyPair = await vaultConnector.getKey(`${localIdentity}/${verificationMethod.id}`);
977
+ const keyParts = identityModels.DocumentHelper.parseId(verificationMethod.id);
978
+ const keyPair = await vaultConnector.getKey(`${localIdentity}/${keyParts.fragment}`);
976
979
  const privateKey = core.Converter.bytesToBase64(keyPair.privateKey);
977
980
  const publicKey = core.Is.uint8Array(keyPair.publicKey)
978
981
  ? core.Converter.bytesToBase64(keyPair.publicKey)
@@ -993,7 +996,7 @@ async function actionCommandVerificationMethodAdd(opts) {
993
996
  `DID_VERIFICATION_METHOD_PUBLIC_KEY="${publicKey}"`
994
997
  ], opts.mergeEnv);
995
998
  }
996
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(did)}?tab=DID`);
999
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
997
1000
  cliCore.CLIDisplay.break();
998
1001
  cliCore.CLIDisplay.done();
999
1002
  }
@@ -1037,13 +1040,13 @@ function buildCommandVerificationMethodRemove() {
1037
1040
  * @param opts.connector The connector to perform the operations with.
1038
1041
  * @param opts.node The node URL.
1039
1042
  * @param opts.explorer The explorer URL.
1040
- * @param opts.network The network to use for rebased connector.
1043
+ * @param opts.network The network to use for connector.
1041
1044
  */
1042
1045
  async function actionCommandVerificationMethodRemove(opts) {
1043
1046
  const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
1044
1047
  const id = cliCore.CLIParam.stringValue("id", opts.id);
1045
1048
  const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
1046
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
1049
+ const network = opts.connector === IdentityConnectorTypes.Iota
1047
1050
  ? cliCore.CLIParam.stringValue("network", opts.network)
1048
1051
  : undefined;
1049
1052
  const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
@@ -1067,7 +1070,7 @@ async function actionCommandVerificationMethodRemove(opts) {
1067
1070
  cliCore.CLIDisplay.spinnerStart();
1068
1071
  await identityConnector.removeVerificationMethod(localIdentity, id);
1069
1072
  cliCore.CLIDisplay.spinnerStop();
1070
- cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIota.IotaIdentityUtils.didToAddress(identityModels.DocumentHelper.parseId(id).id)}?tab=DID`);
1073
+ cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(identityModels.DocumentHelper.parseId(id).id)}?tab=DID`);
1071
1074
  cliCore.CLIDisplay.break();
1072
1075
  cliCore.CLIDisplay.done();
1073
1076
  }
@@ -1090,7 +1093,7 @@ class CLI extends cliCore.CLIBase {
1090
1093
  return this.execute({
1091
1094
  title: "TWIN Identity",
1092
1095
  appName: "twin-identity",
1093
- version: "0.0.1-next.24",
1096
+ version: "0.0.1-next.26",
1094
1097
  icon: "🌍",
1095
1098
  supportsEnvFiles: true,
1096
1099
  overrideOutputWidth: options?.overrideOutputWidth
@@ -4,16 +4,16 @@ import { CLIOptions, CLIParam, CLIDisplay, CLIUtils, CLIBase } from '@twin.org/c
4
4
  import { buildCommandMnemonic, buildCommandAddress } from '@twin.org/crypto-cli';
5
5
  import { setupWalletConnector, buildCommandFaucet, buildCommandTransfer } from '@twin.org/wallet-cli';
6
6
  import { I18n, Is, Converter, StringHelper, Coerce, GeneralError } from '@twin.org/core';
7
- import { IotaIdentityConnector, IotaIdentityUtils, IotaIdentityResolverConnector } from '@twin.org/identity-connector-iota';
7
+ import { IotaStardustIdentityConnector, IotaStardustIdentityUtils, IotaStardustIdentityResolverConnector } from '@twin.org/identity-connector-iota-stardust';
8
8
  import { VaultConnectorFactory, VaultKeyType } from '@twin.org/vault-models';
9
9
  import { WalletConnectorFactory } from '@twin.org/wallet-models';
10
10
  import { Command, Option } from 'commander';
11
11
  import { MemoryEntityStorageConnector } from '@twin.org/entity-storage-connector-memory';
12
12
  import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
13
- import { IotaRebasedIdentityConnector } from '@twin.org/identity-connector-iota-rebased';
13
+ import { IotaIdentityConnector } from '@twin.org/identity-connector-iota';
14
14
  import { initSchema, EntityStorageVaultConnector } from '@twin.org/vault-connector-entity-storage';
15
- import { DidContexts, DidTypes, DidVerificationMethodType } from '@twin.org/standards-w3c-did';
16
15
  import { DocumentHelper } from '@twin.org/identity-models';
16
+ import { DidTypes, DidContexts, DidVerificationMethodType } from '@twin.org/standards-w3c-did';
17
17
 
18
18
  // Copyright 2024 IOTA Stiftung.
19
19
  // SPDX-License-Identifier: Apache-2.0.
@@ -27,9 +27,9 @@ const IdentityConnectorTypes = {
27
27
  */
28
28
  Iota: "iota",
29
29
  /**
30
- * IOTA Rebased.
30
+ * IOTA Stardust.
31
31
  */
32
- IotaRebased: "iota-rebased"
32
+ IotaStardust: "iota-stardust"
33
33
  };
34
34
 
35
35
  // Copyright 2024 IOTA Stiftung.
@@ -60,8 +60,8 @@ function setupVault() {
60
60
  */
61
61
  function setupIdentityConnector(options, connector) {
62
62
  connector ??= IdentityConnectorTypes.Iota;
63
- if (connector === IdentityConnectorTypes.IotaRebased) {
64
- return new IotaRebasedIdentityConnector({
63
+ if (connector === IdentityConnectorTypes.Iota) {
64
+ return new IotaIdentityConnector({
65
65
  config: {
66
66
  clientOptions: {
67
67
  url: options.nodeEndpoint
@@ -72,7 +72,7 @@ function setupIdentityConnector(options, connector) {
72
72
  }
73
73
  });
74
74
  }
75
- return new IotaIdentityConnector({
75
+ return new IotaStardustIdentityConnector({
76
76
  config: {
77
77
  clientOptions: {
78
78
  nodes: [options.nodeEndpoint],
@@ -121,13 +121,13 @@ function buildCommandIdentityCreate() {
121
121
  * @param opts.seed The private key for the controller.
122
122
  * @param opts.connector The connector to perform the operations with.
123
123
  * @param opts.node The node URL.
124
- * @param opts.network The network to use for rebased connector.
124
+ * @param opts.network The network to use for connector.
125
125
  * @param opts.explorer The explorer URL.
126
126
  */
127
127
  async function actionCommandIdentityCreate(opts) {
128
128
  const seed = CLIParam.hexBase64("seed", opts.seed);
129
129
  const nodeEndpoint = CLIParam.url("node", opts.node);
130
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
130
+ const network = opts.connector === IdentityConnectorTypes.Iota
131
131
  ? CLIParam.stringValue("network", opts.network)
132
132
  : undefined;
133
133
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
@@ -162,7 +162,7 @@ async function actionCommandIdentityCreate(opts) {
162
162
  if (Is.stringValue(opts?.env)) {
163
163
  await CLIUtils.writeEnvFile(opts.env, [`DID="${document.id}"`], opts.mergeEnv);
164
164
  }
165
- CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaIdentityUtils.didToAddress(document.id)}?tab=DID`);
165
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(document.id)}?tab=DID`);
166
166
  CLIDisplay.break();
167
167
  CLIDisplay.done();
168
168
  }
@@ -203,13 +203,13 @@ function buildCommandIdentityResolve() {
203
203
  * @param opts.did The identity to resolve.
204
204
  * @param opts.connector The connector to perform the operations with.
205
205
  * @param opts.node The node URL.
206
- * @param opts.network The network to use for rebased connector.
206
+ * @param opts.network The network to use for connector.
207
207
  * @param opts.explorer The explorer URL.
208
208
  */
209
209
  async function actionCommandIdentityResolve(opts) {
210
210
  const did = CLIParam.stringValue("did", opts.did);
211
211
  const nodeEndpoint = CLIParam.url("node", opts.node);
212
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
212
+ const network = opts.connector === IdentityConnectorTypes.Iota
213
213
  ? CLIParam.stringValue("network", opts.network)
214
214
  : undefined;
215
215
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
@@ -223,7 +223,7 @@ async function actionCommandIdentityResolve(opts) {
223
223
  setupVault();
224
224
  const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
225
225
  WalletConnectorFactory.register("wallet", () => walletConnector);
226
- const iotaIdentityResolverConnector = new IotaIdentityResolverConnector({
226
+ const iotaIdentityResolverConnector = new IotaStardustIdentityResolverConnector({
227
227
  config: {
228
228
  clientOptions: {
229
229
  nodes: [nodeEndpoint],
@@ -244,7 +244,7 @@ async function actionCommandIdentityResolve(opts) {
244
244
  if (Is.stringValue(opts?.json)) {
245
245
  await CLIUtils.writeJsonFile(opts.json, document, opts.mergeJson);
246
246
  }
247
- CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaIdentityUtils.didToAddress(document.id)}?tab=DID`);
247
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(document.id)}?tab=DID`);
248
248
  CLIDisplay.break();
249
249
  CLIDisplay.done();
250
250
  }
@@ -288,14 +288,14 @@ function buildCommandProofCreate() {
288
288
  * @param opts.data The data to create the proof for.
289
289
  * @param opts.connector The connector to perform the operations with.
290
290
  * @param opts.node The node URL.
291
- * @param opts.network The network to use for rebased connector.
291
+ * @param opts.network The network to use for connector.
292
292
  */
293
293
  async function actionCommandProofCreate(opts) {
294
294
  const id = CLIParam.stringValue("id", opts.id);
295
295
  const privateKey = CLIParam.hexBase64("private-key", opts.privateKey);
296
296
  const data = CLIParam.hexBase64("data", opts.data);
297
297
  const nodeEndpoint = CLIParam.url("node", opts.node);
298
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
298
+ const network = opts.connector === IdentityConnectorTypes.Iota
299
299
  ? CLIParam.stringValue("network", opts.network)
300
300
  : undefined;
301
301
  CLIDisplay.value(I18n.formatMessage("commands.proof-create.labels.verificationMethodId"), id);
@@ -306,8 +306,9 @@ async function actionCommandProofCreate(opts) {
306
306
  CLIDisplay.break();
307
307
  setupVault();
308
308
  const localIdentity = "local";
309
+ const vmParts = DocumentHelper.parseId(id);
309
310
  const vaultConnector = VaultConnectorFactory.get("vault");
310
- await vaultConnector.addKey(`${localIdentity}/${id}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
311
+ await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
311
312
  const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
312
313
  WalletConnectorFactory.register("wallet", () => walletConnector);
313
314
  const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
@@ -370,7 +371,7 @@ function buildCommandProofVerify() {
370
371
  * @param opts.value The proof value.
371
372
  * @param opts.connector The connector to perform the operations with.
372
373
  * @param opts.node The node URL.
373
- * @param opts.network The network to use for rebased connector.
374
+ * @param opts.network The network to use for connector.
374
375
  */
375
376
  async function actionCommandProofVerify(opts) {
376
377
  const id = CLIParam.stringValue("id", opts.id);
@@ -378,7 +379,7 @@ async function actionCommandProofVerify(opts) {
378
379
  const cryptosuite = CLIParam.stringValue("cryptosuite", opts.cryptosuite);
379
380
  const value = CLIParam.stringValue("value", opts.value);
380
381
  const nodeEndpoint = CLIParam.url("node", opts.node);
381
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
382
+ const network = opts.connector === IdentityConnectorTypes.Iota
382
383
  ? CLIParam.stringValue("network", opts.network)
383
384
  : undefined;
384
385
  CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.verificationMethodId"), id);
@@ -472,7 +473,7 @@ async function actionCommandServiceAdd(opts) {
472
473
  const type = CLIParam.stringValue("type", opts.type);
473
474
  const endpoint = CLIParam.url("endpoint", opts.endpoint);
474
475
  const nodeEndpoint = CLIParam.url("node", opts.node);
475
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
476
+ const network = opts.connector === IdentityConnectorTypes.Iota
476
477
  ? CLIParam.stringValue("network", opts.network)
477
478
  : undefined;
478
479
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
@@ -509,7 +510,7 @@ async function actionCommandServiceAdd(opts) {
509
510
  `DID_SERVICE_ENDPOINT="${service.serviceEndpoint}"`
510
511
  ], opts.mergeEnv);
511
512
  }
512
- CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaIdentityUtils.didToAddress(did)}?tab=DID`);
513
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
513
514
  CLIDisplay.break();
514
515
  CLIDisplay.done();
515
516
  }
@@ -552,14 +553,14 @@ function buildCommandServiceRemove() {
552
553
  * @param opts.id The id of the service to remove.
553
554
  * @param opts.connector The connector to perform the operations with.
554
555
  * @param opts.node The node URL.
555
- * @param opts.network The network to use for rebased connector.
556
+ * @param opts.network The network to use for connector.
556
557
  * @param opts.explorer The explorer URL.
557
558
  */
558
559
  async function actionCommandServiceRemove(opts) {
559
560
  const seed = CLIParam.hexBase64("seed", opts.seed);
560
561
  const id = CLIParam.stringValue("id", opts.id);
561
562
  const nodeEndpoint = CLIParam.url("node", opts.node);
562
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
563
+ const network = opts.connector === IdentityConnectorTypes.Iota
563
564
  ? CLIParam.stringValue("network", opts.network)
564
565
  : undefined;
565
566
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
@@ -583,7 +584,7 @@ async function actionCommandServiceRemove(opts) {
583
584
  CLIDisplay.spinnerStart();
584
585
  await identityConnector.removeService(localIdentity, id);
585
586
  CLIDisplay.spinnerStop();
586
- CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaIdentityUtils.didToAddress(DocumentHelper.parseId(id).id)}?tab=DID`);
587
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(DocumentHelper.parseId(id).id)}?tab=DID`);
587
588
  CLIDisplay.break();
588
589
  CLIDisplay.done();
589
590
  }
@@ -639,7 +640,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
639
640
  const subjectJson = path.resolve(CLIParam.stringValue("subject-json", opts.subjectJson));
640
641
  const revocationIndex = Coerce.number(opts.revocationIndex);
641
642
  const nodeEndpoint = CLIParam.url("node", opts.node);
642
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
643
+ const network = opts.connector === IdentityConnectorTypes.Iota
643
644
  ? CLIParam.stringValue("network", opts.network)
644
645
  : undefined;
645
646
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.verificationMethodId"), id);
@@ -653,8 +654,9 @@ async function actionCommandVerifiableCredentialCreate(opts) {
653
654
  CLIDisplay.break();
654
655
  setupVault();
655
656
  const localIdentity = "local";
657
+ const vmParts = DocumentHelper.parseId(id);
656
658
  const vaultConnector = VaultConnectorFactory.get("vault");
657
- await vaultConnector.addKey(`${localIdentity}/${id}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
659
+ await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
658
660
  const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
659
661
  WalletConnectorFactory.register("wallet", () => walletConnector);
660
662
  const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
@@ -716,14 +718,14 @@ function buildCommandVerifiableCredentialRevoke() {
716
718
  * @param opts.revocationIndex The revocation index for the credential.
717
719
  * @param opts.connector The connector to perform the operations with.
718
720
  * @param opts.node The node URL.
719
- * @param opts.network The network to use for rebased connector.
721
+ * @param opts.network The network to use for connector.
720
722
  */
721
723
  async function actionCommandVerifiableCredentialRevoke(opts) {
722
724
  const seed = CLIParam.hexBase64("seed", opts.seed);
723
725
  const did = CLIParam.stringValue("did", opts.did);
724
726
  const revocationIndex = CLIParam.integer("revocation-index", opts.revocationIndex);
725
727
  const nodeEndpoint = CLIParam.url("node", opts.node);
726
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
728
+ const network = opts.connector === IdentityConnectorTypes.Iota
727
729
  ? CLIParam.stringValue("network", opts.network)
728
730
  : undefined;
729
731
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
@@ -781,14 +783,14 @@ function buildCommandVerifiableCredentialUnrevoke() {
781
783
  * @param opts.revocationIndex The revocation index for the credential.
782
784
  * @param opts.connector The connector to perform the operations with.
783
785
  * @param opts.node The node URL.
784
- * @param opts.network The network to use for rebased connector.
786
+ * @param opts.network The network to use for connector.
785
787
  */
786
788
  async function actionCommandVerifiableCredentialUnrevoke(opts) {
787
789
  const seed = CLIParam.hexBase64("seed", opts.seed);
788
790
  const did = CLIParam.stringValue("did", opts.did);
789
791
  const revocationIndex = CLIParam.integer("revocation-index", opts.revocationIndex);
790
792
  const nodeEndpoint = CLIParam.url("node", opts.node);
791
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
793
+ const network = opts.connector === IdentityConnectorTypes.Iota
792
794
  ? CLIParam.stringValue("network", opts.network)
793
795
  : undefined;
794
796
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
@@ -853,7 +855,7 @@ function buildCommandVerifiableCredentialVerify() {
853
855
  async function actionCommandVerifiableCredentialVerify(opts) {
854
856
  const jwt = CLIParam.stringValue("jwt", opts.jwt);
855
857
  const nodeEndpoint = CLIParam.url("node", opts.node);
856
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
858
+ const network = opts.connector === IdentityConnectorTypes.Iota
857
859
  ? CLIParam.stringValue("network", opts.network)
858
860
  : undefined;
859
861
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-verify.labels.jwt"), jwt);
@@ -941,7 +943,7 @@ async function actionCommandVerificationMethodAdd(opts) {
941
943
  const did = CLIParam.stringValue("did", opts.did);
942
944
  const type = CLIParam.stringValue("type", opts.type);
943
945
  const nodeEndpoint = CLIParam.url("node", opts.node);
944
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
946
+ const network = opts.connector === IdentityConnectorTypes.Iota
945
947
  ? CLIParam.stringValue("network", opts.network)
946
948
  : undefined;
947
949
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
@@ -969,7 +971,8 @@ async function actionCommandVerificationMethodAdd(opts) {
969
971
  CLIDisplay.spinnerStart();
970
972
  const verificationMethod = await identityConnector.addVerificationMethod(localIdentity, did, type, opts?.id);
971
973
  CLIDisplay.spinnerStop();
972
- const keyPair = await vaultConnector.getKey(`${localIdentity}/${verificationMethod.id}`);
974
+ const keyParts = DocumentHelper.parseId(verificationMethod.id);
975
+ const keyPair = await vaultConnector.getKey(`${localIdentity}/${keyParts.fragment}`);
973
976
  const privateKey = Converter.bytesToBase64(keyPair.privateKey);
974
977
  const publicKey = Is.uint8Array(keyPair.publicKey)
975
978
  ? Converter.bytesToBase64(keyPair.publicKey)
@@ -990,7 +993,7 @@ async function actionCommandVerificationMethodAdd(opts) {
990
993
  `DID_VERIFICATION_METHOD_PUBLIC_KEY="${publicKey}"`
991
994
  ], opts.mergeEnv);
992
995
  }
993
- CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaIdentityUtils.didToAddress(did)}?tab=DID`);
996
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
994
997
  CLIDisplay.break();
995
998
  CLIDisplay.done();
996
999
  }
@@ -1034,13 +1037,13 @@ function buildCommandVerificationMethodRemove() {
1034
1037
  * @param opts.connector The connector to perform the operations with.
1035
1038
  * @param opts.node The node URL.
1036
1039
  * @param opts.explorer The explorer URL.
1037
- * @param opts.network The network to use for rebased connector.
1040
+ * @param opts.network The network to use for connector.
1038
1041
  */
1039
1042
  async function actionCommandVerificationMethodRemove(opts) {
1040
1043
  const seed = CLIParam.hexBase64("seed", opts.seed);
1041
1044
  const id = CLIParam.stringValue("id", opts.id);
1042
1045
  const nodeEndpoint = CLIParam.url("node", opts.node);
1043
- const network = opts.connector === IdentityConnectorTypes.IotaRebased
1046
+ const network = opts.connector === IdentityConnectorTypes.Iota
1044
1047
  ? CLIParam.stringValue("network", opts.network)
1045
1048
  : undefined;
1046
1049
  const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
@@ -1064,7 +1067,7 @@ async function actionCommandVerificationMethodRemove(opts) {
1064
1067
  CLIDisplay.spinnerStart();
1065
1068
  await identityConnector.removeVerificationMethod(localIdentity, id);
1066
1069
  CLIDisplay.spinnerStop();
1067
- CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaIdentityUtils.didToAddress(DocumentHelper.parseId(id).id)}?tab=DID`);
1070
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(DocumentHelper.parseId(id).id)}?tab=DID`);
1068
1071
  CLIDisplay.break();
1069
1072
  CLIDisplay.done();
1070
1073
  }
@@ -1087,7 +1090,7 @@ class CLI extends CLIBase {
1087
1090
  return this.execute({
1088
1091
  title: "TWIN Identity",
1089
1092
  appName: "twin-identity",
1090
- version: "0.0.1-next.24",
1093
+ version: "0.0.1-next.26",
1091
1094
  icon: "🌍",
1092
1095
  supportsEnvFiles: true,
1093
1096
  overrideOutputWidth: options?.overrideOutputWidth