@twin.org/identity-cli 0.0.3-next.19 → 0.0.3-next.20

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.
Files changed (32) hide show
  1. package/dist/es/cli.js +9 -1
  2. package/dist/es/cli.js.map +1 -1
  3. package/dist/es/commands/alsoKnownAsAdd.js +108 -0
  4. package/dist/es/commands/alsoKnownAsAdd.js.map +1 -0
  5. package/dist/es/commands/alsoKnownAsRemove.js +106 -0
  6. package/dist/es/commands/alsoKnownAsRemove.js.map +1 -0
  7. package/dist/es/commands/verifiableCredentialCreate.js +10 -7
  8. package/dist/es/commands/verifiableCredentialCreate.js.map +1 -1
  9. package/dist/es/commands/verifiableCredentialVerify.js +24 -5
  10. package/dist/es/commands/verifiableCredentialVerify.js.map +1 -1
  11. package/dist/es/commands/verifiablePresentationCreate.js +137 -0
  12. package/dist/es/commands/verifiablePresentationCreate.js.map +1 -0
  13. package/dist/es/commands/verifiablePresentationVerify.js +107 -0
  14. package/dist/es/commands/verifiablePresentationVerify.js.map +1 -0
  15. package/dist/es/index.js +2 -0
  16. package/dist/es/index.js.map +1 -1
  17. package/dist/locales/en.json +142 -2
  18. package/dist/types/commands/alsoKnownAsAdd.d.ts +30 -0
  19. package/dist/types/commands/alsoKnownAsRemove.d.ts +30 -0
  20. package/dist/types/commands/verifiableCredentialCreate.d.ts +2 -2
  21. package/dist/types/commands/verifiableCredentialVerify.d.ts +3 -1
  22. package/dist/types/commands/verifiablePresentationCreate.d.ts +32 -0
  23. package/dist/types/commands/verifiablePresentationVerify.d.ts +24 -0
  24. package/dist/types/index.d.ts +2 -0
  25. package/docs/changelog.md +15 -0
  26. package/docs/reference/functions/actionCommandVerifiablePresentationCreate.md +17 -0
  27. package/docs/reference/functions/actionCommandVerifiablePresentationVerify.md +17 -0
  28. package/docs/reference/functions/buildCommandVerifiablePresentationCreate.md +11 -0
  29. package/docs/reference/functions/buildCommandVerifiablePresentationVerify.md +11 -0
  30. package/docs/reference/index.md +4 -0
  31. package/locales/en.json +142 -2
  32. package/package.json +3 -3
@@ -0,0 +1,137 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import path from "node:path";
4
+ import { CLIDisplay, CLIOptions, CLIParam, CLIUtils } from "@twin.org/cli-core";
5
+ import { Coerce, GeneralError, I18n, Is } from "@twin.org/core";
6
+ import { DocumentHelper } from "@twin.org/identity-models";
7
+ import { VaultConnectorFactory, VaultKeyType } from "@twin.org/vault-models";
8
+ import { setupWalletConnector } from "@twin.org/wallet-cli";
9
+ import { WalletConnectorFactory } from "@twin.org/wallet-models";
10
+ import { Command, Option } from "commander";
11
+ import { setupIdentityConnector, setupVault } from "./setupCommands.js";
12
+ import { IdentityConnectorTypes } from "../models/identityConnectorTypes.js";
13
+ /**
14
+ * Build the verifiable presentation create command for the CLI.
15
+ * @returns The command.
16
+ */
17
+ export function buildCommandVerifiablePresentationCreate() {
18
+ const command = new Command();
19
+ command
20
+ .name("verifiable-presentation-create")
21
+ .summary(I18n.formatMessage("commands.verifiable-presentation-create.summary"))
22
+ .description(I18n.formatMessage("commands.verifiable-presentation-create.description"))
23
+ .requiredOption(I18n.formatMessage("commands.verifiable-presentation-create.options.verification-method-id.param"), I18n.formatMessage("commands.verifiable-presentation-create.options.verification-method-id.description"))
24
+ .requiredOption(I18n.formatMessage("commands.verifiable-presentation-create.options.private-key.param"), I18n.formatMessage("commands.verifiable-presentation-create.options.private-key.description"))
25
+ .option(I18n.formatMessage("commands.verifiable-presentation-create.options.presentation-id.param"), I18n.formatMessage("commands.verifiable-presentation-create.options.presentation-id.description"))
26
+ .option(I18n.formatMessage("commands.verifiable-presentation-create.options.jwt.param"), I18n.formatMessage("commands.verifiable-presentation-create.options.jwt.description"))
27
+ .option(I18n.formatMessage("commands.verifiable-presentation-create.options.json-ld.param"), I18n.formatMessage("commands.verifiable-presentation-create.options.json-ld.description"))
28
+ .option(I18n.formatMessage("commands.verifiable-presentation-create.options.expiration-date.param"), I18n.formatMessage("commands.verifiable-presentation-create.options.expiration-date.description"));
29
+ CLIOptions.output(command, {
30
+ noConsole: true,
31
+ json: true,
32
+ env: true,
33
+ mergeJson: true,
34
+ mergeEnv: true
35
+ });
36
+ command
37
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
38
+ .choices(Object.values(IdentityConnectorTypes))
39
+ .default(IdentityConnectorTypes.Iota))
40
+ .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
41
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
42
+ .action(actionCommandVerifiablePresentationCreate);
43
+ return command;
44
+ }
45
+ /**
46
+ * Action the verifiable presentation create command.
47
+ * @param opts The options for the command.
48
+ * @param opts.verificationMethodId The id of the verification method to use.
49
+ * @param opts.privateKey The private key for the verification method.
50
+ * @param opts.presentationId The optional id of the presentation.
51
+ * @param opts.jwt Comma-separated JWT credential strings to include.
52
+ * @param opts.jsonLd Comma-separated JSON-LD filenames to include.
53
+ * @param opts.expirationDate The expiration date for the presentation.
54
+ * @param opts.connector The connector to perform the operations with.
55
+ * @param opts.node The node URL.
56
+ * @param opts.network The network name.
57
+ */
58
+ export async function actionCommandVerifiablePresentationCreate(opts) {
59
+ const verificationMethodId = CLIParam.stringValue("verification-method-id", opts.verificationMethodId);
60
+ const privateKey = CLIParam.hexBase64("private-key", opts.privateKey);
61
+ const presentationId = Is.stringValue(opts.presentationId)
62
+ ? CLIParam.stringValue("presentation-id", opts.presentationId)
63
+ : undefined;
64
+ const nodeEndpoint = CLIParam.url("node", opts.node);
65
+ const network = opts.connector === IdentityConnectorTypes.Iota
66
+ ? CLIParam.stringValue("network", opts.network)
67
+ : undefined;
68
+ const jwtCredentials = (opts.jwt ?? "")
69
+ .split(",")
70
+ .map(j => j.trim())
71
+ .filter(Boolean);
72
+ const jsonLdFilenames = (opts.jsonLd ?? "")
73
+ .split(",")
74
+ .map(f => f.trim())
75
+ .filter(Boolean);
76
+ if (jwtCredentials.length === 0 && jsonLdFilenames.length === 0) {
77
+ throw new GeneralError("commands", "commands.verifiable-presentation-create.noCredentialsProvided");
78
+ }
79
+ CLIDisplay.value(I18n.formatMessage("commands.verifiable-presentation-create.labels.verificationMethodId"), verificationMethodId);
80
+ if (Is.stringValue(presentationId)) {
81
+ CLIDisplay.value(I18n.formatMessage("commands.verifiable-presentation-create.labels.presentationId"), presentationId);
82
+ }
83
+ if (jwtCredentials.length > 0) {
84
+ CLIDisplay.value(I18n.formatMessage("commands.verifiable-presentation-create.labels.jwt"), jwtCredentials.join(", "));
85
+ }
86
+ if (jsonLdFilenames.length > 0) {
87
+ CLIDisplay.value(I18n.formatMessage("commands.verifiable-presentation-create.labels.jsonLd"), jsonLdFilenames.join(", "));
88
+ }
89
+ CLIDisplay.value(I18n.formatMessage("commands.verifiable-presentation-create.labels.expirationDate"), opts.expirationDate);
90
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
91
+ if (Is.stringValue(network)) {
92
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
93
+ }
94
+ CLIDisplay.break();
95
+ setupVault();
96
+ const vmParts = DocumentHelper.parseId(verificationMethodId);
97
+ const vaultConnector = VaultConnectorFactory.get("vault");
98
+ await vaultConnector.addKey(`${vmParts.id}/${vmParts.fragment}`, VaultKeyType.Ed25519, privateKey, new Uint8Array());
99
+ const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
100
+ WalletConnectorFactory.register("wallet", () => walletConnector);
101
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
102
+ CLIDisplay.task(I18n.formatMessage("commands.verifiable-presentation-create.progress.loadingCredentialData"));
103
+ CLIDisplay.break();
104
+ const verifiableCredentials = [...jwtCredentials];
105
+ for (const filename of jsonLdFilenames) {
106
+ const resolvedPath = path.resolve(filename);
107
+ const jsonData = await CLIUtils.readJsonFile(resolvedPath);
108
+ if (Is.undefined(jsonData)) {
109
+ throw new GeneralError("commands", "commands.verifiable-presentation-create.jsonLdFileNotFound");
110
+ }
111
+ verifiableCredentials.push(jsonData);
112
+ }
113
+ CLIDisplay.task(I18n.formatMessage("commands.verifiable-presentation-create.progress.creatingVerifiablePresentation"));
114
+ CLIDisplay.break();
115
+ CLIDisplay.spinnerStart();
116
+ const verifiablePresentation = await identityConnector.createVerifiablePresentation(vmParts.id, verificationMethodId, presentationId, undefined, undefined, verifiableCredentials, {
117
+ expirationDate: Coerce.dateTime(opts.expirationDate)
118
+ });
119
+ CLIDisplay.spinnerStop();
120
+ if (opts.console) {
121
+ CLIDisplay.section(I18n.formatMessage("commands.verifiable-presentation-create.labels.verifiablePresentation"));
122
+ CLIDisplay.write(verifiablePresentation.jwt);
123
+ CLIDisplay.break();
124
+ CLIDisplay.break();
125
+ }
126
+ if (Is.stringValue(opts?.json)) {
127
+ await CLIUtils.writeJsonFile(opts.json, {
128
+ verifiablePresentationJwt: verifiablePresentation.jwt,
129
+ verifiablePresentation: verifiablePresentation.verifiablePresentation
130
+ }, opts.mergeJson);
131
+ }
132
+ if (Is.stringValue(opts?.env)) {
133
+ await CLIUtils.writeEnvFile(opts.env, [`DID_VERIFIABLE_PRESENTATION_JWT="${verifiablePresentation.jwt}"`], opts.mergeEnv);
134
+ }
135
+ CLIDisplay.done();
136
+ }
137
+ //# sourceMappingURL=verifiablePresentationCreate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifiablePresentationCreate.js","sourceRoot":"","sources":["../../../src/commands/verifiablePresentationCreate.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,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AAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;QAC7C,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;YACC,yBAAyB,EAAE,sBAAsB,CAAC,GAAG;YACrD,sBAAsB,EAAE,sBAAsB,CAAC,sBAAsB;SACrE,EACD,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,oCAAoC,sBAAsB,CAAC,GAAG,GAAG,CAAC,EACnE,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 { DocumentHelper } from \"@twin.org/identity-models\";\nimport type { IDidVerifiableCredential } 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 verifiable presentation create command for the CLI.\n * @returns The command.\n */\nexport function buildCommandVerifiablePresentationCreate(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"verifiable-presentation-create\")\n\t\t.summary(I18n.formatMessage(\"commands.verifiable-presentation-create.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.verifiable-presentation-create.description\"))\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"commands.verifiable-presentation-create.options.verification-method-id.param\"\n\t\t\t),\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"commands.verifiable-presentation-create.options.verification-method-id.description\"\n\t\t\t)\n\t\t)\n\t\t.requiredOption(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.options.private-key.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.options.private-key.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.options.presentation-id.param\"),\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"commands.verifiable-presentation-create.options.presentation-id.description\"\n\t\t\t)\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.options.jwt.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.options.jwt.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.options.json-ld.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.options.json-ld.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.options.expiration-date.param\"),\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"commands.verifiable-presentation-create.options.expiration-date.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(actionCommandVerifiablePresentationCreate);\n\n\treturn command;\n}\n\n/**\n * Action the verifiable presentation create command.\n * @param opts The options for the command.\n * @param opts.verificationMethodId The id of the verification method to use.\n * @param opts.privateKey The private key for the verification method.\n * @param opts.presentationId The optional id of the presentation.\n * @param opts.jwt Comma-separated JWT credential strings to include.\n * @param opts.jsonLd Comma-separated JSON-LD filenames to include.\n * @param opts.expirationDate The expiration date for the presentation.\n * @param opts.connector The connector to perform the operations with.\n * @param opts.node The node URL.\n * @param opts.network The network name.\n */\nexport async function actionCommandVerifiablePresentationCreate(\n\topts: {\n\t\tverificationMethodId: string;\n\t\tprivateKey: string;\n\t\tpresentationId?: string;\n\t\tjwt?: string;\n\t\tjsonLd?: string;\n\t\texpirationDate?: string;\n\t\tconnector?: IdentityConnectorTypes;\n\t\tnode: string;\n\t\tnetwork?: string;\n\t} & CliOutputOptions\n): Promise<void> {\n\tconst verificationMethodId: string = CLIParam.stringValue(\n\t\t\"verification-method-id\",\n\t\topts.verificationMethodId\n\t);\n\tconst privateKey: Uint8Array = CLIParam.hexBase64(\"private-key\", opts.privateKey);\n\tconst presentationId: string | undefined = Is.stringValue(opts.presentationId)\n\t\t? CLIParam.stringValue(\"presentation-id\", opts.presentationId)\n\t\t: undefined;\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\tconst jwtCredentials = (opts.jwt ?? \"\")\n\t\t.split(\",\")\n\t\t.map(j => j.trim())\n\t\t.filter(Boolean);\n\tconst jsonLdFilenames = (opts.jsonLd ?? \"\")\n\t\t.split(\",\")\n\t\t.map(f => f.trim())\n\t\t.filter(Boolean);\n\n\tif (jwtCredentials.length === 0 && jsonLdFilenames.length === 0) {\n\t\tthrow new GeneralError(\n\t\t\t\"commands\",\n\t\t\t\"commands.verifiable-presentation-create.noCredentialsProvided\"\n\t\t);\n\t}\n\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.labels.verificationMethodId\"),\n\t\tverificationMethodId\n\t);\n\tif (Is.stringValue(presentationId)) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.labels.presentationId\"),\n\t\t\tpresentationId\n\t\t);\n\t}\n\tif (jwtCredentials.length > 0) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.labels.jwt\"),\n\t\t\tjwtCredentials.join(\", \")\n\t\t);\n\t}\n\tif (jsonLdFilenames.length > 0) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-create.labels.jsonLd\"),\n\t\t\tjsonLdFilenames.join(\", \")\n\t\t);\n\t}\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.verifiable-presentation-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(verificationMethodId);\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-presentation-create.progress.loadingCredentialData\")\n\t);\n\tCLIDisplay.break();\n\n\tconst verifiableCredentials: (string | IDidVerifiableCredential)[] = [...jwtCredentials];\n\n\tfor (const filename of jsonLdFilenames) {\n\t\tconst resolvedPath = path.resolve(filename);\n\t\tconst jsonData = await CLIUtils.readJsonFile<IDidVerifiableCredential>(resolvedPath);\n\t\tif (Is.undefined(jsonData)) {\n\t\t\tthrow new GeneralError(\n\t\t\t\t\"commands\",\n\t\t\t\t\"commands.verifiable-presentation-create.jsonLdFileNotFound\"\n\t\t\t);\n\t\t}\n\t\tverifiableCredentials.push(jsonData);\n\t}\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\n\t\t\t\"commands.verifiable-presentation-create.progress.creatingVerifiablePresentation\"\n\t\t)\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.spinnerStart();\n\n\tconst verifiablePresentation = await identityConnector.createVerifiablePresentation(\n\t\tvmParts.id,\n\t\tverificationMethodId,\n\t\tpresentationId,\n\t\tundefined,\n\t\tundefined,\n\t\tverifiableCredentials,\n\t\t{\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-presentation-create.labels.verifiablePresentation\")\n\t\t);\n\t\tCLIDisplay.write(verifiablePresentation.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{\n\t\t\t\tverifiablePresentationJwt: verifiablePresentation.jwt,\n\t\t\t\tverifiablePresentation: verifiablePresentation.verifiablePresentation\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[`DID_VERIFIABLE_PRESENTATION_JWT=\"${verifiablePresentation.jwt}\"`],\n\t\t\topts.mergeEnv\n\t\t);\n\t}\n\n\tCLIDisplay.done();\n}\n"]}
@@ -0,0 +1,107 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import path from "node:path";
4
+ import { CLIDisplay, CLIOptions, CLIParam, CLIUtils } from "@twin.org/cli-core";
5
+ import { GeneralError, I18n, Is } from "@twin.org/core";
6
+ import { setupWalletConnector } from "@twin.org/wallet-cli";
7
+ import { WalletConnectorFactory } from "@twin.org/wallet-models";
8
+ import { Command, Option } from "commander";
9
+ import { setupIdentityConnector, setupVault } from "./setupCommands.js";
10
+ import { IdentityConnectorTypes } from "../models/identityConnectorTypes.js";
11
+ /**
12
+ * Build the verifiable presentation verify command for the CLI.
13
+ * @returns The command.
14
+ */
15
+ export function buildCommandVerifiablePresentationVerify() {
16
+ const command = new Command();
17
+ command
18
+ .name("verifiable-presentation-verify")
19
+ .summary(I18n.formatMessage("commands.verifiable-presentation-verify.summary"))
20
+ .description(I18n.formatMessage("commands.verifiable-presentation-verify.description"))
21
+ .option(I18n.formatMessage("commands.verifiable-presentation-verify.options.jwt.param"), I18n.formatMessage("commands.verifiable-presentation-verify.options.jwt.description"))
22
+ .option(I18n.formatMessage("commands.verifiable-presentation-verify.options.json-ld.param"), I18n.formatMessage("commands.verifiable-presentation-verify.options.json-ld.description"));
23
+ CLIOptions.output(command, {
24
+ noConsole: true,
25
+ json: true,
26
+ env: true,
27
+ mergeJson: true,
28
+ mergeEnv: true
29
+ });
30
+ command
31
+ .addOption(new Option(I18n.formatMessage("commands.common.options.connector.param"), I18n.formatMessage("commands.common.options.connector.description"))
32
+ .choices(Object.values(IdentityConnectorTypes))
33
+ .default(IdentityConnectorTypes.Iota))
34
+ .option(I18n.formatMessage("commands.common.options.node.param"), I18n.formatMessage("commands.common.options.node.description"), "!NODE_URL")
35
+ .option(I18n.formatMessage("commands.common.options.network.param"), I18n.formatMessage("commands.common.options.network.description"), "!NETWORK")
36
+ .action(actionCommandVerifiablePresentationVerify);
37
+ return command;
38
+ }
39
+ /**
40
+ * Action the verifiable presentation verify command.
41
+ * @param opts The options for the command.
42
+ * @param opts.jwt The JSON web token for the verifiable presentation.
43
+ * @param opts.jsonLd The filename of a JSON-LD verifiable presentation to verify.
44
+ * @param opts.connector The connector to perform the operations with.
45
+ * @param opts.node The node URL.
46
+ * @param opts.network The network name.
47
+ */
48
+ export async function actionCommandVerifiablePresentationVerify(opts) {
49
+ const nodeEndpoint = CLIParam.url("node", opts.node);
50
+ const network = opts.connector === IdentityConnectorTypes.Iota
51
+ ? CLIParam.stringValue("network", opts.network)
52
+ : undefined;
53
+ let presentation;
54
+ if (Is.stringValue(opts.jwt)) {
55
+ const jwt = CLIParam.stringValue("jwt", opts.jwt);
56
+ CLIDisplay.value(I18n.formatMessage("commands.verifiable-presentation-verify.labels.jwt"), jwt);
57
+ presentation = jwt;
58
+ }
59
+ else if (Is.stringValue(opts.jsonLd)) {
60
+ const jsonLdPath = path.resolve(CLIParam.stringValue("json-ld", opts.jsonLd));
61
+ CLIDisplay.value(I18n.formatMessage("commands.verifiable-presentation-verify.labels.jsonLd"), jsonLdPath);
62
+ const jsonData = await CLIUtils.readJsonFile(jsonLdPath);
63
+ if (Is.undefined(jsonData)) {
64
+ throw new GeneralError("commands", "commands.verifiable-presentation-verify.jsonLdFileNotFound");
65
+ }
66
+ presentation = jsonData;
67
+ }
68
+ else {
69
+ throw new GeneralError("commands", "commands.verifiable-presentation-verify.noPresentationProvided");
70
+ }
71
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.node"), nodeEndpoint);
72
+ if (Is.stringValue(network)) {
73
+ CLIDisplay.value(I18n.formatMessage("commands.common.labels.network"), network);
74
+ }
75
+ CLIDisplay.break();
76
+ setupVault();
77
+ const walletConnector = setupWalletConnector({ nodeEndpoint, network }, opts.connector);
78
+ WalletConnectorFactory.register("wallet", () => walletConnector);
79
+ const identityConnector = setupIdentityConnector({ nodeEndpoint, network }, opts.connector);
80
+ CLIDisplay.task(I18n.formatMessage("commands.verifiable-presentation-verify.progress.verifyingPresentation"));
81
+ CLIDisplay.break();
82
+ CLIDisplay.spinnerStart();
83
+ const verification = await identityConnector.checkVerifiablePresentation(presentation);
84
+ const isVerified = Is.notEmpty(verification.verifiablePresentation);
85
+ const isRevoked = verification.revoked;
86
+ CLIDisplay.spinnerStop();
87
+ if (opts.console) {
88
+ CLIDisplay.value(I18n.formatMessage("commands.verifiable-presentation-verify.labels.isVerified"), isVerified);
89
+ CLIDisplay.value(I18n.formatMessage("commands.verifiable-presentation-verify.labels.isRevoked"), isRevoked);
90
+ CLIDisplay.break();
91
+ }
92
+ if (Is.stringValue(opts?.json)) {
93
+ await CLIUtils.writeJsonFile(opts.json, {
94
+ isVerified,
95
+ isRevoked,
96
+ verifiablePresentation: verification.verifiablePresentation
97
+ }, opts.mergeJson);
98
+ }
99
+ if (Is.stringValue(opts?.env)) {
100
+ await CLIUtils.writeEnvFile(opts.env, [
101
+ `DID_VERIFIABLE_PRESENTATION_VERIFIED="${isVerified}"`,
102
+ `DID_VERIFIABLE_PRESENTATION_REVOKED="${isRevoked}"`
103
+ ], opts.mergeEnv);
104
+ }
105
+ CLIDisplay.done();
106
+ }
107
+ //# sourceMappingURL=verifiablePresentationVerify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifiablePresentationVerify.js","sourceRoot":"","sources":["../../../src/commands/verifiablePresentationVerify.ts"],"names":[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Display,\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 { IDidVerifiablePresentation } from \"@twin.org/standards-w3c-did\";\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 presentation verify command for the CLI.\n * @returns The command.\n */\nexport function buildCommandVerifiablePresentationVerify(): Command {\n\tconst command = new Command();\n\tcommand\n\t\t.name(\"verifiable-presentation-verify\")\n\t\t.summary(I18n.formatMessage(\"commands.verifiable-presentation-verify.summary\"))\n\t\t.description(I18n.formatMessage(\"commands.verifiable-presentation-verify.description\"))\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-verify.options.jwt.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-verify.options.jwt.description\")\n\t\t)\n\t\t.option(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-verify.options.json-ld.param\"),\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-verify.options.json-ld.description\")\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(actionCommandVerifiablePresentationVerify);\n\n\treturn command;\n}\n\n/**\n * Action the verifiable presentation verify command.\n * @param opts The options for the command.\n * @param opts.jwt The JSON web token for the verifiable presentation.\n * @param opts.jsonLd The filename of a JSON-LD verifiable presentation to verify.\n * @param opts.connector The connector to perform the operations with.\n * @param opts.node The node URL.\n * @param opts.network The network name.\n */\nexport async function actionCommandVerifiablePresentationVerify(\n\topts: {\n\t\tjwt?: string;\n\t\tjsonLd?: string;\n\t\tconnector?: IdentityConnectorTypes;\n\t\tnode: string;\n\t\tnetwork?: string;\n\t} & CliOutputOptions\n): Promise<void> {\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\tlet presentation: string | IDidVerifiablePresentation;\n\n\tif (Is.stringValue(opts.jwt)) {\n\t\tconst jwt = CLIParam.stringValue(\"jwt\", opts.jwt);\n\t\tCLIDisplay.value(I18n.formatMessage(\"commands.verifiable-presentation-verify.labels.jwt\"), jwt);\n\t\tpresentation = jwt;\n\t} else if (Is.stringValue(opts.jsonLd)) {\n\t\tconst jsonLdPath = path.resolve(CLIParam.stringValue(\"json-ld\", opts.jsonLd));\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-verify.labels.jsonLd\"),\n\t\t\tjsonLdPath\n\t\t);\n\t\tconst jsonData = await CLIUtils.readJsonFile<IDidVerifiablePresentation>(jsonLdPath);\n\t\tif (Is.undefined(jsonData)) {\n\t\t\tthrow new GeneralError(\n\t\t\t\t\"commands\",\n\t\t\t\t\"commands.verifiable-presentation-verify.jsonLdFileNotFound\"\n\t\t\t);\n\t\t}\n\t\tpresentation = jsonData;\n\t} else {\n\t\tthrow new GeneralError(\n\t\t\t\"commands\",\n\t\t\t\"commands.verifiable-presentation-verify.noPresentationProvided\"\n\t\t);\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 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-presentation-verify.progress.verifyingPresentation\")\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.spinnerStart();\n\n\tconst verification = await identityConnector.checkVerifiablePresentation(presentation);\n\n\tconst isVerified = Is.notEmpty(verification.verifiablePresentation);\n\tconst isRevoked = verification.revoked;\n\n\tCLIDisplay.spinnerStop();\n\n\tif (opts.console) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-verify.labels.isVerified\"),\n\t\t\tisVerified\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.verifiable-presentation-verify.labels.isRevoked\"),\n\t\t\tisRevoked\n\t\t);\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\tisVerified,\n\t\t\t\tisRevoked,\n\t\t\t\tverifiablePresentation: verification.verifiablePresentation\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_VERIFIABLE_PRESENTATION_VERIFIED=\"${isVerified}\"`,\n\t\t\t\t`DID_VERIFIABLE_PRESENTATION_REVOKED=\"${isRevoked}\"`\n\t\t\t],\n\t\t\topts.mergeEnv\n\t\t);\n\t}\n\n\tCLIDisplay.done();\n}\n"]}
package/dist/es/index.js CHANGED
@@ -9,6 +9,8 @@ export * from "./commands/serviceAdd.js";
9
9
  export * from "./commands/serviceRemove.js";
10
10
  export * from "./commands/setupCommands.js";
11
11
  export * from "./commands/verifiableCredentialCreate.js";
12
+ export * from "./commands/verifiablePresentationCreate.js";
13
+ export * from "./commands/verifiablePresentationVerify.js";
12
14
  export * from "./commands/verifiableCredentialRevoke.js";
13
15
  export * from "./commands/verifiableCredentialUnrevoke.js";
14
16
  export * from "./commands/verifiableCredentialVerify.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0CAA0C,CAAC;AACzD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,0CAA0C,CAAC;AACzD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,4CAA4C,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./cli.js\";\nexport * from \"./commands/identityCreate.js\";\nexport * from \"./commands/identityResolve.js\";\nexport * from \"./commands/proofCreate.js\";\nexport * from \"./commands/proofVerify.js\";\nexport * from \"./commands/serviceAdd.js\";\nexport * from \"./commands/serviceRemove.js\";\nexport * from \"./commands/setupCommands.js\";\nexport * from \"./commands/verifiableCredentialCreate.js\";\nexport * from \"./commands/verifiableCredentialRevoke.js\";\nexport * from \"./commands/verifiableCredentialUnrevoke.js\";\nexport * from \"./commands/verifiableCredentialVerify.js\";\nexport * from \"./commands/verificationMethodAdd.js\";\nexport * from \"./commands/verificationMethodRemove.js\";\nexport * from \"./models/identityConnectorTypes.js\";\nexport * from \"./models/identityResolverConnectorTypes.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,0CAA0C,CAAC;AACzD,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,oCAAoC,CAAC;AACnD,cAAc,4CAA4C,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./cli.js\";\nexport * from \"./commands/identityCreate.js\";\nexport * from \"./commands/identityResolve.js\";\nexport * from \"./commands/proofCreate.js\";\nexport * from \"./commands/proofVerify.js\";\nexport * from \"./commands/serviceAdd.js\";\nexport * from \"./commands/serviceRemove.js\";\nexport * from \"./commands/setupCommands.js\";\nexport * from \"./commands/verifiableCredentialCreate.js\";\nexport * from \"./commands/verifiablePresentationCreate.js\";\nexport * from \"./commands/verifiablePresentationVerify.js\";\nexport * from \"./commands/verifiableCredentialRevoke.js\";\nexport * from \"./commands/verifiableCredentialUnrevoke.js\";\nexport * from \"./commands/verifiableCredentialVerify.js\";\nexport * from \"./commands/verificationMethodAdd.js\";\nexport * from \"./commands/verificationMethodRemove.js\";\nexport * from \"./models/identityConnectorTypes.js\";\nexport * from \"./models/identityResolverConnectorTypes.js\";\n"]}
@@ -162,6 +162,18 @@
162
162
  "optionMinValue": "The \"{option}\" option must be greater than or equal to {minValue}, it is {value}.",
163
163
  "optionMaxValue": "The \"{option}\" option must be less than or equal to {maxValue}, it is {value}."
164
164
  },
165
+ "verifiable-presentation-create": {
166
+ "noCredentialsProvided": "Either --jwt or --json-ld must be provided with at least one credential.",
167
+ "jsonLdFileNotFound": "The JSON-LD credential file was not found."
168
+ },
169
+ "verifiable-credential-verify": {
170
+ "noCredentialProvided": "Either --jwt or --json-ld must be provided.",
171
+ "jsonLdFileNotFound": "The JSON-LD file was not found."
172
+ },
173
+ "verifiable-presentation-verify": {
174
+ "noPresentationProvided": "Either --jwt or --json-ld must be provided.",
175
+ "jsonLdFileNotFound": "The JSON-LD file was not found."
176
+ },
165
177
  "verifiable-credential-create": {
166
178
  "subjectJsonFileNotFound": "The subject JSON file was not found."
167
179
  },
@@ -732,12 +744,77 @@
732
744
  "addressIndex": "Address Index"
733
745
  }
734
746
  },
747
+ "verifiable-presentation-create": {
748
+ "summary": "Create a verifiable presentation.",
749
+ "description": "Create a verifiable presentation.",
750
+ "options": {
751
+ "verification-method-id": {
752
+ "param": "--verification-method-id '<'verification-method-id'>'",
753
+ "description": "The full verification method id including did, or start with ! to read environment variable."
754
+ },
755
+ "private-key": {
756
+ "param": "--private-key '<'private-key'>'",
757
+ "description": "The private key for the verification method id, in either hex or base64 form, or start with ! to read environment variable."
758
+ },
759
+ "presentation-id": {
760
+ "param": "--presentation-id '<'presentation-id'>'",
761
+ "description": "The presentation id which uniquely identifies the presentation."
762
+ },
763
+ "jwt": {
764
+ "param": "--jwt '<'jwt'>'",
765
+ "description": "Comma-separated list of verifiable credential JWTs to include in the presentation, or start with ! to read environment variable."
766
+ },
767
+ "json-ld": {
768
+ "param": "--json-ld '<'json-ld'>'",
769
+ "description": "Comma-separated list of JSON-LD filenames containing verifiable credentials to include in the presentation."
770
+ },
771
+ "expiration-date": {
772
+ "param": "--expiration-date '<'ISO Date'>'",
773
+ "description": "The expiration date for the presentation."
774
+ }
775
+ },
776
+ "progress": {
777
+ "creatingVerifiablePresentation": "Creating Verifiable Presentation",
778
+ "loadingCredentialData": "Loading Credential Data"
779
+ },
780
+ "labels": {
781
+ "verificationMethodId": "Verification Method Id",
782
+ "presentationId": "Presentation Id",
783
+ "jwt": "JWT Credentials",
784
+ "jsonLd": "JSON-LD Credentials",
785
+ "verifiablePresentation": "Verifiable Presentation",
786
+ "expirationDate": "Expiration Date"
787
+ }
788
+ },
789
+ "verifiable-presentation-verify": {
790
+ "summary": "Verify a verifiable presentation.",
791
+ "description": "Verify a verifiable presentation.",
792
+ "options": {
793
+ "jwt": {
794
+ "param": "--jwt '<'jwt'>'",
795
+ "description": "The verifiable presentation as a JSON web token to verify, or start with ! to read environment variable."
796
+ },
797
+ "json-ld": {
798
+ "param": "--json-ld '<'json-ld'>'",
799
+ "description": "A JSON-LD file containing the verifiable presentation to verify."
800
+ }
801
+ },
802
+ "progress": {
803
+ "verifyingPresentation": "Verifying Presentation"
804
+ },
805
+ "labels": {
806
+ "jwt": "JWT",
807
+ "jsonLd": "JSON-LD",
808
+ "isVerified": "Is Verified",
809
+ "isRevoked": "Is Revoked"
810
+ }
811
+ },
735
812
  "verifiable-credential-create": {
736
813
  "summary": "Create a verifiable credential.",
737
814
  "description": "Create a verifiable credential.",
738
815
  "options": {
739
- "id": {
740
- "param": "--id '<'id'>'",
816
+ "verification-method-id": {
817
+ "param": "--verification-method-id '<'verification-method-id'>'",
741
818
  "description": "The full verification method id including did, or start with ! to read environment variable."
742
819
  },
743
820
  "private-key": {
@@ -781,6 +858,10 @@
781
858
  "jwt": {
782
859
  "param": "--jwt '<'jwt'>'",
783
860
  "description": "The verifiable credential as a JSON web token to verify, or start with ! to read environment variable."
861
+ },
862
+ "json-ld": {
863
+ "param": "--json-ld '<'json-ld'>'",
864
+ "description": "A JSON-LD file containing the verifiable credential to verify."
784
865
  }
785
866
  },
786
867
  "progress": {
@@ -788,6 +869,7 @@
788
869
  },
789
870
  "labels": {
790
871
  "jwt": "JWT",
872
+ "jsonLd": "JSON-LD",
791
873
  "isVerified": "Is Verified",
792
874
  "isRevoked": "Is Revoked"
793
875
  }
@@ -896,6 +978,64 @@
896
978
  "proofFilename": "Proof Filename",
897
979
  "isVerified": "Is Verified"
898
980
  }
981
+ },
982
+ "also-known-as-add": {
983
+ "summary": "Add an alias (alsoKnownAs) to a DID.",
984
+ "description": "Add an alias (alsoKnownAs) to a DID.",
985
+ "options": {
986
+ "seed": {
987
+ "param": "--seed '<'seed'>'",
988
+ "description": "The seed for the private key for the controller address of the document in hex or base64, or start with ! to read environment variable."
989
+ },
990
+ "did": {
991
+ "param": "--did '<'did'>'",
992
+ "description": "The identifier to add the alias to, or start with ! to read environment variable."
993
+ },
994
+ "alias": {
995
+ "param": "--alias '<'alias'>'",
996
+ "description": "The alias (alsoKnownAs) value to add."
997
+ },
998
+ "addressIndex": {
999
+ "param": "--address-index '<'index'>'",
1000
+ "description": "The address index to use for the identity controller."
1001
+ }
1002
+ },
1003
+ "progress": {
1004
+ "addingAlsoKnownAs": "Adding Alias (alsoKnownAs)"
1005
+ },
1006
+ "labels": {
1007
+ "alias": "Alias (alsoKnownAs)",
1008
+ "addressIndex": "Address Index"
1009
+ }
1010
+ },
1011
+ "also-known-as-remove": {
1012
+ "summary": "Remove an alias (alsoKnownAs) from a DID.",
1013
+ "description": "Remove an alias (alsoKnownAs) from a DID.",
1014
+ "options": {
1015
+ "seed": {
1016
+ "param": "--seed '<'seed'>'",
1017
+ "description": "The seed for the private key for the controller address of the document in hex or base64, or start with ! to read environment variable."
1018
+ },
1019
+ "did": {
1020
+ "param": "--did '<'did'>'",
1021
+ "description": "The identifier to remove the alias from, or start with ! to read environment variable."
1022
+ },
1023
+ "alias": {
1024
+ "param": "--alias '<'alias'>'",
1025
+ "description": "The alias (alsoKnownAs) value to remove."
1026
+ },
1027
+ "addressIndex": {
1028
+ "param": "--address-index '<'index'>'",
1029
+ "description": "The address index to use for the identity controller."
1030
+ }
1031
+ },
1032
+ "progress": {
1033
+ "removingAlsoKnownAs": "Removing Alias (alsoKnownAs)"
1034
+ },
1035
+ "labels": {
1036
+ "alias": "Alias (alsoKnownAs)",
1037
+ "addressIndex": "Address Index"
1038
+ }
899
1039
  }
900
1040
  },
901
1041
  "errorMessages": {
@@ -0,0 +1,30 @@
1
+ import { type CliOutputOptions } from "@twin.org/cli-core";
2
+ import { Command } from "commander";
3
+ import { IdentityConnectorTypes } from "../models/identityConnectorTypes.js";
4
+ /**
5
+ * Build the alsoKnownAs add command for the CLI.
6
+ * @returns The command.
7
+ */
8
+ export declare function buildCommandAlsoKnownAsAdd(): Command;
9
+ /**
10
+ * Action the alsoKnownAs add command.
11
+ * @param opts The options for the command.
12
+ * @param opts.seed The private key for the controller.
13
+ * @param opts.did The identity of the document to add to.
14
+ * @param opts.alias The alsoKnownAs value to add.
15
+ * @param opts.addressIndex The address index to use for key derivation (if applicable).
16
+ * @param opts.connector The connector to perform the operations with.
17
+ * @param opts.node The node URL.
18
+ * @param opts.network The network to use for connector.
19
+ * @param opts.explorer The explorer URL.
20
+ */
21
+ export declare function actionCommandAlsoKnownAsAdd(opts: {
22
+ seed: string;
23
+ did: string;
24
+ alias: string;
25
+ addressIndex?: string;
26
+ connector?: IdentityConnectorTypes;
27
+ node: string;
28
+ network?: string;
29
+ explorer: string;
30
+ } & CliOutputOptions): Promise<void>;
@@ -0,0 +1,30 @@
1
+ import { type CliOutputOptions } from "@twin.org/cli-core";
2
+ import { Command } from "commander";
3
+ import { IdentityConnectorTypes } from "../models/identityConnectorTypes.js";
4
+ /**
5
+ * Build the alsoKnownAs remove command for the CLI.
6
+ * @returns The command.
7
+ */
8
+ export declare function buildCommandAlsoKnownAsRemove(): Command;
9
+ /**
10
+ * Action the alsoKnownAs remove command.
11
+ * @param opts The options for the command.
12
+ * @param opts.seed The private key for the controller.
13
+ * @param opts.did The identity of the document to remove from.
14
+ * @param opts.alias The alsoKnownAs value to remove.
15
+ * @param opts.addressIndex The address index to use for key derivation (if applicable).
16
+ * @param opts.connector The connector to perform the operations with.
17
+ * @param opts.node The node URL.
18
+ * @param opts.network The network to use for connector.
19
+ * @param opts.explorer The explorer URL.
20
+ */
21
+ export declare function actionCommandAlsoKnownAsRemove(opts: {
22
+ seed: string;
23
+ did: string;
24
+ alias: string;
25
+ addressIndex?: string;
26
+ connector?: IdentityConnectorTypes;
27
+ node: string;
28
+ network?: string;
29
+ explorer: string;
30
+ } & CliOutputOptions): Promise<void>;
@@ -9,7 +9,7 @@ export declare function buildCommandVerifiableCredentialCreate(): Command;
9
9
  /**
10
10
  * Action the verifiable credential create command.
11
11
  * @param opts The options for the command.
12
- * @param opts.id The id of the verification method to use for the credential.
12
+ * @param opts.verificationMethodId 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.credentialId The id of the credential.
15
15
  * @param opts.subjectJson The JSON data for the subject.
@@ -19,7 +19,7 @@ export declare function buildCommandVerifiableCredentialCreate(): Command;
19
19
  * @param opts.node The node URL.
20
20
  */
21
21
  export declare function actionCommandVerifiableCredentialCreate(opts: {
22
- id: string;
22
+ verificationMethodId: string;
23
23
  privateKey: string;
24
24
  credentialId?: string;
25
25
  subjectJson: string;
@@ -10,11 +10,13 @@ export declare function buildCommandVerifiableCredentialVerify(): Command;
10
10
  * Action the verifiable credential verify command.
11
11
  * @param opts The options for the command.
12
12
  * @param opts.jwt The JSON web token for the verifiable credential.
13
+ * @param opts.jsonLd The filename of a JSON-LD verifiable credential to verify.
13
14
  * @param opts.connector The connector to perform the operations with.
14
15
  * @param opts.node The node URL.
15
16
  */
16
17
  export declare function actionCommandVerifiableCredentialVerify(opts: {
17
- jwt: string;
18
+ jwt?: string;
19
+ jsonLd?: string;
18
20
  connector?: IdentityConnectorTypes;
19
21
  node: string;
20
22
  network?: string;
@@ -0,0 +1,32 @@
1
+ import { type CliOutputOptions } from "@twin.org/cli-core";
2
+ import { Command } from "commander";
3
+ import { IdentityConnectorTypes } from "../models/identityConnectorTypes.js";
4
+ /**
5
+ * Build the verifiable presentation create command for the CLI.
6
+ * @returns The command.
7
+ */
8
+ export declare function buildCommandVerifiablePresentationCreate(): Command;
9
+ /**
10
+ * Action the verifiable presentation create command.
11
+ * @param opts The options for the command.
12
+ * @param opts.verificationMethodId The id of the verification method to use.
13
+ * @param opts.privateKey The private key for the verification method.
14
+ * @param opts.presentationId The optional id of the presentation.
15
+ * @param opts.jwt Comma-separated JWT credential strings to include.
16
+ * @param opts.jsonLd Comma-separated JSON-LD filenames to include.
17
+ * @param opts.expirationDate The expiration date for the presentation.
18
+ * @param opts.connector The connector to perform the operations with.
19
+ * @param opts.node The node URL.
20
+ * @param opts.network The network name.
21
+ */
22
+ export declare function actionCommandVerifiablePresentationCreate(opts: {
23
+ verificationMethodId: string;
24
+ privateKey: string;
25
+ presentationId?: string;
26
+ jwt?: string;
27
+ jsonLd?: string;
28
+ expirationDate?: string;
29
+ connector?: IdentityConnectorTypes;
30
+ node: string;
31
+ network?: string;
32
+ } & CliOutputOptions): Promise<void>;