@twin.org/identity-cli 0.0.1-next.24 → 0.0.1-next.25
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 +35 -35
- package/dist/esm/index.mjs +36 -36
- package/dist/locales/en.json +862 -859
- package/dist/types/commands/identityCreate.d.ts +1 -1
- package/dist/types/commands/identityResolve.d.ts +1 -1
- package/dist/types/commands/proofCreate.d.ts +1 -1
- package/dist/types/commands/proofVerify.d.ts +1 -1
- package/dist/types/commands/serviceRemove.d.ts +1 -1
- package/dist/types/commands/verifiableCredentialRevoke.d.ts +1 -1
- package/dist/types/commands/verifiableCredentialUnrevoke.d.ts +1 -1
- package/dist/types/commands/verificationMethodRemove.d.ts +1 -1
- package/dist/types/models/identityConnectorTypes.d.ts +2 -2
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/CLI.md +1 -1
- package/docs/reference/functions/actionCommandServiceRemove.md +3 -3
- package/docs/reference/functions/actionCommandVerifiableCredentialRevoke.md +3 -3
- package/docs/reference/functions/actionCommandVerifiableCredentialUnrevoke.md +3 -3
- package/docs/reference/functions/actionCommandVerificationMethodRemove.md +3 -3
- package/docs/reference/functions/setupIdentityConnector.md +3 -3
- package/docs/reference/variables/IdentityConnectorTypes.md +3 -3
- package/package.json +6 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -6,13 +6,13 @@ 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
|
|
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
|
|
15
|
+
var identityConnectorIota = require('@twin.org/identity-connector-iota');
|
|
16
16
|
var vaultConnectorEntityStorage = require('@twin.org/vault-connector-entity-storage');
|
|
17
17
|
var standardsW3cDid = require('@twin.org/standards-w3c-did');
|
|
18
18
|
var identityModels = require('@twin.org/identity-models');
|
|
@@ -30,9 +30,9 @@ const IdentityConnectorTypes = {
|
|
|
30
30
|
*/
|
|
31
31
|
Iota: "iota",
|
|
32
32
|
/**
|
|
33
|
-
* IOTA
|
|
33
|
+
* IOTA Stardust.
|
|
34
34
|
*/
|
|
35
|
-
|
|
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.
|
|
67
|
-
return new
|
|
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
|
|
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
|
|
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.
|
|
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/${
|
|
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
|
|
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.
|
|
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
|
|
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/${
|
|
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
|
|
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.
|
|
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);
|
|
@@ -373,7 +373,7 @@ function buildCommandProofVerify() {
|
|
|
373
373
|
* @param opts.value The proof value.
|
|
374
374
|
* @param opts.connector The connector to perform the operations with.
|
|
375
375
|
* @param opts.node The node URL.
|
|
376
|
-
* @param opts.network The network to use for
|
|
376
|
+
* @param opts.network The network to use for connector.
|
|
377
377
|
*/
|
|
378
378
|
async function actionCommandProofVerify(opts) {
|
|
379
379
|
const id = cliCore.CLIParam.stringValue("id", opts.id);
|
|
@@ -381,7 +381,7 @@ async function actionCommandProofVerify(opts) {
|
|
|
381
381
|
const cryptosuite = cliCore.CLIParam.stringValue("cryptosuite", opts.cryptosuite);
|
|
382
382
|
const value = cliCore.CLIParam.stringValue("value", opts.value);
|
|
383
383
|
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
384
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
384
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
385
385
|
? cliCore.CLIParam.stringValue("network", opts.network)
|
|
386
386
|
: undefined;
|
|
387
387
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.proof-verify.labels.verificationMethodId"), id);
|
|
@@ -475,7 +475,7 @@ async function actionCommandServiceAdd(opts) {
|
|
|
475
475
|
const type = cliCore.CLIParam.stringValue("type", opts.type);
|
|
476
476
|
const endpoint = cliCore.CLIParam.url("endpoint", opts.endpoint);
|
|
477
477
|
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
478
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
478
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
479
479
|
? cliCore.CLIParam.stringValue("network", opts.network)
|
|
480
480
|
: undefined;
|
|
481
481
|
const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
|
|
@@ -512,7 +512,7 @@ async function actionCommandServiceAdd(opts) {
|
|
|
512
512
|
`DID_SERVICE_ENDPOINT="${service.serviceEndpoint}"`
|
|
513
513
|
], opts.mergeEnv);
|
|
514
514
|
}
|
|
515
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${
|
|
515
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
516
516
|
cliCore.CLIDisplay.break();
|
|
517
517
|
cliCore.CLIDisplay.done();
|
|
518
518
|
}
|
|
@@ -555,14 +555,14 @@ function buildCommandServiceRemove() {
|
|
|
555
555
|
* @param opts.id The id of the service to remove.
|
|
556
556
|
* @param opts.connector The connector to perform the operations with.
|
|
557
557
|
* @param opts.node The node URL.
|
|
558
|
-
* @param opts.network The network to use for
|
|
558
|
+
* @param opts.network The network to use for connector.
|
|
559
559
|
* @param opts.explorer The explorer URL.
|
|
560
560
|
*/
|
|
561
561
|
async function actionCommandServiceRemove(opts) {
|
|
562
562
|
const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
|
|
563
563
|
const id = cliCore.CLIParam.stringValue("id", opts.id);
|
|
564
564
|
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
565
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
565
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
566
566
|
? cliCore.CLIParam.stringValue("network", opts.network)
|
|
567
567
|
: undefined;
|
|
568
568
|
const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
|
|
@@ -586,7 +586,7 @@ async function actionCommandServiceRemove(opts) {
|
|
|
586
586
|
cliCore.CLIDisplay.spinnerStart();
|
|
587
587
|
await identityConnector.removeService(localIdentity, id);
|
|
588
588
|
cliCore.CLIDisplay.spinnerStop();
|
|
589
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${
|
|
589
|
+
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
590
|
cliCore.CLIDisplay.break();
|
|
591
591
|
cliCore.CLIDisplay.done();
|
|
592
592
|
}
|
|
@@ -642,7 +642,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
|
|
|
642
642
|
const subjectJson = path.resolve(cliCore.CLIParam.stringValue("subject-json", opts.subjectJson));
|
|
643
643
|
const revocationIndex = core.Coerce.number(opts.revocationIndex);
|
|
644
644
|
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
645
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
645
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
646
646
|
? cliCore.CLIParam.stringValue("network", opts.network)
|
|
647
647
|
: undefined;
|
|
648
648
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-create.labels.verificationMethodId"), id);
|
|
@@ -719,14 +719,14 @@ function buildCommandVerifiableCredentialRevoke() {
|
|
|
719
719
|
* @param opts.revocationIndex The revocation index for the credential.
|
|
720
720
|
* @param opts.connector The connector to perform the operations with.
|
|
721
721
|
* @param opts.node The node URL.
|
|
722
|
-
* @param opts.network The network to use for
|
|
722
|
+
* @param opts.network The network to use for connector.
|
|
723
723
|
*/
|
|
724
724
|
async function actionCommandVerifiableCredentialRevoke(opts) {
|
|
725
725
|
const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
|
|
726
726
|
const did = cliCore.CLIParam.stringValue("did", opts.did);
|
|
727
727
|
const revocationIndex = cliCore.CLIParam.integer("revocation-index", opts.revocationIndex);
|
|
728
728
|
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
729
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
729
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
730
730
|
? cliCore.CLIParam.stringValue("network", opts.network)
|
|
731
731
|
: undefined;
|
|
732
732
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.did"), did);
|
|
@@ -784,14 +784,14 @@ function buildCommandVerifiableCredentialUnrevoke() {
|
|
|
784
784
|
* @param opts.revocationIndex The revocation index for the credential.
|
|
785
785
|
* @param opts.connector The connector to perform the operations with.
|
|
786
786
|
* @param opts.node The node URL.
|
|
787
|
-
* @param opts.network The network to use for
|
|
787
|
+
* @param opts.network The network to use for connector.
|
|
788
788
|
*/
|
|
789
789
|
async function actionCommandVerifiableCredentialUnrevoke(opts) {
|
|
790
790
|
const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
|
|
791
791
|
const did = cliCore.CLIParam.stringValue("did", opts.did);
|
|
792
792
|
const revocationIndex = cliCore.CLIParam.integer("revocation-index", opts.revocationIndex);
|
|
793
793
|
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
794
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
794
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
795
795
|
? cliCore.CLIParam.stringValue("network", opts.network)
|
|
796
796
|
: undefined;
|
|
797
797
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.did"), did);
|
|
@@ -856,7 +856,7 @@ function buildCommandVerifiableCredentialVerify() {
|
|
|
856
856
|
async function actionCommandVerifiableCredentialVerify(opts) {
|
|
857
857
|
const jwt = cliCore.CLIParam.stringValue("jwt", opts.jwt);
|
|
858
858
|
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
859
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
859
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
860
860
|
? cliCore.CLIParam.stringValue("network", opts.network)
|
|
861
861
|
: undefined;
|
|
862
862
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.verifiable-credential-verify.labels.jwt"), jwt);
|
|
@@ -944,7 +944,7 @@ async function actionCommandVerificationMethodAdd(opts) {
|
|
|
944
944
|
const did = cliCore.CLIParam.stringValue("did", opts.did);
|
|
945
945
|
const type = cliCore.CLIParam.stringValue("type", opts.type);
|
|
946
946
|
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
947
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
947
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
948
948
|
? cliCore.CLIParam.stringValue("network", opts.network)
|
|
949
949
|
: undefined;
|
|
950
950
|
const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
|
|
@@ -993,7 +993,7 @@ async function actionCommandVerificationMethodAdd(opts) {
|
|
|
993
993
|
`DID_VERIFICATION_METHOD_PUBLIC_KEY="${publicKey}"`
|
|
994
994
|
], opts.mergeEnv);
|
|
995
995
|
}
|
|
996
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${
|
|
996
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
997
997
|
cliCore.CLIDisplay.break();
|
|
998
998
|
cliCore.CLIDisplay.done();
|
|
999
999
|
}
|
|
@@ -1037,13 +1037,13 @@ function buildCommandVerificationMethodRemove() {
|
|
|
1037
1037
|
* @param opts.connector The connector to perform the operations with.
|
|
1038
1038
|
* @param opts.node The node URL.
|
|
1039
1039
|
* @param opts.explorer The explorer URL.
|
|
1040
|
-
* @param opts.network The network to use for
|
|
1040
|
+
* @param opts.network The network to use for connector.
|
|
1041
1041
|
*/
|
|
1042
1042
|
async function actionCommandVerificationMethodRemove(opts) {
|
|
1043
1043
|
const seed = cliCore.CLIParam.hexBase64("seed", opts.seed);
|
|
1044
1044
|
const id = cliCore.CLIParam.stringValue("id", opts.id);
|
|
1045
1045
|
const nodeEndpoint = cliCore.CLIParam.url("node", opts.node);
|
|
1046
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
1046
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
1047
1047
|
? cliCore.CLIParam.stringValue("network", opts.network)
|
|
1048
1048
|
: undefined;
|
|
1049
1049
|
const explorerEndpoint = cliCore.CLIParam.url("explorer", opts.explorer);
|
|
@@ -1067,7 +1067,7 @@ async function actionCommandVerificationMethodRemove(opts) {
|
|
|
1067
1067
|
cliCore.CLIDisplay.spinnerStart();
|
|
1068
1068
|
await identityConnector.removeVerificationMethod(localIdentity, id);
|
|
1069
1069
|
cliCore.CLIDisplay.spinnerStop();
|
|
1070
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${
|
|
1070
|
+
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
1071
|
cliCore.CLIDisplay.break();
|
|
1072
1072
|
cliCore.CLIDisplay.done();
|
|
1073
1073
|
}
|
|
@@ -1090,7 +1090,7 @@ class CLI extends cliCore.CLIBase {
|
|
|
1090
1090
|
return this.execute({
|
|
1091
1091
|
title: "TWIN Identity",
|
|
1092
1092
|
appName: "twin-identity",
|
|
1093
|
-
version: "0.0.1-next.
|
|
1093
|
+
version: "0.0.1-next.25",
|
|
1094
1094
|
icon: "🌍",
|
|
1095
1095
|
supportsEnvFiles: true,
|
|
1096
1096
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/dist/esm/index.mjs
CHANGED
|
@@ -4,15 +4,15 @@ 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 {
|
|
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 {
|
|
13
|
+
import { IotaIdentityConnector } from '@twin.org/identity-connector-iota';
|
|
14
14
|
import { initSchema, EntityStorageVaultConnector } from '@twin.org/vault-connector-entity-storage';
|
|
15
|
-
import {
|
|
15
|
+
import { DidTypes, DidContexts, DidVerificationMethodType } from '@twin.org/standards-w3c-did';
|
|
16
16
|
import { DocumentHelper } from '@twin.org/identity-models';
|
|
17
17
|
|
|
18
18
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -27,9 +27,9 @@ const IdentityConnectorTypes = {
|
|
|
27
27
|
*/
|
|
28
28
|
Iota: "iota",
|
|
29
29
|
/**
|
|
30
|
-
* IOTA
|
|
30
|
+
* IOTA Stardust.
|
|
31
31
|
*/
|
|
32
|
-
|
|
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.
|
|
64
|
-
return new
|
|
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
|
|
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
|
|
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.
|
|
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/${
|
|
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
|
|
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.
|
|
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
|
|
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/${
|
|
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
|
|
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.
|
|
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);
|
|
@@ -370,7 +370,7 @@ function buildCommandProofVerify() {
|
|
|
370
370
|
* @param opts.value The proof value.
|
|
371
371
|
* @param opts.connector The connector to perform the operations with.
|
|
372
372
|
* @param opts.node The node URL.
|
|
373
|
-
* @param opts.network The network to use for
|
|
373
|
+
* @param opts.network The network to use for connector.
|
|
374
374
|
*/
|
|
375
375
|
async function actionCommandProofVerify(opts) {
|
|
376
376
|
const id = CLIParam.stringValue("id", opts.id);
|
|
@@ -378,7 +378,7 @@ async function actionCommandProofVerify(opts) {
|
|
|
378
378
|
const cryptosuite = CLIParam.stringValue("cryptosuite", opts.cryptosuite);
|
|
379
379
|
const value = CLIParam.stringValue("value", opts.value);
|
|
380
380
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
381
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
381
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
382
382
|
? CLIParam.stringValue("network", opts.network)
|
|
383
383
|
: undefined;
|
|
384
384
|
CLIDisplay.value(I18n.formatMessage("commands.proof-verify.labels.verificationMethodId"), id);
|
|
@@ -472,7 +472,7 @@ async function actionCommandServiceAdd(opts) {
|
|
|
472
472
|
const type = CLIParam.stringValue("type", opts.type);
|
|
473
473
|
const endpoint = CLIParam.url("endpoint", opts.endpoint);
|
|
474
474
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
475
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
475
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
476
476
|
? CLIParam.stringValue("network", opts.network)
|
|
477
477
|
: undefined;
|
|
478
478
|
const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
|
|
@@ -509,7 +509,7 @@ async function actionCommandServiceAdd(opts) {
|
|
|
509
509
|
`DID_SERVICE_ENDPOINT="${service.serviceEndpoint}"`
|
|
510
510
|
], opts.mergeEnv);
|
|
511
511
|
}
|
|
512
|
-
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${
|
|
512
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
513
513
|
CLIDisplay.break();
|
|
514
514
|
CLIDisplay.done();
|
|
515
515
|
}
|
|
@@ -552,14 +552,14 @@ function buildCommandServiceRemove() {
|
|
|
552
552
|
* @param opts.id The id of the service to remove.
|
|
553
553
|
* @param opts.connector The connector to perform the operations with.
|
|
554
554
|
* @param opts.node The node URL.
|
|
555
|
-
* @param opts.network The network to use for
|
|
555
|
+
* @param opts.network The network to use for connector.
|
|
556
556
|
* @param opts.explorer The explorer URL.
|
|
557
557
|
*/
|
|
558
558
|
async function actionCommandServiceRemove(opts) {
|
|
559
559
|
const seed = CLIParam.hexBase64("seed", opts.seed);
|
|
560
560
|
const id = CLIParam.stringValue("id", opts.id);
|
|
561
561
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
562
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
562
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
563
563
|
? CLIParam.stringValue("network", opts.network)
|
|
564
564
|
: undefined;
|
|
565
565
|
const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
|
|
@@ -583,7 +583,7 @@ async function actionCommandServiceRemove(opts) {
|
|
|
583
583
|
CLIDisplay.spinnerStart();
|
|
584
584
|
await identityConnector.removeService(localIdentity, id);
|
|
585
585
|
CLIDisplay.spinnerStop();
|
|
586
|
-
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${
|
|
586
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(DocumentHelper.parseId(id).id)}?tab=DID`);
|
|
587
587
|
CLIDisplay.break();
|
|
588
588
|
CLIDisplay.done();
|
|
589
589
|
}
|
|
@@ -639,7 +639,7 @@ async function actionCommandVerifiableCredentialCreate(opts) {
|
|
|
639
639
|
const subjectJson = path.resolve(CLIParam.stringValue("subject-json", opts.subjectJson));
|
|
640
640
|
const revocationIndex = Coerce.number(opts.revocationIndex);
|
|
641
641
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
642
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
642
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
643
643
|
? CLIParam.stringValue("network", opts.network)
|
|
644
644
|
: undefined;
|
|
645
645
|
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.verificationMethodId"), id);
|
|
@@ -716,14 +716,14 @@ function buildCommandVerifiableCredentialRevoke() {
|
|
|
716
716
|
* @param opts.revocationIndex The revocation index for the credential.
|
|
717
717
|
* @param opts.connector The connector to perform the operations with.
|
|
718
718
|
* @param opts.node The node URL.
|
|
719
|
-
* @param opts.network The network to use for
|
|
719
|
+
* @param opts.network The network to use for connector.
|
|
720
720
|
*/
|
|
721
721
|
async function actionCommandVerifiableCredentialRevoke(opts) {
|
|
722
722
|
const seed = CLIParam.hexBase64("seed", opts.seed);
|
|
723
723
|
const did = CLIParam.stringValue("did", opts.did);
|
|
724
724
|
const revocationIndex = CLIParam.integer("revocation-index", opts.revocationIndex);
|
|
725
725
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
726
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
726
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
727
727
|
? CLIParam.stringValue("network", opts.network)
|
|
728
728
|
: undefined;
|
|
729
729
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
|
|
@@ -781,14 +781,14 @@ function buildCommandVerifiableCredentialUnrevoke() {
|
|
|
781
781
|
* @param opts.revocationIndex The revocation index for the credential.
|
|
782
782
|
* @param opts.connector The connector to perform the operations with.
|
|
783
783
|
* @param opts.node The node URL.
|
|
784
|
-
* @param opts.network The network to use for
|
|
784
|
+
* @param opts.network The network to use for connector.
|
|
785
785
|
*/
|
|
786
786
|
async function actionCommandVerifiableCredentialUnrevoke(opts) {
|
|
787
787
|
const seed = CLIParam.hexBase64("seed", opts.seed);
|
|
788
788
|
const did = CLIParam.stringValue("did", opts.did);
|
|
789
789
|
const revocationIndex = CLIParam.integer("revocation-index", opts.revocationIndex);
|
|
790
790
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
791
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
791
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
792
792
|
? CLIParam.stringValue("network", opts.network)
|
|
793
793
|
: undefined;
|
|
794
794
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.did"), did);
|
|
@@ -853,7 +853,7 @@ function buildCommandVerifiableCredentialVerify() {
|
|
|
853
853
|
async function actionCommandVerifiableCredentialVerify(opts) {
|
|
854
854
|
const jwt = CLIParam.stringValue("jwt", opts.jwt);
|
|
855
855
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
856
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
856
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
857
857
|
? CLIParam.stringValue("network", opts.network)
|
|
858
858
|
: undefined;
|
|
859
859
|
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-verify.labels.jwt"), jwt);
|
|
@@ -941,7 +941,7 @@ async function actionCommandVerificationMethodAdd(opts) {
|
|
|
941
941
|
const did = CLIParam.stringValue("did", opts.did);
|
|
942
942
|
const type = CLIParam.stringValue("type", opts.type);
|
|
943
943
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
944
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
944
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
945
945
|
? CLIParam.stringValue("network", opts.network)
|
|
946
946
|
: undefined;
|
|
947
947
|
const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
|
|
@@ -990,7 +990,7 @@ async function actionCommandVerificationMethodAdd(opts) {
|
|
|
990
990
|
`DID_VERIFICATION_METHOD_PUBLIC_KEY="${publicKey}"`
|
|
991
991
|
], opts.mergeEnv);
|
|
992
992
|
}
|
|
993
|
-
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${
|
|
993
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
994
994
|
CLIDisplay.break();
|
|
995
995
|
CLIDisplay.done();
|
|
996
996
|
}
|
|
@@ -1034,13 +1034,13 @@ function buildCommandVerificationMethodRemove() {
|
|
|
1034
1034
|
* @param opts.connector The connector to perform the operations with.
|
|
1035
1035
|
* @param opts.node The node URL.
|
|
1036
1036
|
* @param opts.explorer The explorer URL.
|
|
1037
|
-
* @param opts.network The network to use for
|
|
1037
|
+
* @param opts.network The network to use for connector.
|
|
1038
1038
|
*/
|
|
1039
1039
|
async function actionCommandVerificationMethodRemove(opts) {
|
|
1040
1040
|
const seed = CLIParam.hexBase64("seed", opts.seed);
|
|
1041
1041
|
const id = CLIParam.stringValue("id", opts.id);
|
|
1042
1042
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
1043
|
-
const network = opts.connector === IdentityConnectorTypes.
|
|
1043
|
+
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
1044
1044
|
? CLIParam.stringValue("network", opts.network)
|
|
1045
1045
|
: undefined;
|
|
1046
1046
|
const explorerEndpoint = CLIParam.url("explorer", opts.explorer);
|
|
@@ -1064,7 +1064,7 @@ async function actionCommandVerificationMethodRemove(opts) {
|
|
|
1064
1064
|
CLIDisplay.spinnerStart();
|
|
1065
1065
|
await identityConnector.removeVerificationMethod(localIdentity, id);
|
|
1066
1066
|
CLIDisplay.spinnerStop();
|
|
1067
|
-
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${
|
|
1067
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(DocumentHelper.parseId(id).id)}?tab=DID`);
|
|
1068
1068
|
CLIDisplay.break();
|
|
1069
1069
|
CLIDisplay.done();
|
|
1070
1070
|
}
|
|
@@ -1087,7 +1087,7 @@ class CLI extends CLIBase {
|
|
|
1087
1087
|
return this.execute({
|
|
1088
1088
|
title: "TWIN Identity",
|
|
1089
1089
|
appName: "twin-identity",
|
|
1090
|
-
version: "0.0.1-next.
|
|
1090
|
+
version: "0.0.1-next.25",
|
|
1091
1091
|
icon: "🌍",
|
|
1092
1092
|
supportsEnvFiles: true,
|
|
1093
1093
|
overrideOutputWidth: options?.overrideOutputWidth
|