@twin.org/identity-cli 0.0.1 → 0.0.2-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +63 -26
- package/dist/esm/index.mjs +63 -26
- package/dist/locales/en.json +110 -104
- package/dist/types/commands/proofCreate.d.ts +3 -0
- package/dist/types/commands/serviceAdd.d.ts +2 -0
- package/dist/types/commands/serviceRemove.d.ts +2 -0
- package/dist/types/commands/verifiableCredentialCreate.d.ts +2 -0
- package/dist/types/commands/verifiableCredentialRevoke.d.ts +2 -0
- package/dist/types/commands/verifiableCredentialUnrevoke.d.ts +2 -0
- package/dist/types/commands/verificationMethodAdd.d.ts +3 -0
- package/dist/types/commands/verificationMethodRemove.d.ts +2 -0
- package/docs/changelog.md +164 -0
- package/docs/reference/functions/actionCommandServiceRemove.md +6 -0
- package/docs/reference/functions/actionCommandVerifiableCredentialRevoke.md +6 -0
- package/docs/reference/functions/actionCommandVerifiableCredentialUnrevoke.md +6 -0
- package/docs/reference/functions/actionCommandVerificationMethodRemove.md +6 -0
- package/docs/reference/variables/IdentityConnectorTypes.md +1 -1
- package/docs/reference/variables/IdentityResolverConnectorTypes.md +1 -1
- package/locales/en.json +55 -13
- package/package.json +35 -20
package/dist/esm/index.mjs
CHANGED
|
@@ -181,7 +181,7 @@ async function actionCommandIdentityCreate(opts) {
|
|
|
181
181
|
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
182
182
|
const didUrn = Urn.fromValidString(document.id);
|
|
183
183
|
const didParts = didUrn.parts();
|
|
184
|
-
const objectId = didParts[
|
|
184
|
+
const objectId = didParts[didParts.length - 1];
|
|
185
185
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
186
186
|
}
|
|
187
187
|
CLIDisplay.break();
|
|
@@ -261,7 +261,7 @@ async function actionCommandIdentityResolve(opts) {
|
|
|
261
261
|
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
262
262
|
const didUrn = Urn.fromValidString(document.id);
|
|
263
263
|
const didParts = didUrn.parts();
|
|
264
|
-
const objectId = didParts[
|
|
264
|
+
const objectId = didParts[didParts.length - 1];
|
|
265
265
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
266
266
|
}
|
|
267
267
|
CLIDisplay.break();
|
|
@@ -282,7 +282,8 @@ function buildCommandProofCreate() {
|
|
|
282
282
|
.description(I18n.formatMessage("commands.proof-create.description"))
|
|
283
283
|
.requiredOption(I18n.formatMessage("commands.proof-create.options.id.param"), I18n.formatMessage("commands.proof-create.options.id.description"))
|
|
284
284
|
.requiredOption(I18n.formatMessage("commands.proof-create.options.private-key.param"), I18n.formatMessage("commands.proof-create.options.private-key.description"))
|
|
285
|
-
.requiredOption(I18n.formatMessage("commands.proof-create.options.document-filename.param"), I18n.formatMessage("commands.proof-create.options.document-filename.description"))
|
|
285
|
+
.requiredOption(I18n.formatMessage("commands.proof-create.options.document-filename.param"), I18n.formatMessage("commands.proof-create.options.document-filename.description"))
|
|
286
|
+
.option(I18n.formatMessage("commands.proof-create.options.addressIndex.param"), I18n.formatMessage("commands.proof-create.options.addressIndex.description"), "0");
|
|
286
287
|
CLIOptions.output(command, {
|
|
287
288
|
noConsole: true,
|
|
288
289
|
json: true,
|
|
@@ -304,6 +305,8 @@ function buildCommandProofCreate() {
|
|
|
304
305
|
* @param opts The options for the command.
|
|
305
306
|
* @param opts.id The id of the verification method to use for the credential.
|
|
306
307
|
* @param opts.privateKey The private key for the verification method.
|
|
308
|
+
* @param opts.documentFilename The filename of the document to create the proof for.
|
|
309
|
+
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
307
310
|
* @param opts.data The data to create the proof for.
|
|
308
311
|
* @param opts.connector The connector to perform the operations with.
|
|
309
312
|
* @param opts.node The node URL.
|
|
@@ -312,6 +315,7 @@ function buildCommandProofCreate() {
|
|
|
312
315
|
async function actionCommandProofCreate(opts) {
|
|
313
316
|
const id = CLIParam.stringValue("id", opts.id);
|
|
314
317
|
const privateKey = CLIParam.hexBase64("private-key", opts.privateKey);
|
|
318
|
+
const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
|
|
315
319
|
const documentFilename = path.resolve(CLIParam.stringValue("document-filename", opts.documentFilename));
|
|
316
320
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
317
321
|
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
@@ -319,6 +323,7 @@ async function actionCommandProofCreate(opts) {
|
|
|
319
323
|
: undefined;
|
|
320
324
|
CLIDisplay.value(I18n.formatMessage("commands.proof-create.labels.verificationMethodId"), id);
|
|
321
325
|
CLIDisplay.value(I18n.formatMessage("commands.proof-create.labels.documentFilename"), documentFilename);
|
|
326
|
+
CLIDisplay.value(I18n.formatMessage("commands.proof-create.labels.addressIndex"), addressIndex);
|
|
322
327
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
323
328
|
if (Is.stringValue(network)) {
|
|
324
329
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
|
|
@@ -331,7 +336,7 @@ async function actionCommandProofCreate(opts) {
|
|
|
331
336
|
await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
|
|
332
337
|
const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
|
|
333
338
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
334
|
-
const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
|
|
339
|
+
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, addressIndex }, opts.connector);
|
|
335
340
|
CLIDisplay.task(I18n.formatMessage("commands.proof-create.progress.creatingProof"));
|
|
336
341
|
CLIDisplay.break();
|
|
337
342
|
CLIDisplay.spinnerStart();
|
|
@@ -454,7 +459,8 @@ function buildCommandServiceAdd() {
|
|
|
454
459
|
.requiredOption(I18n.formatMessage("commands.service-add.options.did.param"), I18n.formatMessage("commands.service-add.options.did.description"))
|
|
455
460
|
.requiredOption(I18n.formatMessage("commands.service-add.options.id.param"), I18n.formatMessage("commands.service-add.options.id.description"))
|
|
456
461
|
.requiredOption(I18n.formatMessage("commands.service-add.options.type.param"), I18n.formatMessage("commands.service-add.options.type.description"))
|
|
457
|
-
.requiredOption(I18n.formatMessage("commands.service-add.options.endpoint.param"), I18n.formatMessage("commands.service-add.options.endpoint.description"))
|
|
462
|
+
.requiredOption(I18n.formatMessage("commands.service-add.options.endpoint.param"), I18n.formatMessage("commands.service-add.options.endpoint.description"))
|
|
463
|
+
.option(I18n.formatMessage("commands.service-add.options.addressIndex.param"), I18n.formatMessage("commands.service-add.options.addressIndex.description"), "0");
|
|
458
464
|
CLIOptions.output(command, {
|
|
459
465
|
noConsole: true,
|
|
460
466
|
json: true,
|
|
@@ -480,6 +486,7 @@ function buildCommandServiceAdd() {
|
|
|
480
486
|
* @param opts.id The id of the service to add.
|
|
481
487
|
* @param opts.type The type of the service to add.
|
|
482
488
|
* @param opts.endpoint The service endpoint.
|
|
489
|
+
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
483
490
|
* @param opts.connector The connector to perform the operations with.
|
|
484
491
|
* @param opts.node The node URL.
|
|
485
492
|
* @param opts.explorer The explorer URL.
|
|
@@ -490,6 +497,7 @@ async function actionCommandServiceAdd(opts) {
|
|
|
490
497
|
const id = CLIParam.stringValue("id", opts.id);
|
|
491
498
|
const type = CLIParam.stringValue("type", opts.type);
|
|
492
499
|
const endpoint = CLIParam.url("endpoint", opts.endpoint);
|
|
500
|
+
const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
|
|
493
501
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
494
502
|
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
495
503
|
? CLIParam.stringValue("network", opts.network)
|
|
@@ -499,6 +507,7 @@ async function actionCommandServiceAdd(opts) {
|
|
|
499
507
|
CLIDisplay.value(I18n.formatMessage("commands.service-add.labels.serviceId"), id);
|
|
500
508
|
CLIDisplay.value(I18n.formatMessage("commands.service-add.labels.serviceType"), type);
|
|
501
509
|
CLIDisplay.value(I18n.formatMessage("commands.service-add.labels.serviceEndpoint"), endpoint);
|
|
510
|
+
CLIDisplay.value(I18n.formatMessage("commands.service-add.labels.addressIndex"), addressIndex);
|
|
502
511
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
503
512
|
if (Is.stringValue(network)) {
|
|
504
513
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
|
|
@@ -512,7 +521,7 @@ async function actionCommandServiceAdd(opts) {
|
|
|
512
521
|
await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
|
|
513
522
|
const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
|
|
514
523
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
515
|
-
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
|
|
524
|
+
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, addressIndex, vaultSeedId }, opts.connector);
|
|
516
525
|
CLIDisplay.task(I18n.formatMessage("commands.service-add.progress.addingService"));
|
|
517
526
|
CLIDisplay.break();
|
|
518
527
|
CLIDisplay.spinnerStart();
|
|
@@ -531,7 +540,7 @@ async function actionCommandServiceAdd(opts) {
|
|
|
531
540
|
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
532
541
|
const didUrn = Urn.fromValidString(did);
|
|
533
542
|
const didParts = didUrn.parts();
|
|
534
|
-
const objectId = didParts[
|
|
543
|
+
const objectId = didParts[didParts.length - 1];
|
|
535
544
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
536
545
|
}
|
|
537
546
|
CLIDisplay.break();
|
|
@@ -551,7 +560,8 @@ function buildCommandServiceRemove() {
|
|
|
551
560
|
.summary(I18n.formatMessage("commands.service-remove.summary"))
|
|
552
561
|
.description(I18n.formatMessage("commands.service-remove.description"))
|
|
553
562
|
.requiredOption(I18n.formatMessage("commands.service-remove.options.seed.param"), I18n.formatMessage("commands.service-remove.options.seed.description"))
|
|
554
|
-
.requiredOption(I18n.formatMessage("commands.service-remove.options.id.param"), I18n.formatMessage("commands.service-remove.options.id.description"))
|
|
563
|
+
.requiredOption(I18n.formatMessage("commands.service-remove.options.id.param"), I18n.formatMessage("commands.service-remove.options.id.description"))
|
|
564
|
+
.option(I18n.formatMessage("commands.service-remove.options.addressIndex.param"), I18n.formatMessage("commands.service-remove.options.addressIndex.description"), "0");
|
|
555
565
|
CLIOptions.output(command, {
|
|
556
566
|
noConsole: true,
|
|
557
567
|
json: true,
|
|
@@ -578,16 +588,19 @@ function buildCommandServiceRemove() {
|
|
|
578
588
|
* @param opts.node The node URL.
|
|
579
589
|
* @param opts.network The network to use for connector.
|
|
580
590
|
* @param opts.explorer The explorer URL.
|
|
591
|
+
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
581
592
|
*/
|
|
582
593
|
async function actionCommandServiceRemove(opts) {
|
|
583
594
|
const seed = CLIParam.hexBase64("seed", opts.seed);
|
|
584
595
|
const id = CLIParam.stringValue("id", opts.id);
|
|
596
|
+
const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
|
|
585
597
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
586
598
|
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
587
599
|
? CLIParam.stringValue("network", opts.network)
|
|
588
600
|
: undefined;
|
|
589
601
|
const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
|
|
590
602
|
CLIDisplay.value(I18n.formatMessage("commands.service-remove.labels.serviceId"), id);
|
|
603
|
+
CLIDisplay.value(I18n.formatMessage("commands.service-remove.labels.addressIndex"), addressIndex);
|
|
591
604
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
592
605
|
if (Is.stringValue(network)) {
|
|
593
606
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
|
|
@@ -601,7 +614,7 @@ async function actionCommandServiceRemove(opts) {
|
|
|
601
614
|
await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
|
|
602
615
|
const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
|
|
603
616
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
604
|
-
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
|
|
617
|
+
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, addressIndex, vaultSeedId }, opts.connector);
|
|
605
618
|
CLIDisplay.task(I18n.formatMessage("commands.service-remove.progress.removingService"));
|
|
606
619
|
CLIDisplay.break();
|
|
607
620
|
CLIDisplay.spinnerStart();
|
|
@@ -611,7 +624,7 @@ async function actionCommandServiceRemove(opts) {
|
|
|
611
624
|
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
612
625
|
const didUrn = Urn.fromValidString(did);
|
|
613
626
|
const didParts = didUrn.parts();
|
|
614
|
-
const objectId = didParts[
|
|
627
|
+
const objectId = didParts[didParts.length - 1];
|
|
615
628
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
616
629
|
}
|
|
617
630
|
CLIDisplay.break();
|
|
@@ -634,7 +647,8 @@ function buildCommandVerifiableCredentialCreate() {
|
|
|
634
647
|
.requiredOption(I18n.formatMessage("commands.verifiable-credential-create.options.private-key.param"), I18n.formatMessage("commands.verifiable-credential-create.options.private-key.description"))
|
|
635
648
|
.option(I18n.formatMessage("commands.verifiable-credential-create.options.credential-id.param"), I18n.formatMessage("commands.verifiable-credential-create.options.credential-id.description"))
|
|
636
649
|
.requiredOption(I18n.formatMessage("commands.verifiable-credential-create.options.subject-json.param"), I18n.formatMessage("commands.verifiable-credential-create.options.subject-json.description"))
|
|
637
|
-
.option(I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.description"))
|
|
650
|
+
.option(I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.description"))
|
|
651
|
+
.option(I18n.formatMessage("commands.verifiable-credential-create.options.addressIndex.param"), I18n.formatMessage("commands.verifiable-credential-create.options.addressIndex.description"), "0");
|
|
638
652
|
CLIOptions.output(command, {
|
|
639
653
|
noConsole: true,
|
|
640
654
|
json: true,
|
|
@@ -659,6 +673,7 @@ function buildCommandVerifiableCredentialCreate() {
|
|
|
659
673
|
* @param opts.credentialId The id of the credential.
|
|
660
674
|
* @param opts.subjectJson The JSON data for the subject.
|
|
661
675
|
* @param opts.revocationIndex The revocation index for the credential.
|
|
676
|
+
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
662
677
|
* @param opts.connector The connector to perform the operations with.
|
|
663
678
|
* @param opts.node The node URL.
|
|
664
679
|
*/
|
|
@@ -668,6 +683,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
|
|
|
668
683
|
const credentialId = CLIParam.stringValue("credential-id", opts.credentialId);
|
|
669
684
|
const subjectJson = path.resolve(CLIParam.stringValue("subject-json", opts.subjectJson));
|
|
670
685
|
const revocationIndex = Coerce.number(opts.revocationIndex);
|
|
686
|
+
const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
|
|
671
687
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
672
688
|
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
673
689
|
? CLIParam.stringValue("network", opts.network)
|
|
@@ -676,6 +692,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
|
|
|
676
692
|
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.credentialId"), credentialId);
|
|
677
693
|
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.subjectJson"), subjectJson);
|
|
678
694
|
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.revocationIndex"), revocationIndex);
|
|
695
|
+
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.addressIndex"), addressIndex);
|
|
679
696
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
680
697
|
if (Is.stringValue(network)) {
|
|
681
698
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
|
|
@@ -688,7 +705,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
|
|
|
688
705
|
await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
|
|
689
706
|
const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
|
|
690
707
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
691
|
-
const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
|
|
708
|
+
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, addressIndex }, opts.connector);
|
|
692
709
|
CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-create.progress.loadingSubjectData"));
|
|
693
710
|
CLIDisplay.break();
|
|
694
711
|
const jsonData = await CLIUtils.readJsonFile(subjectJson);
|
|
@@ -698,7 +715,9 @@ async function actionCommandVerifiableCredentialCreate(opts) {
|
|
|
698
715
|
CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-create.progress.creatingVerifiableCredential"));
|
|
699
716
|
CLIDisplay.break();
|
|
700
717
|
CLIDisplay.spinnerStart();
|
|
701
|
-
const verifiableCredential = await identityConnector.createVerifiableCredential(localIdentity, id, credentialId, jsonData,
|
|
718
|
+
const verifiableCredential = await identityConnector.createVerifiableCredential(localIdentity, id, credentialId, jsonData, {
|
|
719
|
+
revocationIndex
|
|
720
|
+
});
|
|
702
721
|
CLIDisplay.spinnerStop();
|
|
703
722
|
if (opts.console) {
|
|
704
723
|
CLIDisplay.section(I18n.formatMessage("commands.verifiable-credential-create.labels.verifiableCredential"));
|
|
@@ -729,7 +748,8 @@ function buildCommandVerifiableCredentialRevoke() {
|
|
|
729
748
|
.description(I18n.formatMessage("commands.verifiable-credential-revoke.description"))
|
|
730
749
|
.requiredOption(I18n.formatMessage("commands.verifiable-credential-revoke.options.seed.param"), I18n.formatMessage("commands.verifiable-credential-revoke.options.seed.description"))
|
|
731
750
|
.requiredOption(I18n.formatMessage("commands.verifiable-credential-revoke.options.did.param"), I18n.formatMessage("commands.verifiable-credential-revoke.options.did.description"))
|
|
732
|
-
.requiredOption(I18n.formatMessage("commands.verifiable-credential-revoke.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-revoke.options.revocation-index.description"))
|
|
751
|
+
.requiredOption(I18n.formatMessage("commands.verifiable-credential-revoke.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-revoke.options.revocation-index.description"))
|
|
752
|
+
.option(I18n.formatMessage("commands.verifiable-credential-revoke.options.addressIndex.param"), I18n.formatMessage("commands.verifiable-credential-revoke.options.addressIndex.description"), "0");
|
|
733
753
|
command
|
|
734
754
|
.addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
|
|
735
755
|
.choices(Object.values(IdentityConnectorTypes))
|
|
@@ -748,17 +768,20 @@ function buildCommandVerifiableCredentialRevoke() {
|
|
|
748
768
|
* @param opts.connector The connector to perform the operations with.
|
|
749
769
|
* @param opts.node The node URL.
|
|
750
770
|
* @param opts.network The network to use for connector.
|
|
771
|
+
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
751
772
|
*/
|
|
752
773
|
async function actionCommandVerifiableCredentialRevoke(opts) {
|
|
753
774
|
const seed = CLIParam.hexBase64("seed", opts.seed);
|
|
754
775
|
const did = CLIParam.stringValue("did", opts.did);
|
|
755
776
|
const revocationIndex = CLIParam.integer("revocation-index", opts.revocationIndex);
|
|
777
|
+
const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
|
|
756
778
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
757
779
|
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
758
780
|
? CLIParam.stringValue("network", opts.network)
|
|
759
781
|
: undefined;
|
|
760
782
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
|
|
761
783
|
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-revoke.labels.revocationIndex"), revocationIndex);
|
|
784
|
+
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-revoke.labels.addressIndex"), addressIndex);
|
|
762
785
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
763
786
|
if (Is.stringValue(network)) {
|
|
764
787
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
|
|
@@ -771,7 +794,7 @@ async function actionCommandVerifiableCredentialRevoke(opts) {
|
|
|
771
794
|
await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
|
|
772
795
|
const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
|
|
773
796
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
774
|
-
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
|
|
797
|
+
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, addressIndex, vaultSeedId }, opts.connector);
|
|
775
798
|
CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-revoke.progress.revokingCredential"));
|
|
776
799
|
CLIDisplay.break();
|
|
777
800
|
CLIDisplay.spinnerStart();
|
|
@@ -794,7 +817,8 @@ function buildCommandVerifiableCredentialUnrevoke() {
|
|
|
794
817
|
.description(I18n.formatMessage("commands.verifiable-credential-unrevoke.description"))
|
|
795
818
|
.requiredOption(I18n.formatMessage("commands.verifiable-credential-unrevoke.options.seed.param"), I18n.formatMessage("commands.verifiable-credential-unrevoke.options.seed.description"))
|
|
796
819
|
.requiredOption(I18n.formatMessage("commands.verifiable-credential-unrevoke.options.did.param"), I18n.formatMessage("commands.verifiable-credential-unrevoke.options.did.description"))
|
|
797
|
-
.requiredOption(I18n.formatMessage("commands.verifiable-credential-unrevoke.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-unrevoke.options.revocation-index.description"))
|
|
820
|
+
.requiredOption(I18n.formatMessage("commands.verifiable-credential-unrevoke.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-unrevoke.options.revocation-index.description"))
|
|
821
|
+
.option(I18n.formatMessage("commands.verifiable-credential-unrevoke.options.addressIndex.param"), I18n.formatMessage("commands.verifiable-credential-unrevoke.options.addressIndex.description"), "0");
|
|
798
822
|
command
|
|
799
823
|
.addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
|
|
800
824
|
.choices(Object.values(IdentityConnectorTypes))
|
|
@@ -813,17 +837,20 @@ function buildCommandVerifiableCredentialUnrevoke() {
|
|
|
813
837
|
* @param opts.connector The connector to perform the operations with.
|
|
814
838
|
* @param opts.node The node URL.
|
|
815
839
|
* @param opts.network The network to use for connector.
|
|
840
|
+
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
816
841
|
*/
|
|
817
842
|
async function actionCommandVerifiableCredentialUnrevoke(opts) {
|
|
818
843
|
const seed = CLIParam.hexBase64("seed", opts.seed);
|
|
819
844
|
const did = CLIParam.stringValue("did", opts.did);
|
|
820
845
|
const revocationIndex = CLIParam.integer("revocation-index", opts.revocationIndex);
|
|
846
|
+
const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
|
|
821
847
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
822
848
|
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
823
849
|
? CLIParam.stringValue("network", opts.network)
|
|
824
850
|
: undefined;
|
|
825
851
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
|
|
826
852
|
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-unrevoke.labels.revocationIndex"), revocationIndex);
|
|
853
|
+
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-unrevoke.labels.addressIndex"), addressIndex);
|
|
827
854
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
828
855
|
if (Is.stringValue(network)) {
|
|
829
856
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
|
|
@@ -836,7 +863,7 @@ async function actionCommandVerifiableCredentialUnrevoke(opts) {
|
|
|
836
863
|
await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
|
|
837
864
|
const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
|
|
838
865
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
839
|
-
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
|
|
866
|
+
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, addressIndex, vaultSeedId }, opts.connector);
|
|
840
867
|
CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-unrevoke.progress.unrevokingCredential"));
|
|
841
868
|
CLIDisplay.break();
|
|
842
869
|
CLIDisplay.spinnerStart();
|
|
@@ -938,7 +965,8 @@ function buildCommandVerificationMethodAdd() {
|
|
|
938
965
|
.addOption(new Option(I18n.formatMessage("commands.verification-method-add.options.type.param"), I18n.formatMessage("commands.verification-method-add.options.type.description"))
|
|
939
966
|
.choices(Object.values(DidVerificationMethodType))
|
|
940
967
|
.makeOptionMandatory())
|
|
941
|
-
.option(I18n.formatMessage("commands.verification-method-add.options.id.param"), I18n.formatMessage("commands.verification-method-add.options.id.description"))
|
|
968
|
+
.option(I18n.formatMessage("commands.verification-method-add.options.id.param"), I18n.formatMessage("commands.verification-method-add.options.id.description"))
|
|
969
|
+
.option(I18n.formatMessage("commands.verification-method-add.options.addressIndex.param"), I18n.formatMessage("commands.verification-method-add.options.addressIndex.description"), "0");
|
|
942
970
|
CLIOptions.output(command, {
|
|
943
971
|
noConsole: true,
|
|
944
972
|
json: true,
|
|
@@ -966,11 +994,14 @@ function buildCommandVerificationMethodAdd() {
|
|
|
966
994
|
* @param opts.connector The connector to perform the operations with.
|
|
967
995
|
* @param opts.node The node URL.
|
|
968
996
|
* @param opts.explorer The explorer URL.
|
|
997
|
+
* @param opts.network The network to use for connector.
|
|
998
|
+
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
969
999
|
*/
|
|
970
1000
|
async function actionCommandVerificationMethodAdd(opts) {
|
|
971
1001
|
const seed = CLIParam.hexBase64("seed", opts.seed);
|
|
972
1002
|
const did = CLIParam.stringValue("did", opts.did);
|
|
973
1003
|
const type = CLIParam.stringValue("type", opts.type);
|
|
1004
|
+
const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
|
|
974
1005
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
975
1006
|
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
976
1007
|
? CLIParam.stringValue("network", opts.network)
|
|
@@ -981,6 +1012,7 @@ async function actionCommandVerificationMethodAdd(opts) {
|
|
|
981
1012
|
if (Is.stringValue(opts.id)) {
|
|
982
1013
|
CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.verificationMethodId"), opts?.id);
|
|
983
1014
|
}
|
|
1015
|
+
CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.addressIndex"), addressIndex);
|
|
984
1016
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
985
1017
|
if (Is.stringValue(network)) {
|
|
986
1018
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
|
|
@@ -994,7 +1026,7 @@ async function actionCommandVerificationMethodAdd(opts) {
|
|
|
994
1026
|
await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
|
|
995
1027
|
const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
|
|
996
1028
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
997
|
-
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
|
|
1029
|
+
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, addressIndex, vaultSeedId }, opts.connector);
|
|
998
1030
|
CLIDisplay.task(I18n.formatMessage("commands.verification-method-add.progress.addingVerificationMethod"));
|
|
999
1031
|
CLIDisplay.break();
|
|
1000
1032
|
CLIDisplay.spinnerStart();
|
|
@@ -1038,7 +1070,7 @@ async function actionCommandVerificationMethodAdd(opts) {
|
|
|
1038
1070
|
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
1039
1071
|
const didUrn = Urn.fromValidString(did);
|
|
1040
1072
|
const didParts = didUrn.parts();
|
|
1041
|
-
const objectId = didParts[
|
|
1073
|
+
const objectId = didParts[didParts.length - 1];
|
|
1042
1074
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
1043
1075
|
}
|
|
1044
1076
|
CLIDisplay.break();
|
|
@@ -1058,7 +1090,8 @@ function buildCommandVerificationMethodRemove() {
|
|
|
1058
1090
|
.summary(I18n.formatMessage("commands.verification-method-remove.summary"))
|
|
1059
1091
|
.description(I18n.formatMessage("commands.verification-method-remove.description"))
|
|
1060
1092
|
.requiredOption(I18n.formatMessage("commands.verification-method-remove.options.seed.param"), I18n.formatMessage("commands.verification-method-remove.options.seed.description"))
|
|
1061
|
-
.requiredOption(I18n.formatMessage("commands.verification-method-remove.options.id.param"), I18n.formatMessage("commands.verification-method-remove.options.id.description"))
|
|
1093
|
+
.requiredOption(I18n.formatMessage("commands.verification-method-remove.options.id.param"), I18n.formatMessage("commands.verification-method-remove.options.id.description"))
|
|
1094
|
+
.option(I18n.formatMessage("commands.verification-method-remove.options.addressIndex.param"), I18n.formatMessage("commands.verification-method-remove.options.addressIndex.description"), "0");
|
|
1062
1095
|
CLIOptions.output(command, {
|
|
1063
1096
|
noConsole: true,
|
|
1064
1097
|
json: true,
|
|
@@ -1085,16 +1118,19 @@ function buildCommandVerificationMethodRemove() {
|
|
|
1085
1118
|
* @param opts.node The node URL.
|
|
1086
1119
|
* @param opts.explorer The explorer URL.
|
|
1087
1120
|
* @param opts.network The network to use for connector.
|
|
1121
|
+
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
1088
1122
|
*/
|
|
1089
1123
|
async function actionCommandVerificationMethodRemove(opts) {
|
|
1090
1124
|
const seed = CLIParam.hexBase64("seed", opts.seed);
|
|
1091
1125
|
const id = CLIParam.stringValue("id", opts.id);
|
|
1126
|
+
const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
|
|
1092
1127
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
1093
1128
|
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
1094
1129
|
? CLIParam.stringValue("network", opts.network)
|
|
1095
1130
|
: undefined;
|
|
1096
1131
|
const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
|
|
1097
|
-
CLIDisplay.value(I18n.formatMessage("commands.verification-method-
|
|
1132
|
+
CLIDisplay.value(I18n.formatMessage("commands.verification-method-remove.labels.verificationMethodId"), id);
|
|
1133
|
+
CLIDisplay.value(I18n.formatMessage("commands.verification-method-remove.labels.addressIndex"), addressIndex);
|
|
1098
1134
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
1099
1135
|
if (Is.stringValue(network)) {
|
|
1100
1136
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
|
|
@@ -1108,7 +1144,7 @@ async function actionCommandVerificationMethodRemove(opts) {
|
|
|
1108
1144
|
await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
|
|
1109
1145
|
const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
|
|
1110
1146
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
1111
|
-
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, vaultSeedId }, opts.connector);
|
|
1147
|
+
const identityConnector = setupIdentityConnector({ nodeEndpoint, network, addressIndex, vaultSeedId }, opts.connector);
|
|
1112
1148
|
CLIDisplay.task(I18n.formatMessage("commands.verification-method-remove.progress.removingVerificationMethod"));
|
|
1113
1149
|
CLIDisplay.break();
|
|
1114
1150
|
CLIDisplay.spinnerStart();
|
|
@@ -1118,7 +1154,7 @@ async function actionCommandVerificationMethodRemove(opts) {
|
|
|
1118
1154
|
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
1119
1155
|
const didUrn = Urn.fromValidString(did);
|
|
1120
1156
|
const didParts = didUrn.parts();
|
|
1121
|
-
const objectId = didParts[
|
|
1157
|
+
const objectId = didParts[didParts.length - 1];
|
|
1122
1158
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
1123
1159
|
}
|
|
1124
1160
|
CLIDisplay.break();
|
|
@@ -1143,10 +1179,11 @@ class CLI extends CLIBase {
|
|
|
1143
1179
|
return this.execute({
|
|
1144
1180
|
title: "TWIN Identity",
|
|
1145
1181
|
appName: "twin-identity",
|
|
1146
|
-
version: "0.0.
|
|
1182
|
+
version: "0.0.2-next.10", // x-release-please-version
|
|
1147
1183
|
icon: "🌍",
|
|
1148
1184
|
supportsEnvFiles: true,
|
|
1149
|
-
overrideOutputWidth: options?.overrideOutputWidth
|
|
1185
|
+
overrideOutputWidth: options?.overrideOutputWidth,
|
|
1186
|
+
showDevToolWarning: true
|
|
1150
1187
|
}, localesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), "../locales"), argv);
|
|
1151
1188
|
}
|
|
1152
1189
|
/**
|