@twin.org/identity-cli 0.0.3-next.4 → 0.0.3-next.6
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/es/cli.js +1 -1
- package/dist/es/cli.js.map +1 -1
- package/dist/es/commands/proofCreate.js +2 -6
- package/dist/es/commands/proofCreate.js.map +1 -1
- package/dist/es/commands/verifiableCredentialCreate.js +2 -6
- package/dist/es/commands/verifiableCredentialCreate.js.map +1 -1
- package/dist/locales/en.json +2 -12
- package/dist/types/commands/proofCreate.d.ts +0 -2
- package/dist/types/commands/verifiableCredentialCreate.d.ts +0 -2
- package/docs/changelog.md +30 -0
- package/locales/en.json +2 -12
- package/package.json +3 -3
package/dist/es/cli.js
CHANGED
|
@@ -33,7 +33,7 @@ export class CLI extends CLIBase {
|
|
|
33
33
|
return this.execute({
|
|
34
34
|
title: "TWIN Identity",
|
|
35
35
|
appName: "twin-identity",
|
|
36
|
-
version: "0.0.3-next.
|
|
36
|
+
version: "0.0.3-next.6", // x-release-please-version
|
|
37
37
|
icon: "🌍",
|
|
38
38
|
supportsEnvFiles: true,
|
|
39
39
|
overrideOutputWidth: options?.overrideOutputWidth,
|
package/dist/es/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAA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pB,oBAAoB,EAAE;YACtB,0BAA0B,EAAE;YAC5B,2BAA2B,EAAE;YAC7B,iCAAiC,EAAE;YACnC,oCAAoC,EAAE;YACtC,sBAAsB,EAAE;YACxB,yBAAyB,EAAE;YAC3B,sCAAsC,EAAE;YACxC,sCAAsC,EAAE;YACxC,sCAAsC,EAAE;YACxC,wCAAwC,EAAE;YAC1C,uBAAuB,EAAE;YACzB,uBAAuB,EAAE;SACzB,CAAC;IACH,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { CLIBase } from \"@twin.org/cli-core\";\nimport { buildCommandAddress, buildCommandMnemonic } from \"@twin.org/crypto-cli\";\nimport { buildCommandFaucet, buildCommandTransfer } from \"@twin.org/wallet-cli\";\nimport type { Command } from \"commander\";\nimport { buildCommandIdentityCreate } from \"./commands/identityCreate.js\";\nimport { buildCommandIdentityResolve } from \"./commands/identityResolve.js\";\nimport { buildCommandProofCreate } from \"./commands/proofCreate.js\";\nimport { buildCommandProofVerify } from \"./commands/proofVerify.js\";\nimport { buildCommandServiceAdd } from \"./commands/serviceAdd.js\";\nimport { buildCommandServiceRemove } from \"./commands/serviceRemove.js\";\nimport { buildCommandVerifiableCredentialCreate } from \"./commands/verifiableCredentialCreate.js\";\nimport { buildCommandVerifiableCredentialRevoke } from \"./commands/verifiableCredentialRevoke.js\";\nimport { buildCommandVerifiableCredentialUnrevoke } from \"./commands/verifiableCredentialUnrevoke.js\";\nimport { buildCommandVerifiableCredentialVerify } from \"./commands/verifiableCredentialVerify.js\";\nimport { buildCommandVerificationMethodAdd } from \"./commands/verificationMethodAdd.js\";\nimport { buildCommandVerificationMethodRemove } from \"./commands/verificationMethodRemove.js\";\n\n/**\n * The main entry point for the CLI.\n */\nexport class CLI extends CLIBase {\n\t/**\n\t * Run the app.\n\t * @param argv The process arguments.\n\t * @param localesDirectory The directory for the locales, default to relative to the script.\n\t * @param options Additional options for the CLI.\n\t * @param options.overrideOutputWidth The override output width.\n\t * @returns The exit code.\n\t */\n\tpublic async run(\n\t\targv: string[],\n\t\tlocalesDirectory?: string,\n\t\toptions?: { overrideOutputWidth?: number }\n\t): Promise<number> {\n\t\treturn this.execute(\n\t\t\t{\n\t\t\t\ttitle: \"TWIN Identity\",\n\t\t\t\tappName: \"twin-identity\",\n\t\t\t\tversion: \"0.0.3-next.
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,sCAAsC,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,sCAAsC,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,wCAAwC,EAAE,MAAM,4CAA4C,CAAC;AACtG,OAAO,EAAE,sCAAsC,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAE9F;;GAEG;AACH,MAAM,OAAO,GAAI,SAAQ,OAAO;IAC/B;;;;;;;OAOG;IACI,KAAK,CAAC,GAAG,CACf,IAAc,EACd,gBAAyB,EACzB,OAA0C;QAE1C,OAAO,IAAI,CAAC,OAAO,CAClB;YACC,KAAK,EAAE,eAAe;YACtB,OAAO,EAAE,eAAe;YACxB,OAAO,EAAE,cAAc,EAAE,2BAA2B;YACpD,IAAI,EAAE,IAAI;YACV,gBAAgB,EAAE,IAAI;YACtB,mBAAmB,EAAE,OAAO,EAAE,mBAAmB;YACjD,kBAAkB,EAAE,IAAI;SACxB,EACD,gBAAgB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EACzF,IAAI,CACJ,CAAC;IACH,CAAC;IAED;;;;OAIG;IACO,WAAW,CAAC,OAAgB;QACrC,OAAO;YACN,oBAAoB,EAAE;YACtB,mBAAmB,EAAE;YACrB,kBAAkB,EAAE;YACpB,oBAAoB,EAAE;YACtB,0BAA0B,EAAE;YAC5B,2BAA2B,EAAE;YAC7B,iCAAiC,EAAE;YACnC,oCAAoC,EAAE;YACtC,sBAAsB,EAAE;YACxB,yBAAyB,EAAE;YAC3B,sCAAsC,EAAE;YACxC,sCAAsC,EAAE;YACxC,sCAAsC,EAAE;YACxC,wCAAwC,EAAE;YAC1C,uBAAuB,EAAE;YACzB,uBAAuB,EAAE;SACzB,CAAC;IACH,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { CLIBase } from \"@twin.org/cli-core\";\nimport { buildCommandAddress, buildCommandMnemonic } from \"@twin.org/crypto-cli\";\nimport { buildCommandFaucet, buildCommandTransfer } from \"@twin.org/wallet-cli\";\nimport type { Command } from \"commander\";\nimport { buildCommandIdentityCreate } from \"./commands/identityCreate.js\";\nimport { buildCommandIdentityResolve } from \"./commands/identityResolve.js\";\nimport { buildCommandProofCreate } from \"./commands/proofCreate.js\";\nimport { buildCommandProofVerify } from \"./commands/proofVerify.js\";\nimport { buildCommandServiceAdd } from \"./commands/serviceAdd.js\";\nimport { buildCommandServiceRemove } from \"./commands/serviceRemove.js\";\nimport { buildCommandVerifiableCredentialCreate } from \"./commands/verifiableCredentialCreate.js\";\nimport { buildCommandVerifiableCredentialRevoke } from \"./commands/verifiableCredentialRevoke.js\";\nimport { buildCommandVerifiableCredentialUnrevoke } from \"./commands/verifiableCredentialUnrevoke.js\";\nimport { buildCommandVerifiableCredentialVerify } from \"./commands/verifiableCredentialVerify.js\";\nimport { buildCommandVerificationMethodAdd } from \"./commands/verificationMethodAdd.js\";\nimport { buildCommandVerificationMethodRemove } from \"./commands/verificationMethodRemove.js\";\n\n/**\n * The main entry point for the CLI.\n */\nexport class CLI extends CLIBase {\n\t/**\n\t * Run the app.\n\t * @param argv The process arguments.\n\t * @param localesDirectory The directory for the locales, default to relative to the script.\n\t * @param options Additional options for the CLI.\n\t * @param options.overrideOutputWidth The override output width.\n\t * @returns The exit code.\n\t */\n\tpublic async run(\n\t\targv: string[],\n\t\tlocalesDirectory?: string,\n\t\toptions?: { overrideOutputWidth?: number }\n\t): Promise<number> {\n\t\treturn this.execute(\n\t\t\t{\n\t\t\t\ttitle: \"TWIN Identity\",\n\t\t\t\tappName: \"twin-identity\",\n\t\t\t\tversion: \"0.0.3-next.6\", // x-release-please-version\n\t\t\t\ticon: \"🌍\",\n\t\t\t\tsupportsEnvFiles: true,\n\t\t\t\toverrideOutputWidth: options?.overrideOutputWidth,\n\t\t\t\tshowDevToolWarning: true\n\t\t\t},\n\t\t\tlocalesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), \"../locales\"),\n\t\t\targv\n\t\t);\n\t}\n\n\t/**\n\t * Get the commands for the CLI.\n\t * @param program The main program to add the commands to.\n\t * @internal\n\t */\n\tprotected getCommands(program: Command): Command[] {\n\t\treturn [\n\t\t\tbuildCommandMnemonic(),\n\t\t\tbuildCommandAddress(),\n\t\t\tbuildCommandFaucet(),\n\t\t\tbuildCommandTransfer(),\n\t\t\tbuildCommandIdentityCreate(),\n\t\t\tbuildCommandIdentityResolve(),\n\t\t\tbuildCommandVerificationMethodAdd(),\n\t\t\tbuildCommandVerificationMethodRemove(),\n\t\t\tbuildCommandServiceAdd(),\n\t\t\tbuildCommandServiceRemove(),\n\t\t\tbuildCommandVerifiableCredentialCreate(),\n\t\t\tbuildCommandVerifiableCredentialVerify(),\n\t\t\tbuildCommandVerifiableCredentialRevoke(),\n\t\t\tbuildCommandVerifiableCredentialUnrevoke(),\n\t\t\tbuildCommandProofCreate(),\n\t\t\tbuildCommandProofVerify()\n\t\t];\n\t}\n}\n"]}
|
|
@@ -23,8 +23,7 @@ export function buildCommandProofCreate() {
|
|
|
23
23
|
.description(I18n.formatMessage("commands.proof-create.description"))
|
|
24
24
|
.requiredOption(I18n.formatMessage("commands.proof-create.options.id.param"), I18n.formatMessage("commands.proof-create.options.id.description"))
|
|
25
25
|
.requiredOption(I18n.formatMessage("commands.proof-create.options.private-key.param"), I18n.formatMessage("commands.proof-create.options.private-key.description"))
|
|
26
|
-
.requiredOption(I18n.formatMessage("commands.proof-create.options.document-filename.param"), I18n.formatMessage("commands.proof-create.options.document-filename.description"))
|
|
27
|
-
.option(I18n.formatMessage("commands.proof-create.options.addressIndex.param"), I18n.formatMessage("commands.proof-create.options.addressIndex.description"), "0");
|
|
26
|
+
.requiredOption(I18n.formatMessage("commands.proof-create.options.document-filename.param"), I18n.formatMessage("commands.proof-create.options.document-filename.description"));
|
|
28
27
|
CLIOptions.output(command, {
|
|
29
28
|
noConsole: true,
|
|
30
29
|
json: true,
|
|
@@ -47,7 +46,6 @@ export function buildCommandProofCreate() {
|
|
|
47
46
|
* @param opts.id The id of the verification method to use for the credential.
|
|
48
47
|
* @param opts.privateKey The private key for the verification method.
|
|
49
48
|
* @param opts.documentFilename The filename of the document to create the proof for.
|
|
50
|
-
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
51
49
|
* @param opts.data The data to create the proof for.
|
|
52
50
|
* @param opts.connector The connector to perform the operations with.
|
|
53
51
|
* @param opts.node The node URL.
|
|
@@ -56,7 +54,6 @@ export function buildCommandProofCreate() {
|
|
|
56
54
|
export async function actionCommandProofCreate(opts) {
|
|
57
55
|
const id = CLIParam.stringValue("id", opts.id);
|
|
58
56
|
const privateKey = CLIParam.hexBase64("private-key", opts.privateKey);
|
|
59
|
-
const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
|
|
60
57
|
const documentFilename = path.resolve(CLIParam.stringValue("document-filename", opts.documentFilename));
|
|
61
58
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
62
59
|
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
@@ -64,7 +61,6 @@ export async function actionCommandProofCreate(opts) {
|
|
|
64
61
|
: undefined;
|
|
65
62
|
CLIDisplay.value(I18n.formatMessage("commands.proof-create.labels.verificationMethodId"), id);
|
|
66
63
|
CLIDisplay.value(I18n.formatMessage("commands.proof-create.labels.documentFilename"), documentFilename);
|
|
67
|
-
CLIDisplay.value(I18n.formatMessage("commands.proof-create.labels.addressIndex"), addressIndex);
|
|
68
64
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
69
65
|
if (Is.stringValue(network)) {
|
|
70
66
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
|
|
@@ -77,7 +73,7 @@ export async function actionCommandProofCreate(opts) {
|
|
|
77
73
|
await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
|
|
78
74
|
const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
|
|
79
75
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
80
|
-
const identityConnector = setupIdentityConnector({ nodeEndpoint, network
|
|
76
|
+
const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
|
|
81
77
|
CLIDisplay.task(I18n.formatMessage("commands.proof-create.progress.creatingProof"));
|
|
82
78
|
CLIDisplay.break();
|
|
83
79
|
CLIDisplay.spinnerStart();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proofCreate.js","sourceRoot":"","sources":["../../../src/commands/proofCreate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAE7E;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACtC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO;SACL,IAAI,CAAC,cAAc,CAAC;SACpB,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,+BAA+B,CAAC,CAAC;SAC5D,WAAW,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AU,CAAC,kBAAkB,EAC7B,QAAQ,CACR,CAAC;IAEF,UAAU,CAAC,WAAW,EAAE,CAAC;IAEzB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEvB,UAAU,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IAED,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,cAAc,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChG,CAAC;IAED,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport {\n\tCLIDisplay,\n\tCLIOptions,\n\tCLIParam,\n\tCLIUtils,\n\ttype CliOutputOptions\n} from \"@twin.org/cli-core\";\nimport { GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { DocumentHelper } from \"@twin.org/identity-models\";\nimport { ProofTypes } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory, VaultKeyType } from \"@twin.org/vault-models\";\nimport { setupWalletConnector } from \"@twin.org/wallet-cli\";\nimport { WalletConnectorFactory } from \"@twin.org/wallet-models\";\nimport { Command, Option } from \"commander\";\nimport { setupIdentityConnector, setupVault } from \"./setupCommands.js\";\nimport { IdentityConnectorTypes } from \"../models/identityConnectorTypes.js\";\n\n/**\n * Build the proof create command for the CLI.\n * @returns The command.\n */\nexport function buildCommandProofCreate(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"proof-create\")\n\t\t.summary(I18n.formatMessage(\"commands.proof-create.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.proof-create.description\"))\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.id.param\"),\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.id.description\")\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.private-key.param\"),\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.private-key.description\")\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.document-filename.param\"),\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.document-filename.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.addressIndex.param\"),\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.addressIndex.description\"),\n\t\t\t\"0\"\n\t\t);\n\n\tCLIOptions.output(command, {\n\t\tnoConsole: true,\n\t\tjson: true,\n\t\tenv: true,\n\t\tmergeJson: true,\n\t\tmergeEnv: true\n\t});\n\n\tcommand\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.common.options.connector.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.common.options.connector.description\")\n\t\t\t)\n\t\t\t\t.choices(Object.values(IdentityConnectorTypes))\n\t\t\t\t.default(IdentityConnectorTypes.Iota)\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.node.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.node.description\"),\n\t\t\t\"!NODE_URL\"\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.network.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.network.description\"),\n\t\t\t\"!NETWORK\"\n\t\t)\n\t\t.action(actionCommandProofCreate);\n\n\treturn command;\n}\n\n/**\n * Action the proof create command.\n * @param opts The options for the command.\n * @param opts.id The id of the verification method to use for the credential.\n * @param opts.privateKey The private key for the verification method.\n * @param opts.documentFilename The filename of the document to create the proof for.\n * @param opts.addressIndex The address index to use for key derivation (if applicable).\n * @param opts.data The data to create the proof for.\n * @param opts.connector The connector to perform the operations with.\n * @param opts.node The node URL.\n * @param opts.network The network to use for connector.\n */\nexport async function actionCommandProofCreate(\n\topts: {\n\t\tid: string;\n\t\tprivateKey: string;\n\t\tdocumentFilename: string;\n\t\taddressIndex?: string;\n\t\tconnector?: IdentityConnectorTypes;\n\t\tnode: string;\n\t\tnetwork?: string;\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst id: string = CLIParam.stringValue(\"id\", opts.id);\n\tconst privateKey: Uint8Array = CLIParam.hexBase64(\"private-key\", opts.privateKey);\n\tconst addressIndex: number = CLIParam.integer(\"addressIndex\", opts.addressIndex ?? \"0\", false, 0);\n\tconst documentFilename: string = path.resolve(\n\t\tCLIParam.stringValue(\"document-filename\", opts.documentFilename)\n\t);\n\tconst nodeEndpoint: string = CLIParam.url(\"node\", opts.node);\n\tconst network: string | undefined =\n\t\topts.connector === IdentityConnectorTypes.Iota\n\t\t\t? CLIParam.stringValue(\"network\", opts.network)\n\t\t\t: undefined;\n\n\tCLIDisplay.value(I18n.formatMessage(\"commands.proof-create.labels.verificationMethodId\"), id);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.proof-create.labels.documentFilename\"),\n\t\tdocumentFilename\n\t);\n\tCLIDisplay.value(I18n.formatMessage(\"commands.proof-create.labels.addressIndex\"), addressIndex);\n\n\tCLIDisplay.value(I18n.formatMessage(\"commands.common.labels.node\"), nodeEndpoint);\n\tif (Is.stringValue(network)) {\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.common.labels.network\"), network);\n\t}\n\tCLIDisplay.break();\n\n\tsetupVault();\n\n\tconst localIdentity = \"local\";\n\n\tconst vmParts = DocumentHelper.parseId(id);\n\n\tconst vaultConnector = VaultConnectorFactory.get(\"vault\");\n\tawait vaultConnector.addKey(\n\t\t`${localIdentity}/${vmParts.fragment}`,\n\t\tVaultKeyType.Ed25519,\n\t\tprivateKey,\n\t\tnew Uint8Array()\n\t);\n\n\tconst walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);\n\tWalletConnectorFactory.register(\"wallet\", () => walletConnector);\n\n\tconst identityConnector = setupIdentityConnector(\n\t\t{ nodeEndpoint, network, addressIndex },\n\t\topts.connector\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.proof-create.progress.creatingProof\"));\n\tCLIDisplay.break();\n\n\tCLIDisplay.spinnerStart();\n\n\tconst document = await CLIUtils.readJsonFile<IJsonLdNodeObject>(documentFilename);\n\tif (Is.undefined(document)) {\n\t\tthrow new GeneralError(\"commands\", \"commands.proof-create.documentJsonFileNotFound\");\n\t}\n\tconst proof = await identityConnector.createProof(\n\t\tlocalIdentity,\n\t\tid,\n\t\tProofTypes.DataIntegrityProof,\n\t\tdocument\n\t);\n\n\tCLIDisplay.spinnerStop();\n\n\tif (opts.console) {\n\t\tCLIDisplay.json(proof);\n\n\t\tCLIDisplay.break();\n\t}\n\n\tif (Is.stringValue(opts?.json)) {\n\t\tawait CLIUtils.writeJsonFile(opts.json, proof, opts.mergeJson);\n\t}\n\tif (Is.stringValue(opts?.env)) {\n\t\tawait CLIUtils.writeEnvFile(opts.env, [`DID_PROOF='${JSON.stringify(proof)}'`], opts.mergeEnv);\n\t}\n\n\tCLIDisplay.done();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"proofCreate.js","sourceRoot":"","sources":["../../../src/commands/proofCreate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EAER,MAAM,oBAAoB,CAA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OutputOptions\n} from \"@twin.org/cli-core\";\nimport { GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { DocumentHelper } from \"@twin.org/identity-models\";\nimport { ProofTypes } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory, VaultKeyType } from \"@twin.org/vault-models\";\nimport { setupWalletConnector } from \"@twin.org/wallet-cli\";\nimport { WalletConnectorFactory } from \"@twin.org/wallet-models\";\nimport { Command, Option } from \"commander\";\nimport { setupIdentityConnector, setupVault } from \"./setupCommands.js\";\nimport { IdentityConnectorTypes } from \"../models/identityConnectorTypes.js\";\n\n/**\n * Build the proof create command for the CLI.\n * @returns The command.\n */\nexport function buildCommandProofCreate(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"proof-create\")\n\t\t.summary(I18n.formatMessage(\"commands.proof-create.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.proof-create.description\"))\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.id.param\"),\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.id.description\")\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.private-key.param\"),\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.private-key.description\")\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.document-filename.param\"),\n\t\t\tI18n.formatMessage(\"commands.proof-create.options.document-filename.description\")\n\t\t);\n\n\tCLIOptions.output(command, {\n\t\tnoConsole: true,\n\t\tjson: true,\n\t\tenv: true,\n\t\tmergeJson: true,\n\t\tmergeEnv: true\n\t});\n\n\tcommand\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.common.options.connector.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.common.options.connector.description\")\n\t\t\t)\n\t\t\t\t.choices(Object.values(IdentityConnectorTypes))\n\t\t\t\t.default(IdentityConnectorTypes.Iota)\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.node.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.node.description\"),\n\t\t\t\"!NODE_URL\"\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.network.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.network.description\"),\n\t\t\t\"!NETWORK\"\n\t\t)\n\t\t.action(actionCommandProofCreate);\n\n\treturn command;\n}\n\n/**\n * Action the proof create command.\n * @param opts The options for the command.\n * @param opts.id The id of the verification method to use for the credential.\n * @param opts.privateKey The private key for the verification method.\n * @param opts.documentFilename The filename of the document to create the proof for.\n * @param opts.data The data to create the proof for.\n * @param opts.connector The connector to perform the operations with.\n * @param opts.node The node URL.\n * @param opts.network The network to use for connector.\n */\nexport async function actionCommandProofCreate(\n\topts: {\n\t\tid: string;\n\t\tprivateKey: string;\n\t\tdocumentFilename: string;\n\t\tconnector?: IdentityConnectorTypes;\n\t\tnode: string;\n\t\tnetwork?: string;\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst id: string = CLIParam.stringValue(\"id\", opts.id);\n\tconst privateKey: Uint8Array = CLIParam.hexBase64(\"private-key\", opts.privateKey);\n\tconst documentFilename: string = path.resolve(\n\t\tCLIParam.stringValue(\"document-filename\", opts.documentFilename)\n\t);\n\tconst nodeEndpoint: string = CLIParam.url(\"node\", opts.node);\n\tconst network: string | undefined =\n\t\topts.connector === IdentityConnectorTypes.Iota\n\t\t\t? CLIParam.stringValue(\"network\", opts.network)\n\t\t\t: undefined;\n\n\tCLIDisplay.value(I18n.formatMessage(\"commands.proof-create.labels.verificationMethodId\"), id);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.proof-create.labels.documentFilename\"),\n\t\tdocumentFilename\n\t);\n\n\tCLIDisplay.value(I18n.formatMessage(\"commands.common.labels.node\"), nodeEndpoint);\n\tif (Is.stringValue(network)) {\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.common.labels.network\"), network);\n\t}\n\tCLIDisplay.break();\n\n\tsetupVault();\n\n\tconst localIdentity = \"local\";\n\n\tconst vmParts = DocumentHelper.parseId(id);\n\n\tconst vaultConnector = VaultConnectorFactory.get(\"vault\");\n\tawait vaultConnector.addKey(\n\t\t`${localIdentity}/${vmParts.fragment}`,\n\t\tVaultKeyType.Ed25519,\n\t\tprivateKey,\n\t\tnew Uint8Array()\n\t);\n\n\tconst walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);\n\tWalletConnectorFactory.register(\"wallet\", () => walletConnector);\n\n\tconst identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.proof-create.progress.creatingProof\"));\n\tCLIDisplay.break();\n\n\tCLIDisplay.spinnerStart();\n\n\tconst document = await CLIUtils.readJsonFile<IJsonLdNodeObject>(documentFilename);\n\tif (Is.undefined(document)) {\n\t\tthrow new GeneralError(\"commands\", \"commands.proof-create.documentJsonFileNotFound\");\n\t}\n\tconst proof = await identityConnector.createProof(\n\t\tlocalIdentity,\n\t\tid,\n\t\tProofTypes.DataIntegrityProof,\n\t\tdocument\n\t);\n\n\tCLIDisplay.spinnerStop();\n\n\tif (opts.console) {\n\t\tCLIDisplay.json(proof);\n\n\t\tCLIDisplay.break();\n\t}\n\n\tif (Is.stringValue(opts?.json)) {\n\t\tawait CLIUtils.writeJsonFile(opts.json, proof, opts.mergeJson);\n\t}\n\tif (Is.stringValue(opts?.env)) {\n\t\tawait CLIUtils.writeEnvFile(opts.env, [`DID_PROOF='${JSON.stringify(proof)}'`], opts.mergeEnv);\n\t}\n\n\tCLIDisplay.done();\n}\n"]}
|
|
@@ -24,8 +24,7 @@ export function buildCommandVerifiableCredentialCreate() {
|
|
|
24
24
|
.requiredOption(I18n.formatMessage("commands.verifiable-credential-create.options.private-key.param"), I18n.formatMessage("commands.verifiable-credential-create.options.private-key.description"))
|
|
25
25
|
.option(I18n.formatMessage("commands.verifiable-credential-create.options.credential-id.param"), I18n.formatMessage("commands.verifiable-credential-create.options.credential-id.description"))
|
|
26
26
|
.requiredOption(I18n.formatMessage("commands.verifiable-credential-create.options.subject-json.param"), I18n.formatMessage("commands.verifiable-credential-create.options.subject-json.description"))
|
|
27
|
-
.option(I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.description"))
|
|
28
|
-
.option(I18n.formatMessage("commands.verifiable-credential-create.options.addressIndex.param"), I18n.formatMessage("commands.verifiable-credential-create.options.addressIndex.description"), "0");
|
|
27
|
+
.option(I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.description"));
|
|
29
28
|
CLIOptions.output(command, {
|
|
30
29
|
noConsole: true,
|
|
31
30
|
json: true,
|
|
@@ -50,7 +49,6 @@ export function buildCommandVerifiableCredentialCreate() {
|
|
|
50
49
|
* @param opts.credentialId The id of the credential.
|
|
51
50
|
* @param opts.subjectJson The JSON data for the subject.
|
|
52
51
|
* @param opts.revocationIndex The revocation index for the credential.
|
|
53
|
-
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
54
52
|
* @param opts.connector The connector to perform the operations with.
|
|
55
53
|
* @param opts.node The node URL.
|
|
56
54
|
*/
|
|
@@ -60,7 +58,6 @@ export async function actionCommandVerifiableCredentialCreate(opts) {
|
|
|
60
58
|
const credentialId = CLIParam.stringValue("credential-id", opts.credentialId);
|
|
61
59
|
const subjectJson = path.resolve(CLIParam.stringValue("subject-json", opts.subjectJson));
|
|
62
60
|
const revocationIndex = Coerce.number(opts.revocationIndex);
|
|
63
|
-
const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
|
|
64
61
|
const nodeEndpoint = CLIParam.url("node", opts.node);
|
|
65
62
|
const network = opts.connector === IdentityConnectorTypes.Iota
|
|
66
63
|
? CLIParam.stringValue("network", opts.network)
|
|
@@ -69,7 +66,6 @@ export async function actionCommandVerifiableCredentialCreate(opts) {
|
|
|
69
66
|
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.credentialId"), credentialId);
|
|
70
67
|
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.subjectJson"), subjectJson);
|
|
71
68
|
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.revocationIndex"), revocationIndex);
|
|
72
|
-
CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.addressIndex"), addressIndex);
|
|
73
69
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
|
|
74
70
|
if (Is.stringValue(network)) {
|
|
75
71
|
CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
|
|
@@ -82,7 +78,7 @@ export async function actionCommandVerifiableCredentialCreate(opts) {
|
|
|
82
78
|
await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
|
|
83
79
|
const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
|
|
84
80
|
WalletConnectorFactory.register("wallet", () => walletConnector);
|
|
85
|
-
const identityConnector = setupIdentityConnector({ nodeEndpoint, network
|
|
81
|
+
const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
|
|
86
82
|
CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-create.progress.loadingSubjectData"));
|
|
87
83
|
CLIDisplay.break();
|
|
88
84
|
const jsonData = await CLIUtils.readJsonFile(subjectJson);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifiableCredentialCreate.js","sourceRoot":"","sources":["../../../src/commands/verifiableCredentialCreate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EAER,MAAM,oBAAoB,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EAAE,CAAC;IAEnB,UAAU,CAAC,YAAY,EAAE,CAAC;IAE1B,MAAM,oBAAoB,GAAG,MAAM,iBAAiB,CAAC,0BAA0B,CAC9E,aAAa,EACb,EAAE,EACF,YAAY,EACZ,QAAQ,EACR;QACC,eAAe;KACf,CACD,CAAC;IAEF,UAAU,CAAC,WAAW,EAAE,CAAC;IAEzB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,mEAAmE,CAAC,CACvF,CAAC;QAEF,UAAU,CAAC,KAAK,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAC3C,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,UAAU,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IAED,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,QAAQ,CAAC,aAAa,CAC3B,IAAI,CAAC,IAAI,EACT,EAAE,uBAAuB,EAAE,oBAAoB,CAAC,GAAG,EAAE,EACrD,IAAI,CAAC,SAAS,CACd,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,QAAQ,CAAC,YAAY,CAC1B,IAAI,CAAC,GAAG,EACR,CAAC,kCAAkC,oBAAoB,CAAC,GAAG,GAAG,CAAC,EAC/D,IAAI,CAAC,QAAQ,CACb,CAAC;IACH,CAAC;IAED,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport {\n\tCLIDisplay,\n\tCLIOptions,\n\tCLIParam,\n\tCLIUtils,\n\ttype CliOutputOptions\n} from \"@twin.org/cli-core\";\nimport { Coerce, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { DocumentHelper } from \"@twin.org/identity-models\";\nimport { VaultConnectorFactory, VaultKeyType } from \"@twin.org/vault-models\";\nimport { setupWalletConnector } from \"@twin.org/wallet-cli\";\nimport { WalletConnectorFactory } from \"@twin.org/wallet-models\";\nimport { Command, Option } from \"commander\";\nimport { setupIdentityConnector, setupVault } from \"./setupCommands.js\";\nimport { IdentityConnectorTypes } from \"../models/identityConnectorTypes.js\";\n\n/**\n * Build the verifiable credential create command for the CLI.\n * @returns The command.\n */\nexport function buildCommandVerifiableCredentialCreate(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"verifiable-credential-create\")\n\t\t.summary(I18n.formatMessage(\"commands.verifiable-credential-create.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.verifiable-credential-create.description\"))\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.id.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.id.description\")\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.private-key.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.private-key.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.credential-id.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.credential-id.description\")\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.subject-json.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.subject-json.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.revocation-index.param\"),\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"commands.verifiable-credential-create.options.revocation-index.description\"\n\t\t\t)\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.addressIndex.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.addressIndex.description\"),\n\t\t\t\"0\"\n\t\t);\n\tCLIOptions.output(command, {\n\t\tnoConsole: true,\n\t\tjson: true,\n\t\tenv: true,\n\t\tmergeJson: true,\n\t\tmergeEnv: true\n\t});\n\n\tcommand\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.common.options.connector.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.common.options.connector.description\")\n\t\t\t)\n\t\t\t\t.choices(Object.values(IdentityConnectorTypes))\n\t\t\t\t.default(IdentityConnectorTypes.Iota)\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.node.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.node.description\"),\n\t\t\t\"!NODE_URL\"\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.network.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.network.description\"),\n\t\t\t\"!NETWORK\"\n\t\t)\n\t\t.action(actionCommandVerifiableCredentialCreate);\n\n\treturn command;\n}\n\n/**\n * Action the verifiable credential create command.\n * @param opts The options for the command.\n * @param opts.id The id of the verification method to use for the credential.\n * @param opts.privateKey The private key for the verification method.\n * @param opts.credentialId The id of the credential.\n * @param opts.subjectJson The JSON data for the subject.\n * @param opts.revocationIndex The revocation index for the credential.\n * @param opts.addressIndex The address index to use for key derivation (if applicable).\n * @param opts.connector The connector to perform the operations with.\n * @param opts.node The node URL.\n */\nexport async function actionCommandVerifiableCredentialCreate(\n\topts: {\n\t\tid: string;\n\t\tprivateKey: string;\n\t\tcredentialId?: string;\n\t\tsubjectJson: string;\n\t\trevocationIndex?: string;\n\t\taddressIndex?: string;\n\t\tconnector?: IdentityConnectorTypes;\n\t\tnode: string;\n\t\tnetwork?: string;\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst id: string = CLIParam.stringValue(\"id\", opts.id);\n\tconst privateKey: Uint8Array = CLIParam.hexBase64(\"private-key\", opts.privateKey);\n\tconst credentialId: string = CLIParam.stringValue(\"credential-id\", opts.credentialId);\n\tconst subjectJson: string = path.resolve(CLIParam.stringValue(\"subject-json\", opts.subjectJson));\n\tconst revocationIndex: number | undefined = Coerce.number(opts.revocationIndex);\n\tconst addressIndex: number = CLIParam.integer(\"addressIndex\", opts.addressIndex ?? \"0\", false, 0);\n\tconst nodeEndpoint: string = CLIParam.url(\"node\", opts.node);\n\tconst network: string | undefined =\n\t\topts.connector === IdentityConnectorTypes.Iota\n\t\t\t? CLIParam.stringValue(\"network\", opts.network)\n\t\t\t: undefined;\n\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.verificationMethodId\"),\n\t\tid\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.credentialId\"),\n\t\tcredentialId\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.subjectJson\"),\n\t\tsubjectJson\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.revocationIndex\"),\n\t\trevocationIndex\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.addressIndex\"),\n\t\taddressIndex\n\t);\n\tCLIDisplay.value(I18n.formatMessage(\"commands.common.labels.node\"), nodeEndpoint);\n\tif (Is.stringValue(network)) {\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.common.labels.network\"), network);\n\t}\n\tCLIDisplay.break();\n\n\tsetupVault();\n\n\tconst localIdentity = \"local\";\n\n\tconst vmParts = DocumentHelper.parseId(id);\n\n\tconst vaultConnector = VaultConnectorFactory.get(\"vault\");\n\tawait vaultConnector.addKey(\n\t\t`${localIdentity}/${vmParts.fragment}`,\n\t\tVaultKeyType.Ed25519,\n\t\tprivateKey,\n\t\tnew Uint8Array()\n\t);\n\n\tconst walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);\n\tWalletConnectorFactory.register(\"wallet\", () => walletConnector);\n\n\tconst identityConnector = setupIdentityConnector(\n\t\t{ nodeEndpoint, network, addressIndex },\n\t\topts.connector\n\t);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.progress.loadingSubjectData\")\n\t);\n\tCLIDisplay.break();\n\n\tconst jsonData = await CLIUtils.readJsonFile<IJsonLdNodeObject>(subjectJson);\n\tif (Is.undefined(jsonData)) {\n\t\tthrow new GeneralError(\n\t\t\t\"commands\",\n\t\t\t\"commands.verifiable-credential-create.subjectJsonFileNotFound\"\n\t\t);\n\t}\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\n\t\t\t\"commands.verifiable-credential-create.progress.creatingVerifiableCredential\"\n\t\t)\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.spinnerStart();\n\n\tconst verifiableCredential = await identityConnector.createVerifiableCredential(\n\t\tlocalIdentity,\n\t\tid,\n\t\tcredentialId,\n\t\tjsonData,\n\t\t{\n\t\t\trevocationIndex\n\t\t}\n\t);\n\n\tCLIDisplay.spinnerStop();\n\n\tif (opts.console) {\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.verifiableCredential\")\n\t\t);\n\n\t\tCLIDisplay.write(verifiableCredential.jwt);\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.break();\n\t}\n\n\tif (Is.stringValue(opts?.json)) {\n\t\tawait CLIUtils.writeJsonFile(\n\t\t\topts.json,\n\t\t\t{ verifiableCredentialJwt: verifiableCredential.jwt },\n\t\t\topts.mergeJson\n\t\t);\n\t}\n\tif (Is.stringValue(opts?.env)) {\n\t\tawait CLIUtils.writeEnvFile(\n\t\t\topts.env,\n\t\t\t[`DID_VERIFIABLE_CREDENTIAL_JWT=\"${verifiableCredential.jwt}\"`],\n\t\t\topts.mergeEnv\n\t\t);\n\t}\n\n\tCLIDisplay.done();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"verif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,YAAY,EACZ,QAAQ,EACR;QACC,eAAe;KACf,CACD,CAAC;IAEF,UAAU,CAAC,WAAW,EAAE,CAAC;IAEzB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAClB,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,mEAAmE,CAAC,CACvF,CAAC;QAEF,UAAU,CAAC,KAAK,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAC3C,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,UAAU,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IAED,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,QAAQ,CAAC,aAAa,CAC3B,IAAI,CAAC,IAAI,EACT,EAAE,uBAAuB,EAAE,oBAAoB,CAAC,GAAG,EAAE,EACrD,IAAI,CAAC,SAAS,CACd,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,QAAQ,CAAC,YAAY,CAC1B,IAAI,CAAC,GAAG,EACR,CAAC,kCAAkC,oBAAoB,CAAC,GAAG,GAAG,CAAC,EAC/D,IAAI,CAAC,QAAQ,CACb,CAAC;IACH,CAAC;IAED,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport {\n\tCLIDisplay,\n\tCLIOptions,\n\tCLIParam,\n\tCLIUtils,\n\ttype CliOutputOptions\n} from \"@twin.org/cli-core\";\nimport { Coerce, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IJsonLdNodeObject } from \"@twin.org/data-json-ld\";\nimport { DocumentHelper } from \"@twin.org/identity-models\";\nimport { VaultConnectorFactory, VaultKeyType } from \"@twin.org/vault-models\";\nimport { setupWalletConnector } from \"@twin.org/wallet-cli\";\nimport { WalletConnectorFactory } from \"@twin.org/wallet-models\";\nimport { Command, Option } from \"commander\";\nimport { setupIdentityConnector, setupVault } from \"./setupCommands.js\";\nimport { IdentityConnectorTypes } from \"../models/identityConnectorTypes.js\";\n\n/**\n * Build the verifiable credential create command for the CLI.\n * @returns The command.\n */\nexport function buildCommandVerifiableCredentialCreate(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"verifiable-credential-create\")\n\t\t.summary(I18n.formatMessage(\"commands.verifiable-credential-create.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.verifiable-credential-create.description\"))\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.id.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.id.description\")\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.private-key.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.private-key.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.credential-id.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.credential-id.description\")\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.subject-json.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.subject-json.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.options.revocation-index.param\"),\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"commands.verifiable-credential-create.options.revocation-index.description\"\n\t\t\t)\n\t\t);\n\tCLIOptions.output(command, {\n\t\tnoConsole: true,\n\t\tjson: true,\n\t\tenv: true,\n\t\tmergeJson: true,\n\t\tmergeEnv: true\n\t});\n\n\tcommand\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.common.options.connector.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.common.options.connector.description\")\n\t\t\t)\n\t\t\t\t.choices(Object.values(IdentityConnectorTypes))\n\t\t\t\t.default(IdentityConnectorTypes.Iota)\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.node.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.node.description\"),\n\t\t\t\"!NODE_URL\"\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.network.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.network.description\"),\n\t\t\t\"!NETWORK\"\n\t\t)\n\t\t.action(actionCommandVerifiableCredentialCreate);\n\n\treturn command;\n}\n\n/**\n * Action the verifiable credential create command.\n * @param opts The options for the command.\n * @param opts.id The id of the verification method to use for the credential.\n * @param opts.privateKey The private key for the verification method.\n * @param opts.credentialId The id of the credential.\n * @param opts.subjectJson The JSON data for the subject.\n * @param opts.revocationIndex The revocation index for the credential.\n * @param opts.connector The connector to perform the operations with.\n * @param opts.node The node URL.\n */\nexport async function actionCommandVerifiableCredentialCreate(\n\topts: {\n\t\tid: string;\n\t\tprivateKey: string;\n\t\tcredentialId?: string;\n\t\tsubjectJson: string;\n\t\trevocationIndex?: string;\n\t\tconnector?: IdentityConnectorTypes;\n\t\tnode: string;\n\t\tnetwork?: string;\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst id: string = CLIParam.stringValue(\"id\", opts.id);\n\tconst privateKey: Uint8Array = CLIParam.hexBase64(\"private-key\", opts.privateKey);\n\tconst credentialId: string = CLIParam.stringValue(\"credential-id\", opts.credentialId);\n\tconst subjectJson: string = path.resolve(CLIParam.stringValue(\"subject-json\", opts.subjectJson));\n\tconst revocationIndex: number | undefined = Coerce.number(opts.revocationIndex);\n\tconst nodeEndpoint: string = CLIParam.url(\"node\", opts.node);\n\tconst network: string | undefined =\n\t\topts.connector === IdentityConnectorTypes.Iota\n\t\t\t? CLIParam.stringValue(\"network\", opts.network)\n\t\t\t: undefined;\n\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.verificationMethodId\"),\n\t\tid\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.credentialId\"),\n\t\tcredentialId\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.subjectJson\"),\n\t\tsubjectJson\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.revocationIndex\"),\n\t\trevocationIndex\n\t);\n\tCLIDisplay.value(I18n.formatMessage(\"commands.common.labels.node\"), nodeEndpoint);\n\tif (Is.stringValue(network)) {\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.common.labels.network\"), network);\n\t}\n\tCLIDisplay.break();\n\n\tsetupVault();\n\n\tconst localIdentity = \"local\";\n\n\tconst vmParts = DocumentHelper.parseId(id);\n\n\tconst vaultConnector = VaultConnectorFactory.get(\"vault\");\n\tawait vaultConnector.addKey(\n\t\t`${localIdentity}/${vmParts.fragment}`,\n\t\tVaultKeyType.Ed25519,\n\t\tprivateKey,\n\t\tnew Uint8Array()\n\t);\n\n\tconst walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);\n\tWalletConnectorFactory.register(\"wallet\", () => walletConnector);\n\n\tconst identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.progress.loadingSubjectData\")\n\t);\n\tCLIDisplay.break();\n\n\tconst jsonData = await CLIUtils.readJsonFile<IJsonLdNodeObject>(subjectJson);\n\tif (Is.undefined(jsonData)) {\n\t\tthrow new GeneralError(\n\t\t\t\"commands\",\n\t\t\t\"commands.verifiable-credential-create.subjectJsonFileNotFound\"\n\t\t);\n\t}\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\n\t\t\t\"commands.verifiable-credential-create.progress.creatingVerifiableCredential\"\n\t\t)\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.spinnerStart();\n\n\tconst verifiableCredential = await identityConnector.createVerifiableCredential(\n\t\tlocalIdentity,\n\t\tid,\n\t\tcredentialId,\n\t\tjsonData,\n\t\t{\n\t\t\trevocationIndex\n\t\t}\n\t);\n\n\tCLIDisplay.spinnerStop();\n\n\tif (opts.console) {\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.verifiableCredential\")\n\t\t);\n\n\t\tCLIDisplay.write(verifiableCredential.jwt);\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.break();\n\t}\n\n\tif (Is.stringValue(opts?.json)) {\n\t\tawait CLIUtils.writeJsonFile(\n\t\t\topts.json,\n\t\t\t{ verifiableCredentialJwt: verifiableCredential.jwt },\n\t\t\topts.mergeJson\n\t\t);\n\t}\n\tif (Is.stringValue(opts?.env)) {\n\t\tawait CLIUtils.writeEnvFile(\n\t\t\topts.env,\n\t\t\t[`DID_VERIFIABLE_CREDENTIAL_JWT=\"${verifiableCredential.jwt}\"`],\n\t\t\topts.mergeEnv\n\t\t);\n\t}\n\n\tCLIDisplay.done();\n}\n"]}
|
package/dist/locales/en.json
CHANGED
|
@@ -732,10 +732,6 @@
|
|
|
732
732
|
"revocation-index": {
|
|
733
733
|
"param": "--revocation-index '<'revocation-index'>'",
|
|
734
734
|
"description": "The revocation index in the issuing document to use if revoking the credential."
|
|
735
|
-
},
|
|
736
|
-
"addressIndex": {
|
|
737
|
-
"param": "--address-index '<'index'>'",
|
|
738
|
-
"description": "The address index to use for the identity controller."
|
|
739
735
|
}
|
|
740
736
|
},
|
|
741
737
|
"progress": {
|
|
@@ -747,8 +743,7 @@
|
|
|
747
743
|
"credentialId": "Credential Id",
|
|
748
744
|
"subjectJson": "Subject JSON",
|
|
749
745
|
"revocationIndex": "Revocation Index",
|
|
750
|
-
"verifiableCredential": "Verifiable Credential"
|
|
751
|
-
"addressIndex": "Address Index"
|
|
746
|
+
"verifiableCredential": "Verifiable Credential"
|
|
752
747
|
}
|
|
753
748
|
},
|
|
754
749
|
"verifiable-credential-verify": {
|
|
@@ -842,10 +837,6 @@
|
|
|
842
837
|
"document-filename": {
|
|
843
838
|
"param": "--document-filename '<'document-filename'>'",
|
|
844
839
|
"description": "The filename of a JSON-LD document to create the proof for."
|
|
845
|
-
},
|
|
846
|
-
"addressIndex": {
|
|
847
|
-
"param": "--address-index '<'index'>'",
|
|
848
|
-
"description": "The address index to use for the identity controller."
|
|
849
840
|
}
|
|
850
841
|
},
|
|
851
842
|
"progress": {
|
|
@@ -853,8 +844,7 @@
|
|
|
853
844
|
},
|
|
854
845
|
"labels": {
|
|
855
846
|
"documentFilename": "Document Filename",
|
|
856
|
-
"verificationMethodId": "Verification Method Id"
|
|
857
|
-
"addressIndex": "Address Index"
|
|
847
|
+
"verificationMethodId": "Verification Method Id"
|
|
858
848
|
}
|
|
859
849
|
},
|
|
860
850
|
"proof-verify": {
|
|
@@ -12,7 +12,6 @@ export declare function buildCommandProofCreate(): Command;
|
|
|
12
12
|
* @param opts.id The id of the verification method to use for the credential.
|
|
13
13
|
* @param opts.privateKey The private key for the verification method.
|
|
14
14
|
* @param opts.documentFilename The filename of the document to create the proof for.
|
|
15
|
-
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
16
15
|
* @param opts.data The data to create the proof for.
|
|
17
16
|
* @param opts.connector The connector to perform the operations with.
|
|
18
17
|
* @param opts.node The node URL.
|
|
@@ -22,7 +21,6 @@ export declare function actionCommandProofCreate(opts: {
|
|
|
22
21
|
id: string;
|
|
23
22
|
privateKey: string;
|
|
24
23
|
documentFilename: string;
|
|
25
|
-
addressIndex?: string;
|
|
26
24
|
connector?: IdentityConnectorTypes;
|
|
27
25
|
node: string;
|
|
28
26
|
network?: string;
|
|
@@ -14,7 +14,6 @@ export declare function buildCommandVerifiableCredentialCreate(): Command;
|
|
|
14
14
|
* @param opts.credentialId The id of the credential.
|
|
15
15
|
* @param opts.subjectJson The JSON data for the subject.
|
|
16
16
|
* @param opts.revocationIndex The revocation index for the credential.
|
|
17
|
-
* @param opts.addressIndex The address index to use for key derivation (if applicable).
|
|
18
17
|
* @param opts.connector The connector to perform the operations with.
|
|
19
18
|
* @param opts.node The node URL.
|
|
20
19
|
*/
|
|
@@ -24,7 +23,6 @@ export declare function actionCommandVerifiableCredentialCreate(opts: {
|
|
|
24
23
|
credentialId?: string;
|
|
25
24
|
subjectJson: string;
|
|
26
25
|
revocationIndex?: string;
|
|
27
|
-
addressIndex?: string;
|
|
28
26
|
connector?: IdentityConnectorTypes;
|
|
29
27
|
node: string;
|
|
30
28
|
network?: string;
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @twin.org/identity-cli - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.6](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.5...identity-cli-v0.0.3-next.6) (2025-11-26)
|
|
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.3-next.5 to 0.0.3-next.6
|
|
16
|
+
* @twin.org/identity-connector-iota bumped from 0.0.3-next.5 to 0.0.3-next.6
|
|
17
|
+
|
|
18
|
+
## [0.0.3-next.5](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.4...identity-cli-v0.0.3-next.5) (2025-11-20)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* remove unused address index params in CLI ([c4c0cc1](https://github.com/twinfoundation/identity/commit/c4c0cc18e17804380cf52330e1b9de8716cc193d))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Dependencies
|
|
27
|
+
|
|
28
|
+
* The following workspace dependencies were updated
|
|
29
|
+
* dependencies
|
|
30
|
+
* @twin.org/identity-models bumped from 0.0.3-next.4 to 0.0.3-next.5
|
|
31
|
+
* @twin.org/identity-connector-iota bumped from 0.0.3-next.4 to 0.0.3-next.5
|
|
32
|
+
|
|
3
33
|
## [0.0.3-next.4](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.3...identity-cli-v0.0.3-next.4) (2025-11-17)
|
|
4
34
|
|
|
5
35
|
|
package/locales/en.json
CHANGED
|
@@ -202,10 +202,6 @@
|
|
|
202
202
|
"revocation-index": {
|
|
203
203
|
"param": "--revocation-index '<'revocation-index'>'",
|
|
204
204
|
"description": "The revocation index in the issuing document to use if revoking the credential."
|
|
205
|
-
},
|
|
206
|
-
"addressIndex": {
|
|
207
|
-
"param": "--address-index '<'index'>'",
|
|
208
|
-
"description": "The address index to use for the identity controller."
|
|
209
205
|
}
|
|
210
206
|
},
|
|
211
207
|
"progress": {
|
|
@@ -217,8 +213,7 @@
|
|
|
217
213
|
"credentialId": "Credential Id",
|
|
218
214
|
"subjectJson": "Subject JSON",
|
|
219
215
|
"revocationIndex": "Revocation Index",
|
|
220
|
-
"verifiableCredential": "Verifiable Credential"
|
|
221
|
-
"addressIndex": "Address Index"
|
|
216
|
+
"verifiableCredential": "Verifiable Credential"
|
|
222
217
|
}
|
|
223
218
|
},
|
|
224
219
|
"verifiable-credential-verify": {
|
|
@@ -312,10 +307,6 @@
|
|
|
312
307
|
"document-filename": {
|
|
313
308
|
"param": "--document-filename '<'document-filename'>'",
|
|
314
309
|
"description": "The filename of a JSON-LD document to create the proof for."
|
|
315
|
-
},
|
|
316
|
-
"addressIndex": {
|
|
317
|
-
"param": "--address-index '<'index'>'",
|
|
318
|
-
"description": "The address index to use for the identity controller."
|
|
319
310
|
}
|
|
320
311
|
},
|
|
321
312
|
"progress": {
|
|
@@ -323,8 +314,7 @@
|
|
|
323
314
|
},
|
|
324
315
|
"labels": {
|
|
325
316
|
"documentFilename": "Document Filename",
|
|
326
|
-
"verificationMethodId": "Verification Method Id"
|
|
327
|
-
"addressIndex": "Address Index"
|
|
317
|
+
"verificationMethodId": "Verification Method Id"
|
|
328
318
|
}
|
|
329
319
|
},
|
|
330
320
|
"proof-verify": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-cli",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.6",
|
|
4
4
|
"description": "A command line interface for interacting with the identity connectors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,8 +21,8 @@
|
|
|
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.3-next.
|
|
25
|
-
"@twin.org/identity-models": "0.0.3-next.
|
|
24
|
+
"@twin.org/identity-connector-iota": "0.0.3-next.6",
|
|
25
|
+
"@twin.org/identity-models": "0.0.3-next.6",
|
|
26
26
|
"@twin.org/nameof": "next",
|
|
27
27
|
"@twin.org/standards-w3c-did": "next",
|
|
28
28
|
"@twin.org/vault-connector-entity-storage": "next",
|