@twin.org/identity-cli 0.0.1-next.42 → 0.0.1-next.44
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 +107 -16
- package/dist/esm/index.mjs +109 -20
- package/dist/locales/en.json +2 -1
- package/dist/types/commands/setupCommands.d.ts +14 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/models/identityResolverConnectorTypes.d.ts +17 -0
- package/docs/changelog.md +32 -0
- package/docs/examples.md +5 -3
- package/docs/reference/functions/setupIdentityResolverConnector.md +35 -0
- package/docs/reference/index.md +3 -0
- package/docs/reference/type-aliases/IdentityResolverConnectorTypes.md +5 -0
- package/docs/reference/variables/IdentityResolverConnectorTypes.md +19 -0
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -35,6 +35,23 @@ const IdentityConnectorTypes = {
|
|
|
35
35
|
IotaStardust: "iota-stardust"
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
// Copyright 2024 IOTA Stiftung.
|
|
39
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
40
|
+
/**
|
|
41
|
+
* The identity resolver connector types.
|
|
42
|
+
*/
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
44
|
+
const IdentityResolverConnectorTypes = {
|
|
45
|
+
/**
|
|
46
|
+
* IOTA.
|
|
47
|
+
*/
|
|
48
|
+
Iota: "iota",
|
|
49
|
+
/**
|
|
50
|
+
* IOTA Stardust.
|
|
51
|
+
*/
|
|
52
|
+
IotaStardust: "iota-stardust"
|
|
53
|
+
};
|
|
54
|
+
|
|
38
55
|
// Copyright 2024 IOTA Stiftung.
|
|
39
56
|
// SPDX-License-Identifier: Apache-2.0.
|
|
40
57
|
/**
|
|
@@ -86,6 +103,35 @@ function setupIdentityConnector(options, connector) {
|
|
|
86
103
|
}
|
|
87
104
|
});
|
|
88
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Setup the identity resolver connector for use in the CLI commands.
|
|
108
|
+
* @param options The options for the identity connector.
|
|
109
|
+
* @param options.nodeEndpoint The node endpoint.
|
|
110
|
+
* @param options.network The network.
|
|
111
|
+
* @param connector The connector to use.
|
|
112
|
+
* @returns The identity connector.
|
|
113
|
+
*/
|
|
114
|
+
function setupIdentityResolverConnector(options, connector) {
|
|
115
|
+
connector ??= IdentityResolverConnectorTypes.Iota;
|
|
116
|
+
if (connector === IdentityResolverConnectorTypes.Iota) {
|
|
117
|
+
return new identityConnectorIota.IotaIdentityResolverConnector({
|
|
118
|
+
config: {
|
|
119
|
+
clientOptions: {
|
|
120
|
+
url: options.nodeEndpoint
|
|
121
|
+
},
|
|
122
|
+
network: options.network ?? ""
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return new identityConnectorIotaStardust.IotaStardustIdentityResolverConnector({
|
|
127
|
+
config: {
|
|
128
|
+
clientOptions: {
|
|
129
|
+
nodes: [options.nodeEndpoint],
|
|
130
|
+
localPow: true
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
89
135
|
|
|
90
136
|
// Copyright 2024 IOTA Stiftung.
|
|
91
137
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -165,7 +211,15 @@ async function actionCommandIdentityCreate(opts) {
|
|
|
165
211
|
if (core.Is.stringValue(opts?.env)) {
|
|
166
212
|
await cliCore.CLIUtils.writeEnvFile(opts.env, [`DID="${document.id}"`], opts.mergeEnv);
|
|
167
213
|
}
|
|
168
|
-
|
|
214
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
215
|
+
const didUrn = core.Urn.fromValidString(document.id);
|
|
216
|
+
const didParts = didUrn.parts();
|
|
217
|
+
const objectId = didParts[3];
|
|
218
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(document.id)}?tab=DID`);
|
|
222
|
+
}
|
|
169
223
|
cliCore.CLIDisplay.break();
|
|
170
224
|
cliCore.CLIDisplay.done();
|
|
171
225
|
}
|
|
@@ -226,18 +280,11 @@ async function actionCommandIdentityResolve(opts) {
|
|
|
226
280
|
setupVault();
|
|
227
281
|
const walletConnector = walletCli.setupWalletConnector({ nodeEndpoint, network }, opts.connector);
|
|
228
282
|
walletModels.WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
229
|
-
const
|
|
230
|
-
config: {
|
|
231
|
-
clientOptions: {
|
|
232
|
-
nodes: [nodeEndpoint],
|
|
233
|
-
localPow: true
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
});
|
|
283
|
+
const identityResolverConnector = setupIdentityResolverConnector({ nodeEndpoint, network }, opts.connector);
|
|
237
284
|
cliCore.CLIDisplay.task(core.I18n.formatMessage("commands.identity-resolve.progress.resolvingIdentity"));
|
|
238
285
|
cliCore.CLIDisplay.break();
|
|
239
286
|
cliCore.CLIDisplay.spinnerStart();
|
|
240
|
-
const document = await
|
|
287
|
+
const document = await identityResolverConnector.resolveDocument(did);
|
|
241
288
|
cliCore.CLIDisplay.spinnerStop();
|
|
242
289
|
if (opts.console) {
|
|
243
290
|
cliCore.CLIDisplay.section(core.I18n.formatMessage("commands.identity-resolve.labels.didDocument"));
|
|
@@ -247,7 +294,15 @@ async function actionCommandIdentityResolve(opts) {
|
|
|
247
294
|
if (core.Is.stringValue(opts?.json)) {
|
|
248
295
|
await cliCore.CLIUtils.writeJsonFile(opts.json, document, opts.mergeJson);
|
|
249
296
|
}
|
|
250
|
-
|
|
297
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
298
|
+
const didUrn = core.Urn.fromValidString(document.id);
|
|
299
|
+
const didParts = didUrn.parts();
|
|
300
|
+
const objectId = didParts[3];
|
|
301
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(document.id)}?tab=DID`);
|
|
305
|
+
}
|
|
251
306
|
cliCore.CLIDisplay.break();
|
|
252
307
|
cliCore.CLIDisplay.done();
|
|
253
308
|
}
|
|
@@ -512,7 +567,15 @@ async function actionCommandServiceAdd(opts) {
|
|
|
512
567
|
`DID_SERVICE_ENDPOINT="${service.serviceEndpoint}"`
|
|
513
568
|
], opts.mergeEnv);
|
|
514
569
|
}
|
|
515
|
-
|
|
570
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
571
|
+
const didUrn = core.Urn.fromValidString(did);
|
|
572
|
+
const didParts = didUrn.parts();
|
|
573
|
+
const objectId = didParts[3];
|
|
574
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
578
|
+
}
|
|
516
579
|
cliCore.CLIDisplay.break();
|
|
517
580
|
cliCore.CLIDisplay.done();
|
|
518
581
|
}
|
|
@@ -586,7 +649,16 @@ async function actionCommandServiceRemove(opts) {
|
|
|
586
649
|
cliCore.CLIDisplay.spinnerStart();
|
|
587
650
|
await identityConnector.removeService(localIdentity, id);
|
|
588
651
|
cliCore.CLIDisplay.spinnerStop();
|
|
589
|
-
|
|
652
|
+
const did = identityModels.DocumentHelper.parseId(id).id;
|
|
653
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
654
|
+
const didUrn = core.Urn.fromValidString(did);
|
|
655
|
+
const didParts = didUrn.parts();
|
|
656
|
+
const objectId = didParts[3];
|
|
657
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
660
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
661
|
+
}
|
|
590
662
|
cliCore.CLIDisplay.break();
|
|
591
663
|
cliCore.CLIDisplay.done();
|
|
592
664
|
}
|
|
@@ -995,7 +1067,15 @@ async function actionCommandVerificationMethodAdd(opts) {
|
|
|
995
1067
|
`DID_VERIFICATION_METHOD_PUBLIC_KEY="${publicKey}"`
|
|
996
1068
|
], opts.mergeEnv);
|
|
997
1069
|
}
|
|
998
|
-
|
|
1070
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
1071
|
+
const didUrn = core.Urn.fromValidString(did);
|
|
1072
|
+
const didParts = didUrn.parts();
|
|
1073
|
+
const objectId = didParts[3];
|
|
1074
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
1078
|
+
}
|
|
999
1079
|
cliCore.CLIDisplay.break();
|
|
1000
1080
|
cliCore.CLIDisplay.done();
|
|
1001
1081
|
}
|
|
@@ -1069,7 +1149,16 @@ async function actionCommandVerificationMethodRemove(opts) {
|
|
|
1069
1149
|
cliCore.CLIDisplay.spinnerStart();
|
|
1070
1150
|
await identityConnector.removeVerificationMethod(localIdentity, id);
|
|
1071
1151
|
cliCore.CLIDisplay.spinnerStop();
|
|
1072
|
-
|
|
1152
|
+
const did = identityModels.DocumentHelper.parseId(id).id;
|
|
1153
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
1154
|
+
const didUrn = core.Urn.fromValidString(did);
|
|
1155
|
+
const didParts = didUrn.parts();
|
|
1156
|
+
const objectId = didParts[3];
|
|
1157
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
1158
|
+
}
|
|
1159
|
+
else {
|
|
1160
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.common.labels.explore"), `${core.StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${identityConnectorIotaStardust.IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
1161
|
+
}
|
|
1073
1162
|
cliCore.CLIDisplay.break();
|
|
1074
1163
|
cliCore.CLIDisplay.done();
|
|
1075
1164
|
}
|
|
@@ -1092,7 +1181,7 @@ class CLI extends cliCore.CLIBase {
|
|
|
1092
1181
|
return this.execute({
|
|
1093
1182
|
title: "TWIN Identity",
|
|
1094
1183
|
appName: "twin-identity",
|
|
1095
|
-
version: "0.0.1-next.
|
|
1184
|
+
version: "0.0.1-next.44", // x-release-please-version
|
|
1096
1185
|
icon: "🌍",
|
|
1097
1186
|
supportsEnvFiles: true,
|
|
1098
1187
|
overrideOutputWidth: options?.overrideOutputWidth
|
|
@@ -1127,6 +1216,7 @@ class CLI extends cliCore.CLIBase {
|
|
|
1127
1216
|
|
|
1128
1217
|
exports.CLI = CLI;
|
|
1129
1218
|
exports.IdentityConnectorTypes = IdentityConnectorTypes;
|
|
1219
|
+
exports.IdentityResolverConnectorTypes = IdentityResolverConnectorTypes;
|
|
1130
1220
|
exports.actionCommandIdentityCreate = actionCommandIdentityCreate;
|
|
1131
1221
|
exports.actionCommandIdentityResolve = actionCommandIdentityResolve;
|
|
1132
1222
|
exports.actionCommandProofCreate = actionCommandProofCreate;
|
|
@@ -1152,4 +1242,5 @@ exports.buildCommandVerifiableCredentialVerify = buildCommandVerifiableCredentia
|
|
|
1152
1242
|
exports.buildCommandVerificationMethodAdd = buildCommandVerificationMethodAdd;
|
|
1153
1243
|
exports.buildCommandVerificationMethodRemove = buildCommandVerificationMethodRemove;
|
|
1154
1244
|
exports.setupIdentityConnector = setupIdentityConnector;
|
|
1245
|
+
exports.setupIdentityResolverConnector = setupIdentityResolverConnector;
|
|
1155
1246
|
exports.setupVault = setupVault;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -3,14 +3,14 @@ import { fileURLToPath } from 'node:url';
|
|
|
3
3
|
import { CLIOptions, CLIParam, CLIDisplay, CLIUtils, CLIBase } from '@twin.org/cli-core';
|
|
4
4
|
import { buildCommandMnemonic, buildCommandAddress } from '@twin.org/crypto-cli';
|
|
5
5
|
import { setupWalletConnector, buildCommandFaucet, buildCommandTransfer } from '@twin.org/wallet-cli';
|
|
6
|
-
import { I18n, Is, Converter, StringHelper, GeneralError, Coerce } from '@twin.org/core';
|
|
7
|
-
import { IotaStardustIdentityConnector,
|
|
6
|
+
import { I18n, Is, Converter, Urn, StringHelper, GeneralError, Coerce } from '@twin.org/core';
|
|
7
|
+
import { IotaStardustIdentityConnector, IotaStardustIdentityResolverConnector, IotaStardustIdentityUtils } 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 { IotaIdentityConnector } from '@twin.org/identity-connector-iota';
|
|
13
|
+
import { IotaIdentityConnector, IotaIdentityResolverConnector } from '@twin.org/identity-connector-iota';
|
|
14
14
|
import { initSchema, EntityStorageVaultConnector } from '@twin.org/vault-connector-entity-storage';
|
|
15
15
|
import { DocumentHelper } from '@twin.org/identity-models';
|
|
16
16
|
import { ProofTypes, DidVerificationMethodType } from '@twin.org/standards-w3c-did';
|
|
@@ -32,6 +32,23 @@ const IdentityConnectorTypes = {
|
|
|
32
32
|
IotaStardust: "iota-stardust"
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
// Copyright 2024 IOTA Stiftung.
|
|
36
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
37
|
+
/**
|
|
38
|
+
* The identity resolver connector types.
|
|
39
|
+
*/
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
41
|
+
const IdentityResolverConnectorTypes = {
|
|
42
|
+
/**
|
|
43
|
+
* IOTA.
|
|
44
|
+
*/
|
|
45
|
+
Iota: "iota",
|
|
46
|
+
/**
|
|
47
|
+
* IOTA Stardust.
|
|
48
|
+
*/
|
|
49
|
+
IotaStardust: "iota-stardust"
|
|
50
|
+
};
|
|
51
|
+
|
|
35
52
|
// Copyright 2024 IOTA Stiftung.
|
|
36
53
|
// SPDX-License-Identifier: Apache-2.0.
|
|
37
54
|
/**
|
|
@@ -83,6 +100,35 @@ function setupIdentityConnector(options, connector) {
|
|
|
83
100
|
}
|
|
84
101
|
});
|
|
85
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Setup the identity resolver connector for use in the CLI commands.
|
|
105
|
+
* @param options The options for the identity connector.
|
|
106
|
+
* @param options.nodeEndpoint The node endpoint.
|
|
107
|
+
* @param options.network The network.
|
|
108
|
+
* @param connector The connector to use.
|
|
109
|
+
* @returns The identity connector.
|
|
110
|
+
*/
|
|
111
|
+
function setupIdentityResolverConnector(options, connector) {
|
|
112
|
+
connector ??= IdentityResolverConnectorTypes.Iota;
|
|
113
|
+
if (connector === IdentityResolverConnectorTypes.Iota) {
|
|
114
|
+
return new IotaIdentityResolverConnector({
|
|
115
|
+
config: {
|
|
116
|
+
clientOptions: {
|
|
117
|
+
url: options.nodeEndpoint
|
|
118
|
+
},
|
|
119
|
+
network: options.network ?? ""
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return new IotaStardustIdentityResolverConnector({
|
|
124
|
+
config: {
|
|
125
|
+
clientOptions: {
|
|
126
|
+
nodes: [options.nodeEndpoint],
|
|
127
|
+
localPow: true
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
86
132
|
|
|
87
133
|
// Copyright 2024 IOTA Stiftung.
|
|
88
134
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -162,7 +208,15 @@ async function actionCommandIdentityCreate(opts) {
|
|
|
162
208
|
if (Is.stringValue(opts?.env)) {
|
|
163
209
|
await CLIUtils.writeEnvFile(opts.env, [`DID="${document.id}"`], opts.mergeEnv);
|
|
164
210
|
}
|
|
165
|
-
|
|
211
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
212
|
+
const didUrn = Urn.fromValidString(document.id);
|
|
213
|
+
const didParts = didUrn.parts();
|
|
214
|
+
const objectId = didParts[3];
|
|
215
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(document.id)}?tab=DID`);
|
|
219
|
+
}
|
|
166
220
|
CLIDisplay.break();
|
|
167
221
|
CLIDisplay.done();
|
|
168
222
|
}
|
|
@@ -223,18 +277,11 @@ async function actionCommandIdentityResolve(opts) {
|
|
|
223
277
|
setupVault();
|
|
224
278
|
const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
|
|
225
279
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
226
|
-
const
|
|
227
|
-
config: {
|
|
228
|
-
clientOptions: {
|
|
229
|
-
nodes: [nodeEndpoint],
|
|
230
|
-
localPow: true
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
});
|
|
280
|
+
const identityResolverConnector = setupIdentityResolverConnector({ nodeEndpoint, network }, opts.connector);
|
|
234
281
|
CLIDisplay.task(I18n.formatMessage("commands.identity-resolve.progress.resolvingIdentity"));
|
|
235
282
|
CLIDisplay.break();
|
|
236
283
|
CLIDisplay.spinnerStart();
|
|
237
|
-
const document = await
|
|
284
|
+
const document = await identityResolverConnector.resolveDocument(did);
|
|
238
285
|
CLIDisplay.spinnerStop();
|
|
239
286
|
if (opts.console) {
|
|
240
287
|
CLIDisplay.section(I18n.formatMessage("commands.identity-resolve.labels.didDocument"));
|
|
@@ -244,7 +291,15 @@ async function actionCommandIdentityResolve(opts) {
|
|
|
244
291
|
if (Is.stringValue(opts?.json)) {
|
|
245
292
|
await CLIUtils.writeJsonFile(opts.json, document, opts.mergeJson);
|
|
246
293
|
}
|
|
247
|
-
|
|
294
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
295
|
+
const didUrn = Urn.fromValidString(document.id);
|
|
296
|
+
const didParts = didUrn.parts();
|
|
297
|
+
const objectId = didParts[3];
|
|
298
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(document.id)}?tab=DID`);
|
|
302
|
+
}
|
|
248
303
|
CLIDisplay.break();
|
|
249
304
|
CLIDisplay.done();
|
|
250
305
|
}
|
|
@@ -509,7 +564,15 @@ async function actionCommandServiceAdd(opts) {
|
|
|
509
564
|
`DID_SERVICE_ENDPOINT="${service.serviceEndpoint}"`
|
|
510
565
|
], opts.mergeEnv);
|
|
511
566
|
}
|
|
512
|
-
|
|
567
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
568
|
+
const didUrn = Urn.fromValidString(did);
|
|
569
|
+
const didParts = didUrn.parts();
|
|
570
|
+
const objectId = didParts[3];
|
|
571
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
575
|
+
}
|
|
513
576
|
CLIDisplay.break();
|
|
514
577
|
CLIDisplay.done();
|
|
515
578
|
}
|
|
@@ -583,7 +646,16 @@ async function actionCommandServiceRemove(opts) {
|
|
|
583
646
|
CLIDisplay.spinnerStart();
|
|
584
647
|
await identityConnector.removeService(localIdentity, id);
|
|
585
648
|
CLIDisplay.spinnerStop();
|
|
586
|
-
|
|
649
|
+
const did = DocumentHelper.parseId(id).id;
|
|
650
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
651
|
+
const didUrn = Urn.fromValidString(did);
|
|
652
|
+
const didParts = didUrn.parts();
|
|
653
|
+
const objectId = didParts[3];
|
|
654
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
658
|
+
}
|
|
587
659
|
CLIDisplay.break();
|
|
588
660
|
CLIDisplay.done();
|
|
589
661
|
}
|
|
@@ -992,7 +1064,15 @@ async function actionCommandVerificationMethodAdd(opts) {
|
|
|
992
1064
|
`DID_VERIFICATION_METHOD_PUBLIC_KEY="${publicKey}"`
|
|
993
1065
|
], opts.mergeEnv);
|
|
994
1066
|
}
|
|
995
|
-
|
|
1067
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
1068
|
+
const didUrn = Urn.fromValidString(did);
|
|
1069
|
+
const didParts = didUrn.parts();
|
|
1070
|
+
const objectId = didParts[3];
|
|
1071
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
1075
|
+
}
|
|
996
1076
|
CLIDisplay.break();
|
|
997
1077
|
CLIDisplay.done();
|
|
998
1078
|
}
|
|
@@ -1066,7 +1146,16 @@ async function actionCommandVerificationMethodRemove(opts) {
|
|
|
1066
1146
|
CLIDisplay.spinnerStart();
|
|
1067
1147
|
await identityConnector.removeVerificationMethod(localIdentity, id);
|
|
1068
1148
|
CLIDisplay.spinnerStop();
|
|
1069
|
-
|
|
1149
|
+
const did = DocumentHelper.parseId(id).id;
|
|
1150
|
+
if (opts.connector === IdentityConnectorTypes.Iota) {
|
|
1151
|
+
const didUrn = Urn.fromValidString(did);
|
|
1152
|
+
const didParts = didUrn.parts();
|
|
1153
|
+
const objectId = didParts[3];
|
|
1154
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`);
|
|
1155
|
+
}
|
|
1156
|
+
else {
|
|
1157
|
+
CLIDisplay.value(I18n.formatMessage("commands.common.labels.explore"), `${StringHelper.trimTrailingSlashes(explorerEndpoint)}/addr/${IotaStardustIdentityUtils.didToAddress(did)}?tab=DID`);
|
|
1158
|
+
}
|
|
1070
1159
|
CLIDisplay.break();
|
|
1071
1160
|
CLIDisplay.done();
|
|
1072
1161
|
}
|
|
@@ -1089,7 +1178,7 @@ class CLI extends CLIBase {
|
|
|
1089
1178
|
return this.execute({
|
|
1090
1179
|
title: "TWIN Identity",
|
|
1091
1180
|
appName: "twin-identity",
|
|
1092
|
-
version: "0.0.1-next.
|
|
1181
|
+
version: "0.0.1-next.44", // x-release-please-version
|
|
1093
1182
|
icon: "🌍",
|
|
1094
1183
|
supportsEnvFiles: true,
|
|
1095
1184
|
overrideOutputWidth: options?.overrideOutputWidth
|
|
@@ -1122,4 +1211,4 @@ class CLI extends CLIBase {
|
|
|
1122
1211
|
}
|
|
1123
1212
|
}
|
|
1124
1213
|
|
|
1125
|
-
export { CLI, IdentityConnectorTypes, actionCommandIdentityCreate, actionCommandIdentityResolve, actionCommandProofCreate, actionCommandProofVerify, actionCommandServiceAdd, actionCommandServiceRemove, actionCommandVerifiableCredentialCreate, actionCommandVerifiableCredentialRevoke, actionCommandVerifiableCredentialUnrevoke, actionCommandVerifiableCredentialVerify, actionCommandVerificationMethodAdd, actionCommandVerificationMethodRemove, buildCommandIdentityCreate, buildCommandIdentityResolve, buildCommandProofCreate, buildCommandProofVerify, buildCommandServiceAdd, buildCommandServiceRemove, buildCommandVerifiableCredentialCreate, buildCommandVerifiableCredentialRevoke, buildCommandVerifiableCredentialUnrevoke, buildCommandVerifiableCredentialVerify, buildCommandVerificationMethodAdd, buildCommandVerificationMethodRemove, setupIdentityConnector, setupVault };
|
|
1214
|
+
export { CLI, IdentityConnectorTypes, IdentityResolverConnectorTypes, actionCommandIdentityCreate, actionCommandIdentityResolve, actionCommandProofCreate, actionCommandProofVerify, actionCommandServiceAdd, actionCommandServiceRemove, actionCommandVerifiableCredentialCreate, actionCommandVerifiableCredentialRevoke, actionCommandVerifiableCredentialUnrevoke, actionCommandVerifiableCredentialVerify, actionCommandVerificationMethodAdd, actionCommandVerificationMethodRemove, buildCommandIdentityCreate, buildCommandIdentityResolve, buildCommandProofCreate, buildCommandProofVerify, buildCommandServiceAdd, buildCommandServiceRemove, buildCommandVerifiableCredentialCreate, buildCommandVerifiableCredentialRevoke, buildCommandVerifiableCredentialUnrevoke, buildCommandVerifiableCredentialVerify, buildCommandVerificationMethodAdd, buildCommandVerificationMethodRemove, setupIdentityConnector, setupIdentityResolverConnector, setupVault };
|
package/dist/locales/en.json
CHANGED
|
@@ -287,7 +287,8 @@
|
|
|
287
287
|
"unrevokeVerifiableCredentialsFailed": "Unrevoking verifiable credentials failed",
|
|
288
288
|
"proofType": "The proof type must be DataIntegrityProof, it is currently {proofType}",
|
|
289
289
|
"integerNegative": "The value must be a positive integer, it is currently {value}",
|
|
290
|
-
"invalidDocumentIdFormat": "The document ID format is invalid, it is currently {documentId}"
|
|
290
|
+
"invalidDocumentIdFormat": "The document ID format is invalid, it is currently {documentId}",
|
|
291
|
+
"invalidSubjectId": "The subject id format is invalid it must be a Url or Urn, it is \"{subjectId}\""
|
|
291
292
|
},
|
|
292
293
|
"iota": {
|
|
293
294
|
"insufficientFunds": "There were insufficient funds to complete the operation",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { IIdentityConnector } from "@twin.org/identity-models";
|
|
1
|
+
import type { IIdentityConnector, IIdentityResolverConnector } from "@twin.org/identity-models";
|
|
2
2
|
import { IdentityConnectorTypes } from "../models/identityConnectorTypes";
|
|
3
|
+
import { IdentityResolverConnectorTypes } from "../models/identityResolverConnectorTypes";
|
|
3
4
|
/**
|
|
4
5
|
* Setup the vault for use in the CLI commands.
|
|
5
6
|
*/
|
|
@@ -20,3 +21,15 @@ export declare function setupIdentityConnector(options: {
|
|
|
20
21
|
addressIndex?: number;
|
|
21
22
|
vaultSeedId?: string;
|
|
22
23
|
}, connector?: IdentityConnectorTypes): IIdentityConnector;
|
|
24
|
+
/**
|
|
25
|
+
* Setup the identity resolver connector for use in the CLI commands.
|
|
26
|
+
* @param options The options for the identity connector.
|
|
27
|
+
* @param options.nodeEndpoint The node endpoint.
|
|
28
|
+
* @param options.network The network.
|
|
29
|
+
* @param connector The connector to use.
|
|
30
|
+
* @returns The identity connector.
|
|
31
|
+
*/
|
|
32
|
+
export declare function setupIdentityResolverConnector(options: {
|
|
33
|
+
nodeEndpoint: string;
|
|
34
|
+
network?: string;
|
|
35
|
+
}, connector?: IdentityResolverConnectorTypes): IIdentityResolverConnector;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -13,3 +13,4 @@ export * from "./commands/verifiableCredentialVerify";
|
|
|
13
13
|
export * from "./commands/verificationMethodAdd";
|
|
14
14
|
export * from "./commands/verificationMethodRemove";
|
|
15
15
|
export * from "./models/identityConnectorTypes";
|
|
16
|
+
export * from "./models/identityResolverConnectorTypes";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The identity resolver connector types.
|
|
3
|
+
*/
|
|
4
|
+
export declare const IdentityResolverConnectorTypes: {
|
|
5
|
+
/**
|
|
6
|
+
* IOTA.
|
|
7
|
+
*/
|
|
8
|
+
readonly Iota: "iota";
|
|
9
|
+
/**
|
|
10
|
+
* IOTA Stardust.
|
|
11
|
+
*/
|
|
12
|
+
readonly IotaStardust: "iota-stardust";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The identity resolver connector types.
|
|
16
|
+
*/
|
|
17
|
+
export type IdentityResolverConnectorTypes = (typeof IdentityResolverConnectorTypes)[keyof typeof IdentityResolverConnectorTypes];
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @twin.org/identity-cli - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.1-next.44](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.1-next.43...identity-cli-v0.0.1-next.44) (2025-04-30)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **identity-cli:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/identity-models bumped from 0.0.1-next.43 to 0.0.1-next.44
|
|
16
|
+
* @twin.org/identity-connector-iota bumped from 0.0.1-next.43 to 0.0.1-next.44
|
|
17
|
+
* @twin.org/identity-connector-iota-stardust bumped from 0.0.1-next.43 to 0.0.1-next.44
|
|
18
|
+
|
|
19
|
+
## [0.0.1-next.43](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.1-next.42...identity-cli-v0.0.1-next.43) (2025-04-25)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* explorer urls in CLI ([82a745d](https://github.com/twinfoundation/identity/commit/82a745d536e8fe42554e7ad92a7468a653fc0cfb))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
* The following workspace dependencies were updated
|
|
30
|
+
* dependencies
|
|
31
|
+
* @twin.org/identity-models bumped from 0.0.1-next.42 to 0.0.1-next.43
|
|
32
|
+
* @twin.org/identity-connector-iota bumped from 0.0.1-next.42 to 0.0.1-next.43
|
|
33
|
+
* @twin.org/identity-connector-iota-stardust bumped from 0.0.1-next.42 to 0.0.1-next.43
|
|
34
|
+
|
|
3
35
|
## [0.0.1-next.42](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.1-next.41...identity-cli-v0.0.1-next.42) (2025-04-17)
|
|
4
36
|
|
|
5
37
|
|
package/docs/examples.md
CHANGED
|
@@ -93,9 +93,11 @@ twin-identity address --load-env wallet.env --hrp tst --seed !SEED --count 4 --e
|
|
|
93
93
|
To run this on the IOTA testnet you will need an env file with the following settings. Store the following config as config.env
|
|
94
94
|
|
|
95
95
|
```shell
|
|
96
|
-
NODE_URL="https://api.
|
|
97
|
-
FAUCET_URL="https://faucet.
|
|
98
|
-
|
|
96
|
+
NODE_URL="https://api.devnet.iota.cafe"
|
|
97
|
+
FAUCET_URL="https://faucet.devnet.iota.cafe"
|
|
98
|
+
COIN_TYPE="4218"
|
|
99
|
+
NETWORK="devnet"
|
|
100
|
+
EXPLORER_URL="https://explorer.rebased.iota.org/"
|
|
99
101
|
```
|
|
100
102
|
|
|
101
103
|
To then request some funds and generate the identity you can issue the following commands:
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Function: setupIdentityResolverConnector()
|
|
2
|
+
|
|
3
|
+
> **setupIdentityResolverConnector**(`options`, `connector?`): `IIdentityResolverConnector`
|
|
4
|
+
|
|
5
|
+
Setup the identity resolver connector for use in the CLI commands.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### options
|
|
10
|
+
|
|
11
|
+
The options for the identity connector.
|
|
12
|
+
|
|
13
|
+
#### nodeEndpoint
|
|
14
|
+
|
|
15
|
+
`string`
|
|
16
|
+
|
|
17
|
+
The node endpoint.
|
|
18
|
+
|
|
19
|
+
#### network?
|
|
20
|
+
|
|
21
|
+
`string`
|
|
22
|
+
|
|
23
|
+
The network.
|
|
24
|
+
|
|
25
|
+
### connector?
|
|
26
|
+
|
|
27
|
+
[`IdentityResolverConnectorTypes`](../type-aliases/IdentityResolverConnectorTypes.md)
|
|
28
|
+
|
|
29
|
+
The connector to use.
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
`IIdentityResolverConnector`
|
|
34
|
+
|
|
35
|
+
The identity connector.
|
package/docs/reference/index.md
CHANGED
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
## Type Aliases
|
|
8
8
|
|
|
9
9
|
- [IdentityConnectorTypes](type-aliases/IdentityConnectorTypes.md)
|
|
10
|
+
- [IdentityResolverConnectorTypes](type-aliases/IdentityResolverConnectorTypes.md)
|
|
10
11
|
|
|
11
12
|
## Variables
|
|
12
13
|
|
|
13
14
|
- [IdentityConnectorTypes](variables/IdentityConnectorTypes.md)
|
|
15
|
+
- [IdentityResolverConnectorTypes](variables/IdentityResolverConnectorTypes.md)
|
|
14
16
|
|
|
15
17
|
## Functions
|
|
16
18
|
|
|
@@ -28,6 +30,7 @@
|
|
|
28
30
|
- [actionCommandServiceRemove](functions/actionCommandServiceRemove.md)
|
|
29
31
|
- [setupVault](functions/setupVault.md)
|
|
30
32
|
- [setupIdentityConnector](functions/setupIdentityConnector.md)
|
|
33
|
+
- [setupIdentityResolverConnector](functions/setupIdentityResolverConnector.md)
|
|
31
34
|
- [buildCommandVerifiableCredentialCreate](functions/buildCommandVerifiableCredentialCreate.md)
|
|
32
35
|
- [actionCommandVerifiableCredentialCreate](functions/actionCommandVerifiableCredentialCreate.md)
|
|
33
36
|
- [buildCommandVerifiableCredentialRevoke](functions/buildCommandVerifiableCredentialRevoke.md)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Type Alias: IdentityResolverConnectorTypes
|
|
2
|
+
|
|
3
|
+
> **IdentityResolverConnectorTypes** = *typeof* [`IdentityResolverConnectorTypes`](../variables/IdentityResolverConnectorTypes.md)\[keyof *typeof* [`IdentityResolverConnectorTypes`](../variables/IdentityResolverConnectorTypes.md)\]
|
|
4
|
+
|
|
5
|
+
The identity resolver connector types.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Variable: IdentityResolverConnectorTypes
|
|
2
|
+
|
|
3
|
+
> `const` **IdentityResolverConnectorTypes**: `object`
|
|
4
|
+
|
|
5
|
+
The identity resolver connector types.
|
|
6
|
+
|
|
7
|
+
## Type declaration
|
|
8
|
+
|
|
9
|
+
### Iota
|
|
10
|
+
|
|
11
|
+
> `readonly` **Iota**: `"iota"` = `"iota"`
|
|
12
|
+
|
|
13
|
+
IOTA.
|
|
14
|
+
|
|
15
|
+
### IotaStardust
|
|
16
|
+
|
|
17
|
+
> `readonly` **IotaStardust**: `"iota-stardust"` = `"iota-stardust"`
|
|
18
|
+
|
|
19
|
+
IOTA Stardust.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-cli",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.44",
|
|
4
4
|
"description": "A command line interface for interacting with the identity connectors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"@twin.org/data-json-ld": "next",
|
|
22
22
|
"@twin.org/entity": "next",
|
|
23
23
|
"@twin.org/entity-storage-connector-memory": "next",
|
|
24
|
-
"@twin.org/identity-connector-iota": "0.0.1-next.
|
|
25
|
-
"@twin.org/identity-connector-iota-stardust": "0.0.1-next.
|
|
26
|
-
"@twin.org/identity-models": "0.0.1-next.
|
|
24
|
+
"@twin.org/identity-connector-iota": "0.0.1-next.44",
|
|
25
|
+
"@twin.org/identity-connector-iota-stardust": "0.0.1-next.44",
|
|
26
|
+
"@twin.org/identity-models": "0.0.1-next.44",
|
|
27
27
|
"@twin.org/nameof": "next",
|
|
28
28
|
"@twin.org/standards-w3c-did": "next",
|
|
29
29
|
"@twin.org/vault-connector-entity-storage": "next",
|