@twin.org/identity-cli 0.0.3-next.1 → 0.0.3-next.11

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 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.1", // x-release-please-version
36
+ version: "0.0.3-next.11", // x-release-please-version
37
37
  icon: "🌍",
38
38
  supportsEnvFiles: true,
39
39
  overrideOutputWidth: options?.overrideOutputWidth,
@@ -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,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.1\", // 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"]}
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,EA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E;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.11\", // 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"]}
@@ -19,6 +19,7 @@ export function buildCommandIdentityCreate() {
19
19
  .summary(I18n.formatMessage("commands.identity-create.summary"))
20
20
  .description(I18n.formatMessage("commands.identity-create.description"))
21
21
  .requiredOption(I18n.formatMessage("commands.identity-create.options.seed.param"), I18n.formatMessage("commands.identity-create.options.seed.description"))
22
+ .option(I18n.formatMessage("commands.identity-create.options.controller.param"), I18n.formatMessage("commands.identity-create.options.controller.description"))
22
23
  .option(I18n.formatMessage("commands.identity-create.options.addressIndex.param"), I18n.formatMessage("commands.identity-create.options.addressIndex.description"), "0");
23
24
  CLIOptions.output(command, {
24
25
  noConsole: true,
@@ -63,7 +64,7 @@ export async function actionCommandIdentityCreate(opts) {
63
64
  CLIDisplay.break();
64
65
  setupVault();
65
66
  const vaultSeedId = "local-seed";
66
- const localIdentity = "local";
67
+ const localIdentity = opts.controller ?? "local";
67
68
  const vaultConnector = VaultConnectorFactory.get("vault");
68
69
  await vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));
69
70
  const walletConnector = setupWalletConnector({ nodeEndpoint, vaultSeedId, network }, opts.connector);
@@ -1 +1 @@
1
- {"version":3,"file":"identityCreate.js","sourceRoot":"","sources":["../../../src/commands/identityCreate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,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,0BAA0B;IACzC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO;SACL,IAAI,CAAC,iBAAiB,CAAC;SACvB,OAAO,CAAC,IAAI,CAA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AC;QAC/B,MAAM,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,QAAQ,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,IAAI,CAAC,SAAS,KAAK,sBAAsB,CAAC,IAAI,EAAE,CAAC;QACpD,MAAM,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC/C,UAAU,CAAC,KAAK,CACf,IAAI,CAAC,aAAa,CAAC,gCAAgC,CAAC,EACpD,GAAG,YAAY,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,WAAW,QAAQ,YAAY,OAAO,EAAE,CAC7F,CAAC;IACH,CAAC;IACD,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tCLIDisplay,\n\tCLIOptions,\n\tCLIParam,\n\tCLIUtils,\n\ttype CliOutputOptions\n} from \"@twin.org/cli-core\";\nimport { Converter, I18n, Is, StringHelper, Urn } from \"@twin.org/core\";\nimport { VaultConnectorFactory } 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 identity create command for the CLI.\n * @returns The command.\n */\nexport function buildCommandIdentityCreate(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"identity-create\")\n\t\t.summary(I18n.formatMessage(\"commands.identity-create.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.identity-create.description\"))\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.identity-create.options.seed.param\"),\n\t\t\tI18n.formatMessage(\"commands.identity-create.options.seed.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.identity-create.options.addressIndex.param\"),\n\t\t\tI18n.formatMessage(\"commands.identity-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.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.explorer.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.explorer.description\"),\n\t\t\t\"!EXPLORER_URL\"\n\t\t)\n\t\t.action(actionCommandIdentityCreate);\n\n\treturn command;\n}\n\n/**\n * Action the identity create command.\n * @param opts The options for the command.\n * @param opts.seed The private key for the controller.\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 * @param opts.explorer The explorer URL.\n */\nexport async function actionCommandIdentityCreate(\n\topts: {\n\t\tseed: string;\n\t\tconnector?: IdentityConnectorTypes;\n\t\tnode: string;\n\t\tnetwork?: string;\n\t\texplorer: string;\n\t\taddressIndex?: string;\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst seed: Uint8Array = CLIParam.hexBase64(\"seed\", opts.seed);\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\tconst explorerEndpoint: string = CLIParam.url(\"explorer\", opts.explorer);\n\tconst addressIndex: number = CLIParam.integer(\"addressIndex\", opts.addressIndex ?? \"0\", false, 0);\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.value(I18n.formatMessage(\"commands.common.labels.explorer\"), explorerEndpoint);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.identity-create.labels.addressIndex\"),\n\t\taddressIndex\n\t);\n\tCLIDisplay.break();\n\n\tsetupVault();\n\n\tconst vaultSeedId = \"local-seed\";\n\tconst localIdentity = \"local\";\n\n\tconst vaultConnector = VaultConnectorFactory.get(\"vault\");\n\tawait vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));\n\n\tconst walletConnector = setupWalletConnector(\n\t\t{ nodeEndpoint, vaultSeedId, network },\n\t\topts.connector\n\t);\n\tWalletConnectorFactory.register(\"wallet\", () => walletConnector);\n\n\tconst identityConnector = setupIdentityConnector(\n\t\t{ nodeEndpoint, vaultSeedId, network, addressIndex },\n\t\topts.connector\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.identity-create.progress.creatingIdentity\"));\n\tCLIDisplay.break();\n\n\tCLIDisplay.spinnerStart();\n\n\tconst document = await identityConnector.createDocument(localIdentity);\n\n\tCLIDisplay.spinnerStop();\n\n\tif (opts.console) {\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.identity-create.labels.identity\"), document.id);\n\t\tCLIDisplay.break();\n\t}\n\n\tif (Is.stringValue(opts?.json)) {\n\t\tawait CLIUtils.writeJsonFile(opts.json, { did: document.id }, opts.mergeJson);\n\t}\n\tif (Is.stringValue(opts?.env)) {\n\t\tawait CLIUtils.writeEnvFile(opts.env, [`DID=\"${document.id}\"`], opts.mergeEnv);\n\t}\n\n\tif (opts.connector === IdentityConnectorTypes.Iota) {\n\t\tconst didUrn = Urn.fromValidString(document.id);\n\t\tconst didParts = didUrn.parts();\n\t\tconst objectId = didParts[didParts.length - 1];\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.common.labels.explore\"),\n\t\t\t`${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`\n\t\t);\n\t}\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n}\n"]}
1
+ {"version":3,"file":"identityCreate.js","sourceRoot":"","sources":["../../../src/commands/identityCreate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,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,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,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,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/E,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,QAAQ,QAAQ,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,IAAI,CAAC,SAAS,KAAK,sBAAsB,CAAC,IAAI,EAAE,CAAC;QACpD,MAAM,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC/C,UAAU,CAAC,KAAK,CACf,IAAI,CAAC,aAAa,CAAC,gCAAgC,CAAC,EACpD,GAAG,YAAY,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,WAAW,QAAQ,YAAY,OAAO,EAAE,CAC7F,CAAC;IACH,CAAC;IACD,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tCLIDisplay,\n\tCLIOptions,\n\tCLIParam,\n\tCLIUtils,\n\ttype CliOutputOptions\n} from \"@twin.org/cli-core\";\nimport { Converter, I18n, Is, StringHelper, Urn } from \"@twin.org/core\";\nimport { VaultConnectorFactory } 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 identity create command for the CLI.\n * @returns The command.\n */\nexport function buildCommandIdentityCreate(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"identity-create\")\n\t\t.summary(I18n.formatMessage(\"commands.identity-create.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.identity-create.description\"))\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.identity-create.options.seed.param\"),\n\t\t\tI18n.formatMessage(\"commands.identity-create.options.seed.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.identity-create.options.controller.param\"),\n\t\t\tI18n.formatMessage(\"commands.identity-create.options.controller.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.identity-create.options.addressIndex.param\"),\n\t\t\tI18n.formatMessage(\"commands.identity-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.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.explorer.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.explorer.description\"),\n\t\t\t\"!EXPLORER_URL\"\n\t\t)\n\t\t.action(actionCommandIdentityCreate);\n\n\treturn command;\n}\n\n/**\n * Action the identity create command.\n * @param opts The options for the command.\n * @param opts.seed The private key for the controller.\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 * @param opts.explorer The explorer URL.\n */\nexport async function actionCommandIdentityCreate(\n\topts: {\n\t\tseed: string;\n\t\tconnector?: IdentityConnectorTypes;\n\t\tnode: string;\n\t\tnetwork?: string;\n\t\texplorer: string;\n\t\taddressIndex?: string;\n\t\tcontroller?: string;\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst seed: Uint8Array = CLIParam.hexBase64(\"seed\", opts.seed);\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\tconst explorerEndpoint: string = CLIParam.url(\"explorer\", opts.explorer);\n\tconst addressIndex: number = CLIParam.integer(\"addressIndex\", opts.addressIndex ?? \"0\", false, 0);\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.value(I18n.formatMessage(\"commands.common.labels.explorer\"), explorerEndpoint);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.identity-create.labels.addressIndex\"),\n\t\taddressIndex\n\t);\n\tCLIDisplay.break();\n\n\tsetupVault();\n\n\tconst vaultSeedId = \"local-seed\";\n\tconst localIdentity = opts.controller ?? \"local\";\n\n\tconst vaultConnector = VaultConnectorFactory.get(\"vault\");\n\tawait vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));\n\n\tconst walletConnector = setupWalletConnector(\n\t\t{ nodeEndpoint, vaultSeedId, network },\n\t\topts.connector\n\t);\n\tWalletConnectorFactory.register(\"wallet\", () => walletConnector);\n\n\tconst identityConnector = setupIdentityConnector(\n\t\t{ nodeEndpoint, vaultSeedId, network, addressIndex },\n\t\topts.connector\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.identity-create.progress.creatingIdentity\"));\n\tCLIDisplay.break();\n\n\tCLIDisplay.spinnerStart();\n\n\tconst document = await identityConnector.createDocument(localIdentity);\n\n\tCLIDisplay.spinnerStop();\n\n\tif (opts.console) {\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.identity-create.labels.identity\"), document.id);\n\t\tCLIDisplay.break();\n\t}\n\n\tif (Is.stringValue(opts?.json)) {\n\t\tawait CLIUtils.writeJsonFile(opts.json, { did: document.id }, opts.mergeJson);\n\t}\n\tif (Is.stringValue(opts?.env)) {\n\t\tawait CLIUtils.writeEnvFile(opts.env, [`DID=\"${document.id}\"`], opts.mergeEnv);\n\t}\n\n\tif (opts.connector === IdentityConnectorTypes.Iota) {\n\t\tconst didUrn = Urn.fromValidString(document.id);\n\t\tconst didParts = didUrn.parts();\n\t\tconst objectId = didParts[didParts.length - 1];\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.common.labels.explore\"),\n\t\t\t`${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`\n\t\t);\n\t}\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\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,20 +61,18 @@ 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);
71
67
  }
72
68
  CLIDisplay.break();
73
69
  setupVault();
74
- const localIdentity = "local";
75
70
  const vmParts = DocumentHelper.parseId(id);
76
71
  const vaultConnector = VaultConnectorFactory.get("vault");
77
- await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
72
+ await vaultConnector.addKey(`${vmParts.id}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
78
73
  const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
79
74
  WalletConnectorFactory.register("wallet", () => walletConnector);
80
- const identityConnector = setupIdentityConnector({ nodeEndpoint, network, addressIndex }, opts.connector);
75
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
81
76
  CLIDisplay.task(I18n.formatMessage("commands.proof-create.progress.creatingProof"));
82
77
  CLIDisplay.break();
83
78
  CLIDisplay.spinnerStart();
@@ -85,7 +80,7 @@ export async function actionCommandProofCreate(opts) {
85
80
  if (Is.undefined(document)) {
86
81
  throw new GeneralError("commands", "commands.proof-create.documentJsonFileNotFound");
87
82
  }
88
- const proof = await identityConnector.createProof(localIdentity, id, ProofTypes.DataIntegrityProof, document);
83
+ const proof = await identityConnector.createProof(vmParts.id, id, ProofTypes.DataIntegrityProof, document);
89
84
  CLIDisplay.spinnerStop();
90
85
  if (opts.console) {
91
86
  CLIDisplay.json(proof);
@@ -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,EAA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AAc,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,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,M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,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\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 vmParts = DocumentHelper.parseId(id);\n\n\tconst vaultConnector = VaultConnectorFactory.get(\"vault\");\n\tawait vaultConnector.addKey(\n\t\t`${vmParts.id}/${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\tvmParts.id,\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,8 @@ 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.expiration-date.param"), I18n.formatMessage("commands.verifiable-credential-create.options.expiration-date.description"))
28
+ .option(I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.param"), I18n.formatMessage("commands.verifiable-credential-create.options.revocation-index.description"));
29
29
  CLIOptions.output(command, {
30
30
  noConsole: true,
31
31
  json: true,
@@ -49,8 +49,8 @@ export function buildCommandVerifiableCredentialCreate() {
49
49
  * @param opts.privateKey The private key for the verification method.
50
50
  * @param opts.credentialId The id of the credential.
51
51
  * @param opts.subjectJson The JSON data for the subject.
52
+ * @param opts.expirationDate The expiration date for the credential.
52
53
  * @param opts.revocationIndex The revocation index for the credential.
53
- * @param opts.addressIndex The address index to use for key derivation (if applicable).
54
54
  * @param opts.connector The connector to perform the operations with.
55
55
  * @param opts.node The node URL.
56
56
  */
@@ -60,7 +60,6 @@ export async function actionCommandVerifiableCredentialCreate(opts) {
60
60
  const credentialId = CLIParam.stringValue("credential-id", opts.credentialId);
61
61
  const subjectJson = path.resolve(CLIParam.stringValue("subject-json", opts.subjectJson));
62
62
  const revocationIndex = Coerce.number(opts.revocationIndex);
63
- const addressIndex = CLIParam.integer("addressIndex", opts.addressIndex ?? "0", false, 0);
64
63
  const nodeEndpoint = CLIParam.url("node", opts.node);
65
64
  const network = opts.connector === IdentityConnectorTypes.Iota
66
65
  ? CLIParam.stringValue("network", opts.network)
@@ -69,20 +68,19 @@ export async function actionCommandVerifiableCredentialCreate(opts) {
69
68
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.credentialId"), credentialId);
70
69
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.subjectJson"), subjectJson);
71
70
  CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.revocationIndex"), revocationIndex);
72
- CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.addressIndex"), addressIndex);
71
+ CLIDisplay.value(I18n.formatMessage("commands.verifiable-credential-create.labels.expirationDate"), opts.expirationDate);
73
72
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
74
73
  if (Is.stringValue(network)) {
75
74
  CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
76
75
  }
77
76
  CLIDisplay.break();
78
77
  setupVault();
79
- const localIdentity = "local";
80
78
  const vmParts = DocumentHelper.parseId(id);
81
79
  const vaultConnector = VaultConnectorFactory.get("vault");
82
- await vaultConnector.addKey(`${localIdentity}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
80
+ await vaultConnector.addKey(`${vmParts.id}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
83
81
  const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
84
82
  WalletConnectorFactory.register("wallet", () => walletConnector);
85
- const identityConnector = setupIdentityConnector({ nodeEndpoint, network, addressIndex }, opts.connector);
83
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
86
84
  CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-create.progress.loadingSubjectData"));
87
85
  CLIDisplay.break();
88
86
  const jsonData = await CLIUtils.readJsonFile(subjectJson);
@@ -92,8 +90,9 @@ export async function actionCommandVerifiableCredentialCreate(opts) {
92
90
  CLIDisplay.task(I18n.formatMessage("commands.verifiable-credential-create.progress.creatingVerifiableCredential"));
93
91
  CLIDisplay.break();
94
92
  CLIDisplay.spinnerStart();
95
- const verifiableCredential = await identityConnector.createVerifiableCredential(localIdentity, id, credentialId, jsonData, {
96
- revocationIndex
93
+ const verifiableCredential = await identityConnector.createVerifiableCredential(vmParts.id, id, credentialId, jsonData, {
94
+ revocationIndex,
95
+ expirationDate: Coerce.dateTime(opts.expirationDate)
97
96
  });
98
97
  CLIDisplay.spinnerStop();
99
98
  if (opts.console) {
@@ -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,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OA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B,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":"verifiableCredentialCreate.js","sourceRoot":"","sources":["../../../src/commands/verifiableCredentialCreate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAA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M,oBAAoB,GAAG,MAAM,iBAAiB,CAAC,0BAA0B,CAC9E,OAAO,CAAC,EAAE,EACV,EAAE,EACF,YAAY,EACZ,QAAQ,EACR;QACC,eAAe;QACf,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC;KACpD,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.expiration-date.param\"),\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"commands.verifiable-credential-create.options.expiration-date.description\"\n\t\t\t)\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.expirationDate The expiration date for the credential.\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\texpirationDate?: 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(\n\t\tI18n.formatMessage(\"commands.verifiable-credential-create.labels.expirationDate\"),\n\t\topts.expirationDate\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 vmParts = DocumentHelper.parseId(id);\n\n\tconst vaultConnector = VaultConnectorFactory.get(\"vault\");\n\tawait vaultConnector.addKey(\n\t\t`${vmParts.id}/${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\tvmParts.id,\n\t\tid,\n\t\tcredentialId,\n\t\tjsonData,\n\t\t{\n\t\t\trevocationIndex,\n\t\t\texpirationDate: Coerce.dateTime(opts.expirationDate)\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"]}
@@ -95,10 +95,14 @@ export async function actionCommandVerificationMethodAdd(opts) {
95
95
  CLIDisplay.spinnerStop();
96
96
  const keyParts = DocumentHelper.parseId(verificationMethod.id);
97
97
  const keyPair = await vaultConnector.getKey(`${localIdentity}/${keyParts.fragment}`);
98
- const privateKeyBase64 = Converter.bytesToBase64Url(keyPair.privateKey);
99
- const publicKeyBase64 = Is.uint8Array(keyPair.publicKey)
98
+ const privateKeyBase64Url = Converter.bytesToBase64Url(keyPair.privateKey);
99
+ const publicKeyBase64Url = Is.uint8Array(keyPair.publicKey)
100
100
  ? Converter.bytesToBase64Url(keyPair.publicKey)
101
101
  : "";
102
+ const privateKeyBase64 = Converter.bytesToBase64(keyPair.privateKey);
103
+ const publicKeyBase64 = Is.uint8Array(keyPair.publicKey)
104
+ ? Converter.bytesToBase64(keyPair.publicKey)
105
+ : "";
102
106
  const privateKeyHex = Converter.bytesToHex(keyPair.privateKey, true);
103
107
  const publicKeyHex = Is.uint8Array(keyPair.publicKey)
104
108
  ? Converter.bytesToHex(keyPair.publicKey, true)
@@ -108,6 +112,8 @@ export async function actionCommandVerificationMethodAdd(opts) {
108
112
  if (opts.console) {
109
113
  CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.verificationMethodId"), verificationMethod.id);
110
114
  CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.kid"), kid);
115
+ CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.privateKeyBase64Url"), privateKeyBase64Url);
116
+ CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.publicKeyBase64Url"), publicKeyBase64Url);
111
117
  CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.privateKeyBase64"), privateKeyBase64);
112
118
  CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.publicKeyBase64"), publicKeyBase64);
113
119
  CLIDisplay.value(I18n.formatMessage("commands.verification-method-add.labels.privateKeyHex"), privateKeyHex);
@@ -116,16 +122,31 @@ export async function actionCommandVerificationMethodAdd(opts) {
116
122
  }
117
123
  if (Is.stringValue(opts?.json)) {
118
124
  await CLIUtils.writeJsonFile(opts.json, {
119
- kid,
120
- ...jwk
125
+ verificationMethodId: verificationMethod.id,
126
+ privateKeyJwk: {
127
+ kid,
128
+ ...jwk
129
+ },
130
+ privateKeyHex,
131
+ publicKeyHex,
132
+ privateKeyBase64,
133
+ publicKeyBase64
121
134
  }, opts.mergeJson);
122
135
  }
123
136
  if (Is.stringValue(opts?.env)) {
124
137
  await CLIUtils.writeEnvFile(opts.env, [
125
138
  `DID_VERIFICATION_METHOD_ID="${verificationMethod.id}"`,
126
139
  `DID_VERIFICATION_METHOD_KID="${kid}"`,
127
- `DID_VERIFICATION_METHOD_PRIVATE_KEY="${privateKeyHex}"`,
128
- `DID_VERIFICATION_METHOD_PUBLIC_KEY="${publicKeyHex}"`
140
+ `DID_VERIFICATION_METHOD_JWK_KTY="${jwk.kty}"`,
141
+ `DID_VERIFICATION_METHOD_JWK_USE="${jwk.use}"`,
142
+ `DID_VERIFICATION_METHOD_JWK_ALG="${jwk.alg}"`,
143
+ `DID_VERIFICATION_METHOD_JWK_CRV="${jwk.crv}"`,
144
+ `DID_VERIFICATION_METHOD_JWK_X="${jwk.x}"`,
145
+ `DID_VERIFICATION_METHOD_JWK_D="${jwk.d}"`,
146
+ `DID_VERIFICATION_METHOD_PRIVATE_KEY_HEX="${privateKeyHex}"`,
147
+ `DID_VERIFICATION_METHOD_PUBLIC_KEY_HEX="${publicKeyHex}"`,
148
+ `DID_VERIFICATION_METHOD_PRIVATE_KEY_BASE64="${privateKeyBase64}"`,
149
+ `DID_VERIFICATION_METHOD_PUBLIC_KEY_BASE64="${publicKeyBase64}"`
129
150
  ], opts.mergeEnv);
130
151
  }
131
152
  if (opts.connector === IdentityConnectorTypes.Iota) {
@@ -1 +1 @@
1
- {"version":3,"file":"verificationMethodAdd.js","sourceRoot":"","sources":["../../../src/commands/verificationMethodAdd.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EAER,MA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CAAC,EACpD,GAAG,YAAY,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,WAAW,QAAQ,YAAY,OAAO,EAAE,CAC7F,CAAC;IACH,CAAC;IAED,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tCLIDisplay,\n\tCLIOptions,\n\tCLIParam,\n\tCLIUtils,\n\ttype CliOutputOptions\n} from \"@twin.org/cli-core\";\nimport { Converter, I18n, Is, StringHelper, Urn } from \"@twin.org/core\";\nimport { DocumentHelper } from \"@twin.org/identity-models\";\nimport { DidVerificationMethodType } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory } from \"@twin.org/vault-models\";\nimport { setupWalletConnector } from \"@twin.org/wallet-cli\";\nimport { WalletConnectorFactory } from \"@twin.org/wallet-models\";\nimport { Jwk } from \"@twin.org/web\";\nimport { Command, Option } from \"commander\";\nimport { setupIdentityConnector, setupVault } from \"./setupCommands.js\";\nimport { IdentityConnectorTypes } from \"../models/identityConnectorTypes.js\";\n\n/**\n * Build the verification method add command for the CLI.\n * @returns The command.\n */\nexport function buildCommandVerificationMethodAdd(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"verification-method-add\")\n\t\t.summary(I18n.formatMessage(\"commands.verification-method-add.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.verification-method-add.description\"))\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.seed.param\"),\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.seed.description\")\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.did.param\"),\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.did.description\")\n\t\t)\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.type.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.type.description\")\n\t\t\t)\n\t\t\t\t.choices(Object.values(DidVerificationMethodType))\n\t\t\t\t.makeOptionMandatory()\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.id.param\"),\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.id.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.addressIndex.param\"),\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.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.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.explorer.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.explorer.description\"),\n\t\t\t\"!EXPLORER_URL\"\n\t\t)\n\t\t.action(actionCommandVerificationMethodAdd);\n\n\treturn command;\n}\n\n/**\n * Action the verification method add command.\n * @param opts The options for the command.\n * @param opts.seed The private key for the controller.\n * @param opts.did The identity of the document to add to.\n * @param opts.type The type of the verification method to add.\n * @param opts.id The id of the verification method to add.\n * @param opts.connector The connector to perform the operations with.\n * @param opts.node The node URL.\n * @param opts.explorer The explorer URL.\n * @param opts.network The network to use for connector.\n * @param opts.addressIndex The address index to use for key derivation (if applicable).\n */\nexport async function actionCommandVerificationMethodAdd(\n\topts: {\n\t\tseed: string;\n\t\tdid: string;\n\t\ttype: DidVerificationMethodType;\n\t\tid?: string;\n\t\taddressIndex?: string;\n\t\tconnector?: IdentityConnectorTypes;\n\t\tnode: string;\n\t\tnetwork?: string;\n\t\texplorer: string;\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst seed: Uint8Array = CLIParam.hexBase64(\"seed\", opts.seed);\n\tconst did: string = CLIParam.stringValue(\"did\", opts.did);\n\tconst type: DidVerificationMethodType = CLIParam.stringValue(\n\t\t\"type\",\n\t\topts.type\n\t) as DidVerificationMethodType;\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\tconst explorerEndpoint: string = CLIParam.url(\"explorer\", opts.explorer);\n\n\tCLIDisplay.value(I18n.formatMessage(\"commands.common.labels.did\"), did);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verification-method-add.labels.verificationMethodType\"),\n\t\ttype\n\t);\n\tif (Is.stringValue(opts.id)) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.verificationMethodId\"),\n\t\t\topts?.id\n\t\t);\n\t}\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verification-method-add.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.value(I18n.formatMessage(\"commands.common.labels.explorer\"), explorerEndpoint);\n\tCLIDisplay.break();\n\n\tsetupVault();\n\n\tconst vaultSeedId = \"local-seed\";\n\tconst localIdentity = \"local\";\n\n\tconst vaultConnector = VaultConnectorFactory.get(\"vault\");\n\tawait vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));\n\n\tconst walletConnector = setupWalletConnector(\n\t\t{ nodeEndpoint, vaultSeedId, network },\n\t\topts.connector\n\t);\n\tWalletConnectorFactory.register(\"wallet\", () => walletConnector);\n\n\tconst identityConnector = setupIdentityConnector(\n\t\t{ nodeEndpoint, network, addressIndex, vaultSeedId },\n\t\topts.connector\n\t);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"commands.verification-method-add.progress.addingVerificationMethod\")\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.spinnerStart();\n\n\tconst verificationMethod = await identityConnector.addVerificationMethod(\n\t\tlocalIdentity,\n\t\tdid,\n\t\ttype,\n\t\topts?.id\n\t);\n\n\tCLIDisplay.spinnerStop();\n\n\tconst keyParts = DocumentHelper.parseId(verificationMethod.id);\n\n\tconst keyPair = await vaultConnector.getKey(`${localIdentity}/${keyParts.fragment}`);\n\tconst privateKeyBase64 = Converter.bytesToBase64Url(keyPair.privateKey);\n\tconst publicKeyBase64 = Is.uint8Array(keyPair.publicKey)\n\t\t? Converter.bytesToBase64Url(keyPair.publicKey)\n\t\t: \"\";\n\n\tconst privateKeyHex = Converter.bytesToHex(keyPair.privateKey, true);\n\tconst publicKeyHex = Is.uint8Array(keyPair.publicKey)\n\t\t? Converter.bytesToHex(keyPair.publicKey, true)\n\t\t: \"\";\n\n\tconst jwk = await Jwk.fromEd25519Private(keyPair.privateKey);\n\tconst kid = await Jwk.generateKid(jwk);\n\n\tif (opts.console) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.verificationMethodId\"),\n\t\t\tverificationMethod.id\n\t\t);\n\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.verification-method-add.labels.kid\"), kid);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.privateKeyBase64\"),\n\t\t\tprivateKeyBase64\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.publicKeyBase64\"),\n\t\t\tpublicKeyBase64\n\t\t);\n\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.privateKeyHex\"),\n\t\t\tprivateKeyHex\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.publicKeyHex\"),\n\t\t\tpublicKeyHex\n\t\t);\n\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{\n\t\t\t\tkid,\n\t\t\t\t...jwk\n\t\t\t},\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[\n\t\t\t\t`DID_VERIFICATION_METHOD_ID=\"${verificationMethod.id}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_KID=\"${kid}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_PRIVATE_KEY=\"${privateKeyHex}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_PUBLIC_KEY=\"${publicKeyHex}\"`\n\t\t\t],\n\t\t\topts.mergeEnv\n\t\t);\n\t}\n\n\tif (opts.connector === IdentityConnectorTypes.Iota) {\n\t\tconst didUrn = Urn.fromValidString(did);\n\t\tconst didParts = didUrn.parts();\n\t\tconst objectId = didParts[didParts.length - 1];\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.common.labels.explore\"),\n\t\t\t`${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`\n\t\t);\n\t}\n\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n}\n"]}
1
+ {"version":3,"file":"verificationMethodAdd.js","sourceRoot":"","sources":["../../../src/commands/verificationMethodAdd.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,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,iCAAiC;IAChD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO;SACL,IAAI,CAAC,yBAAyB,CAAC;SAC/B,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC,CAAC;SACvE,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC,CAAC;SAC/E,cAAc,CACd,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC,EACzE,IAAI,CAAC,aAAa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AAC;IACH,CAAC;IAED,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tCLIDisplay,\n\tCLIOptions,\n\tCLIParam,\n\tCLIUtils,\n\ttype CliOutputOptions\n} from \"@twin.org/cli-core\";\nimport { Converter, I18n, Is, StringHelper, Urn } from \"@twin.org/core\";\nimport { DocumentHelper } from \"@twin.org/identity-models\";\nimport { DidVerificationMethodType } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory } from \"@twin.org/vault-models\";\nimport { setupWalletConnector } from \"@twin.org/wallet-cli\";\nimport { WalletConnectorFactory } from \"@twin.org/wallet-models\";\nimport { Jwk } from \"@twin.org/web\";\nimport { Command, Option } from \"commander\";\nimport { setupIdentityConnector, setupVault } from \"./setupCommands.js\";\nimport { IdentityConnectorTypes } from \"../models/identityConnectorTypes.js\";\n\n/**\n * Build the verification method add command for the CLI.\n * @returns The command.\n */\nexport function buildCommandVerificationMethodAdd(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"verification-method-add\")\n\t\t.summary(I18n.formatMessage(\"commands.verification-method-add.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.verification-method-add.description\"))\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.seed.param\"),\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.seed.description\")\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.did.param\"),\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.did.description\")\n\t\t)\n\t\t.addOption(\n\t\t\tnew Option(\n\t\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.type.param\"),\n\t\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.type.description\")\n\t\t\t)\n\t\t\t\t.choices(Object.values(DidVerificationMethodType))\n\t\t\t\t.makeOptionMandatory()\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.id.param\"),\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.id.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.options.addressIndex.param\"),\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.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.option(\n\t\t\tI18n.formatMessage(\"commands.common.options.explorer.param\"),\n\t\t\tI18n.formatMessage(\"commands.common.options.explorer.description\"),\n\t\t\t\"!EXPLORER_URL\"\n\t\t)\n\t\t.action(actionCommandVerificationMethodAdd);\n\n\treturn command;\n}\n\n/**\n * Action the verification method add command.\n * @param opts The options for the command.\n * @param opts.seed The private key for the controller.\n * @param opts.did The identity of the document to add to.\n * @param opts.type The type of the verification method to add.\n * @param opts.id The id of the verification method to add.\n * @param opts.connector The connector to perform the operations with.\n * @param opts.node The node URL.\n * @param opts.explorer The explorer URL.\n * @param opts.network The network to use for connector.\n * @param opts.addressIndex The address index to use for key derivation (if applicable).\n */\nexport async function actionCommandVerificationMethodAdd(\n\topts: {\n\t\tseed: string;\n\t\tdid: string;\n\t\ttype: DidVerificationMethodType;\n\t\tid?: string;\n\t\taddressIndex?: string;\n\t\tconnector?: IdentityConnectorTypes;\n\t\tnode: string;\n\t\tnetwork?: string;\n\t\texplorer: string;\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst seed: Uint8Array = CLIParam.hexBase64(\"seed\", opts.seed);\n\tconst did: string = CLIParam.stringValue(\"did\", opts.did);\n\tconst type: DidVerificationMethodType = CLIParam.stringValue(\n\t\t\"type\",\n\t\topts.type\n\t) as DidVerificationMethodType;\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\tconst explorerEndpoint: string = CLIParam.url(\"explorer\", opts.explorer);\n\n\tCLIDisplay.value(I18n.formatMessage(\"commands.common.labels.did\"), did);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verification-method-add.labels.verificationMethodType\"),\n\t\ttype\n\t);\n\tif (Is.stringValue(opts.id)) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.verificationMethodId\"),\n\t\t\topts?.id\n\t\t);\n\t}\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verification-method-add.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.value(I18n.formatMessage(\"commands.common.labels.explorer\"), explorerEndpoint);\n\tCLIDisplay.break();\n\n\tsetupVault();\n\n\tconst vaultSeedId = \"local-seed\";\n\tconst localIdentity = \"local\";\n\n\tconst vaultConnector = VaultConnectorFactory.get(\"vault\");\n\tawait vaultConnector.setSecret(`${localIdentity}/${vaultSeedId}`, Converter.bytesToBase64(seed));\n\n\tconst walletConnector = setupWalletConnector(\n\t\t{ nodeEndpoint, vaultSeedId, network },\n\t\topts.connector\n\t);\n\tWalletConnectorFactory.register(\"wallet\", () => walletConnector);\n\n\tconst identityConnector = setupIdentityConnector(\n\t\t{ nodeEndpoint, network, addressIndex, vaultSeedId },\n\t\topts.connector\n\t);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"commands.verification-method-add.progress.addingVerificationMethod\")\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.spinnerStart();\n\n\tconst verificationMethod = await identityConnector.addVerificationMethod(\n\t\tlocalIdentity,\n\t\tdid,\n\t\ttype,\n\t\topts?.id\n\t);\n\n\tCLIDisplay.spinnerStop();\n\n\tconst keyParts = DocumentHelper.parseId(verificationMethod.id);\n\n\tconst keyPair = await vaultConnector.getKey(`${localIdentity}/${keyParts.fragment}`);\n\tconst privateKeyBase64Url = Converter.bytesToBase64Url(keyPair.privateKey);\n\tconst publicKeyBase64Url = Is.uint8Array(keyPair.publicKey)\n\t\t? Converter.bytesToBase64Url(keyPair.publicKey)\n\t\t: \"\";\n\n\tconst privateKeyBase64 = Converter.bytesToBase64(keyPair.privateKey);\n\tconst publicKeyBase64 = Is.uint8Array(keyPair.publicKey)\n\t\t? Converter.bytesToBase64(keyPair.publicKey)\n\t\t: \"\";\n\n\tconst privateKeyHex = Converter.bytesToHex(keyPair.privateKey, true);\n\tconst publicKeyHex = Is.uint8Array(keyPair.publicKey)\n\t\t? Converter.bytesToHex(keyPair.publicKey, true)\n\t\t: \"\";\n\n\tconst jwk = await Jwk.fromEd25519Private(keyPair.privateKey);\n\tconst kid = await Jwk.generateKid(jwk);\n\n\tif (opts.console) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.verificationMethodId\"),\n\t\t\tverificationMethod.id\n\t\t);\n\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.verification-method-add.labels.kid\"), kid);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.privateKeyBase64Url\"),\n\t\t\tprivateKeyBase64Url\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.publicKeyBase64Url\"),\n\t\t\tpublicKeyBase64Url\n\t\t);\n\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.privateKeyBase64\"),\n\t\t\tprivateKeyBase64\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.publicKeyBase64\"),\n\t\t\tpublicKeyBase64\n\t\t);\n\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.privateKeyHex\"),\n\t\t\tprivateKeyHex\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verification-method-add.labels.publicKeyHex\"),\n\t\t\tpublicKeyHex\n\t\t);\n\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{\n\t\t\t\tverificationMethodId: verificationMethod.id,\n\t\t\t\tprivateKeyJwk: {\n\t\t\t\t\tkid,\n\t\t\t\t\t...jwk\n\t\t\t\t},\n\t\t\t\tprivateKeyHex,\n\t\t\t\tpublicKeyHex,\n\t\t\t\tprivateKeyBase64,\n\t\t\t\tpublicKeyBase64\n\t\t\t},\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[\n\t\t\t\t`DID_VERIFICATION_METHOD_ID=\"${verificationMethod.id}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_KID=\"${kid}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_JWK_KTY=\"${jwk.kty}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_JWK_USE=\"${jwk.use}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_JWK_ALG=\"${jwk.alg}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_JWK_CRV=\"${jwk.crv}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_JWK_X=\"${jwk.x}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_JWK_D=\"${jwk.d}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_PRIVATE_KEY_HEX=\"${privateKeyHex}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_PUBLIC_KEY_HEX=\"${publicKeyHex}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_PRIVATE_KEY_BASE64=\"${privateKeyBase64}\"`,\n\t\t\t\t`DID_VERIFICATION_METHOD_PUBLIC_KEY_BASE64=\"${publicKeyBase64}\"`\n\t\t\t],\n\t\t\topts.mergeEnv\n\t\t);\n\t}\n\n\tif (opts.connector === IdentityConnectorTypes.Iota) {\n\t\tconst didUrn = Urn.fromValidString(did);\n\t\tconst didParts = didUrn.parts();\n\t\tconst objectId = didParts[didParts.length - 1];\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.common.labels.explore\"),\n\t\t\t`${StringHelper.trimTrailingSlashes(explorerEndpoint)}/object/${objectId}?network=${network}`\n\t\t);\n\t}\n\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n}\n"]}
@@ -81,6 +81,8 @@
81
81
  "urn": "Property \"{property}\" must be a Urn formatted string, it is \"{value}\"",
82
82
  "url": "Property \"{property}\" must be a Url formatted string, it is \"{value}\"",
83
83
  "email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\"",
84
+ "uuidV7": "Property \"{property}\" must be a UUIDv7 formatted string, it is \"{value}\"",
85
+ "uuidV7Compact": "Property \"{property}\" must be a UUIDv7 formatted string in compact mode, it is \"{value}\"",
84
86
  "length32Multiple": "Property \"{property}\" should be a multiple of 32, it is {value}",
85
87
  "lengthEntropy": "Property \"{property}\" should be a multiple of 4, >=16 and <= 32, it is {value}",
86
88
  "didPartsTooFew": "The DID \"{value}\" is invalid: expected at least 3 parts but got fewer",
@@ -207,6 +209,10 @@
207
209
  "createFailed": "Failed to create JWS",
208
210
  "verifyFailed": "Failed to verify JWS"
209
211
  },
212
+ "headerHelper": {
213
+ "invalidLinkHeaderURL": "URL for Link header cannot contain \">\" character.",
214
+ "invalidLinkHeaderRel": "Relation type for Link header cannot contain \" character."
215
+ },
210
216
  "contextIdHelper": {
211
217
  "contextIdMissing": "The context ID \"{key}\" is missing from the provided context IDs",
212
218
  "contextIdSplitMismatch": "The context ID split parts length \"{actual}\" does not match the provided keys length \"{expected}\""
@@ -552,6 +558,10 @@
552
558
  "param": "--seed '<'seed'>'",
553
559
  "description": "The seed for the controller address in hex or base64 used to create the DID, or start with ! to read environment variable."
554
560
  },
561
+ "controller": {
562
+ "param": "--controller '<'controller'>'",
563
+ "description": "The controller for the DID, or start with ! to read environment variable."
564
+ },
555
565
  "addressIndex": {
556
566
  "param": "--address-index '<'index'>'",
557
567
  "description": "The address index to use for the creation."
@@ -612,6 +622,8 @@
612
622
  "labels": {
613
623
  "verificationMethodType": "Verification Method Type",
614
624
  "verificationMethodId": "Verification Method Id",
625
+ "privateKeyBase64Url": "Private Key Base64 Url",
626
+ "publicKeyBase64Url": "Public Key Base64 Url",
615
627
  "privateKeyBase64": "Private Key Base64",
616
628
  "publicKeyBase64": "Public Key Base64",
617
629
  "privateKeyHex": "Private Key Hex",
@@ -733,9 +745,9 @@
733
745
  "param": "--revocation-index '<'revocation-index'>'",
734
746
  "description": "The revocation index in the issuing document to use if revoking the credential."
735
747
  },
736
- "addressIndex": {
737
- "param": "--address-index '<'index'>'",
738
- "description": "The address index to use for the identity controller."
748
+ "expiration-date": {
749
+ "param": "--expiration-date '<'ISO Date'>'",
750
+ "description": "The expiration date for the credential."
739
751
  }
740
752
  },
741
753
  "progress": {
@@ -748,7 +760,7 @@
748
760
  "subjectJson": "Subject JSON",
749
761
  "revocationIndex": "Revocation Index",
750
762
  "verifiableCredential": "Verifiable Credential",
751
- "addressIndex": "Address Index"
763
+ "expirationDate": "Expiration Date"
752
764
  }
753
765
  },
754
766
  "verifiable-credential-verify": {
@@ -842,10 +854,6 @@
842
854
  "document-filename": {
843
855
  "param": "--document-filename '<'document-filename'>'",
844
856
  "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
857
  }
850
858
  },
851
859
  "progress": {
@@ -853,8 +861,7 @@
853
861
  },
854
862
  "labels": {
855
863
  "documentFilename": "Document Filename",
856
- "verificationMethodId": "Verification Method Id",
857
- "addressIndex": "Address Index"
864
+ "verificationMethodId": "Verification Method Id"
858
865
  }
859
866
  },
860
867
  "proof-verify": {
@@ -22,4 +22,5 @@ export declare function actionCommandIdentityCreate(opts: {
22
22
  network?: string;
23
23
  explorer: string;
24
24
  addressIndex?: string;
25
+ controller?: string;
25
26
  } & CliOutputOptions): Promise<void>;
@@ -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;
@@ -13,8 +13,8 @@ export declare function buildCommandVerifiableCredentialCreate(): Command;
13
13
  * @param opts.privateKey The private key for the verification method.
14
14
  * @param opts.credentialId The id of the credential.
15
15
  * @param opts.subjectJson The JSON data for the subject.
16
+ * @param opts.expirationDate The expiration date for the credential.
16
17
  * @param opts.revocationIndex The revocation index for the credential.
17
- * @param opts.addressIndex The address index to use for key derivation (if applicable).
18
18
  * @param opts.connector The connector to perform the operations with.
19
19
  * @param opts.node The node URL.
20
20
  */
@@ -23,8 +23,8 @@ export declare function actionCommandVerifiableCredentialCreate(opts: {
23
23
  privateKey: string;
24
24
  credentialId?: string;
25
25
  subjectJson: string;
26
+ expirationDate?: string;
26
27
  revocationIndex?: string;
27
- addressIndex?: string;
28
28
  connector?: IdentityConnectorTypes;
29
29
  node: string;
30
30
  network?: string;
package/docs/changelog.md CHANGED
@@ -1,5 +1,199 @@
1
1
  # @twin.org/identity-cli - Changelog
2
2
 
3
+ ## [0.0.3-next.11](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.10...identity-cli-v0.0.3-next.11) (2026-01-15)
4
+
5
+
6
+ ### Features
7
+
8
+ * add addressIndex option to all commands ([a644674](https://github.com/twinfoundation/identity/commit/a644674017d1a8fe5d8685950316bec922a9b195))
9
+ * add context id features ([#62](https://github.com/twinfoundation/identity/issues/62)) ([e02ecca](https://github.com/twinfoundation/identity/commit/e02ecca9c45a849104bfbf7bc18a1f44e6eea8a1))
10
+ * add expiration date option to vc creation ([73e05e1](https://github.com/twinfoundation/identity/commit/73e05e1ae61112c7e056889969751f4ff82d9f29))
11
+ * add mainnet support ([af56a38](https://github.com/twinfoundation/identity/commit/af56a382837896cd4e13d5814c0924c46658b99c))
12
+ * add validate-locales ([04d74b4](https://github.com/twinfoundation/identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
13
+ * eslint migration to flat config ([fd6246d](https://github.com/twinfoundation/identity/commit/fd6246d566280b6d5d10a108eb1e92c4b510f2f2))
14
+ * identity key separator use slash ([1319d0d](https://github.com/twinfoundation/identity/commit/1319d0d07164a36b3ec279e6421b8835ffefc3d3))
15
+ * iota rebased release ([5d14674](https://github.com/twinfoundation/identity/commit/5d146744ca9eed622ef7eb34a7fa935216f9e975))
16
+ * support mainnet for alias extraction ([1114e0f](https://github.com/twinfoundation/identity/commit/1114e0f518070ef930d7d6ed73a616cce647206c))
17
+ * update framework core ([c824497](https://github.com/twinfoundation/identity/commit/c82449709af0215eb7af496cf687c93fb30b5ae0))
18
+ * update namespaces and contexts ([#90](https://github.com/twinfoundation/identity/issues/90)) ([0c34d64](https://github.com/twinfoundation/identity/commit/0c34d64add8cca77856fa2d0357e774d72fbbfc1))
19
+ * use new generateKid method ([f0fe779](https://github.com/twinfoundation/identity/commit/f0fe779323b675575bb9f80aa74f1957dc57a094))
20
+ * use shared store mechanism ([#27](https://github.com/twinfoundation/identity/issues/27)) ([ce41f3f](https://github.com/twinfoundation/identity/commit/ce41f3fc3da1b206ec06da7ea5b2c968f788804d))
21
+ * verification method output JWK and hex on CLI ([49db9da](https://github.com/twinfoundation/identity/commit/49db9da2371eafdcd7176ce44303961b9b8b8380))
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * correctly display mainnet explorer urls ([45a9f3c](https://github.com/twinfoundation/identity/commit/45a9f3cc041cce7b40a86e98df306931a95f48ea))
27
+ * expiration date coerced to full date time ([83e94e3](https://github.com/twinfoundation/identity/commit/83e94e3fc2b982fbb41f87a177e0e79a7f2e4079))
28
+ * explorer urls in CLI ([82a745d](https://github.com/twinfoundation/identity/commit/82a745d536e8fe42554e7ad92a7468a653fc0cfb))
29
+ * Import path and bump version ([#21](https://github.com/twinfoundation/identity/issues/21)) ([ccea845](https://github.com/twinfoundation/identity/commit/ccea845bf32562267280bc1b3dde1c9af1a00360))
30
+ * Install sdk-wasm ([#20](https://github.com/twinfoundation/identity/issues/20)) ([75ec14e](https://github.com/twinfoundation/identity/commit/75ec14e072f8c219863a1c028a3b0783802086e9))
31
+ * remove unused address index params in CLI ([c4c0cc1](https://github.com/twinfoundation/identity/commit/c4c0cc18e17804380cf52330e1b9de8716cc193d))
32
+ * update vault key naming convention to use document ID prefix ([#94](https://github.com/twinfoundation/identity/issues/94)) ([ab125c1](https://github.com/twinfoundation/identity/commit/ab125c1b7eb189b5dceaddc69e5e53e33a0886db))
33
+
34
+
35
+ ### Dependencies
36
+
37
+ * The following workspace dependencies were updated
38
+ * dependencies
39
+ * @twin.org/identity-models bumped from 0.0.3-next.10 to 0.0.3-next.11
40
+ * @twin.org/identity-connector-iota bumped from 0.0.3-next.10 to 0.0.3-next.11
41
+
42
+ ## [0.0.3-next.10](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.9...identity-cli-v0.0.3-next.10) (2026-01-15)
43
+
44
+
45
+ ### Bug Fixes
46
+
47
+ * expiration date coerced to full date time ([83e94e3](https://github.com/twinfoundation/identity/commit/83e94e3fc2b982fbb41f87a177e0e79a7f2e4079))
48
+
49
+
50
+ ### Dependencies
51
+
52
+ * The following workspace dependencies were updated
53
+ * dependencies
54
+ * @twin.org/identity-models bumped from 0.0.3-next.9 to 0.0.3-next.10
55
+ * @twin.org/identity-connector-iota bumped from 0.0.3-next.9 to 0.0.3-next.10
56
+
57
+ ## [0.0.3-next.9](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.8...identity-cli-v0.0.3-next.9) (2026-01-14)
58
+
59
+
60
+ ### Bug Fixes
61
+
62
+ * update vault key naming convention to use document ID prefix ([#94](https://github.com/twinfoundation/identity/issues/94)) ([ab125c1](https://github.com/twinfoundation/identity/commit/ab125c1b7eb189b5dceaddc69e5e53e33a0886db))
63
+
64
+
65
+ ### Dependencies
66
+
67
+ * The following workspace dependencies were updated
68
+ * dependencies
69
+ * @twin.org/identity-models bumped from 0.0.3-next.8 to 0.0.3-next.9
70
+ * @twin.org/identity-connector-iota bumped from 0.0.3-next.8 to 0.0.3-next.9
71
+
72
+ ## [0.0.3-next.8](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.7...identity-cli-v0.0.3-next.8) (2026-01-14)
73
+
74
+
75
+ ### Features
76
+
77
+ * update namespaces and contexts ([#90](https://github.com/twinfoundation/identity/issues/90)) ([0c34d64](https://github.com/twinfoundation/identity/commit/0c34d64add8cca77856fa2d0357e774d72fbbfc1))
78
+
79
+
80
+ ### Dependencies
81
+
82
+ * The following workspace dependencies were updated
83
+ * dependencies
84
+ * @twin.org/identity-models bumped from 0.0.3-next.7 to 0.0.3-next.8
85
+ * @twin.org/identity-connector-iota bumped from 0.0.3-next.7 to 0.0.3-next.8
86
+
87
+ ## [0.0.3-next.7](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.6...identity-cli-v0.0.3-next.7) (2026-01-13)
88
+
89
+
90
+ ### Miscellaneous Chores
91
+
92
+ * **identity-cli:** Synchronize repo versions
93
+
94
+
95
+ ### Dependencies
96
+
97
+ * The following workspace dependencies were updated
98
+ * dependencies
99
+ * @twin.org/identity-models bumped from 0.0.3-next.6 to 0.0.3-next.7
100
+ * @twin.org/identity-connector-iota bumped from 0.0.3-next.6 to 0.0.3-next.7
101
+
102
+ ## [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)
103
+
104
+
105
+ ### Miscellaneous Chores
106
+
107
+ * **identity-cli:** Synchronize repo versions
108
+
109
+
110
+ ### Dependencies
111
+
112
+ * The following workspace dependencies were updated
113
+ * dependencies
114
+ * @twin.org/identity-models bumped from 0.0.3-next.5 to 0.0.3-next.6
115
+ * @twin.org/identity-connector-iota bumped from 0.0.3-next.5 to 0.0.3-next.6
116
+
117
+ ## [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)
118
+
119
+
120
+ ### Bug Fixes
121
+
122
+ * remove unused address index params in CLI ([c4c0cc1](https://github.com/twinfoundation/identity/commit/c4c0cc18e17804380cf52330e1b9de8716cc193d))
123
+
124
+
125
+ ### Dependencies
126
+
127
+ * The following workspace dependencies were updated
128
+ * dependencies
129
+ * @twin.org/identity-models bumped from 0.0.3-next.4 to 0.0.3-next.5
130
+ * @twin.org/identity-connector-iota bumped from 0.0.3-next.4 to 0.0.3-next.5
131
+
132
+ ## [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)
133
+
134
+
135
+ ### Features
136
+
137
+ * add addressIndex option to all commands ([a644674](https://github.com/twinfoundation/identity/commit/a644674017d1a8fe5d8685950316bec922a9b195))
138
+ * add context id features ([#62](https://github.com/twinfoundation/identity/issues/62)) ([e02ecca](https://github.com/twinfoundation/identity/commit/e02ecca9c45a849104bfbf7bc18a1f44e6eea8a1))
139
+ * add expiration date option to vc creation ([73e05e1](https://github.com/twinfoundation/identity/commit/73e05e1ae61112c7e056889969751f4ff82d9f29))
140
+ * add mainnet support ([af56a38](https://github.com/twinfoundation/identity/commit/af56a382837896cd4e13d5814c0924c46658b99c))
141
+ * add validate-locales ([04d74b4](https://github.com/twinfoundation/identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
142
+ * eslint migration to flat config ([fd6246d](https://github.com/twinfoundation/identity/commit/fd6246d566280b6d5d10a108eb1e92c4b510f2f2))
143
+ * identity key separator use slash ([1319d0d](https://github.com/twinfoundation/identity/commit/1319d0d07164a36b3ec279e6421b8835ffefc3d3))
144
+ * iota rebased release ([5d14674](https://github.com/twinfoundation/identity/commit/5d146744ca9eed622ef7eb34a7fa935216f9e975))
145
+ * support mainnet for alias extraction ([1114e0f](https://github.com/twinfoundation/identity/commit/1114e0f518070ef930d7d6ed73a616cce647206c))
146
+ * update framework core ([c824497](https://github.com/twinfoundation/identity/commit/c82449709af0215eb7af496cf687c93fb30b5ae0))
147
+ * use new generateKid method ([f0fe779](https://github.com/twinfoundation/identity/commit/f0fe779323b675575bb9f80aa74f1957dc57a094))
148
+ * use shared store mechanism ([#27](https://github.com/twinfoundation/identity/issues/27)) ([ce41f3f](https://github.com/twinfoundation/identity/commit/ce41f3fc3da1b206ec06da7ea5b2c968f788804d))
149
+ * verification method output JWK and hex on CLI ([49db9da](https://github.com/twinfoundation/identity/commit/49db9da2371eafdcd7176ce44303961b9b8b8380))
150
+
151
+
152
+ ### Bug Fixes
153
+
154
+ * correctly display mainnet explorer urls ([45a9f3c](https://github.com/twinfoundation/identity/commit/45a9f3cc041cce7b40a86e98df306931a95f48ea))
155
+ * explorer urls in CLI ([82a745d](https://github.com/twinfoundation/identity/commit/82a745d536e8fe42554e7ad92a7468a653fc0cfb))
156
+ * Import path and bump version ([#21](https://github.com/twinfoundation/identity/issues/21)) ([ccea845](https://github.com/twinfoundation/identity/commit/ccea845bf32562267280bc1b3dde1c9af1a00360))
157
+ * Install sdk-wasm ([#20](https://github.com/twinfoundation/identity/issues/20)) ([75ec14e](https://github.com/twinfoundation/identity/commit/75ec14e072f8c219863a1c028a3b0783802086e9))
158
+
159
+
160
+ ### Dependencies
161
+
162
+ * The following workspace dependencies were updated
163
+ * dependencies
164
+ * @twin.org/identity-models bumped from 0.0.3-next.3 to 0.0.3-next.4
165
+ * @twin.org/identity-connector-iota bumped from 0.0.3-next.3 to 0.0.3-next.4
166
+
167
+ ## [0.0.3-next.3](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.2...identity-cli-v0.0.3-next.3) (2025-11-17)
168
+
169
+
170
+ ### Miscellaneous Chores
171
+
172
+ * **identity-cli:** Synchronize repo versions
173
+
174
+
175
+ ### Dependencies
176
+
177
+ * The following workspace dependencies were updated
178
+ * dependencies
179
+ * @twin.org/identity-models bumped from 0.0.3-next.2 to 0.0.3-next.3
180
+ * @twin.org/identity-connector-iota bumped from 0.0.3-next.2 to 0.0.3-next.3
181
+
182
+ ## [0.0.3-next.2](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.1...identity-cli-v0.0.3-next.2) (2025-11-14)
183
+
184
+
185
+ ### Miscellaneous Chores
186
+
187
+ * **identity-cli:** Synchronize repo versions
188
+
189
+
190
+ ### Dependencies
191
+
192
+ * The following workspace dependencies were updated
193
+ * dependencies
194
+ * @twin.org/identity-models bumped from 0.0.3-next.1 to 0.0.3-next.2
195
+ * @twin.org/identity-connector-iota bumped from 0.0.3-next.1 to 0.0.3-next.2
196
+
3
197
  ## [0.0.3-next.1](https://github.com/twinfoundation/identity/compare/identity-cli-v0.0.3-next.0...identity-cli-v0.0.3-next.1) (2025-11-11)
4
198
 
5
199
 
package/locales/en.json CHANGED
@@ -22,6 +22,10 @@
22
22
  "param": "--seed '<'seed'>'",
23
23
  "description": "The seed for the controller address in hex or base64 used to create the DID, or start with ! to read environment variable."
24
24
  },
25
+ "controller": {
26
+ "param": "--controller '<'controller'>'",
27
+ "description": "The controller for the DID, or start with ! to read environment variable."
28
+ },
25
29
  "addressIndex": {
26
30
  "param": "--address-index '<'index'>'",
27
31
  "description": "The address index to use for the creation."
@@ -82,6 +86,8 @@
82
86
  "labels": {
83
87
  "verificationMethodType": "Verification Method Type",
84
88
  "verificationMethodId": "Verification Method Id",
89
+ "privateKeyBase64Url": "Private Key Base64 Url",
90
+ "publicKeyBase64Url": "Public Key Base64 Url",
85
91
  "privateKeyBase64": "Private Key Base64",
86
92
  "publicKeyBase64": "Public Key Base64",
87
93
  "privateKeyHex": "Private Key Hex",
@@ -203,9 +209,9 @@
203
209
  "param": "--revocation-index '<'revocation-index'>'",
204
210
  "description": "The revocation index in the issuing document to use if revoking the credential."
205
211
  },
206
- "addressIndex": {
207
- "param": "--address-index '<'index'>'",
208
- "description": "The address index to use for the identity controller."
212
+ "expiration-date": {
213
+ "param": "--expiration-date '<'ISO Date'>'",
214
+ "description": "The expiration date for the credential."
209
215
  }
210
216
  },
211
217
  "progress": {
@@ -218,7 +224,7 @@
218
224
  "subjectJson": "Subject JSON",
219
225
  "revocationIndex": "Revocation Index",
220
226
  "verifiableCredential": "Verifiable Credential",
221
- "addressIndex": "Address Index"
227
+ "expirationDate": "Expiration Date"
222
228
  }
223
229
  },
224
230
  "verifiable-credential-verify": {
@@ -312,10 +318,6 @@
312
318
  "document-filename": {
313
319
  "param": "--document-filename '<'document-filename'>'",
314
320
  "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
321
  }
320
322
  },
321
323
  "progress": {
@@ -323,8 +325,7 @@
323
325
  },
324
326
  "labels": {
325
327
  "documentFilename": "Document Filename",
326
- "verificationMethodId": "Verification Method Id",
327
- "addressIndex": "Address Index"
328
+ "verificationMethodId": "Verification Method Id"
328
329
  }
329
330
  },
330
331
  "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.1",
3
+ "version": "0.0.3-next.11",
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.1",
25
- "@twin.org/identity-models": "0.0.3-next.1",
24
+ "@twin.org/identity-connector-iota": "0.0.3-next.11",
25
+ "@twin.org/identity-models": "0.0.3-next.11",
26
26
  "@twin.org/nameof": "next",
27
27
  "@twin.org/standards-w3c-did": "next",
28
28
  "@twin.org/vault-connector-entity-storage": "next",