@twin.org/node-core 0.0.2-next.9 → 0.0.3-next.10

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 (195) hide show
  1. package/README.md +1 -1
  2. package/dist/es/builders/engineEnvBuilder.js +1132 -0
  3. package/dist/es/builders/engineEnvBuilder.js.map +1 -0
  4. package/dist/es/builders/engineServerEnvBuilder.js +206 -0
  5. package/dist/es/builders/engineServerEnvBuilder.js.map +1 -0
  6. package/dist/es/builders/extensionsBuilder.js +109 -0
  7. package/dist/es/builders/extensionsBuilder.js.map +1 -0
  8. package/dist/es/cli.js +255 -0
  9. package/dist/es/cli.js.map +1 -0
  10. package/dist/es/commands/bootstrapLegacy.js +175 -0
  11. package/dist/es/commands/bootstrapLegacy.js.map +1 -0
  12. package/dist/es/commands/help.js +85 -0
  13. package/dist/es/commands/help.js.map +1 -0
  14. package/dist/es/commands/identityCreate.js +310 -0
  15. package/dist/es/commands/identityCreate.js.map +1 -0
  16. package/dist/es/commands/identityImports.js +76 -0
  17. package/dist/es/commands/identityImports.js.map +1 -0
  18. package/dist/es/commands/identityVerifiableCredentialCreate.js +140 -0
  19. package/dist/es/commands/identityVerifiableCredentialCreate.js.map +1 -0
  20. package/dist/es/commands/identityVerificationMethodCreate.js +208 -0
  21. package/dist/es/commands/identityVerificationMethodCreate.js.map +1 -0
  22. package/dist/es/commands/identityVerificationMethodImport.js +120 -0
  23. package/dist/es/commands/identityVerificationMethodImport.js.map +1 -0
  24. package/dist/es/commands/nodeSetIdentity.js +51 -0
  25. package/dist/es/commands/nodeSetIdentity.js.map +1 -0
  26. package/dist/es/commands/nodeSetTenant.js +49 -0
  27. package/dist/es/commands/nodeSetTenant.js.map +1 -0
  28. package/dist/es/commands/tenantCreate.js +120 -0
  29. package/dist/es/commands/tenantCreate.js.map +1 -0
  30. package/dist/es/commands/tenantImport.js +78 -0
  31. package/dist/es/commands/tenantImport.js.map +1 -0
  32. package/dist/es/commands/userCreate.js +197 -0
  33. package/dist/es/commands/userCreate.js.map +1 -0
  34. package/dist/es/commands/vaultKeyCreate.js +185 -0
  35. package/dist/es/commands/vaultKeyCreate.js.map +1 -0
  36. package/dist/es/commands/vaultKeyImport.js +98 -0
  37. package/dist/es/commands/vaultKeyImport.js.map +1 -0
  38. package/dist/es/defaults.js +28 -0
  39. package/dist/es/defaults.js.map +1 -0
  40. package/dist/es/index.js +27 -0
  41. package/dist/es/index.js.map +1 -0
  42. package/dist/es/models/ICacheMetadata.js +4 -0
  43. package/dist/es/models/ICacheMetadata.js.map +1 -0
  44. package/dist/es/models/ICliArgs.js +4 -0
  45. package/dist/es/models/ICliArgs.js.map +1 -0
  46. package/dist/es/models/ICliCommand.js +2 -0
  47. package/dist/es/models/ICliCommand.js.map +1 -0
  48. package/dist/es/models/ICliCommandDefinition.js +2 -0
  49. package/dist/es/models/ICliCommandDefinition.js.map +1 -0
  50. package/dist/es/models/ICliCommandDefinitionParam.js +2 -0
  51. package/dist/es/models/ICliCommandDefinitionParam.js.map +1 -0
  52. package/dist/es/models/IEngineEnvironmentVariables.js +4 -0
  53. package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -0
  54. package/dist/es/models/IEngineServerEnvironmentVariables.js +2 -0
  55. package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -0
  56. package/dist/es/models/IModuleProtocol.js +2 -0
  57. package/dist/es/models/IModuleProtocol.js.map +1 -0
  58. package/dist/es/models/INodeEngineConfig.js +2 -0
  59. package/dist/es/models/INodeEngineConfig.js.map +1 -0
  60. package/dist/es/models/INodeEngineState.js +2 -0
  61. package/dist/es/models/INodeEngineState.js.map +1 -0
  62. package/dist/es/models/INodeEnvironmentVariables.js +2 -0
  63. package/dist/es/models/INodeEnvironmentVariables.js.map +1 -0
  64. package/dist/es/models/INodeOptions.js +2 -0
  65. package/dist/es/models/INodeOptions.js.map +1 -0
  66. package/dist/es/models/IProtocolHandlerResult.js +4 -0
  67. package/dist/es/models/IProtocolHandlerResult.js.map +1 -0
  68. package/dist/es/models/cliCommandParamType.js +4 -0
  69. package/dist/es/models/cliCommandParamType.js.map +1 -0
  70. package/dist/es/models/moduleProtocol.js +29 -0
  71. package/dist/es/models/moduleProtocol.js.map +1 -0
  72. package/dist/es/models/nodeExtensionMethods.js +2 -0
  73. package/dist/es/models/nodeExtensionMethods.js.map +1 -0
  74. package/dist/es/node.js +285 -0
  75. package/dist/es/node.js.map +1 -0
  76. package/dist/es/start.js +128 -0
  77. package/dist/es/start.js.map +1 -0
  78. package/dist/es/utils.js +397 -0
  79. package/dist/es/utils.js.map +1 -0
  80. package/dist/types/builders/engineEnvBuilder.d.ts +6 -2
  81. package/dist/types/builders/engineServerEnvBuilder.d.ts +7 -3
  82. package/dist/types/builders/extensionsBuilder.d.ts +32 -0
  83. package/dist/types/cli.d.ts +66 -0
  84. package/dist/types/commands/bootstrapLegacy.d.ts +66 -0
  85. package/dist/types/commands/help.d.ts +23 -0
  86. package/dist/types/commands/identityCreate.d.ts +39 -0
  87. package/dist/types/commands/identityImports.d.ts +24 -0
  88. package/dist/types/commands/identityVerifiableCredentialCreate.d.ts +43 -0
  89. package/dist/types/commands/identityVerificationMethodCreate.d.ts +47 -0
  90. package/dist/types/commands/identityVerificationMethodImport.d.ts +31 -0
  91. package/dist/types/commands/nodeSetIdentity.d.ts +22 -0
  92. package/dist/types/commands/nodeSetTenant.d.ts +22 -0
  93. package/dist/types/commands/tenantCreate.d.ts +35 -0
  94. package/dist/types/commands/tenantImport.d.ts +24 -0
  95. package/dist/types/commands/userCreate.d.ts +46 -0
  96. package/dist/types/commands/vaultKeyCreate.d.ts +43 -0
  97. package/dist/types/commands/vaultKeyImport.d.ts +28 -0
  98. package/dist/types/defaults.d.ts +16 -0
  99. package/dist/types/index.d.ts +24 -11
  100. package/dist/types/models/ICacheMetadata.d.ts +17 -0
  101. package/dist/types/models/ICliArgs.d.ts +20 -0
  102. package/dist/types/models/ICliCommand.d.ts +17 -0
  103. package/dist/types/models/ICliCommandDefinition.d.ts +46 -0
  104. package/dist/types/models/ICliCommandDefinitionParam.d.ts +35 -0
  105. package/dist/types/models/IEngineEnvironmentVariables.d.ts +154 -37
  106. package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +12 -3
  107. package/dist/types/models/IModuleProtocol.d.ts +18 -0
  108. package/dist/types/models/INodeEngineConfig.d.ts +6 -0
  109. package/dist/types/models/INodeEngineState.d.ts +14 -0
  110. package/dist/types/models/INodeEnvironmentVariables.d.ts +17 -15
  111. package/dist/types/models/INodeOptions.d.ts +14 -3
  112. package/dist/types/models/IProtocolHandlerResult.d.ts +13 -0
  113. package/dist/types/models/cliCommandParamType.d.ts +4 -0
  114. package/dist/types/models/moduleProtocol.d.ts +29 -0
  115. package/dist/types/models/nodeExtensionMethods.d.ts +27 -0
  116. package/dist/types/node.d.ts +21 -7
  117. package/dist/types/start.d.ts +25 -0
  118. package/dist/types/utils.d.ts +83 -6
  119. package/docs/changelog.md +241 -0
  120. package/docs/detailed-guide.md +129 -0
  121. package/docs/reference/functions/buildConfiguration.md +2 -2
  122. package/docs/reference/functions/buildEngineConfiguration.md +8 -2
  123. package/docs/reference/functions/buildEngineServerConfiguration.md +9 -3
  124. package/docs/reference/functions/constructCliCommand.md +27 -0
  125. package/docs/reference/functions/createModuleImportUrl.md +21 -0
  126. package/docs/reference/functions/directoryExists.md +19 -0
  127. package/docs/reference/functions/executeCommand.md +29 -0
  128. package/docs/reference/functions/extensionsConfiguration.md +25 -0
  129. package/docs/reference/functions/extensionsInitialiseEngine.md +25 -0
  130. package/docs/reference/functions/extensionsInitialiseEngineServer.md +31 -0
  131. package/docs/reference/functions/getEnvDefaults.md +19 -0
  132. package/docs/reference/functions/getExtensionsCacheDir.md +31 -0
  133. package/docs/reference/functions/getFiles.md +19 -0
  134. package/docs/reference/functions/getSubFolders.md +19 -0
  135. package/docs/reference/functions/handleHttpsProtocol.md +49 -0
  136. package/docs/reference/functions/handleNpmProtocol.md +31 -0
  137. package/docs/reference/functions/hashUrl.md +19 -0
  138. package/docs/reference/functions/initCli.md +27 -0
  139. package/docs/reference/functions/isCacheExpired.md +31 -0
  140. package/docs/reference/functions/overrideModuleImport.md +8 -2
  141. package/docs/reference/functions/parseCommandLineArgs.md +19 -0
  142. package/docs/reference/functions/parseModuleProtocol.md +19 -0
  143. package/docs/reference/functions/processEnvOptions.md +27 -0
  144. package/docs/reference/functions/registerCommands.md +9 -0
  145. package/docs/reference/functions/resolvePackageEntryPoint.md +32 -0
  146. package/docs/reference/functions/run.md +9 -3
  147. package/docs/reference/functions/shutdownExtensions.md +25 -0
  148. package/docs/reference/functions/start.md +17 -5
  149. package/docs/reference/functions/substituteEnvOptions.md +25 -0
  150. package/docs/reference/index.md +47 -10
  151. package/docs/reference/interfaces/ICacheMetadata.md +27 -0
  152. package/docs/reference/interfaces/ICliArgs.md +35 -0
  153. package/docs/reference/interfaces/ICliCommand.md +23 -0
  154. package/docs/reference/interfaces/ICliCommandDefinition.md +101 -0
  155. package/docs/reference/interfaces/ICliCommandDefinitionParam.md +65 -0
  156. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +303 -60
  157. package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +1737 -5
  158. package/docs/reference/interfaces/IModuleProtocol.md +27 -0
  159. package/docs/reference/interfaces/INodeEngineConfig.md +7 -0
  160. package/docs/reference/interfaces/INodeEngineState.md +23 -0
  161. package/docs/reference/interfaces/INodeEnvironmentVariables.md +599 -198
  162. package/docs/reference/interfaces/INodeOptions.md +27 -3
  163. package/docs/reference/interfaces/IProtocolHandlerResult.md +19 -0
  164. package/docs/reference/type-aliases/CliCommandParamType.md +5 -0
  165. package/docs/reference/type-aliases/ModuleProtocol.md +5 -0
  166. package/docs/reference/type-aliases/NodeExtensionInitialiseEngineMethod.md +18 -0
  167. package/docs/reference/type-aliases/NodeExtensionInitialiseEngineServerMethod.md +24 -0
  168. package/docs/reference/type-aliases/NodeExtensionInitialiseMethod.md +23 -0
  169. package/docs/reference/type-aliases/NodeExtensionShutdownMethod.md +10 -0
  170. package/docs/reference/variables/ATTESTATION_VERIFICATION_METHOD_ID.md +3 -0
  171. package/docs/reference/variables/AUTH_SIGNING_KEY_ID.md +3 -0
  172. package/docs/reference/variables/BLOB_STORAGE_ENCRYPTION_KEY_ID.md +3 -0
  173. package/docs/reference/variables/CONTEXT_ID_HANDLER_FEATURE_DID.md +3 -0
  174. package/docs/reference/variables/CONTEXT_ID_HANDLER_FEATURE_TENANT.md +3 -0
  175. package/docs/reference/variables/IMMUTABLE_PROOF_VERIFICATION_METHOD_ID.md +3 -0
  176. package/docs/reference/variables/ModuleProtocol.md +37 -0
  177. package/docs/reference/variables/SYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID.md +3 -0
  178. package/docs/reference/variables/VC_AUTHENTICATION_VERIFICATION_METHOD_ID.md +3 -0
  179. package/locales/en.json +479 -28
  180. package/package.json +29 -9
  181. package/dist/cjs/index.cjs +0 -1910
  182. package/dist/esm/index.mjs +0 -1870
  183. package/dist/types/bootstrap.d.ts +0 -59
  184. package/dist/types/models/nodeFeatures.d.ts +0 -21
  185. package/dist/types/server.d.ts +0 -17
  186. package/docs/reference/functions/bootstrap.md +0 -29
  187. package/docs/reference/functions/bootstrapAuth.md +0 -35
  188. package/docs/reference/functions/bootstrapBlobEncryption.md +0 -35
  189. package/docs/reference/functions/bootstrapImmutableProofMethod.md +0 -35
  190. package/docs/reference/functions/bootstrapNodeIdentity.md +0 -35
  191. package/docs/reference/functions/bootstrapNodeUser.md +0 -35
  192. package/docs/reference/functions/bootstrapSynchronisedStorage.md +0 -35
  193. package/docs/reference/functions/getFeatures.md +0 -19
  194. package/docs/reference/type-aliases/NodeFeatures.md +0 -5
  195. package/docs/reference/variables/NodeFeatures.md +0 -25
@@ -0,0 +1,208 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { CLIDisplay, CLIUtils } from "@twin.org/cli-core";
4
+ import { ComponentFactory, Converter, GeneralError, Guards, I18n, Is } from "@twin.org/core";
5
+ import { Did, DocumentHelper, IdentityConnectorFactory } from "@twin.org/identity-models";
6
+ import { DidVerificationMethodType } from "@twin.org/standards-w3c-did";
7
+ import { VaultConnectorFactory } from "@twin.org/vault-models";
8
+ import { Jwk } from "@twin.org/web";
9
+ const COMMAND_NAME = "identity-verification-method-create";
10
+ /**
11
+ * Get the command definition parameters.
12
+ * @param commandDefinitions The registered command definitions.
13
+ */
14
+ export function getCommandDefinitionIdentityVerificationMethodCreate(commandDefinitions) {
15
+ commandDefinitions[COMMAND_NAME] = {
16
+ command: COMMAND_NAME,
17
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-create.description"),
18
+ example: I18n.formatMessage("node.cli.commands.identity-verification-method-create.example"),
19
+ requiresNodeIdentity: false,
20
+ requiresTenantId: false,
21
+ params: [
22
+ {
23
+ key: "identity",
24
+ type: "string",
25
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-create.params.identity.description"),
26
+ extendedType: "did"
27
+ },
28
+ {
29
+ key: "controller",
30
+ type: "string",
31
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-create.params.controller.description"),
32
+ extendedType: "did",
33
+ required: false
34
+ },
35
+ {
36
+ key: "verification-method-type",
37
+ type: "string",
38
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-create.params.verification-method-type.description"),
39
+ options: Object.values(DidVerificationMethodType),
40
+ required: false,
41
+ defaultValue: "assertionMethod"
42
+ },
43
+ {
44
+ key: "verification-method-id",
45
+ type: "string",
46
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-create.params.verification-method-id.description"),
47
+ required: false
48
+ },
49
+ {
50
+ key: "overwrite-mode",
51
+ type: "string",
52
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-create.params.overwrite-mode.description"),
53
+ options: ["skip", "overwrite", "error"],
54
+ defaultValue: "skip",
55
+ required: false
56
+ },
57
+ {
58
+ key: "load-env",
59
+ type: "string",
60
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-create.params.load-env.description"),
61
+ required: false
62
+ },
63
+ {
64
+ key: "output-json",
65
+ type: "string",
66
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-create.params.output-json.description"),
67
+ required: false
68
+ },
69
+ {
70
+ key: "output-env",
71
+ type: "string",
72
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-create.params.output-env.description"),
73
+ required: false
74
+ },
75
+ {
76
+ key: "output-env-prefix",
77
+ type: "string",
78
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-create.params.output-env-prefix.description"),
79
+ required: false
80
+ }
81
+ ],
82
+ action: async (engineCore, envVars, params) => identityVerificationMethodCreate(engineCore, envVars, params)
83
+ };
84
+ }
85
+ /**
86
+ * Command for creating an identity verification method.
87
+ * @param engineCore The engine core.
88
+ * @param envVars The environment variables for the node.
89
+ * @param params The parameters for the command.
90
+ * @param params.identity The DID of the identity to create.
91
+ * @param params.verificationMethodType The type of verification method to create.
92
+ * @param params.verificationMethodId The ID of the verification method to create.
93
+ * @param params.controller The controller DID for the identity.
94
+ * @param params.overwriteMode The mode to use when a verification method with the same ID already exists.
95
+ * @param params.outputJson The output .json file to store the command output.
96
+ * @param params.outputEnv The output .env file to store the command output.
97
+ * @param params.outputEnvPrefix The prefix to use for variables in the output .env file.
98
+ * @returns The created verification method details or undefined if skipped.
99
+ */
100
+ export async function identityVerificationMethodCreate(engineCore, envVars, params) {
101
+ Did.guard("identityVerificationMethodCreate", "identity", params.identity);
102
+ Guards.arrayOneOf("identityVerificationMethodCreate", "verificationMethodType", params.verificationMethodType, Object.values(DidVerificationMethodType));
103
+ Guards.arrayOneOf("identityVerificationMethodCreate", "overwrite-mode", params.overwriteMode, [
104
+ "skip",
105
+ "overwrite",
106
+ "error"
107
+ ]);
108
+ const defaultIdentityConnectorType = engineCore.getRegisteredInstanceType("identityConnector");
109
+ const identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);
110
+ const defaultIdentityResolverComponentType = engineCore.getRegisteredInstanceType("identityResolverComponent");
111
+ const identityResolverComponent = ComponentFactory.get(defaultIdentityResolverComponentType);
112
+ const defaultVaultConnectorType = engineCore.getRegisteredInstanceType("vaultConnector");
113
+ const vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);
114
+ let createMethod = true;
115
+ let verificationMethod;
116
+ // We only need to perform the overwrite check if a verification method ID was provided
117
+ // otherwise a new ID will be generated
118
+ if (Is.stringValue(params.verificationMethodId)) {
119
+ if (params.overwriteMode === "skip" || params.overwriteMode === "error") {
120
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.resolvingIdentity"));
121
+ const identityDoc = await identityResolverComponent.identityResolve(params.identity);
122
+ try {
123
+ verificationMethod = DocumentHelper.getVerificationMethod(identityDoc, DocumentHelper.joinId(params.identity, params.verificationMethodId));
124
+ }
125
+ catch { }
126
+ if (!Is.empty(verificationMethod)) {
127
+ if (params.overwriteMode === "error") {
128
+ throw new GeneralError("identityVerificationMethodCreate", "verificationMethodAlreadyExists");
129
+ }
130
+ createMethod = false;
131
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.skipping"));
132
+ }
133
+ }
134
+ }
135
+ if (createMethod) {
136
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.creatingVerificationMethod"));
137
+ CLIDisplay.spinnerStart();
138
+ verificationMethod = await identityConnector.addVerificationMethod(params.controller ?? params.identity, params.identity, params.verificationMethodType, params.verificationMethodId);
139
+ CLIDisplay.spinnerStop();
140
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.createdVerificationMethod"));
141
+ }
142
+ let json;
143
+ if (!Is.empty(verificationMethod)) {
144
+ const keyParts = DocumentHelper.parseId(verificationMethod.id);
145
+ const keyPair = await vaultConnector.getKey(`${params.identity}/${keyParts.fragment}`);
146
+ const privateKeyBase64Url = Converter.bytesToBase64Url(keyPair.privateKey);
147
+ const publicKeyBase64Url = Is.uint8Array(keyPair.publicKey)
148
+ ? Converter.bytesToBase64Url(keyPair.publicKey)
149
+ : "";
150
+ const privateKeyBase64 = Converter.bytesToBase64(keyPair.privateKey);
151
+ const publicKeyBase64 = Is.uint8Array(keyPair.publicKey)
152
+ ? Converter.bytesToBase64(keyPair.publicKey)
153
+ : "";
154
+ const privateKeyHex = Converter.bytesToHex(keyPair.privateKey, true);
155
+ const publicKeyHex = Is.uint8Array(keyPair.publicKey)
156
+ ? Converter.bytesToHex(keyPair.publicKey, true)
157
+ : "";
158
+ const jwk = await Jwk.fromEd25519Private(keyPair.privateKey);
159
+ const kid = await Jwk.generateKid(jwk);
160
+ CLIDisplay.break();
161
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.verificationMethodId"), verificationMethod.id);
162
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.verificationMethodType"), verificationMethod.type);
163
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.kid"), kid);
164
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.privateKeyBase64Url"), privateKeyBase64Url);
165
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.publicKeyBase64Url"), publicKeyBase64Url);
166
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.privateKeyBase64"), privateKeyBase64);
167
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.publicKeyBase64"), publicKeyBase64);
168
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.privateKeyHex"), privateKeyHex);
169
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.identity-verification-method-create.labels.publicKeyHex"), publicKeyHex);
170
+ CLIDisplay.break();
171
+ json = {
172
+ verificationMethodId: verificationMethod.id,
173
+ verificationMethodType: verificationMethod.type,
174
+ privateKeyJwk: {
175
+ kid,
176
+ ...jwk
177
+ },
178
+ privateKeyHex,
179
+ publicKeyHex,
180
+ privateKeyBase64,
181
+ publicKeyBase64
182
+ };
183
+ if (Is.stringValue(params.outputJson)) {
184
+ await CLIUtils.writeJsonFile(params.outputJson, json, false);
185
+ }
186
+ if (Is.stringValue(params.outputEnv)) {
187
+ const output = [
188
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_ID="${verificationMethod.id}"`,
189
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_TYPE="${verificationMethod.type}"`,
190
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_KID="${kid}"`,
191
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_KTY="${jwk.kty}"`,
192
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_USE="${jwk.use}"`,
193
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_ALG="${jwk.alg}"`,
194
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_CRV="${jwk.crv}"`,
195
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_X="${jwk.x}"`,
196
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_D="${jwk.d}"`,
197
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PRIVATE_KEY_HEX="${privateKeyHex}"`,
198
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PUBLIC_KEY_HEX="${publicKeyHex}"`,
199
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PRIVATE_KEY_BASE64="${privateKeyBase64}"`,
200
+ `${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PUBLIC_KEY_BASE64="${publicKeyBase64}"`
201
+ ];
202
+ await CLIUtils.writeEnvFile(params.outputEnv, output, false);
203
+ }
204
+ }
205
+ CLIDisplay.done();
206
+ return json;
207
+ }
208
+ //# sourceMappingURL=identityVerificationMethodCreate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityVerificationMethodCreate.js","sourceRoot":"","sources":["../../../src/commands/identityVerificationMethodCreate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE7F,OAAO,EACN,GAAG,EACH,cAAc,EACd,wBAAwB,EAExB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAa,GAAG,EAAE,MAAM,eAAe,CAAC;AAM/C,MAAM,YAAY,GAAG,qCAAqC,CAAC;AAE3D;;;GAGG;AACH,MAAM,UAAU,oDAAoD,CAAC,kBAEpE;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,mEAAmE,CACnE;QACD,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,+DAA+D,CAAC;QAC5F,oBAAoB,EAAE,KAAK;QAC3B,gBAAgB,EAAE,KAAK;QACvB,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,UAAU;gBACf,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,mFAAmF,CACnF;gBACD,YAAY,EAAE,KAAK;aACnB;YACD;gBACC,GAAG,EAAE,YAAY;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,qFAAqF,CACrF;gBACD,YAAY,EAAE,KAAK;gBACnB,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,0BAA0B;gBAC/B,IAAI,EAAE,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;QAC9D,CAAC;QAED,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACtC,MAAM,MAAM,GAAG;gBACd,GAAG,MAAM,CAAC,eAAe,+BAA+B,kBAAkB,CAAC,EAAE,GAAG;gBAChF,GAAG,MAAM,CAAC,eAAe,iCAAiC,kBAAkB,CAAC,IAAI,GAAG;gBACpF,GAAG,MAAM,CAAC,eAAe,oCAAoC,GAAG,GAAG;gBACnE,GAAG,MAAM,CAAC,eAAe,oCAAoC,GAAG,CAAC,GAAG,GAAG;gBACvE,GAAG,MAAM,CAAC,eAAe,oCAAoC,GAAG,CAAC,GAAG,GAAG;gBACvE,GAAG,MAAM,CAAC,eAAe,oCAAoC,GAAG,CAAC,GAAG,GAAG;gBACvE,GAAG,MAAM,CAAC,eAAe,oCAAoC,GAAG,CAAC,GAAG,GAAG;gBACvE,GAAG,MAAM,CAAC,eAAe,kCAAkC,GAAG,CAAC,CAAC,GAAG;gBACnE,GAAG,MAAM,CAAC,eAAe,kCAAkC,GAAG,CAAC,CAAC,GAAG;gBACnE,GAAG,MAAM,CAAC,eAAe,4CAA4C,aAAa,GAAG;gBACrF,GAAG,MAAM,CAAC,eAAe,2CAA2C,YAAY,GAAG;gBACnF,GAAG,MAAM,CAAC,eAAe,+CAA+C,gBAAgB,GAAG;gBAC3F,GAAG,MAAM,CAAC,eAAe,8CAA8C,eAAe,GAAG;aACzF,CAAC;YACF,MAAM,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAC9D,CAAC;IACF,CAAC;IAED,UAAU,CAAC,IAAI,EAAE,CAAC;IAElB,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { ComponentFactory, Converter, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport {\n\tDid,\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\ttype IIdentityResolverComponent\n} from \"@twin.org/identity-models\";\nimport { DidVerificationMethodType } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory } from \"@twin.org/vault-models\";\nimport { type IJwk, Jwk } from \"@twin.org/web\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"identity-verification-method-create\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionIdentityVerificationMethodCreate(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\n\t\t\t\"node.cli.commands.identity-verification-method-create.description\"\n\t\t),\n\t\texample: I18n.formatMessage(\"node.cli.commands.identity-verification-method-create.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresTenantId: false,\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.identity.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"controller\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.controller.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\",\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-type\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.verification-method-type.description\"\n\t\t\t\t),\n\t\t\t\toptions: Object.values(DidVerificationMethodType),\n\t\t\t\trequired: false,\n\t\t\t\tdefaultValue: \"assertionMethod\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.verification-method-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"overwrite-mode\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.overwrite-mode.description\"\n\t\t\t\t),\n\t\t\t\toptions: [\"skip\", \"overwrite\", \"error\"],\n\t\t\t\tdefaultValue: \"skip\",\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.load-env.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"output-json\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.output-json.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"output-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.output-env.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"output-env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.params.output-env-prefix.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t}\n\t\t],\n\t\taction: async (engineCore, envVars, params) =>\n\t\t\tidentityVerificationMethodCreate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating an identity verification method.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID of the identity to create.\n * @param params.verificationMethodType The type of verification method to create.\n * @param params.verificationMethodId The ID of the verification method to create.\n * @param params.controller The controller DID for the identity.\n * @param params.overwriteMode The mode to use when a verification method with the same ID already exists.\n * @param params.outputJson The output .json file to store the command output.\n * @param params.outputEnv The output .env file to store the command output.\n * @param params.outputEnvPrefix The prefix to use for variables in the output .env file.\n * @returns The created verification method details or undefined if skipped.\n */\nexport async function identityVerificationMethodCreate(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t\tverificationMethodType?: DidVerificationMethodType;\n\t\tverificationMethodId?: string;\n\t\tcontroller?: string;\n\t\toverwriteMode?: \"skip\" | \"overwrite\" | \"error\";\n\t\toutputJson?: string;\n\t\toutputEnv?: string;\n\t\toutputEnvPrefix?: string;\n\t}\n): Promise<\n\t| {\n\t\t\tverificationMethodId: string;\n\t\t\tverificationMethodType: string;\n\t\t\tprivateKeyJwk: IJwk;\n\t\t\tprivateKeyHex: string;\n\t\t\tpublicKeyHex: string;\n\t\t\tprivateKeyBase64: string;\n\t\t\tpublicKeyBase64: string;\n\t }\n\t| undefined\n> {\n\tDid.guard(\"identityVerificationMethodCreate\", \"identity\", params.identity);\n\tGuards.arrayOneOf(\n\t\t\"identityVerificationMethodCreate\",\n\t\t\"verificationMethodType\",\n\t\tparams.verificationMethodType,\n\t\tObject.values(DidVerificationMethodType)\n\t);\n\tGuards.arrayOneOf(\"identityVerificationMethodCreate\", \"overwrite-mode\", params.overwriteMode, [\n\t\t\"skip\",\n\t\t\"overwrite\",\n\t\t\"error\"\n\t]);\n\n\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\tconst defaultIdentityResolverComponentType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverComponent\"\n\t);\n\tconst identityResolverComponent = ComponentFactory.get<IIdentityResolverComponent>(\n\t\tdefaultIdentityResolverComponentType\n\t);\n\n\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\tlet createMethod = true;\n\tlet verificationMethod;\n\n\t// We only need to perform the overwrite check if a verification method ID was provided\n\t// otherwise a new ID will be generated\n\tif (Is.stringValue(params.verificationMethodId)) {\n\t\tif (params.overwriteMode === \"skip\" || params.overwriteMode === \"error\") {\n\t\t\tCLIDisplay.task(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.resolvingIdentity\"\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tconst identityDoc = await identityResolverComponent.identityResolve(params.identity);\n\t\t\ttry {\n\t\t\t\tverificationMethod = DocumentHelper.getVerificationMethod(\n\t\t\t\t\tidentityDoc,\n\t\t\t\t\tDocumentHelper.joinId(params.identity, params.verificationMethodId)\n\t\t\t\t);\n\t\t\t} catch {}\n\n\t\t\tif (!Is.empty(verificationMethod)) {\n\t\t\t\tif (params.overwriteMode === \"error\") {\n\t\t\t\t\tthrow new GeneralError(\n\t\t\t\t\t\t\"identityVerificationMethodCreate\",\n\t\t\t\t\t\t\"verificationMethodAlreadyExists\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcreateMethod = false;\n\t\t\t\tCLIDisplay.task(\n\t\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.skipping\"\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (createMethod) {\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.creatingVerificationMethod\"\n\t\t\t)\n\t\t);\n\t\tCLIDisplay.spinnerStart();\n\n\t\tverificationMethod = await identityConnector.addVerificationMethod(\n\t\t\tparams.controller ?? params.identity,\n\t\t\tparams.identity,\n\t\t\tparams.verificationMethodType as DidVerificationMethodType,\n\t\t\tparams.verificationMethodId\n\t\t);\n\n\t\tCLIDisplay.spinnerStop();\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.createdVerificationMethod\"\n\t\t\t)\n\t\t);\n\t}\n\n\tlet json;\n\n\tif (!Is.empty(verificationMethod)) {\n\t\tconst keyParts = DocumentHelper.parseId(verificationMethod.id);\n\n\t\tconst keyPair = await vaultConnector.getKey(`${params.identity}/${keyParts.fragment}`);\n\t\tconst privateKeyBase64Url = Converter.bytesToBase64Url(keyPair.privateKey);\n\t\tconst publicKeyBase64Url = Is.uint8Array(keyPair.publicKey)\n\t\t\t? Converter.bytesToBase64Url(keyPair.publicKey)\n\t\t\t: \"\";\n\t\tconst privateKeyBase64 = Converter.bytesToBase64(keyPair.privateKey);\n\t\tconst publicKeyBase64 = Is.uint8Array(keyPair.publicKey)\n\t\t\t? Converter.bytesToBase64(keyPair.publicKey)\n\t\t\t: \"\";\n\n\t\tconst privateKeyHex = Converter.bytesToHex(keyPair.privateKey, true);\n\t\tconst publicKeyHex = Is.uint8Array(keyPair.publicKey)\n\t\t\t? Converter.bytesToHex(keyPair.publicKey, true)\n\t\t\t: \"\";\n\n\t\tconst jwk = await Jwk.fromEd25519Private(keyPair.privateKey);\n\t\tconst kid = await Jwk.generateKid(jwk);\n\n\t\tCLIDisplay.break();\n\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.verificationMethodId\"\n\t\t\t),\n\t\t\tverificationMethod.id\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.verificationMethodType\"\n\t\t\t),\n\t\t\tverificationMethod.type\n\t\t);\n\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"node.cli.commands.identity-verification-method-create.labels.kid\"),\n\t\t\tkid\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.privateKeyBase64Url\"\n\t\t\t),\n\t\t\tprivateKeyBase64Url\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.publicKeyBase64Url\"\n\t\t\t),\n\t\t\tpublicKeyBase64Url\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.privateKeyBase64\"\n\t\t\t),\n\t\t\tprivateKeyBase64\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.publicKeyBase64\"\n\t\t\t),\n\t\t\tpublicKeyBase64\n\t\t);\n\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.privateKeyHex\"\n\t\t\t),\n\t\t\tprivateKeyHex\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\n\t\t\t\t\"node.cli.commands.identity-verification-method-create.labels.publicKeyHex\"\n\t\t\t),\n\t\t\tpublicKeyHex\n\t\t);\n\n\t\tCLIDisplay.break();\n\n\t\tjson = {\n\t\t\tverificationMethodId: verificationMethod.id,\n\t\t\tverificationMethodType: verificationMethod.type,\n\t\t\tprivateKeyJwk: {\n\t\t\t\tkid,\n\t\t\t\t...jwk\n\t\t\t},\n\t\t\tprivateKeyHex,\n\t\t\tpublicKeyHex,\n\t\t\tprivateKeyBase64,\n\t\t\tpublicKeyBase64\n\t\t};\n\n\t\tif (Is.stringValue(params.outputJson)) {\n\t\t\tawait CLIUtils.writeJsonFile(params.outputJson, json, false);\n\t\t}\n\n\t\tif (Is.stringValue(params.outputEnv)) {\n\t\t\tconst output = [\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_ID=\"${verificationMethod.id}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_TYPE=\"${verificationMethod.type}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_KID=\"${kid}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_KTY=\"${jwk.kty}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_USE=\"${jwk.use}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_ALG=\"${jwk.alg}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_CRV=\"${jwk.crv}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_X=\"${jwk.x}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_JWK_D=\"${jwk.d}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PRIVATE_KEY_HEX=\"${privateKeyHex}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PUBLIC_KEY_HEX=\"${publicKeyHex}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PRIVATE_KEY_BASE64=\"${privateKeyBase64}\"`,\n\t\t\t\t`${params.outputEnvPrefix}DID_VERIFICATION_METHOD_PUBLIC_KEY_BASE64=\"${publicKeyBase64}\"`\n\t\t\t];\n\t\t\tawait CLIUtils.writeEnvFile(params.outputEnv, output, false);\n\t\t}\n\t}\n\n\tCLIDisplay.done();\n\n\treturn json;\n}\n"]}
@@ -0,0 +1,120 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { CLIDisplay } from "@twin.org/cli-core";
4
+ import { Converter, GeneralError, Guards, HexHelper, I18n, Is } from "@twin.org/core";
5
+ import { Ed25519 } from "@twin.org/crypto";
6
+ import { Did, DocumentHelper, IdentityConnectorFactory, IdentityResolverConnectorFactory } from "@twin.org/identity-models";
7
+ import { DidVerificationMethodType } from "@twin.org/standards-w3c-did";
8
+ import { VaultConnectorFactory, VaultKeyType } from "@twin.org/vault-models";
9
+ const COMMAND_NAME = "identity-verification-method-import";
10
+ /**
11
+ * Get the command definition parameters.
12
+ * @param commandDefinitions The registered command definitions.
13
+ */
14
+ export function getCommandDefinitionIdentityVerificationMethodImport(commandDefinitions) {
15
+ commandDefinitions[COMMAND_NAME] = {
16
+ command: COMMAND_NAME,
17
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-import.description"),
18
+ example: I18n.formatMessage("node.cli.commands.identity-verification-method-import.example"),
19
+ requiresNodeIdentity: false,
20
+ requiresTenantId: false,
21
+ params: [
22
+ {
23
+ key: "identity",
24
+ type: "string",
25
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-import.params.identity.description"),
26
+ extendedType: "did"
27
+ },
28
+ {
29
+ key: "controller",
30
+ type: "string",
31
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-import.params.controller.description"),
32
+ extendedType: "did",
33
+ required: false
34
+ },
35
+ {
36
+ key: "verification-method-type",
37
+ type: "string",
38
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-import.params.verification-method-type.description"),
39
+ options: Object.values(DidVerificationMethodType),
40
+ required: true,
41
+ defaultValue: "assertionMethod"
42
+ },
43
+ {
44
+ key: "verification-method-id",
45
+ type: "string",
46
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-import.params.verification-method-id.description"),
47
+ required: true
48
+ },
49
+ {
50
+ key: "private-key-hex",
51
+ type: "string",
52
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-import.params.private-key-hex.description"),
53
+ required: true
54
+ },
55
+ {
56
+ key: "load-env",
57
+ type: "string",
58
+ description: I18n.formatMessage("node.cli.commands.identity-verification-method-import.params.load-env.description"),
59
+ required: false
60
+ }
61
+ ],
62
+ action: async (engineCore, envVars, params) => identityVerificationMethodImport(engineCore, envVars, params)
63
+ };
64
+ }
65
+ /**
66
+ * Command for creating an identity verification method.
67
+ * @param engineCore The engine core.
68
+ * @param envVars The environment variables for the node.
69
+ * @param params The parameters for the command.
70
+ * @param params.identity The DID of the identity to create.
71
+ * @param params.verificationMethodType The type of verification method to create.
72
+ * @param params.verificationMethodId The ID of the verification method to create.
73
+ * @param params.controller The controller DID for the identity.
74
+ * @param params.privateKeyHex The private key in hex format.
75
+ */
76
+ export async function identityVerificationMethodImport(engineCore, envVars, params) {
77
+ Did.guard("identityVerificationMethodImport", "identity", params.identity);
78
+ Guards.arrayOneOf("identityVerificationMethodImport", "verification-method-type", params.verificationMethodType, Object.values(DidVerificationMethodType));
79
+ Guards.stringValue("identityVerificationMethodImport", "verification-method-id", params.verificationMethodId);
80
+ Guards.stringHex("identityVerificationMethodImport", "private-key-hex", params.privateKeyHex, true);
81
+ const defaultIdentityConnectorType = engineCore.getRegisteredInstanceType("identityConnector");
82
+ const identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);
83
+ const defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType("identityResolverConnector");
84
+ const identityResolverConnector = IdentityResolverConnectorFactory.get(defaultIdentityResolverConnectorType);
85
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.identity-verification-method-import.labels.resolvingIdentity"));
86
+ const identityDocument = await identityResolverConnector.resolveDocument(params.identity);
87
+ if (Is.empty(identityDocument)) {
88
+ throw new GeneralError("identityImport", "identityNotFound", {
89
+ identity: params.identity
90
+ });
91
+ }
92
+ const defaultVaultConnectorType = engineCore.getRegisteredInstanceType("vaultConnector");
93
+ const vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);
94
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.identity-verification-method-import.labels.importing"));
95
+ CLIDisplay.spinnerStart();
96
+ let verificationMethodId = params.verificationMethodId;
97
+ if (verificationMethodId.includes("#")) {
98
+ const parts = DocumentHelper.parseId(verificationMethodId);
99
+ if (Is.stringValue(parts.fragment)) {
100
+ verificationMethodId = parts.fragment;
101
+ }
102
+ }
103
+ let vaultKey;
104
+ const vaultKeyId = `${params.identity}/${verificationMethodId}`;
105
+ try {
106
+ vaultKey = await vaultConnector.getKey(vaultKeyId);
107
+ }
108
+ catch { }
109
+ if (Is.empty(vaultKey)) {
110
+ const privateKeyBytes = Converter.hexToBytes(HexHelper.stripPrefix(params.privateKeyHex));
111
+ const publicKeyBytes = Ed25519.publicKeyFromPrivateKey(privateKeyBytes);
112
+ vaultKey = await vaultConnector.addKey(vaultKeyId, VaultKeyType.Ed25519, privateKeyBytes, publicKeyBytes);
113
+ }
114
+ await identityConnector.addVerificationMethod(params.controller ?? params.identity, params.identity, params.verificationMethodType, verificationMethodId);
115
+ CLIDisplay.spinnerStop();
116
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.identity-verification-method-import.labels.imported"));
117
+ CLIDisplay.break();
118
+ CLIDisplay.done();
119
+ }
120
+ //# sourceMappingURL=identityVerificationMethodImport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityVerificationMethodImport.js","sourceRoot":"","sources":["../../../src/commands/identityVerificationMethodImport.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,YAAY,E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AQ,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,IAAI,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxB,MAAM,eAAe,GAAG,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;QAC1F,MAAM,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC;QACxE,QAAQ,GAAG,MAAM,cAAc,CAAC,MAAM,CACrC,UAAU,EACV,YAAY,CAAC,OAAO,EACpB,eAAe,EACf,cAAc,CACd,CAAC;IACH,CAAC;IAED,MAAM,iBAAiB,CAAC,qBAAqB,CAC5C,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,QAAQ,EACpC,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,sBAAmD,EAC1D,oBAAoB,CACpB,CAAC;IAEF,UAAU,CAAC,WAAW,EAAE,CAAC;IACzB,UAAU,CAAC,IAAI,CACd,IAAI,CAAC,aAAa,CAAC,uEAAuE,CAAC,CAC3F,CAAC;IACF,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { Converter, GeneralError, Guards, HexHelper, I18n, Is } from \"@twin.org/core\";\nimport { Ed25519 } from \"@twin.org/crypto\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport {\n\tDid,\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\tIdentityResolverConnectorFactory\n} from \"@twin.org/identity-models\";\nimport { DidVerificationMethodType } from \"@twin.org/standards-w3c-did\";\nimport { VaultConnectorFactory, VaultKeyType } from \"@twin.org/vault-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"identity-verification-method-import\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionIdentityVerificationMethodImport(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\n\t\t\t\"node.cli.commands.identity-verification-method-import.description\"\n\t\t),\n\t\texample: I18n.formatMessage(\"node.cli.commands.identity-verification-method-import.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresTenantId: false,\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.identity.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"controller\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.controller.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\",\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-type\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.verification-method-type.description\"\n\t\t\t\t),\n\t\t\t\toptions: Object.values(DidVerificationMethodType),\n\t\t\t\trequired: true,\n\t\t\t\tdefaultValue: \"assertionMethod\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"verification-method-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.verification-method-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"private-key-hex\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.private-key-hex.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-verification-method-import.params.load-env.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t}\n\t\t],\n\t\taction: async (engineCore, envVars, params) =>\n\t\t\tidentityVerificationMethodImport(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating an identity verification method.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID of the identity to create.\n * @param params.verificationMethodType The type of verification method to create.\n * @param params.verificationMethodId The ID of the verification method to create.\n * @param params.controller The controller DID for the identity.\n * @param params.privateKeyHex The private key in hex format.\n */\nexport async function identityVerificationMethodImport(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t\tverificationMethodType?: DidVerificationMethodType;\n\t\tverificationMethodId?: string;\n\t\tcontroller?: string;\n\t\tprivateKeyHex?: string;\n\t}\n): Promise<void> {\n\tDid.guard(\"identityVerificationMethodImport\", \"identity\", params.identity);\n\tGuards.arrayOneOf(\n\t\t\"identityVerificationMethodImport\",\n\t\t\"verification-method-type\",\n\t\tparams.verificationMethodType,\n\t\tObject.values(DidVerificationMethodType)\n\t);\n\tGuards.stringValue(\n\t\t\"identityVerificationMethodImport\",\n\t\t\"verification-method-id\",\n\t\tparams.verificationMethodId\n\t);\n\tGuards.stringHex(\n\t\t\"identityVerificationMethodImport\",\n\t\t\"private-key-hex\",\n\t\tparams.privateKeyHex,\n\t\ttrue\n\t);\n\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverConnector\"\n\t);\n\n\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\tdefaultIdentityResolverConnectorType\n\t);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\n\t\t\t\"node.cli.commands.identity-verification-method-import.labels.resolvingIdentity\"\n\t\t)\n\t);\n\tconst identityDocument = await identityResolverConnector.resolveDocument(params.identity);\n\n\tif (Is.empty(identityDocument)) {\n\t\tthrow new GeneralError(\"identityImport\", \"identityNotFound\", {\n\t\t\tidentity: params.identity\n\t\t});\n\t}\n\n\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"node.cli.commands.identity-verification-method-import.labels.importing\")\n\t);\n\tCLIDisplay.spinnerStart();\n\n\tlet verificationMethodId = params.verificationMethodId;\n\tif (verificationMethodId.includes(\"#\")) {\n\t\tconst parts = DocumentHelper.parseId(verificationMethodId);\n\t\tif (Is.stringValue(parts.fragment)) {\n\t\t\tverificationMethodId = parts.fragment;\n\t\t}\n\t}\n\n\tlet vaultKey;\n\tconst vaultKeyId = `${params.identity}/${verificationMethodId}`;\n\n\ttry {\n\t\tvaultKey = await vaultConnector.getKey(vaultKeyId);\n\t} catch {}\n\n\tif (Is.empty(vaultKey)) {\n\t\tconst privateKeyBytes = Converter.hexToBytes(HexHelper.stripPrefix(params.privateKeyHex));\n\t\tconst publicKeyBytes = Ed25519.publicKeyFromPrivateKey(privateKeyBytes);\n\t\tvaultKey = await vaultConnector.addKey(\n\t\t\tvaultKeyId,\n\t\t\tVaultKeyType.Ed25519,\n\t\t\tprivateKeyBytes,\n\t\t\tpublicKeyBytes\n\t\t);\n\t}\n\n\tawait identityConnector.addVerificationMethod(\n\t\tparams.controller ?? params.identity,\n\t\tparams.identity,\n\t\tparams.verificationMethodType as DidVerificationMethodType,\n\t\tverificationMethodId\n\t);\n\n\tCLIDisplay.spinnerStop();\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"node.cli.commands.identity-verification-method-import.labels.imported\")\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n}\n"]}
@@ -0,0 +1,51 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { CLIDisplay } from "@twin.org/cli-core";
4
+ import { I18n } from "@twin.org/core";
5
+ import { Did } from "@twin.org/identity-models";
6
+ const COMMAND_NAME = "node-set-identity";
7
+ /**
8
+ * Get the command definition parameters.
9
+ * @param commandDefinitions The registered command definitions.
10
+ */
11
+ export function getCommandDefinitionNodeSetIdentity(commandDefinitions) {
12
+ commandDefinitions[COMMAND_NAME] = {
13
+ command: COMMAND_NAME,
14
+ description: I18n.formatMessage("node.cli.commands.node-set-identity.description"),
15
+ example: I18n.formatMessage("node.cli.commands.node-set-identity.example"),
16
+ requiresNodeIdentity: false,
17
+ requiresTenantId: false,
18
+ params: [
19
+ {
20
+ key: "identity",
21
+ type: "string",
22
+ description: I18n.formatMessage("node.cli.commands.node-set-identity.params.identity.description"),
23
+ extendedType: "did",
24
+ required: true
25
+ },
26
+ {
27
+ key: "load-env",
28
+ type: "string",
29
+ description: I18n.formatMessage("node.cli.commands.node-set-identity.params.load-env.description"),
30
+ required: false
31
+ }
32
+ ],
33
+ action: async (engineCore, envVars, params) => nodeSetIdentity(engineCore, envVars, params)
34
+ };
35
+ }
36
+ /**
37
+ * Command for setting a node identity.
38
+ * @param engineCore The engine core.
39
+ * @param envVars The environment variables for the node.
40
+ * @param params The parameters for the command.
41
+ * @param params.identity The DID to set for the node.
42
+ */
43
+ export async function nodeSetIdentity(engineCore, envVars, params) {
44
+ Did.guard("nodeSetIdentity", "identity", params.identity);
45
+ const state = engineCore.getState();
46
+ state.nodeId = params.identity;
47
+ engineCore.setStateDirty();
48
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.node-set-identity.labels.stored"));
49
+ CLIDisplay.done();
50
+ }
51
+ //# sourceMappingURL=nodeSetIdentity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeSetIdentity.js","sourceRoot":"","sources":["../../../src/commands/nodeSetIdentity.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAMhD,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CAAC,kBAEnD;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC;QAClF,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,6CAA6C,CAAC;QAC1E,oBAAoB,EAAE,KAAK;QAC3B,gBAAgB,EAAE,KAAK;QACvB,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,UAAU;gBACf,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,iEAAiE,CACjE;gBACD,YAAY,EAAE,KAAK;gBACnB,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,GAAG,EAAE,UAAU;gBACf,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,iEAAiE,CACjE;gBACD,QAAQ,EAAE,KAAK;aACf;SACD;QACD,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC;KAC3F,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,UAA4D,EAC5D,OAAkC,EAClC,MAEC;IAED,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE1D,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC/B,UAAU,CAAC,aAAa,EAAE,CAAC;IAE3B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAEzF,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { I18n } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"node-set-identity\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionNodeSetIdentity(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\"node.cli.commands.node-set-identity.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.node-set-identity.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresTenantId: false,\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.node-set-identity.params.identity.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\",\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.node-set-identity.params.load-env.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t}\n\t\t],\n\t\taction: async (engineCore, envVars, params) => nodeSetIdentity(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for setting a node identity.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID to set for the node.\n */\nexport async function nodeSetIdentity(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t}\n): Promise<void> {\n\tDid.guard(\"nodeSetIdentity\", \"identity\", params.identity);\n\n\tconst state = engineCore.getState();\n\tstate.nodeId = params.identity;\n\tengineCore.setStateDirty();\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.node-set-identity.labels.stored\"));\n\n\tCLIDisplay.done();\n}\n"]}
@@ -0,0 +1,49 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { CLIDisplay } from "@twin.org/cli-core";
4
+ import { Guards, I18n } from "@twin.org/core";
5
+ const COMMAND_NAME = "node-set-tenant";
6
+ /**
7
+ * Get the command definition parameters.
8
+ * @param commandDefinitions The registered command definitions.
9
+ */
10
+ export function getCommandDefinitionNodeSetTenant(commandDefinitions) {
11
+ commandDefinitions[COMMAND_NAME] = {
12
+ command: COMMAND_NAME,
13
+ description: I18n.formatMessage("node.cli.commands.node-set-tenant.description"),
14
+ example: I18n.formatMessage("node.cli.commands.node-set-tenant.example"),
15
+ requiresTenantId: false,
16
+ params: [
17
+ {
18
+ key: "tenant-id",
19
+ type: "string",
20
+ extendedType: "hex(32)",
21
+ description: I18n.formatMessage("node.cli.commands.node-set-tenant.params.tenant-id.description"),
22
+ required: true
23
+ },
24
+ {
25
+ key: "load-env",
26
+ type: "string",
27
+ description: I18n.formatMessage("node.cli.commands.node-set-tenant.params.load-env.description"),
28
+ required: false
29
+ }
30
+ ],
31
+ action: async (engineCore, envVars, params) => nodeSetTenant(engineCore, envVars, params)
32
+ };
33
+ }
34
+ /**
35
+ * Command for setting a node tenant.
36
+ * @param engineCore The engine core.
37
+ * @param envVars The environment variables for the node.
38
+ * @param params The parameters for the command.
39
+ * @param params.tenantId The tenant id to set for the node.
40
+ */
41
+ export async function nodeSetTenant(engineCore, envVars, params) {
42
+ Guards.stringHexLength("nodeSetTenant", "tenant-id", params.tenantId, 32);
43
+ const state = engineCore.getState();
44
+ state.nodeTenantId = params.tenantId;
45
+ engineCore.setStateDirty();
46
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.node-set-tenant.labels.stored"));
47
+ CLIDisplay.done();
48
+ }
49
+ //# sourceMappingURL=nodeSetTenant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeSetTenant.js","sourceRoot":"","sources":["../../../src/commands/nodeSetTenant.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAO9C,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,kBAEjD;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in.org/cli-core\";\nimport { Guards, I18n } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"node-set-tenant\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionNodeSetTenant(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\"node.cli.commands.node-set-tenant.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.node-set-tenant.example\"),\n\t\trequiresTenantId: false,\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.node-set-tenant.params.tenant-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.node-set-tenant.params.load-env.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t}\n\t\t],\n\t\taction: async (engineCore, envVars, params) => nodeSetTenant(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for setting a node tenant.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.tenantId The tenant id to set for the node.\n */\nexport async function nodeSetTenant(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\ttenantId?: string;\n\t}\n): Promise<void> {\n\tGuards.stringHexLength(\"nodeSetTenant\", \"tenant-id\", params.tenantId, 32);\n\n\tconst state = engineCore.getState();\n\tstate.nodeTenantId = params.tenantId;\n\tengineCore.setStateDirty();\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.node-set-tenant.labels.stored\"));\n\n\tCLIDisplay.done();\n}\n"]}