@twin.org/node-core 0.0.3-next.38 → 0.0.3-next.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/builders/extensionsBuilder.js.map +1 -1
- package/dist/es/commands/bootstrapLegacy.js +1 -0
- package/dist/es/commands/bootstrapLegacy.js.map +1 -1
- package/dist/es/commands/userCreate.js +108 -81
- package/dist/es/commands/userCreate.js.map +1 -1
- package/dist/es/commands/userUpdate.js +66 -44
- package/dist/es/commands/userUpdate.js.map +1 -1
- package/dist/es/index.js +4 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/nodeExtensionInitialiseEngineMethod.js +2 -0
- package/dist/es/models/nodeExtensionInitialiseEngineMethod.js.map +1 -0
- package/dist/es/models/nodeExtensionInitialiseEngineServerMethod.js +2 -0
- package/dist/es/models/nodeExtensionInitialiseEngineServerMethod.js.map +1 -0
- package/dist/es/models/nodeExtensionInitialiseMethod.js +2 -0
- package/dist/es/models/nodeExtensionInitialiseMethod.js.map +1 -0
- package/dist/es/models/nodeExtensionShutdownMethod.js +4 -0
- package/dist/es/models/nodeExtensionShutdownMethod.js.map +1 -0
- package/dist/es/node.js +1 -1
- package/dist/es/node.js.map +1 -1
- package/dist/types/commands/userCreate.d.ts +2 -0
- package/dist/types/commands/userUpdate.d.ts +3 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/models/nodeExtensionInitialiseEngineMethod.d.ts +7 -0
- package/dist/types/models/nodeExtensionInitialiseEngineServerMethod.d.ts +8 -0
- package/dist/types/models/nodeExtensionInitialiseMethod.d.ts +8 -0
- package/dist/types/models/nodeExtensionShutdownMethod.d.ts +5 -0
- package/docs/changelog.md +7 -0
- package/docs/reference/index.md +1 -1
- package/locales/en.json +11 -1
- package/package.json +1 -1
- package/dist/es/models/nodeExtensionMethods.js +0 -2
- package/dist/es/models/nodeExtensionMethods.js.map +0 -1
- package/dist/types/models/nodeExtensionMethods.d.ts +0 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensionsBuilder.js","sourceRoot":"","sources":["../../../src/builders/extensionsBuilder.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"extensionsBuilder.js","sourceRoot":"","sources":["../../../src/builders/extensionsBuilder.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQjD,MAAM,cAAc,GAA+C,EAAE,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC5C,OAAkC,EAClC,gBAAmC;IAEnC,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACxC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEjD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACpC,IAAI,sBAAiE,CAAC;YACtE,IAAI,CAAC;gBACJ,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC,EAAE,SAAS,CAAC,CAAC;gBAEzE,sBAAsB,GAAG,MAAM,YAAY,CAAC,eAAe,CAC1D,SAAS,EACT,qBAAqB,CACrB,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,MAAM,IAAI,YAAY,CAAC,MAAM,E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CAAC;oBACJ,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,wBAAwB,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;oBAChF,cAAc,GAAG,MAAM,YAAY,CAAC,eAAe,CAClD,SAAS,EACT,mBAAmB,CACnB,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC,CAAA,CAAC;gBAEV,IAAI,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;oBACjC,MAAM,cAAc,EAAE,CAAC;gBACxB,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore, IEngineServer } from \"@twin.org/engine-models\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\nimport type { NodeExtensionInitialiseEngineMethod } from \"../models/nodeExtensionInitialiseEngineMethod.js\";\nimport type { NodeExtensionInitialiseEngineServerMethod } from \"../models/nodeExtensionInitialiseEngineServerMethod.js\";\nimport type { NodeExtensionInitialiseMethod } from \"../models/nodeExtensionInitialiseMethod.js\";\nimport type { NodeExtensionShutdownMethod } from \"../models/nodeExtensionShutdownMethod.js\";\n\nconst extensionState: { [id: string]: { initialised: boolean } } = {};\n\n/**\n * Handles the configuration of the extensions.\n * @param envVars The environment variables for the node.\n * @param nodeEngineConfig The node engine config.\n * @returns The config for the core and the server.\n */\nexport async function extensionsConfiguration(\n\tenvVars: INodeEnvironmentVariables,\n\tnodeEngineConfig: INodeEngineConfig\n): Promise<INodeEngineConfig> {\n\tif (Is.stringValue(envVars.extensions)) {\n\t\tconst extensions = envVars.extensions.split(\",\");\n\n\t\tfor (const extension of extensions) {\n\t\t\tlet initialiseConfigMethod: NodeExtensionInitialiseMethod | undefined;\n\t\t\ttry {\n\t\t\t\tCLIDisplay.value(I18n.formatMessage(\"node.extensionLoading\"), extension);\n\n\t\t\t\tinitialiseConfigMethod = await ModuleHelper.getModuleMethod<NodeExtensionInitialiseMethod>(\n\t\t\t\t\textension,\n\t\t\t\t\t\"extensionInitialise\"\n\t\t\t\t);\n\t\t\t} catch (err) {\n\t\t\t\tthrow new GeneralError(\"node\", \"extensionLoadingError\", { extension }, err);\n\t\t\t}\n\n\t\t\tif (Is.function(initialiseConfigMethod)) {\n\t\t\t\tawait initialiseConfigMethod(envVars, nodeEngineConfig);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nodeEngineConfig;\n}\n\n/**\n * Handles the initialisation of the extensions when the engine has been constructed.\n * @param envVars The environment variables for the node.\n * @param engineCore The engine core instance.\n * @returns Nothing.\n */\nexport async function extensionsInitialiseEngine(\n\tenvVars: INodeEnvironmentVariables,\n\tengineCore: IEngineCore\n): Promise<void> {\n\tif (Is.stringValue(envVars.extensions)) {\n\t\tconst extensions = envVars.extensions.split(\",\");\n\n\t\tfor (const extension of extensions) {\n\t\t\textensionState[extension] ??= { initialised: false };\n\n\t\t\tif (!extensionState[extension].initialised) {\n\t\t\t\textensionState[extension].initialised = true;\n\n\t\t\t\tlet initialiseEngineMethod: NodeExtensionInitialiseEngineMethod | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.extensionInitialisingEngine\", { extension }));\n\t\t\t\t\tinitialiseEngineMethod =\n\t\t\t\t\t\tawait ModuleHelper.getModuleMethod<NodeExtensionInitialiseEngineMethod>(\n\t\t\t\t\t\t\textension,\n\t\t\t\t\t\t\t\"extensionInitialiseEngine\"\n\t\t\t\t\t\t);\n\t\t\t\t} catch {}\n\n\t\t\t\tif (Is.function(initialiseEngineMethod)) {\n\t\t\t\t\tawait initialiseEngineMethod(engineCore);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Handles the initialisation of the extensions when the engine server has been constructed.\n * @param envVars The environment variables for the node.\n * @param engineCore The engine core instance.\n * @param engineServer The engine server instance.\n * @returns Nothing.\n */\nexport async function extensionsInitialiseEngineServer(\n\tenvVars: INodeEnvironmentVariables,\n\tengineCore: IEngineCore,\n\tengineServer: IEngineServer\n): Promise<void> {\n\tif (Is.stringValue(envVars.extensions)) {\n\t\tconst extensions = envVars.extensions.split(\",\");\n\n\t\tfor (const extension of extensions) {\n\t\t\tlet initialiseEngineServerMethod: NodeExtensionInitialiseEngineServerMethod | undefined;\n\t\t\ttry {\n\t\t\t\tengineCore.logInfo(\n\t\t\t\t\tI18n.formatMessage(\"node.extensionInitialisingEngineServer\", { extension })\n\t\t\t\t);\n\t\t\t\tinitialiseEngineServerMethod =\n\t\t\t\t\tawait ModuleHelper.getModuleMethod<NodeExtensionInitialiseEngineServerMethod>(\n\t\t\t\t\t\textension,\n\t\t\t\t\t\t\"extensionInitialiseEngineServer\"\n\t\t\t\t\t);\n\t\t\t} catch {}\n\n\t\t\tif (Is.function(initialiseEngineServerMethod)) {\n\t\t\t\tawait initialiseEngineServerMethod(engineCore, engineServer);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Handles the shutdown of the extensions.\n * @param envVars The environment variables for the node.\n * @param engineCore The engine core instance.\n * @returns Nothing.\n */\nexport async function shutdownExtensions(\n\tenvVars: INodeEnvironmentVariables,\n\tengineCore: IEngineCore\n): Promise<void> {\n\tif (Is.stringValue(envVars.extensions)) {\n\t\tconst extensions = envVars.extensions.split(\",\");\n\n\t\tfor (const extension of extensions) {\n\t\t\textensionState[extension] ??= { initialised: false };\n\n\t\t\tif (extensionState[extension].initialised) {\n\t\t\t\textensionState[extension].initialised = false;\n\t\t\t\tlet shutdownMethod: NodeExtensionShutdownMethod | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.extensionShutdown\", { extension }));\n\t\t\t\t\tshutdownMethod = await ModuleHelper.getModuleMethod<NodeExtensionShutdownMethod>(\n\t\t\t\t\t\textension,\n\t\t\t\t\t\t\"extensionShutdown\"\n\t\t\t\t\t);\n\t\t\t\t} catch {}\n\n\t\t\t\tif (Is.function(shutdownMethod)) {\n\t\t\t\t\tawait shutdownMethod();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -185,6 +185,7 @@ export async function bootstrapLegacy(engineCore, envVars, params) {
|
|
|
185
185
|
await userCreate(engineCore, envVars, {
|
|
186
186
|
userIdentity: adminUserIdentity.did,
|
|
187
187
|
organizationIdentity: organisation.did,
|
|
188
|
+
tenantId,
|
|
188
189
|
email: envVars.adminUserName ?? "admin@node",
|
|
189
190
|
password: envVars.adminUserPassword,
|
|
190
191
|
scope: "tenant-admin",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrapLegacy.js","sourceRoot":"","sources":["../../../src/commands/bootstrapLegacy.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC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B,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,OAAO;gBACnB,aAAa,EAAE,MAAM;aACrB,CAAC,CAAC;QACJ,CAAC,CACD,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, Converter, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { identityCreate } from \"./identityCreate.js\";\nimport { identityVerificationMethodCreate } from \"./identityVerificationMethodCreate.js\";\nimport { nodeSetIdentity } from \"./nodeSetIdentity.js\";\nimport { nodeSetTenant } from \"./nodeSetTenant.js\";\nimport { tenantCreate } from \"./tenantCreate.js\";\nimport { userCreate } from \"./userCreate.js\";\nimport { vaultKeyCreate } from \"./vaultKeyCreate.js\";\nimport { vaultKeyImport } from \"./vaultKeyImport.js\";\nimport { isTrustRequired, isUrlTransformerRequired } from \"../builders/engineEnvBuilder.js\";\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 = \"bootstrap-legacy\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionBootstrapLegacy(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.bootstrap-legacy.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.bootstrap-legacy.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresTenantId: false,\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.params.env-prefix.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: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.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) => bootstrapLegacy(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for legacy bootstrap.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n */\nexport async function bootstrapLegacy(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables & {\n\t\t/**\n\t\t * The features that are enabled on the node.\n\t\t * @default []\n\t\t */\n\t\tfeatures?: string;\n\n\t\t/**\n\t\t * The identity of the node which, if empty and node-identity feature is enabled it will be generated.\n\t\t */\n\t\tnodeIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the identity, if empty and node-identity feature is enabled it will be randomly generated.\n\t\t */\n\t\tnodeMnemonic?: string;\n\n\t\t/**\n\t\t * A tenant id to use as a default for the node.\n\t\t */\n\t\ttenantId?: string;\n\n\t\t/**\n\t\t * A tenant api key to use as a default for the node.\n\t\t */\n\t\ttenantApiKey?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the organization of the user, if one is not provided it will be generated\n\t\t */\n\t\torganizationIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the organization, if empty and node-admin-user feature is enabled it will be randomly generated.\n\t\t */\n\t\torganizationMnemonic?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the identity of the user, if one is not provided it will be generated\n\t\t */\n\t\tadminUserIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the admin user, if empty and node-admin-user feature is enabled it will be randomly generated.\n\t\t */\n\t\tadminUserMnemonic?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the name of the user.\n\t\t * @default admin@node\n\t\t */\n\t\tadminUserName?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.\n\t\t */\n\t\tadminUserPassword?: string;\n\t},\n\tparams: {}\n): Promise<void> {\n\tconst features = (envVars.features ?? \"\")\n\t\t.split(\",\")\n\t\t.map(f => f.trim())\n\t\t.filter(f => f.length > 0);\n\n\tconst state = engineCore.getState();\n\tconst requireWallet = features.includes(\"node-wallet\");\n\tlet tenantId = state.nodeTenantId;\n\tlet nodeId = state.nodeId;\n\n\tif (features.length === 0) {\n\t\tthrow new GeneralError(\"bootstrapLegacy\", \"noFeaturesEnabled\");\n\t}\n\n\tif (features.includes(\"node-identity\") && Is.empty(nodeId)) {\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeIdentityCreate\")\n\t\t);\n\n\t\tconst nodeIdentity = await identityCreate(engineCore, envVars, {\n\t\t\tidentity: envVars.nodeIdentity,\n\t\t\tmnemonic: envVars.nodeMnemonic,\n\t\t\tfundWallet: requireWallet\n\t\t});\n\n\t\tnodeId = nodeIdentity.did;\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeAuthKeyCreate\")\n\t\t);\n\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\tidentity: nodeIdentity.did,\n\t\t\tkeyType: \"Ed25519\",\n\t\t\tkeyId: envVars.authSigningKeyId,\n\t\t\toverwriteMode: \"skip\"\n\t\t});\n\n\t\tif (isTrustRequired(envVars)) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.labels.trustVerificationMethodCreate\"\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\tidentity: nodeIdentity.did,\n\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\tverificationMethodId: envVars.trustVerificationMethodId,\n\t\t\t\toverwriteMode: \"skip\"\n\t\t\t});\n\t\t}\n\n\t\tif (\n\t\t\t(Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false) &&\n\t\t\tIs.stringBase64(envVars.synchronisedStorageBlobStorageKey)\n\t\t) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.synchronisedStorageKeyAdd\")\n\t\t\t);\n\t\t\tawait vaultKeyImport(engineCore, envVars, {\n\t\t\t\tidentity: nodeIdentity.did,\n\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\tkeyId: envVars.synchronisedStorageBlobStorageEncryptionKeyId,\n\t\t\t\tprivateKeyHex: Converter.bytesToHex(\n\t\t\t\t\tConverter.base64ToBytes(envVars.synchronisedStorageBlobStorageKey)\n\t\t\t\t)\n\t\t\t});\n\t\t}\n\n\t\tif (isUrlTransformerRequired(envVars)) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.urlTransformParamKeyAdd\")\n\t\t\t);\n\t\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\t\tidentity: nodeIdentity.did,\n\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\tkeyId: envVars.urlTransformerEncryptionKeyId\n\t\t\t});\n\t\t}\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeIdentitySet\")\n\t\t);\n\t\tawait nodeSetIdentity(engineCore, envVars, {\n\t\t\tidentity: nodeId\n\t\t});\n\n\t\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\t\tif (tenantEnabled) {\n\t\t\tif (Is.empty(tenantId)) {\n\t\t\t\tawait ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeTenantCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tconst tenantDetails = await tenantCreate(engineCore, envVars, {\n\t\t\t\t\t\ttenantId: envVars.tenantId,\n\t\t\t\t\t\tapiKey: envVars.tenantApiKey,\n\t\t\t\t\t\tlabel: \"Node\"\n\t\t\t\t\t});\n\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeTenantSet\")\n\t\t\t\t\t);\n\t\t\t\t\tawait nodeSetTenant(engineCore, envVars, {\n\t\t\t\t\t\ttenantId: tenantDetails.tenantId\n\t\t\t\t\t});\n\n\t\t\t\t\ttenantId = tenantDetails.tenantId;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tif (features.includes(\"node-admin-user\")) {\n\t\tawait ContextIdStore.run(\n\t\t\t{ [ContextIdKeys.Node]: nodeId, [ContextIdKeys.Tenant]: tenantId },\n\t\t\tasync () => {\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.organisationCreate\")\n\t\t\t\t);\n\t\t\t\tconst organisation = await identityCreate(engineCore, envVars, {\n\t\t\t\t\tidentity: envVars.organizationIdentity,\n\t\t\t\t\tmnemonic: envVars.organizationMnemonic,\n\t\t\t\t\tfundWallet: requireWallet\n\t\t\t\t});\n\n\t\t\t\tif (Coerce.boolean(envVars.blobStorageEnableEncryption) ?? false) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.blobStorageKeyCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: organisation.did,\n\t\t\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\t\t\tkeyId: envVars.blobStorageEncryptionKeyId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst defaultAttestationConnectorType =\n\t\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"attestationConnector\");\n\t\t\t\tif (!Is.empty(defaultAttestationConnectorType)) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.attestationMethodCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: organisation.did,\n\t\t\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\t\t\tverificationMethodId: envVars.attestationVerificationMethodId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst defaultImmutableProofComponentType =\n\t\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"immutableProofComponent\");\n\n\t\t\t\tif (!Is.empty(defaultImmutableProofComponentType)) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.labels.immutableProofMethodCreate\"\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: organisation.did,\n\t\t\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\t\t\tverificationMethodId: envVars.immutableProofVerificationMethodId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.adminIdentityCreate\")\n\t\t\t\t);\n\t\t\t\tconst adminUserIdentity = await identityCreate(engineCore, envVars, {\n\t\t\t\t\tidentity: envVars.adminUserIdentity,\n\t\t\t\t\tmnemonic: envVars.adminUserMnemonic,\n\t\t\t\t\tcontroller: organisation.did\n\t\t\t\t});\n\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.adminUserCreate\")\n\t\t\t\t);\n\t\t\t\tawait userCreate(engineCore, envVars, {\n\t\t\t\t\tuserIdentity: adminUserIdentity.did,\n\t\t\t\t\torganizationIdentity: organisation.did,\n\t\t\t\t\temail: envVars.adminUserName ?? \"admin@node\",\n\t\t\t\t\tpassword: envVars.adminUserPassword,\n\t\t\t\t\tscope: \"tenant-admin\",\n\t\t\t\t\tgivenName: \"Node\",\n\t\t\t\t\tfamilyName: \"Admin\",\n\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t});\n\t\t\t}\n\t\t);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bootstrapLegacy.js","sourceRoot":"","sources":["../../../src/commands/bootstrapLegacy.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,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AAO,CAAC,iBAAiB;gBACnC,UAAU,EAAE,YAAY,CAAC,GAAG;aAC5B,CAAC,CAAC;YAEH,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,2DAA2D,CAAC,CAC/E,CAAC;YACF,MAAM,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE;gBACrC,YAAY,EAAE,iBAAiB,CAAC,GAAG;gBACnC,oBAAoB,EAAE,YAAY,CAAC,GAAG;gBACtC,QAAQ;gBACR,KAAK,EAAE,OAAO,CAAC,aAAa,IAAI,YAAY;gBAC5C,QAAQ,EAAE,OAAO,CAAC,iBAAiB;gBACnC,KAAK,EAAE,cAAc;gBACrB,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,OAAO;gBACnB,aAAa,EAAE,MAAM;aACrB,CAAC,CAAC;QACJ,CAAC,CACD,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, Converter, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { identityCreate } from \"./identityCreate.js\";\nimport { identityVerificationMethodCreate } from \"./identityVerificationMethodCreate.js\";\nimport { nodeSetIdentity } from \"./nodeSetIdentity.js\";\nimport { nodeSetTenant } from \"./nodeSetTenant.js\";\nimport { tenantCreate } from \"./tenantCreate.js\";\nimport { userCreate } from \"./userCreate.js\";\nimport { vaultKeyCreate } from \"./vaultKeyCreate.js\";\nimport { vaultKeyImport } from \"./vaultKeyImport.js\";\nimport { isTrustRequired, isUrlTransformerRequired } from \"../builders/engineEnvBuilder.js\";\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 = \"bootstrap-legacy\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionBootstrapLegacy(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.bootstrap-legacy.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.bootstrap-legacy.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresTenantId: false,\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.params.env-prefix.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: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.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) => bootstrapLegacy(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for legacy bootstrap.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n */\nexport async function bootstrapLegacy(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables & {\n\t\t/**\n\t\t * The features that are enabled on the node.\n\t\t * @default []\n\t\t */\n\t\tfeatures?: string;\n\n\t\t/**\n\t\t * The identity of the node which, if empty and node-identity feature is enabled it will be generated.\n\t\t */\n\t\tnodeIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the identity, if empty and node-identity feature is enabled it will be randomly generated.\n\t\t */\n\t\tnodeMnemonic?: string;\n\n\t\t/**\n\t\t * A tenant id to use as a default for the node.\n\t\t */\n\t\ttenantId?: string;\n\n\t\t/**\n\t\t * A tenant api key to use as a default for the node.\n\t\t */\n\t\ttenantApiKey?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the organization of the user, if one is not provided it will be generated\n\t\t */\n\t\torganizationIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the organization, if empty and node-admin-user feature is enabled it will be randomly generated.\n\t\t */\n\t\torganizationMnemonic?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the identity of the user, if one is not provided it will be generated\n\t\t */\n\t\tadminUserIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the admin user, if empty and node-admin-user feature is enabled it will be randomly generated.\n\t\t */\n\t\tadminUserMnemonic?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the name of the user.\n\t\t * @default admin@node\n\t\t */\n\t\tadminUserName?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.\n\t\t */\n\t\tadminUserPassword?: string;\n\t},\n\tparams: {}\n): Promise<void> {\n\tconst features = (envVars.features ?? \"\")\n\t\t.split(\",\")\n\t\t.map(f => f.trim())\n\t\t.filter(f => f.length > 0);\n\n\tconst state = engineCore.getState();\n\tconst requireWallet = features.includes(\"node-wallet\");\n\tlet tenantId = state.nodeTenantId;\n\tlet nodeId = state.nodeId;\n\n\tif (features.length === 0) {\n\t\tthrow new GeneralError(\"bootstrapLegacy\", \"noFeaturesEnabled\");\n\t}\n\n\tif (features.includes(\"node-identity\") && Is.empty(nodeId)) {\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeIdentityCreate\")\n\t\t);\n\n\t\tconst nodeIdentity = await identityCreate(engineCore, envVars, {\n\t\t\tidentity: envVars.nodeIdentity,\n\t\t\tmnemonic: envVars.nodeMnemonic,\n\t\t\tfundWallet: requireWallet\n\t\t});\n\n\t\tnodeId = nodeIdentity.did;\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeAuthKeyCreate\")\n\t\t);\n\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\tidentity: nodeIdentity.did,\n\t\t\tkeyType: \"Ed25519\",\n\t\t\tkeyId: envVars.authSigningKeyId,\n\t\t\toverwriteMode: \"skip\"\n\t\t});\n\n\t\tif (isTrustRequired(envVars)) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.labels.trustVerificationMethodCreate\"\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\tidentity: nodeIdentity.did,\n\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\tverificationMethodId: envVars.trustVerificationMethodId,\n\t\t\t\toverwriteMode: \"skip\"\n\t\t\t});\n\t\t}\n\n\t\tif (\n\t\t\t(Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false) &&\n\t\t\tIs.stringBase64(envVars.synchronisedStorageBlobStorageKey)\n\t\t) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.synchronisedStorageKeyAdd\")\n\t\t\t);\n\t\t\tawait vaultKeyImport(engineCore, envVars, {\n\t\t\t\tidentity: nodeIdentity.did,\n\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\tkeyId: envVars.synchronisedStorageBlobStorageEncryptionKeyId,\n\t\t\t\tprivateKeyHex: Converter.bytesToHex(\n\t\t\t\t\tConverter.base64ToBytes(envVars.synchronisedStorageBlobStorageKey)\n\t\t\t\t)\n\t\t\t});\n\t\t}\n\n\t\tif (isUrlTransformerRequired(envVars)) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.urlTransformParamKeyAdd\")\n\t\t\t);\n\t\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\t\tidentity: nodeIdentity.did,\n\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\tkeyId: envVars.urlTransformerEncryptionKeyId\n\t\t\t});\n\t\t}\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeIdentitySet\")\n\t\t);\n\t\tawait nodeSetIdentity(engineCore, envVars, {\n\t\t\tidentity: nodeId\n\t\t});\n\n\t\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\t\tif (tenantEnabled) {\n\t\t\tif (Is.empty(tenantId)) {\n\t\t\t\tawait ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeTenantCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tconst tenantDetails = await tenantCreate(engineCore, envVars, {\n\t\t\t\t\t\ttenantId: envVars.tenantId,\n\t\t\t\t\t\tapiKey: envVars.tenantApiKey,\n\t\t\t\t\t\tlabel: \"Node\"\n\t\t\t\t\t});\n\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeTenantSet\")\n\t\t\t\t\t);\n\t\t\t\t\tawait nodeSetTenant(engineCore, envVars, {\n\t\t\t\t\t\ttenantId: tenantDetails.tenantId\n\t\t\t\t\t});\n\n\t\t\t\t\ttenantId = tenantDetails.tenantId;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tif (features.includes(\"node-admin-user\")) {\n\t\tawait ContextIdStore.run(\n\t\t\t{ [ContextIdKeys.Node]: nodeId, [ContextIdKeys.Tenant]: tenantId },\n\t\t\tasync () => {\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.organisationCreate\")\n\t\t\t\t);\n\t\t\t\tconst organisation = await identityCreate(engineCore, envVars, {\n\t\t\t\t\tidentity: envVars.organizationIdentity,\n\t\t\t\t\tmnemonic: envVars.organizationMnemonic,\n\t\t\t\t\tfundWallet: requireWallet\n\t\t\t\t});\n\n\t\t\t\tif (Coerce.boolean(envVars.blobStorageEnableEncryption) ?? false) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.blobStorageKeyCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: organisation.did,\n\t\t\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\t\t\tkeyId: envVars.blobStorageEncryptionKeyId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst defaultAttestationConnectorType =\n\t\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"attestationConnector\");\n\t\t\t\tif (!Is.empty(defaultAttestationConnectorType)) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.attestationMethodCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: organisation.did,\n\t\t\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\t\t\tverificationMethodId: envVars.attestationVerificationMethodId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst defaultImmutableProofComponentType =\n\t\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"immutableProofComponent\");\n\n\t\t\t\tif (!Is.empty(defaultImmutableProofComponentType)) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.labels.immutableProofMethodCreate\"\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: organisation.did,\n\t\t\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\t\t\tverificationMethodId: envVars.immutableProofVerificationMethodId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.adminIdentityCreate\")\n\t\t\t\t);\n\t\t\t\tconst adminUserIdentity = await identityCreate(engineCore, envVars, {\n\t\t\t\t\tidentity: envVars.adminUserIdentity,\n\t\t\t\t\tmnemonic: envVars.adminUserMnemonic,\n\t\t\t\t\tcontroller: organisation.did\n\t\t\t\t});\n\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.adminUserCreate\")\n\t\t\t\t);\n\t\t\t\tawait userCreate(engineCore, envVars, {\n\t\t\t\t\tuserIdentity: adminUserIdentity.did,\n\t\t\t\t\torganizationIdentity: organisation.did,\n\t\t\t\t\ttenantId,\n\t\t\t\t\temail: envVars.adminUserName ?? \"admin@node\",\n\t\t\t\t\tpassword: envVars.adminUserPassword,\n\t\t\t\t\tscope: \"tenant-admin\",\n\t\t\t\t\tgivenName: \"Node\",\n\t\t\t\t\tfamilyName: \"Admin\",\n\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t});\n\t\t\t}\n\t\t);\n\t}\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CLIDisplay, CLIUtils } from "@twin.org/cli-core";
|
|
2
|
+
import { ContextIdKeys, ContextIdStore } from "@twin.org/context";
|
|
2
3
|
import { ComponentFactory, GeneralError, Guards, I18n, Is } from "@twin.org/core";
|
|
3
4
|
import { PasswordGenerator } from "@twin.org/crypto";
|
|
4
5
|
import { Did, IdentityProfileConnectorFactory } from "@twin.org/identity-models";
|
|
@@ -31,6 +32,12 @@ export function getCommandDefinitionUserCreate(commandDefinitions) {
|
|
|
31
32
|
extendedType: "DID",
|
|
32
33
|
description: I18n.formatMessage("node.cli.commands.user-create.params.organization-identity.description")
|
|
33
34
|
},
|
|
35
|
+
{
|
|
36
|
+
key: "tenant-id",
|
|
37
|
+
type: "string",
|
|
38
|
+
extendedType: "hex(32)",
|
|
39
|
+
description: I18n.formatMessage("node.cli.commands.user-create.params.tenant-id.description")
|
|
40
|
+
},
|
|
34
41
|
{
|
|
35
42
|
key: "email",
|
|
36
43
|
type: "string",
|
|
@@ -104,6 +111,7 @@ export function getCommandDefinitionUserCreate(commandDefinitions) {
|
|
|
104
111
|
* @param params The parameters for the command.
|
|
105
112
|
* @param params.userIdentity The DID for the user.
|
|
106
113
|
* @param params.organizationIdentity The organization DID for the user.
|
|
114
|
+
* @param params.tenantId The tenant ID for the user.
|
|
107
115
|
* @param params.email The email for the user.
|
|
108
116
|
* @param params.password The password for the user.
|
|
109
117
|
* @param params.scope The scope for the user.
|
|
@@ -116,9 +124,18 @@ export function getCommandDefinitionUserCreate(commandDefinitions) {
|
|
|
116
124
|
* @returns The created user details or undefined if skipped.
|
|
117
125
|
*/
|
|
118
126
|
export async function userCreate(engineCore, envVars, params) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
const paramsEmail = params.email;
|
|
128
|
+
const paramsUserIdentity = params.userIdentity;
|
|
129
|
+
const paramsOrganizationIdentity = params.organizationIdentity;
|
|
130
|
+
Guards.email("userCreate", "email", paramsEmail);
|
|
131
|
+
Did.guard("userCreate", "user-identity", paramsUserIdentity);
|
|
132
|
+
Did.guard("userCreate", "organization-identity", paramsOrganizationIdentity);
|
|
133
|
+
if (Is.stringValue(params.tenantId)) {
|
|
134
|
+
Guards.stringHexLength("userCreate", "tenant-id", params.tenantId, 32);
|
|
135
|
+
}
|
|
136
|
+
else if (envVars.tenantEnabled ?? false) {
|
|
137
|
+
throw new GeneralError("userCreate", "tenantIdRequired");
|
|
138
|
+
}
|
|
122
139
|
if (Is.stringValue(params.password) && params.password.length < 16) {
|
|
123
140
|
throw new GeneralError("userCreate", "passwordTooShort", { minLength: 16 });
|
|
124
141
|
}
|
|
@@ -127,86 +144,96 @@ export async function userCreate(engineCore, envVars, params) {
|
|
|
127
144
|
const defaultAuthenticationAdminComponentType = engineCore.getRegisteredInstanceType("authenticationAdminComponent");
|
|
128
145
|
const authenticationAdminComponent = ComponentFactory.get(defaultAuthenticationAdminComponentType);
|
|
129
146
|
let createUser = true;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
existingUser
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (!Is.empty(existingUser)) {
|
|
136
|
-
if (params.overwriteMode === "error") {
|
|
137
|
-
throw new GeneralError("userCreate", "userAlreadyExists");
|
|
138
|
-
}
|
|
139
|
-
else if (params.overwriteMode === "skip") {
|
|
140
|
-
createUser = false;
|
|
141
|
-
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-create.labels.skipping"));
|
|
147
|
+
const currentContextIds = (await ContextIdStore.getContextIds()) ?? {};
|
|
148
|
+
const returnJson = await ContextIdStore.run({ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId }, async () => {
|
|
149
|
+
let existingUser;
|
|
150
|
+
try {
|
|
151
|
+
existingUser = await authenticationAdminComponent.get(paramsEmail);
|
|
142
152
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
await authenticationAdminComponent.update(user);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
await authenticationAdminComponent.create(user);
|
|
165
|
-
}
|
|
166
|
-
const name = `${params.givenName ?? ""} ${params.familyName ?? ""}`.trim();
|
|
167
|
-
const publicProfile = {
|
|
168
|
-
"@context": "https://schema.org",
|
|
169
|
-
"@type": "Person",
|
|
170
|
-
name: name.length > 0 ? name : undefined
|
|
171
|
-
};
|
|
172
|
-
const privateProfile = {
|
|
173
|
-
"@context": "https://schema.org",
|
|
174
|
-
"@type": "Person",
|
|
175
|
-
givenName: params.givenName,
|
|
176
|
-
familyName: params.familyName,
|
|
177
|
-
email: params.email
|
|
178
|
-
};
|
|
179
|
-
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-create.labels.storingProfile"));
|
|
180
|
-
await identityProfileConnector.create(params.userIdentity, publicProfile, privateProfile);
|
|
181
|
-
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-create.labels.userCreated"));
|
|
182
|
-
CLIDisplay.value(I18n.formatMessage("node.cli.commands.user-create.labels.email"), user.email);
|
|
183
|
-
CLIDisplay.value(I18n.formatMessage("node.cli.commands.user-create.labels.password"), user.password);
|
|
184
|
-
CLIDisplay.break();
|
|
185
|
-
json = {
|
|
186
|
-
did: params.userIdentity,
|
|
187
|
-
organizationDid: params.organizationIdentity,
|
|
188
|
-
email: params.email,
|
|
189
|
-
password: user.password,
|
|
190
|
-
scope: params.scope?.split(",").map(s => s.trim()) ?? [],
|
|
191
|
-
givenName: params.givenName ?? "",
|
|
192
|
-
familyName: params.familyName ?? ""
|
|
193
|
-
};
|
|
194
|
-
if (Is.stringValue(params.outputJson)) {
|
|
195
|
-
await CLIUtils.writeJsonFile(params.outputJson, json, false);
|
|
153
|
+
catch { }
|
|
154
|
+
if (!Is.empty(existingUser)) {
|
|
155
|
+
if (params.overwriteMode === "error") {
|
|
156
|
+
throw new GeneralError("userCreate", "userAlreadyExists");
|
|
157
|
+
}
|
|
158
|
+
else if (params.overwriteMode === "skip") {
|
|
159
|
+
createUser = false;
|
|
160
|
+
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-create.labels.skipping"));
|
|
161
|
+
}
|
|
162
|
+
else if (params.overwriteMode === "overwrite") {
|
|
163
|
+
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-create.labels.overwriting"));
|
|
164
|
+
const userToRemove = existingUser;
|
|
165
|
+
await ContextIdStore.run({ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId }, async () => {
|
|
166
|
+
await authenticationAdminComponent.remove(userToRemove.email);
|
|
167
|
+
});
|
|
168
|
+
await identityProfileConnector.remove(userToRemove.userIdentity);
|
|
169
|
+
existingUser = undefined;
|
|
170
|
+
}
|
|
196
171
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
172
|
+
let json;
|
|
173
|
+
if (createUser) {
|
|
174
|
+
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-create.labels.creating"));
|
|
175
|
+
const user = {
|
|
176
|
+
email: paramsEmail,
|
|
177
|
+
password: params.password ?? PasswordGenerator.generate(16),
|
|
178
|
+
userIdentity: paramsUserIdentity,
|
|
179
|
+
organizationIdentity: paramsOrganizationIdentity,
|
|
180
|
+
scope: params.scope?.split(",").map(s => s.trim()) ?? []
|
|
181
|
+
};
|
|
182
|
+
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-create.labels.storingUser"));
|
|
183
|
+
await ContextIdStore.run({ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId }, async () => {
|
|
184
|
+
if (existingUser) {
|
|
185
|
+
await authenticationAdminComponent.update(user);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
await authenticationAdminComponent.create(user);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
const name = `${params.givenName ?? ""} ${params.familyName ?? ""}`.trim();
|
|
192
|
+
const publicProfile = {
|
|
193
|
+
"@context": "https://schema.org",
|
|
194
|
+
"@type": "Person",
|
|
195
|
+
name: name.length > 0 ? name : undefined
|
|
196
|
+
};
|
|
197
|
+
const privateProfile = {
|
|
198
|
+
"@context": "https://schema.org",
|
|
199
|
+
"@type": "Person",
|
|
200
|
+
givenName: params.givenName,
|
|
201
|
+
familyName: params.familyName,
|
|
202
|
+
email: paramsEmail
|
|
203
|
+
};
|
|
204
|
+
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-create.labels.storingProfile"));
|
|
205
|
+
await identityProfileConnector.create(paramsUserIdentity, publicProfile, privateProfile);
|
|
206
|
+
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-create.labels.userCreated"));
|
|
207
|
+
CLIDisplay.value(I18n.formatMessage("node.cli.commands.user-create.labels.email"), user.email);
|
|
208
|
+
CLIDisplay.value(I18n.formatMessage("node.cli.commands.user-create.labels.password"), user.password);
|
|
209
|
+
CLIDisplay.break();
|
|
210
|
+
json = {
|
|
211
|
+
did: paramsUserIdentity,
|
|
212
|
+
organizationDid: paramsOrganizationIdentity,
|
|
213
|
+
email: paramsEmail,
|
|
214
|
+
password: user.password,
|
|
215
|
+
scope: params.scope?.split(",").map(s => s.trim()) ?? [],
|
|
216
|
+
givenName: params.givenName ?? "",
|
|
217
|
+
familyName: params.familyName ?? ""
|
|
218
|
+
};
|
|
219
|
+
if (Is.stringValue(params.outputJson)) {
|
|
220
|
+
await CLIUtils.writeJsonFile(params.outputJson, json, false);
|
|
221
|
+
}
|
|
222
|
+
if (Is.stringValue(params.outputEnv)) {
|
|
223
|
+
await CLIUtils.writeEnvFile(params.outputEnv, [
|
|
224
|
+
`${params.outputEnvPrefix}DID="${params.userIdentity}"`,
|
|
225
|
+
`${params.outputEnvPrefix}ORGANIZATION_DID="${params.organizationIdentity}"`,
|
|
226
|
+
`${params.outputEnvPrefix}EMAIL="${paramsEmail}"`,
|
|
227
|
+
`${params.outputEnvPrefix}PASSWORD="${user.password}"`,
|
|
228
|
+
`${params.outputEnvPrefix}SCOPE="${params.scope ?? ""}"`,
|
|
229
|
+
`${params.outputEnvPrefix}GIVEN_NAME="${params.givenName ?? ""}"`,
|
|
230
|
+
`${params.outputEnvPrefix}FAMILY_NAME="${params.familyName ?? ""}"`
|
|
231
|
+
], false);
|
|
232
|
+
}
|
|
207
233
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
234
|
+
CLIDisplay.done();
|
|
235
|
+
return json;
|
|
236
|
+
});
|
|
237
|
+
return returnJson;
|
|
211
238
|
}
|
|
212
239
|
//# sourceMappingURL=userCreate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userCreate.js","sourceRoot":"","sources":["../../../src/commands/userCreate.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,GAAG,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAKjF,MAAM,YAAY,GAAG,aAAa,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,kBAE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,IAAI,EAAE,CAAC,IAAI,EAAE;YACxD,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;YACjC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,EAAE;SACnC,CAAC;QAEF,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YACvC,MAAM,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACtC,MAAM,QAAQ,CAAC,YAAY,CAC1B,MAAM,CAAC,SAAS,EAChB;gBACC,GAAG,MAAM,CAAC,eAAe,QAAQ,MAAM,CAAC,YAAY,GAAG;gBACvD,GAAG,MAAM,CAAC,eAAe,qBAAqB,MAAM,CAAC,oBAAoB,GAAG;gBAC5E,GAAG,MAAM,CAAC,eAAe,UAAU,MAAM,CAAC,KAAK,GAAG;gBAClD,GAAG,MAAM,CAAC,eAAe,aAAa,IAAI,CAAC,QAAQ,GAAG;gBACtD,GAAG,MAAM,CAAC,eAAe,UAAU,MAAM,CAAC,KAAK,IAAI,EAAE,GAAG;gBACxD,GAAG,MAAM,CAAC,eAAe,eAAe,MAAM,CAAC,SAAS,IAAI,EAAE,GAAG;gBACjE,GAAG,MAAM,CAAC,eAAe,gBAAgB,MAAM,CAAC,UAAU,IAAI,EAAE,GAAG;aACnE,EACD,KAAK,CACL,CAAC;QACH,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 type {\n\tIAuthenticationAdminComponent,\n\tIAuthenticationUser\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { ComponentFactory, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport { PasswordGenerator } from \"@twin.org/crypto\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did, IdentityProfileConnectorFactory } from \"@twin.org/identity-models\";\nimport type { Person, WithContext } from \"schema-dts\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"user-create\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionUserCreate(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.user-create.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.user-create.example\"),\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.env-prefix.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: \"user-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.user-identity.description\"\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"organization-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.organization-identity.description\"\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"email\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"email\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-create.params.email.description\")\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"password\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.password.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: \"scope\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-create.params.scope.description\"),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"given-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.given-name.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: \"family-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.family-name.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.user-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.user-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.user-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.user-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.user-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) => userCreate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating a user.\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.userIdentity The DID for the user.\n * @param params.organizationIdentity The organization DID for the user.\n * @param params.email The email for the user.\n * @param params.password The password for the user.\n * @param params.scope The scope for the user.\n * @param params.givenName The given name for the user.\n * @param params.familyName The family name for the user.\n * @param params.overwriteMode The mode to use when a user with the same identity 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 user details or undefined if skipped.\n */\nexport async function userCreate(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tuserIdentity?: string;\n\t\torganizationIdentity?: string;\n\t\temail?: string;\n\t\tpassword?: string;\n\t\tscope?: string;\n\t\tgivenName?: string;\n\t\tfamilyName?: 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\tdid: string;\n\t\t\torganizationDid: string;\n\t\t\temail: string;\n\t\t\tpassword: string;\n\t\t\tscope: string[];\n\t\t\tgivenName: string;\n\t\t\tfamilyName: string;\n\t }\n\t| undefined\n> {\n\tGuards.email(\"userCreate\", \"email\", params.email);\n\tDid.guard(\"userCreate\", \"user-identity\", params.userIdentity);\n\tDid.guard(\"userCreate\", \"organization-identity\", params.organizationIdentity);\n\n\tif (Is.stringValue(params.password) && params.password.length < 16) {\n\t\tthrow new GeneralError(\"userCreate\", \"passwordTooShort\", { minLength: 16 });\n\t}\n\n\tconst defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityProfileConnector\"\n\t);\n\tconst identityProfileConnector = IdentityProfileConnectorFactory.get(\n\t\tdefaultIdentityProfileConnectorType\n\t);\n\n\tconst defaultAuthenticationAdminComponentType = engineCore.getRegisteredInstanceType(\n\t\t\"authenticationAdminComponent\"\n\t);\n\tconst authenticationAdminComponent = ComponentFactory.get<IAuthenticationAdminComponent>(\n\t\tdefaultAuthenticationAdminComponentType\n\t);\n\n\tlet createUser = true;\n\n\tlet existingUser;\n\ttry {\n\t\texistingUser = await authenticationAdminComponent.get(params.email);\n\t} catch {}\n\n\tif (!Is.empty(existingUser)) {\n\t\tif (params.overwriteMode === \"error\") {\n\t\t\tthrow new GeneralError(\"userCreate\", \"userAlreadyExists\");\n\t\t} else if (params.overwriteMode === \"skip\") {\n\t\t\tcreateUser = false;\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.skipping\"));\n\t\t} else if (params.overwriteMode === \"overwrite\") {\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.overwriting\"));\n\t\t\tawait authenticationAdminComponent.remove(existingUser.email);\n\t\t\tawait identityProfileConnector.remove(existingUser.userIdentity);\n\t\t}\n\t}\n\n\tlet json;\n\tif (createUser) {\n\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.creating\"));\n\n\t\tconst user: Omit<IAuthenticationUser, \"salt\"> = {\n\t\t\temail: params.email,\n\t\t\tpassword: params.password ?? PasswordGenerator.generate(16),\n\t\t\tuserIdentity: params.userIdentity,\n\t\t\torganizationIdentity: params.organizationIdentity,\n\t\t\tscope: params.scope?.split(\",\").map(s => s.trim()) ?? []\n\t\t};\n\n\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.storingUser\"));\n\n\t\tif (existingUser) {\n\t\t\tawait authenticationAdminComponent.update(user);\n\t\t} else {\n\t\t\tawait authenticationAdminComponent.create(user);\n\t\t}\n\n\t\tconst name = `${params.givenName ?? \"\"} ${params.familyName ?? \"\"}`.trim();\n\t\tconst publicProfile: WithContext<Person> = {\n\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\"@type\": \"Person\",\n\t\t\tname: name.length > 0 ? name : undefined\n\t\t};\n\t\tconst privateProfile: WithContext<Person> = {\n\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\"@type\": \"Person\",\n\t\t\tgivenName: params.givenName,\n\t\t\tfamilyName: params.familyName,\n\t\t\temail: params.email\n\t\t};\n\n\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.storingProfile\"));\n\t\tawait identityProfileConnector.create(params.userIdentity, publicProfile, privateProfile);\n\n\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.userCreated\"));\n\n\t\tCLIDisplay.value(I18n.formatMessage(\"node.cli.commands.user-create.labels.email\"), user.email);\n\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"node.cli.commands.user-create.labels.password\"),\n\t\t\tuser.password\n\t\t);\n\n\t\tCLIDisplay.break();\n\n\t\tjson = {\n\t\t\tdid: params.userIdentity,\n\t\t\torganizationDid: params.organizationIdentity,\n\t\t\temail: params.email,\n\t\t\tpassword: user.password,\n\t\t\tscope: params.scope?.split(\",\").map(s => s.trim()) ?? [],\n\t\t\tgivenName: params.givenName ?? \"\",\n\t\t\tfamilyName: params.familyName ?? \"\"\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\tawait CLIUtils.writeEnvFile(\n\t\t\t\tparams.outputEnv,\n\t\t\t\t[\n\t\t\t\t\t`${params.outputEnvPrefix}DID=\"${params.userIdentity}\"`,\n\t\t\t\t\t`${params.outputEnvPrefix}ORGANIZATION_DID=\"${params.organizationIdentity}\"`,\n\t\t\t\t\t`${params.outputEnvPrefix}EMAIL=\"${params.email}\"`,\n\t\t\t\t\t`${params.outputEnvPrefix}PASSWORD=\"${user.password}\"`,\n\t\t\t\t\t`${params.outputEnvPrefix}SCOPE=\"${params.scope ?? \"\"}\"`,\n\t\t\t\t\t`${params.outputEnvPrefix}GIVEN_NAME=\"${params.givenName ?? \"\"}\"`,\n\t\t\t\t\t`${params.outputEnvPrefix}FAMILY_NAME=\"${params.familyName ?? \"\"}\"`\n\t\t\t\t],\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\t}\n\n\tCLIDisplay.done();\n\n\treturn json;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"userCreate.js","sourceRoot":"","sources":["../../../src/commands/userCreate.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,GAAG,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAKjF,MAAM,YAAY,GAAG,aAAa,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,kBAE9C;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAA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AAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;gBACvC,MAAM,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;YAC9D,CAAC;YAED,IAAI,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;gBACtC,MAAM,QAAQ,CAAC,YAAY,CAC1B,MAAM,CAAC,SAAS,EAChB;oBACC,GAAG,MAAM,CAAC,eAAe,QAAQ,MAAM,CAAC,YAAY,GAAG;oBACvD,GAAG,MAAM,CAAC,eAAe,qBAAqB,MAAM,CAAC,oBAAoB,GAAG;oBAC5E,GAAG,MAAM,CAAC,eAAe,UAAU,WAAW,GAAG;oBACjD,GAAG,MAAM,CAAC,eAAe,aAAa,IAAI,CAAC,QAAQ,GAAG;oBACtD,GAAG,MAAM,CAAC,eAAe,UAAU,MAAM,CAAC,KAAK,IAAI,EAAE,GAAG;oBACxD,GAAG,MAAM,CAAC,eAAe,eAAe,MAAM,CAAC,SAAS,IAAI,EAAE,GAAG;oBACjE,GAAG,MAAM,CAAC,eAAe,gBAAgB,MAAM,CAAC,UAAU,IAAI,EAAE,GAAG;iBACnE,EACD,KAAK,CACL,CAAC;YACH,CAAC;QACF,CAAC;QAED,UAAU,CAAC,IAAI,EAAE,CAAC;QAElB,OAAO,IAAI,CAAC;IACb,CAAC,CACD,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuthenticationAdminComponent,\n\tIAuthenticationUser\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { ComponentFactory, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport { PasswordGenerator } from \"@twin.org/crypto\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did, IdentityProfileConnectorFactory } from \"@twin.org/identity-models\";\nimport type { Person, WithContext } from \"schema-dts\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"user-create\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionUserCreate(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.user-create.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.user-create.example\"),\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.env-prefix.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: \"user-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.user-identity.description\"\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"organization-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.organization-identity.description\"\n\t\t\t\t)\n\t\t\t},\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.user-create.params.tenant-id.description\"\n\t\t\t\t)\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"email\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"email\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-create.params.email.description\")\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"password\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.password.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: \"scope\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-create.params.scope.description\"),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"given-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.given-name.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: \"family-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-create.params.family-name.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.user-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.user-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.user-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.user-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.user-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) => userCreate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating a user.\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.userIdentity The DID for the user.\n * @param params.organizationIdentity The organization DID for the user.\n * @param params.tenantId The tenant ID for the user.\n * @param params.email The email for the user.\n * @param params.password The password for the user.\n * @param params.scope The scope for the user.\n * @param params.givenName The given name for the user.\n * @param params.familyName The family name for the user.\n * @param params.overwriteMode The mode to use when a user with the same identity 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 user details or undefined if skipped.\n */\nexport async function userCreate(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tuserIdentity?: string;\n\t\torganizationIdentity?: string;\n\t\ttenantId?: string;\n\t\temail?: string;\n\t\tpassword?: string;\n\t\tscope?: string;\n\t\tgivenName?: string;\n\t\tfamilyName?: 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\tdid: string;\n\t\t\torganizationDid: string;\n\t\t\temail: string;\n\t\t\tpassword: string;\n\t\t\tscope: string[];\n\t\t\tgivenName: string;\n\t\t\tfamilyName: string;\n\t }\n\t| undefined\n> {\n\tconst paramsEmail = params.email;\n\tconst paramsUserIdentity = params.userIdentity;\n\tconst paramsOrganizationIdentity = params.organizationIdentity;\n\tGuards.email(\"userCreate\", \"email\", paramsEmail);\n\tDid.guard(\"userCreate\", \"user-identity\", paramsUserIdentity);\n\tDid.guard(\"userCreate\", \"organization-identity\", paramsOrganizationIdentity);\n\tif (Is.stringValue(params.tenantId)) {\n\t\tGuards.stringHexLength(\"userCreate\", \"tenant-id\", params.tenantId, 32);\n\t} else if (envVars.tenantEnabled ?? false) {\n\t\tthrow new GeneralError(\"userCreate\", \"tenantIdRequired\");\n\t}\n\n\tif (Is.stringValue(params.password) && params.password.length < 16) {\n\t\tthrow new GeneralError(\"userCreate\", \"passwordTooShort\", { minLength: 16 });\n\t}\n\n\tconst defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityProfileConnector\"\n\t);\n\tconst identityProfileConnector = IdentityProfileConnectorFactory.get(\n\t\tdefaultIdentityProfileConnectorType\n\t);\n\n\tconst defaultAuthenticationAdminComponentType = engineCore.getRegisteredInstanceType(\n\t\t\"authenticationAdminComponent\"\n\t);\n\tconst authenticationAdminComponent = ComponentFactory.get<IAuthenticationAdminComponent>(\n\t\tdefaultAuthenticationAdminComponentType\n\t);\n\n\tlet createUser = true;\n\n\tconst currentContextIds = (await ContextIdStore.getContextIds()) ?? {};\n\tconst returnJson = await ContextIdStore.run(\n\t\t{ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId },\n\t\tasync () => {\n\t\t\tlet existingUser: IAuthenticationUser | undefined;\n\t\t\ttry {\n\t\t\t\texistingUser = await authenticationAdminComponent.get(paramsEmail);\n\t\t\t} catch {}\n\n\t\t\tif (!Is.empty(existingUser)) {\n\t\t\t\tif (params.overwriteMode === \"error\") {\n\t\t\t\t\tthrow new GeneralError(\"userCreate\", \"userAlreadyExists\");\n\t\t\t\t} else if (params.overwriteMode === \"skip\") {\n\t\t\t\t\tcreateUser = false;\n\t\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.skipping\"));\n\t\t\t\t} else if (params.overwriteMode === \"overwrite\") {\n\t\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.overwriting\"));\n\t\t\t\t\tconst userToRemove = existingUser;\n\t\t\t\t\tawait ContextIdStore.run(\n\t\t\t\t\t\t{ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId },\n\t\t\t\t\t\tasync () => {\n\t\t\t\t\t\t\tawait authenticationAdminComponent.remove(userToRemove.email);\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tawait identityProfileConnector.remove(userToRemove.userIdentity);\n\t\t\t\t\texistingUser = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet json;\n\t\t\tif (createUser) {\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.creating\"));\n\n\t\t\t\tconst user: IAuthenticationUser & { password: string } = {\n\t\t\t\t\temail: paramsEmail,\n\t\t\t\t\tpassword: params.password ?? PasswordGenerator.generate(16),\n\t\t\t\t\tuserIdentity: paramsUserIdentity,\n\t\t\t\t\torganizationIdentity: paramsOrganizationIdentity,\n\t\t\t\t\tscope: params.scope?.split(\",\").map(s => s.trim()) ?? []\n\t\t\t\t};\n\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.storingUser\"));\n\n\t\t\t\tawait ContextIdStore.run(\n\t\t\t\t\t{ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId },\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tif (existingUser) {\n\t\t\t\t\t\t\tawait authenticationAdminComponent.update(user);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tawait authenticationAdminComponent.create(user);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\tconst name = `${params.givenName ?? \"\"} ${params.familyName ?? \"\"}`.trim();\n\t\t\t\tconst publicProfile: WithContext<Person> = {\n\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\tname: name.length > 0 ? name : undefined\n\t\t\t\t};\n\t\t\t\tconst privateProfile: WithContext<Person> = {\n\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\tgivenName: params.givenName,\n\t\t\t\t\tfamilyName: params.familyName,\n\t\t\t\t\temail: paramsEmail\n\t\t\t\t};\n\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.storingProfile\"));\n\t\t\t\tawait identityProfileConnector.create(paramsUserIdentity, publicProfile, privateProfile);\n\n\t\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-create.labels.userCreated\"));\n\n\t\t\t\tCLIDisplay.value(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.user-create.labels.email\"),\n\t\t\t\t\tuser.email\n\t\t\t\t);\n\n\t\t\t\tCLIDisplay.value(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.user-create.labels.password\"),\n\t\t\t\t\tuser.password\n\t\t\t\t);\n\n\t\t\t\tCLIDisplay.break();\n\n\t\t\t\tjson = {\n\t\t\t\t\tdid: paramsUserIdentity,\n\t\t\t\t\torganizationDid: paramsOrganizationIdentity,\n\t\t\t\t\temail: paramsEmail,\n\t\t\t\t\tpassword: user.password,\n\t\t\t\t\tscope: params.scope?.split(\",\").map(s => s.trim()) ?? [],\n\t\t\t\t\tgivenName: params.givenName ?? \"\",\n\t\t\t\t\tfamilyName: params.familyName ?? \"\"\n\t\t\t\t};\n\n\t\t\t\tif (Is.stringValue(params.outputJson)) {\n\t\t\t\t\tawait CLIUtils.writeJsonFile(params.outputJson, json, false);\n\t\t\t\t}\n\n\t\t\t\tif (Is.stringValue(params.outputEnv)) {\n\t\t\t\t\tawait CLIUtils.writeEnvFile(\n\t\t\t\t\t\tparams.outputEnv,\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}DID=\"${params.userIdentity}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}ORGANIZATION_DID=\"${params.organizationIdentity}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}EMAIL=\"${paramsEmail}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}PASSWORD=\"${user.password}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}SCOPE=\"${params.scope ?? \"\"}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}GIVEN_NAME=\"${params.givenName ?? \"\"}\"`,\n\t\t\t\t\t\t\t`${params.outputEnvPrefix}FAMILY_NAME=\"${params.familyName ?? \"\"}\"`\n\t\t\t\t\t\t],\n\t\t\t\t\t\tfalse\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tCLIDisplay.done();\n\n\t\t\treturn json;\n\t\t}\n\t);\n\n\treturn returnJson;\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CLIDisplay } from "@twin.org/cli-core";
|
|
2
|
-
import {
|
|
2
|
+
import { ContextIdKeys, ContextIdStore } from "@twin.org/context";
|
|
3
|
+
import { ComponentFactory, GeneralError, Guards, I18n, Is } from "@twin.org/core";
|
|
3
4
|
import { Did, IdentityProfileConnectorFactory } from "@twin.org/identity-models";
|
|
4
5
|
const COMMAND_NAME = "user-update";
|
|
5
6
|
/**
|
|
@@ -32,6 +33,13 @@ export function getCommandDefinitionUserUpdate(commandDefinitions) {
|
|
|
32
33
|
description: I18n.formatMessage("node.cli.commands.user-update.params.organization-identity.description"),
|
|
33
34
|
required: false
|
|
34
35
|
},
|
|
36
|
+
{
|
|
37
|
+
key: "tenant-id",
|
|
38
|
+
type: "string",
|
|
39
|
+
extendedType: "hex(32)",
|
|
40
|
+
description: I18n.formatMessage("node.cli.commands.user-update.params.tenant-id.description"),
|
|
41
|
+
required: false
|
|
42
|
+
},
|
|
35
43
|
{
|
|
36
44
|
key: "email",
|
|
37
45
|
type: "string",
|
|
@@ -67,12 +75,13 @@ export function getCommandDefinitionUserUpdate(commandDefinitions) {
|
|
|
67
75
|
};
|
|
68
76
|
}
|
|
69
77
|
/**
|
|
70
|
-
* Command for
|
|
78
|
+
* Command for updating a user.
|
|
71
79
|
* @param engineCore The engine core.
|
|
72
80
|
* @param envVars The environment variables for the node.
|
|
73
81
|
* @param params The parameters for the command.
|
|
74
82
|
* @param params.userIdentity The DID for the user.
|
|
75
83
|
* @param params.organizationIdentity The organization DID for the user.
|
|
84
|
+
* @param params.tenantId The tenant ID for the user.
|
|
76
85
|
* @param params.email The email for the user.
|
|
77
86
|
* @param params.scope The scope for the user.
|
|
78
87
|
* @param params.givenName The given name for the user.
|
|
@@ -80,53 +89,66 @@ export function getCommandDefinitionUserUpdate(commandDefinitions) {
|
|
|
80
89
|
* @returns The updated user details or undefined if skipped.
|
|
81
90
|
*/
|
|
82
91
|
export async function userUpdate(engineCore, envVars, params) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
const paramsEmail = params.email;
|
|
93
|
+
const paramsUserIdentity = params.userIdentity;
|
|
94
|
+
const paramsOrganizationIdentity = params.organizationIdentity;
|
|
95
|
+
Guards.email("userUpdate", "email", paramsEmail);
|
|
96
|
+
if (Is.stringValue(paramsUserIdentity)) {
|
|
97
|
+
Did.guard("userUpdate", "user-identity", paramsUserIdentity);
|
|
98
|
+
}
|
|
99
|
+
if (Is.stringValue(paramsOrganizationIdentity)) {
|
|
100
|
+
Did.guard("userUpdate", "organization-identity", paramsOrganizationIdentity);
|
|
86
101
|
}
|
|
87
|
-
if (Is.stringValue(params.
|
|
88
|
-
|
|
102
|
+
if (Is.stringValue(params.tenantId)) {
|
|
103
|
+
Guards.stringHexLength("userUpdate", "tenant-id", params.tenantId, 32);
|
|
104
|
+
}
|
|
105
|
+
else if (envVars.tenantEnabled ?? false) {
|
|
106
|
+
throw new GeneralError("userUpdate", "tenantIdRequired");
|
|
89
107
|
}
|
|
90
108
|
const defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType("identityProfileConnector");
|
|
91
109
|
const identityProfileConnector = IdentityProfileConnectorFactory.get(defaultIdentityProfileConnectorType);
|
|
92
110
|
const defaultAuthenticationAdminComponentType = engineCore.getRegisteredInstanceType("authenticationAdminComponent");
|
|
93
111
|
const authenticationAdminComponent = ComponentFactory.get(defaultAuthenticationAdminComponentType);
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
112
|
+
const currentContextIds = (await ContextIdStore.getContextIds()) ?? {};
|
|
113
|
+
const returnJson = await ContextIdStore.run({ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId }, async () => {
|
|
114
|
+
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-update.labels.updating"));
|
|
115
|
+
const user = {
|
|
116
|
+
email: paramsEmail,
|
|
117
|
+
userIdentity: paramsUserIdentity,
|
|
118
|
+
organizationIdentity: paramsOrganizationIdentity,
|
|
119
|
+
scope: params.scope?.split(",").map(s => s.trim())
|
|
120
|
+
};
|
|
121
|
+
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-update.labels.storingUser"));
|
|
122
|
+
const existingUser = await authenticationAdminComponent.get(paramsEmail);
|
|
123
|
+
await authenticationAdminComponent.update(user);
|
|
124
|
+
const name = `${params.givenName ?? ""} ${params.familyName ?? ""}`.trim();
|
|
125
|
+
const publicProfile = {
|
|
126
|
+
"@context": "https://schema.org",
|
|
127
|
+
"@type": "Person",
|
|
128
|
+
name: name.length > 0 ? name : undefined
|
|
129
|
+
};
|
|
130
|
+
const privateProfile = {
|
|
131
|
+
"@context": "https://schema.org",
|
|
132
|
+
"@type": "Person",
|
|
133
|
+
givenName: params.givenName,
|
|
134
|
+
familyName: params.familyName,
|
|
135
|
+
email: paramsEmail
|
|
136
|
+
};
|
|
137
|
+
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-update.labels.storingProfile"));
|
|
138
|
+
await identityProfileConnector.update(existingUser.userIdentity, publicProfile, privateProfile);
|
|
139
|
+
CLIDisplay.task(I18n.formatMessage("node.cli.commands.user-update.labels.userUpdated"));
|
|
140
|
+
CLIDisplay.break();
|
|
141
|
+
const json = {
|
|
142
|
+
did: params.userIdentity ?? existingUser.userIdentity,
|
|
143
|
+
organizationDid: params.organizationIdentity ?? existingUser.organizationIdentity,
|
|
144
|
+
email: paramsEmail,
|
|
145
|
+
scope: params.scope?.split(",").map(s => s.trim()) ?? existingUser.scope,
|
|
146
|
+
givenName: params.givenName ?? "",
|
|
147
|
+
familyName: params.familyName ?? ""
|
|
148
|
+
};
|
|
149
|
+
CLIDisplay.done();
|
|
150
|
+
return json;
|
|
151
|
+
});
|
|
152
|
+
return returnJson;
|
|
131
153
|
}
|
|
132
154
|
//# sourceMappingURL=userUpdate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userUpdate.js","sourceRoot":"","sources":["../../../src/commands/userUpdate.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UA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,CAAC,UAAU;QAC7B,KAAK,EAAE,MAAM,CAAC,KAAK;KACnB,CAAC;IAEF,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC,CAAC,CAAC;IAC3F,MAAM,wBAAwB,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;IAEhG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,kDAAkD,CAAC,CAAC,CAAC;IAExF,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,MAAM,IAAI,GAAG;QACZ,GAAG,EAAE,MAAM,CAAC,YAAY,IAAI,YAAY,CAAC,YAAY;QACrD,eAAe,EAAE,MAAM,CAAC,oBAAoB,IAAI,YAAY,CAAC,oBAAoB;QACjF,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,YAAY,CAAC,KAAK;QACxE,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,EAAE;KACnC,CAAC;IAEF,UAAU,CAAC,IAAI,EAAE,CAAC;IAElB,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuthenticationAdminComponent,\n\tIAuthenticationUser\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { ComponentFactory, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did, IdentityProfileConnectorFactory } from \"@twin.org/identity-models\";\nimport type { Person, WithContext } from \"schema-dts\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"user-update\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionUserUpdate(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.user-update.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.user-update.example\"),\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.params.env-prefix.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: \"user-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.params.user-identity.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: \"organization-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.params.organization-identity.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: \"email\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"email\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-update.params.email.description\")\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"scope\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-update.params.scope.description\"),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"given-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.params.given-name.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: \"family-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.params.family-name.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: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.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) => userUpdate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for creating a user.\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.userIdentity The DID for the user.\n * @param params.organizationIdentity The organization DID for the user.\n * @param params.email The email for the user.\n * @param params.scope The scope for the user.\n * @param params.givenName The given name for the user.\n * @param params.familyName The family name for the user.\n * @returns The updated user details or undefined if skipped.\n */\nexport async function userUpdate(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tuserIdentity?: string;\n\t\torganizationIdentity?: string;\n\t\temail?: string;\n\t\tscope?: string;\n\t\tgivenName?: string;\n\t\tfamilyName?: string;\n\t}\n): Promise<\n\t| {\n\t\t\tdid: string;\n\t\t\torganizationDid: string;\n\t\t\temail: string;\n\t\t\tscope: string[];\n\t\t\tgivenName: string;\n\t\t\tfamilyName: string;\n\t }\n\t| undefined\n> {\n\tGuards.email(\"userUpdate\", \"email\", params.email);\n\n\tif (Is.stringValue(params.userIdentity)) {\n\t\tDid.guard(\"userUpdate\", \"user-identity\", params.userIdentity);\n\t}\n\tif (Is.stringValue(params.organizationIdentity)) {\n\t\tDid.guard(\"userUpdate\", \"organization-identity\", params.organizationIdentity);\n\t}\n\n\tconst defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityProfileConnector\"\n\t);\n\tconst identityProfileConnector = IdentityProfileConnectorFactory.get(\n\t\tdefaultIdentityProfileConnectorType\n\t);\n\n\tconst defaultAuthenticationAdminComponentType = engineCore.getRegisteredInstanceType(\n\t\t\"authenticationAdminComponent\"\n\t);\n\tconst authenticationAdminComponent = ComponentFactory.get<IAuthenticationAdminComponent>(\n\t\tdefaultAuthenticationAdminComponentType\n\t);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-update.labels.updating\"));\n\n\tconst user: Partial<Omit<IAuthenticationUser, \"password\" | \"salt\">> = {\n\t\temail: params.email,\n\t\tuserIdentity: params.userIdentity,\n\t\torganizationIdentity: params.organizationIdentity,\n\t\tscope: params.scope?.split(\",\").map(s => s.trim())\n\t};\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-update.labels.storingUser\"));\n\n\tconst existingUser = await authenticationAdminComponent.get(params.email);\n\n\tawait authenticationAdminComponent.update(user);\n\n\tconst name = `${params.givenName ?? \"\"} ${params.familyName ?? \"\"}`.trim();\n\tconst publicProfile: WithContext<Person> = {\n\t\t\"@context\": \"https://schema.org\",\n\t\t\"@type\": \"Person\",\n\t\tname: name.length > 0 ? name : undefined\n\t};\n\tconst privateProfile: WithContext<Person> = {\n\t\t\"@context\": \"https://schema.org\",\n\t\t\"@type\": \"Person\",\n\t\tgivenName: params.givenName,\n\t\tfamilyName: params.familyName,\n\t\temail: params.email\n\t};\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-update.labels.storingProfile\"));\n\tawait identityProfileConnector.update(existingUser.userIdentity, publicProfile, privateProfile);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-update.labels.userUpdated\"));\n\n\tCLIDisplay.break();\n\n\tconst json = {\n\t\tdid: params.userIdentity ?? existingUser.userIdentity,\n\t\torganizationDid: params.organizationIdentity ?? existingUser.organizationIdentity,\n\t\temail: params.email,\n\t\tscope: params.scope?.split(\",\").map(s => s.trim()) ?? existingUser.scope,\n\t\tgivenName: params.givenName ?? \"\",\n\t\tfamilyName: params.familyName ?? \"\"\n\t};\n\n\tCLIDisplay.done();\n\n\treturn json;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"userUpdate.js","sourceRoot":"","sources":["../../../src/commands/userUpdate.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAElF,OAAO,EAAE,GAAG,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAKjF,MAAM,YAAY,GAAG,aAAa,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,kBAE9C;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,2CAA2C,CAAC;QAC5E,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,uCAAuC,CAAC;QACpE,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,YAAY;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,6DAA6D,CAC7D;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,eAAe;gBACpB,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,KAAK;gBACnB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,gEAAgE,CAChE;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,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B,KAAK,EAAE,WAAW;SAClB,CAAC;QAEF,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC,CAAC,CAAC;QAC3F,MAAM,wBAAwB,CAAC,MAAM,CACpC,YAAY,CAAC,YAAY,EACzB,aAAa,EACb,cAAc,CACd,CAAC;QAEF,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,kDAAkD,CAAC,CAAC,CAAC;QAExF,UAAU,CAAC,KAAK,EAAE,CAAC;QAEnB,MAAM,IAAI,GAAG;YACZ,GAAG,EAAE,MAAM,CAAC,YAAY,IAAI,YAAY,CAAC,YAAY;YACrD,eAAe,EAAE,MAAM,CAAC,oBAAoB,IAAI,YAAY,CAAC,oBAAoB;YACjF,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,YAAY,CAAC,KAAK;YACxE,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE;YACjC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,EAAE;SACnC,CAAC;QAEF,UAAU,CAAC,IAAI,EAAE,CAAC;QAElB,OAAO,IAAI,CAAC;IACb,CAAC,CACD,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIAuthenticationAdminComponent,\n\tIAuthenticationUser\n} from \"@twin.org/api-auth-entity-storage-models\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { ComponentFactory, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did, IdentityProfileConnectorFactory } from \"@twin.org/identity-models\";\nimport type { Person, WithContext } from \"schema-dts\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"user-update\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionUserUpdate(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.user-update.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.user-update.example\"),\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.params.env-prefix.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: \"user-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.params.user-identity.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: \"organization-identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"DID\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.params.organization-identity.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: \"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.user-update.params.tenant-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: \"email\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"email\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-update.params.email.description\")\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"scope\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\"node.cli.commands.user-update.params.scope.description\"),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"given-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.params.given-name.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: \"family-name\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.params.family-name.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: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.user-update.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) => userUpdate(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for updating a user.\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.userIdentity The DID for the user.\n * @param params.organizationIdentity The organization DID for the user.\n * @param params.tenantId The tenant ID for the user.\n * @param params.email The email for the user.\n * @param params.scope The scope for the user.\n * @param params.givenName The given name for the user.\n * @param params.familyName The family name for the user.\n * @returns The updated user details or undefined if skipped.\n */\nexport async function userUpdate(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: {\n\t\tuserIdentity?: string;\n\t\torganizationIdentity?: string;\n\t\ttenantId?: string;\n\t\temail?: string;\n\t\tscope?: string;\n\t\tgivenName?: string;\n\t\tfamilyName?: string;\n\t}\n): Promise<\n\t| {\n\t\t\tdid: string;\n\t\t\torganizationDid: string;\n\t\t\temail: string;\n\t\t\tscope: string[];\n\t\t\tgivenName: string;\n\t\t\tfamilyName: string;\n\t }\n\t| undefined\n> {\n\tconst paramsEmail = params.email;\n\tconst paramsUserIdentity = params.userIdentity;\n\tconst paramsOrganizationIdentity = params.organizationIdentity;\n\n\tGuards.email(\"userUpdate\", \"email\", paramsEmail);\n\tif (Is.stringValue(paramsUserIdentity)) {\n\t\tDid.guard(\"userUpdate\", \"user-identity\", paramsUserIdentity);\n\t}\n\tif (Is.stringValue(paramsOrganizationIdentity)) {\n\t\tDid.guard(\"userUpdate\", \"organization-identity\", paramsOrganizationIdentity);\n\t}\n\tif (Is.stringValue(params.tenantId)) {\n\t\tGuards.stringHexLength(\"userUpdate\", \"tenant-id\", params.tenantId, 32);\n\t} else if (envVars.tenantEnabled ?? false) {\n\t\tthrow new GeneralError(\"userUpdate\", \"tenantIdRequired\");\n\t}\n\n\tconst defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityProfileConnector\"\n\t);\n\tconst identityProfileConnector = IdentityProfileConnectorFactory.get(\n\t\tdefaultIdentityProfileConnectorType\n\t);\n\n\tconst defaultAuthenticationAdminComponentType = engineCore.getRegisteredInstanceType(\n\t\t\"authenticationAdminComponent\"\n\t);\n\tconst authenticationAdminComponent = ComponentFactory.get<IAuthenticationAdminComponent>(\n\t\tdefaultAuthenticationAdminComponentType\n\t);\n\n\tconst currentContextIds = (await ContextIdStore.getContextIds()) ?? {};\n\tconst returnJson = await ContextIdStore.run(\n\t\t{ ...currentContextIds, [ContextIdKeys.Tenant]: params.tenantId },\n\t\tasync () => {\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-update.labels.updating\"));\n\n\t\t\tconst user: Partial<IAuthenticationUser> = {\n\t\t\t\temail: paramsEmail,\n\t\t\t\tuserIdentity: paramsUserIdentity,\n\t\t\t\torganizationIdentity: paramsOrganizationIdentity,\n\t\t\t\tscope: params.scope?.split(\",\").map(s => s.trim())\n\t\t\t};\n\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-update.labels.storingUser\"));\n\n\t\t\tconst existingUser = await authenticationAdminComponent.get(paramsEmail);\n\t\t\tawait authenticationAdminComponent.update(user);\n\n\t\t\tconst name = `${params.givenName ?? \"\"} ${params.familyName ?? \"\"}`.trim();\n\t\t\tconst publicProfile: WithContext<Person> = {\n\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\"@type\": \"Person\",\n\t\t\t\tname: name.length > 0 ? name : undefined\n\t\t\t};\n\t\t\tconst privateProfile: WithContext<Person> = {\n\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\"@type\": \"Person\",\n\t\t\t\tgivenName: params.givenName,\n\t\t\t\tfamilyName: params.familyName,\n\t\t\t\temail: paramsEmail\n\t\t\t};\n\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-update.labels.storingProfile\"));\n\t\t\tawait identityProfileConnector.update(\n\t\t\t\texistingUser.userIdentity,\n\t\t\t\tpublicProfile,\n\t\t\t\tprivateProfile\n\t\t\t);\n\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.user-update.labels.userUpdated\"));\n\n\t\t\tCLIDisplay.break();\n\n\t\t\tconst json = {\n\t\t\t\tdid: params.userIdentity ?? existingUser.userIdentity,\n\t\t\t\torganizationDid: params.organizationIdentity ?? existingUser.organizationIdentity,\n\t\t\t\temail: paramsEmail,\n\t\t\t\tscope: params.scope?.split(\",\").map(s => s.trim()) ?? existingUser.scope,\n\t\t\t\tgivenName: params.givenName ?? \"\",\n\t\t\t\tfamilyName: params.familyName ?? \"\"\n\t\t\t};\n\n\t\t\tCLIDisplay.done();\n\n\t\t\treturn json;\n\t\t}\n\t);\n\n\treturn returnJson;\n}\n"]}
|
package/dist/es/index.js
CHANGED
|
@@ -20,7 +20,10 @@ export * from "./models/INodeEnvironmentVariables.js";
|
|
|
20
20
|
export * from "./models/INodeOptions.js";
|
|
21
21
|
export * from "./models/IProtocolHandlerResult.js";
|
|
22
22
|
export * from "./models/moduleProtocol.js";
|
|
23
|
-
export * from "./models/
|
|
23
|
+
export * from "./models/nodeExtensionInitialiseEngineMethod.js";
|
|
24
|
+
export * from "./models/nodeExtensionInitialiseEngineServerMethod.js";
|
|
25
|
+
export * from "./models/nodeExtensionInitialiseMethod.js";
|
|
26
|
+
export * from "./models/nodeExtensionShutdownMethod.js";
|
|
24
27
|
export * from "./node.js";
|
|
25
28
|
export * from "./start.js";
|
|
26
29
|
export * from "./utils.js";
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,iCAAiC,CAAC;AAChD,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,cAAc,iCAAiC,CAAC;AAChD,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iDAAiD,CAAC;AAChE,cAAc,uDAAuD,CAAC;AACtE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,yCAAyC,CAAC;AACxD,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./builders/engineEnvBuilder.js\";\nexport * from \"./builders/engineServerEnvBuilder.js\";\nexport * from \"./builders/extensionsBuilder.js\";\nexport * from \"./cli.js\";\nexport * from \"./defaults.js\";\nexport * from \"./models/cliCommandParamType.js\";\nexport * from \"./models/ICacheMetadata.js\";\nexport * from \"./models/ICliArgs.js\";\nexport * from \"./models/ICliCommand.js\";\nexport * from \"./models/ICliCommandDefinition.js\";\nexport * from \"./models/ICliCommandDefinitionParam.js\";\nexport * from \"./models/IEngineEnvironmentVariables.js\";\nexport * from \"./models/IEngineServerEnvironmentVariables.js\";\nexport * from \"./models/IModuleProtocol.js\";\nexport * from \"./models/INodeEngineConfig.js\";\nexport * from \"./models/INodeEngineState.js\";\nexport * from \"./models/INodeEnvironmentVariables.js\";\nexport * from \"./models/INodeOptions.js\";\nexport * from \"./models/IProtocolHandlerResult.js\";\nexport * from \"./models/moduleProtocol.js\";\nexport * from \"./models/nodeExtensionInitialiseEngineMethod.js\";\nexport * from \"./models/nodeExtensionInitialiseEngineServerMethod.js\";\nexport * from \"./models/nodeExtensionInitialiseMethod.js\";\nexport * from \"./models/nodeExtensionShutdownMethod.js\";\nexport * from \"./node.js\";\nexport * from \"./start.js\";\nexport * from \"./utils.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeExtensionInitialiseEngineMethod.js","sourceRoot":"","sources":["../../../src/models/nodeExtensionInitialiseEngineMethod.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEngineCore } from \"@twin.org/engine-models\";\n\n/**\n * The type for the initialise engine method of an extension module.\n * This is called when the engine has been constructed but not yet started.\n * @param engineCore The engine core instance.\n */\nexport type NodeExtensionInitialiseEngineMethod = (engineCore: IEngineCore) => Promise<void>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeExtensionInitialiseEngineServerMethod.js","sourceRoot":"","sources":["../../../src/models/nodeExtensionInitialiseEngineServerMethod.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEngineCore, IEngineServer } from \"@twin.org/engine-models\";\n\n/**\n * The type for the initialise engine server method of an extension module.\n * This is called when the engine server has been constructed but not yet started.\n * @param engineCore The engine core instance.\n * @param engineServer The engine server instance.\n */\nexport type NodeExtensionInitialiseEngineServerMethod = (\n\tengineCore: IEngineCore,\n\tengineServer: IEngineServer\n) => Promise<void>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeExtensionInitialiseMethod.js","sourceRoot":"","sources":["../../../src/models/nodeExtensionInitialiseMethod.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { INodeEngineConfig } from \"./INodeEngineConfig.js\";\nimport type { INodeEnvironmentVariables } from \"./INodeEnvironmentVariables.js\";\n\n/**\n * The type for the initialise method of an extension module.\n * @param envVars The environment variables for the node.\n * @param nodeEngineConfig The node engine config.\n */\nexport type NodeExtensionInitialiseMethod = (\n\tenvVars: INodeEnvironmentVariables,\n\tnodeEngineConfig: INodeEngineConfig\n) => Promise<void>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeExtensionShutdownMethod.js","sourceRoot":"","sources":["../../../src/models/nodeExtensionShutdownMethod.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The type for the shutdown method of an extension module.\n * This is called when the engine is shutting down.\n */\nexport type NodeExtensionShutdownMethod = () => Promise<void>;\n"]}
|
package/dist/es/node.js
CHANGED
|
@@ -28,7 +28,7 @@ export async function run(nodeOptions, args) {
|
|
|
28
28
|
nodeOptions ??= {};
|
|
29
29
|
const serverInfo = {
|
|
30
30
|
name: nodeOptions?.serverName ?? "TWIN Node",
|
|
31
|
-
version: nodeOptions?.serverVersion ?? "0.0.3-next.
|
|
31
|
+
version: nodeOptions?.serverVersion ?? "0.0.3-next.39" // x-release-please-version
|
|
32
32
|
};
|
|
33
33
|
CLIDisplay.header(serverInfo.name, serverInfo.version, "🌩️ ");
|
|
34
34
|
if (!Is.stringValue(nodeOptions?.executionDirectory)) {
|
package/dist/es/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,IAAI,MAAM,W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CAAC,CAAC;oBACvD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC;oBAC5C,IAAI,MAAM,EAAE,CAAC;wBACZ,YAAY,GAAG,UAAU,CAAC;oBAC3B,CAAC;gBACF,CAAC;gBAAC,MAAM,CAAC;oBACR,4CAA4C;gBAC7C,CAAC;gBACD,MAAM;YACP,CAAC;QACF,CAAC;QAED,0CAA0C;QAC1C,IAAI,YAAY,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC,CAAC;YACjE,WAAW,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;YACjC,OAAO;gBACN,MAAM;gBACN,UAAU,EAAE,KAAK;aACjB,CAAC;QACH,CAAC;QAED,OAAO;YACN,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,IAAI;SAChB,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc;IACtB,YAAY,KAAK,QAAQ,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC5E,OAAO,YAAY,CAAC;AACrB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { execSync } from \"node:child_process\";\nimport path from \"node:path\";\nimport type { IServerInfo } from \"@twin.org/api-models\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { BaseError, Coerce, EnvHelper, GeneralError, Is, ObjectHelper } from \"@twin.org/core\";\nimport type { Engine } from \"@twin.org/engine\";\nimport type { EngineServer } from \"@twin.org/engine-server\";\nimport type { IEngineServerConfig } from \"@twin.org/engine-server-types\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport * as dotenv from \"dotenv\";\nimport { buildEngineConfiguration } from \"./builders/engineEnvBuilder.js\";\nimport { buildEngineServerConfiguration } from \"./builders/engineServerEnvBuilder.js\";\nimport { extensionsConfiguration } from \"./builders/extensionsBuilder.js\";\nimport { constructCliCommand, parseCommandLineArgs, registerCommands } from \"./cli.js\";\nimport { getEnvDefaults } from \"./defaults.js\";\nimport type { INodeEngineConfig } from \"./models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"./models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"./models/INodeEnvironmentVariables.js\";\nimport type { INodeOptions } from \"./models/INodeOptions.js\";\nimport { ModuleProtocol } from \"./models/moduleProtocol.js\";\nimport { start } from \"./start.js\";\nimport {\n\tcreateModuleImportUrl,\n\tfileExists,\n\tgetExecutionDirectory,\n\tgetExtensionsCacheDir,\n\tgetScriptDirectory,\n\thandleHttpsProtocol,\n\thandleNpmProtocol,\n\tinitialiseLocales,\n\tloadJsonFile,\n\tloadTextFile,\n\tparseModuleProtocol,\n\tresolvePackageEntryPoint\n} from \"./utils.js\";\n\nconst moduleCache: { [id: string]: unknown } = {};\nlet npmRootCache: string | undefined;\n\n/**\n * Run the TWIN Node.\n * @param nodeOptions Optional configuration options for running the server.\n * @param args Optional command line arguments.\n * @returns A promise that resolves when the server is started containing a shutdown method.\n */\nexport async function run(\n\tnodeOptions?: INodeOptions,\n\targs?: string[]\n): Promise<\n\t| {\n\t\t\tengine: Engine<IEngineServerConfig, INodeEngineState>;\n\t\t\tserver: EngineServer;\n\t\t\tshutdown: () => Promise<void>;\n\t }\n\t| undefined\n> {\n\tlet showErrorDetails = true;\n\ttry {\n\t\tnodeOptions ??= {};\n\n\t\tconst serverInfo: IServerInfo = {\n\t\t\tname: nodeOptions?.serverName ?? \"TWIN Node\",\n\t\t\tversion: nodeOptions?.serverVersion ?? \"0.0.3-next.38\" // x-release-please-version\n\t\t};\n\n\t\tCLIDisplay.header(serverInfo.name, serverInfo.version, \"🌩️ \");\n\n\t\tif (!Is.stringValue(nodeOptions?.executionDirectory)) {\n\t\t\tnodeOptions.executionDirectory = getExecutionDirectory();\n\t\t}\n\t\tCLIDisplay.value(\"Execution Directory\", nodeOptions.executionDirectory);\n\n\t\tif (!Is.stringValue(nodeOptions?.scriptDirectory)) {\n\t\t\tnodeOptions.scriptDirectory = getScriptDirectory(args);\n\t\t}\n\t\tCLIDisplay.value(\"Script Directory\", nodeOptions.scriptDirectory);\n\n\t\tnodeOptions.localesDirectory =\n\t\t\tnodeOptions?.localesDirectory ??\n\t\t\tpath.resolve(path.join(nodeOptions.scriptDirectory, \"dist\", \"locales\"));\n\n\t\tCLIDisplay.value(\"Locales Directory\", nodeOptions.localesDirectory);\n\t\tawait initialiseLocales(nodeOptions.localesDirectory);\n\n\t\tnodeOptions.envPrefix ??= \"TWIN_\";\n\n\t\toverrideModuleImport(nodeOptions.executionDirectory ?? \"\");\n\n\t\tconst commandLineArgs = parseCommandLineArgs(args);\n\n\t\tconst hasEnvPrefix = commandLineArgs.options?.find(option => option.key === \"env-prefix\");\n\t\tif (hasEnvPrefix) {\n\t\t\tnodeOptions.envPrefix = Coerce.string(hasEnvPrefix.value) ?? nodeOptions.envPrefix;\n\t\t}\n\n\t\tCLIDisplay.value(\"Environment Variable Prefix\", nodeOptions.envPrefix);\n\n\t\t// This is the only location in the code base that should access process.env directly\n\t\t// So we can safely disable the linting rule here.\n\t\tlet finalEnvVars =\n\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\tprocess.env as {\n\t\t\t\t[id: string]: string;\n\t\t\t};\n\n\t\tif (Is.objectValue(nodeOptions?.envVars)) {\n\t\t\tfinalEnvVars = {\n\t\t\t\t...finalEnvVars,\n\t\t\t\t...nodeOptions.envVars\n\t\t\t};\n\t\t}\n\n\t\tfinalEnvVars = {\n\t\t\t...getEnvDefaults(nodeOptions.envPrefix),\n\t\t\t...finalEnvVars\n\t\t};\n\n\t\tlet cliCommand;\n\t\tif (Is.arrayValue(commandLineArgs.options)) {\n\t\t\tregisterCommands();\n\t\t\tcliCommand = constructCliCommand(finalEnvVars, commandLineArgs);\n\t\t}\n\n\t\tif (Is.object(cliCommand)) {\n\t\t\tfinalEnvVars[`${nodeOptions.envPrefix}SILENT`] ??= \"true\";\n\t\t} else {\n\t\t\tif (Is.empty(nodeOptions?.openApiSpecFile)) {\n\t\t\t\tconst specFile = path.resolve(\n\t\t\t\t\tpath.join(nodeOptions.scriptDirectory ?? \"\", \"docs\", \"open-api\", \"spec.json\")\n\t\t\t\t);\n\t\t\t\tif (await fileExists(specFile)) {\n\t\t\t\t\tnodeOptions ??= {};\n\t\t\t\t\tnodeOptions.openApiSpecFile = specFile;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.stringValue(nodeOptions.openApiSpecFile)) {\n\t\t\t\tCLIDisplay.value(\"OpenAPI Spec File\", nodeOptions.openApiSpecFile);\n\t\t\t}\n\n\t\t\tif (Is.empty(nodeOptions?.favIconFile)) {\n\t\t\t\tconst favIconFile = path.resolve(\n\t\t\t\t\tpath.join(nodeOptions.scriptDirectory ?? \"\", \"static\", \"favicon.png\")\n\t\t\t\t);\n\t\t\t\tif (await fileExists(favIconFile)) {\n\t\t\t\t\tnodeOptions ??= {};\n\t\t\t\t\tnodeOptions.favIconFile = favIconFile;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.stringValue(nodeOptions.favIconFile)) {\n\t\t\t\tCLIDisplay.value(\"Favicon File\", nodeOptions.favIconFile);\n\t\t\t}\n\t\t}\n\n\t\tconst { nodeEngineConfig, nodeEnvVars, availableContextIdKeys } = await buildConfiguration(\n\t\t\tfinalEnvVars,\n\t\t\tnodeOptions,\n\t\t\tserverInfo\n\t\t);\n\n\t\tCLIDisplay.break();\n\n\t\tconst startResult = await start(\n\t\t\tnodeOptions,\n\t\t\tnodeEngineConfig,\n\t\t\tnodeEnvVars,\n\t\t\tcliCommand,\n\t\t\tavailableContextIdKeys\n\t\t);\n\n\t\tif (!Is.empty(startResult)) {\n\t\t\tshowErrorDetails = false;\n\n\t\t\tlet isShuttingDown = false;\n\t\t\tfor (const signal of [\"SIGHUP\", \"SIGINT\", \"SIGTERM\"]) {\n\t\t\t\tprocess.on(signal, async () => {\n\t\t\t\t\tif (!isShuttingDown) {\n\t\t\t\t\t\tisShuttingDown = true;\n\t\t\t\t\t\tCLIDisplay.value(\"Terminate Signal\", signal);\n\t\t\t\t\t\tawait startResult.shutdown();\n\t\t\t\t\t\tprocess.exit(0);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn startResult;\n\t} catch (err) {\n\t\tif (nodeOptions?.disableProcessExitOnFailure ?? false) {\n\t\t\tthrow err;\n\t\t}\n\n\t\tif (showErrorDetails) {\n\t\t\tconst baseError = BaseError.fromError(err);\n\t\t\tif (baseError.source === \"node\") {\n\t\t\t\tObjectHelper.propertyDelete(err, \"stack\");\n\t\t\t}\n\t\t\tCLIDisplay.error(err);\n\t\t}\n\n\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\tprocess.exit(1);\n\t}\n}\n\n/**\n * Build the configuration for the TWIN Node.\n * @param processEnv The environment variables from the process.\n * @param options The options for running the server.\n * @param serverInfo The server information.\n * @returns A promise that resolves to the engine server configuration, environment prefix, environment variables,\n * and options.\n */\nexport async function buildConfiguration(\n\tprocessEnv: {\n\t\t[id: string]: string;\n\t},\n\toptions: INodeOptions,\n\tserverInfo: IServerInfo\n): Promise<{\n\tnodeEnvVars: INodeEnvironmentVariables & { [id: string]: string | unknown };\n\tnodeEngineConfig: INodeEngineConfig;\n\tavailableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[];\n}> {\n\tconst availableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[] = [];\n\n\tlet defaultEnvOnly = false;\n\tif (Is.empty(options?.envFilenames)) {\n\t\tconst envFile = path.resolve(path.join(options.executionDirectory ?? \"\", \".env\"));\n\t\tCLIDisplay.value(\"Default Environment File\", envFile);\n\t\toptions ??= {};\n\t\toptions.envFilenames = [envFile];\n\t\tdefaultEnvOnly = true;\n\t}\n\n\tif (Is.arrayValue(options?.envFilenames)) {\n\t\tconst output = dotenv.config({\n\t\t\tpath: options?.envFilenames,\n\t\t\tquiet: true\n\t\t});\n\n\t\t// We don't want to throw an error if the default environment file is not found.\n\t\t// Only if we have custom environment files.\n\t\tif (!defaultEnvOnly && output.error) {\n\t\t\tthrow output.error;\n\t\t}\n\n\t\tif (Is.objectValue(output.parsed)) {\n\t\t\tfor (const [key, value] of Object.entries(output.parsed)) {\n\t\t\t\t// Only set environment variables that are not already set in\n\t\t\t\t// the process environment or provided via options.envVars\n\t\t\t\tprocessEnv[key] ??= value;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst envVars = EnvHelper.envToJson<{ [id: string]: string | unknown }>(\n\t\tprocessEnv,\n\t\toptions.envPrefix ?? \"\"\n\t);\n\n\t// Expand any environment variables that use the @file: syntax\n\tconst keys = Object.keys(envVars);\n\tfor (const key of keys) {\n\t\tif (\n\t\t\tIs.stringValue(envVars[key]) &&\n\t\t\t(envVars[key].startsWith(\"@text:\") || envVars[key].startsWith(\"@json:\"))\n\t\t) {\n\t\t\tconst filePath = envVars[key].slice(6).trim();\n\t\t\tconst embeddedFile = path.resolve(path.join(options.executionDirectory ?? \"\", filePath));\n\n\t\t\tif (envVars[key].startsWith(\"@text:\")) {\n\t\t\t\tCLIDisplay.value(`Expanding Environment Variable: ${key} from text file`, embeddedFile);\n\t\t\t\tenvVars[key] = await loadTextFile(embeddedFile);\n\t\t\t} else if (envVars[key].startsWith(\"@json:\")) {\n\t\t\t\tCLIDisplay.value(`Expanding Environment Variable: ${key} from JSON file`, embeddedFile);\n\t\t\t\tenvVars[key] = await loadJsonFile(embeddedFile);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Extend the environment variables with any additional custom configuration.\n\tif (Is.function(options?.extendEnvVars)) {\n\t\tCLIDisplay.task(\"Extending Environment Variables\");\n\t\tawait options.extendEnvVars(envVars);\n\t}\n\n\t// Build the engine configuration from the environment variables.\n\tconst coreConfig = await buildEngineConfiguration(envVars, availableContextIdKeys);\n\tconst engineServerConfig = await buildEngineServerConfiguration(\n\t\tenvVars,\n\t\tavailableContextIdKeys,\n\t\tcoreConfig,\n\t\tserverInfo,\n\t\toptions?.openApiSpecFile,\n\t\toptions?.favIconFile\n\t);\n\n\t// Merge any custom configuration provided in the options.\n\tif (Is.arrayValue(options?.configFilenames)) {\n\t\tfor (const configFile of options.configFilenames) {\n\t\t\tCLIDisplay.value(\"Loading Configuration File\", configFile);\n\t\t\tconst configFilePath = path.resolve(path.join(options.executionDirectory ?? \"\", configFile));\n\t\t\tconst config = await loadJsonFile(configFilePath);\n\t\t\tObject.assign(engineServerConfig, config);\n\t\t}\n\t}\n\n\tif (Is.objectValue(options?.config)) {\n\t\tCLIDisplay.task(\"Merging Custom Configuration\");\n\t\tObject.assign(engineServerConfig, options.config);\n\t}\n\n\t// Merge any custom configuration provided in the options.\n\tif (Is.function(options?.extendConfig)) {\n\t\tCLIDisplay.task(\"Extending Configuration\");\n\t\tawait options.extendConfig(envVars, engineServerConfig);\n\t}\n\n\tconst nodeEngineConfig = await extensionsConfiguration(envVars, engineServerConfig);\n\n\treturn { nodeEngineConfig, nodeEnvVars: envVars, availableContextIdKeys };\n}\n\n/**\n * Override module imports to support protocol-based loading (npm:, https:) and local files.\n * @param executionDirectory The execution directory for resolving local module paths.\n * @param envVars The environment variables containing extension configuration (optional, uses defaults if not provided).\n */\nexport function overrideModuleImport(\n\texecutionDirectory: string,\n\tenvVars?: INodeEnvironmentVariables\n): void {\n\tconst maxSizeMb = Coerce.number(envVars?.extensionsMaxSizeMb) ?? 10;\n\tconst cacheDirectory = envVars?.extensionsCacheDirectory;\n\n\tModuleHelper.overrideImport(async moduleName => {\n\t\tif (moduleCache[moduleName]) {\n\t\t\treturn {\n\t\t\t\tmodule: moduleCache[moduleName],\n\t\t\t\tuseDefault: false\n\t\t\t};\n\t\t}\n\n\t\tconst parsed = parseModuleProtocol(moduleName);\n\t\tlet resolvedPath: string | undefined;\n\n\t\tswitch (parsed.protocol) {\n\t\t\tcase ModuleProtocol.Npm: {\n\t\t\t\tconst result = await handleNpmProtocol(\n\t\t\t\t\tparsed.identifier,\n\t\t\t\t\texecutionDirectory,\n\t\t\t\t\tcacheDirectory\n\t\t\t\t);\n\t\t\t\tresolvedPath = result.resolvedPath;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Https: {\n\t\t\t\tconst result = await handleHttpsProtocol(\n\t\t\t\t\tparsed.identifier,\n\t\t\t\t\texecutionDirectory,\n\t\t\t\t\tmaxSizeMb,\n\t\t\t\t\tcacheDirectory,\n\t\t\t\t\tenvVars?.extensionsCacheTtlHours,\n\t\t\t\t\tenvVars?.extensionsForceRefresh\n\t\t\t\t);\n\t\t\t\tresolvedPath = result.resolvedPath;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Http: {\n\t\t\t\tthrow new GeneralError(\"node\", \"insecureProtocol\", { protocol: ModuleProtocol.Http });\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Local: {\n\t\t\t\tlet localFilename = path.resolve(moduleName);\n\n\t\t\t\tlet exists = await fileExists(localFilename);\n\t\t\t\tif (!exists) {\n\t\t\t\t\tlocalFilename = path.resolve(executionDirectory, moduleName);\n\t\t\t\t\texists = await fileExists(localFilename);\n\t\t\t\t}\n\n\t\t\t\tif (exists) {\n\t\t\t\t\tresolvedPath = localFilename;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Default: {\n\t\t\t\ttry {\n\t\t\t\t\tconst packagePath = path.resolve(getNpmRootPath(), moduleName);\n\t\t\t\t\tconst mainFile = await resolvePackageEntryPoint(packagePath, moduleName);\n\t\t\t\t\tconst modulePath = path.resolve(packagePath, mainFile);\n\t\t\t\t\tconst exists = await fileExists(modulePath);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tresolvedPath = modulePath;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Continue to fallback resolution\n\t\t\t\t}\n\n\t\t\t\t// Fallback: resolve from npm protocol cache directory (installed via handleNpmProtocol)\n\t\t\t\ttry {\n\t\t\t\t\tconst cacheNpmRoot = path.resolve(\n\t\t\t\t\t\tgetExtensionsCacheDir(executionDirectory, ModuleProtocol.Npm, cacheDirectory),\n\t\t\t\t\t\t\"node_modules\"\n\t\t\t\t\t);\n\n\t\t\t\t\tconst packagePath = path.resolve(cacheNpmRoot, moduleName);\n\t\t\t\t\tconst mainFile = await resolvePackageEntryPoint(packagePath, moduleName);\n\t\t\t\t\tconst modulePath = path.resolve(packagePath, mainFile);\n\t\t\t\t\tconst exists = await fileExists(modulePath);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tresolvedPath = modulePath;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// No cached resolution either; fall through\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Common module loading and caching logic\n\t\tif (resolvedPath) {\n\t\t\tconst module = await import(createModuleImportUrl(resolvedPath));\n\t\t\tmoduleCache[moduleName] = module;\n\t\t\treturn {\n\t\t\t\tmodule,\n\t\t\t\tuseDefault: false\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tmodule: undefined,\n\t\t\tuseDefault: true\n\t\t};\n\t});\n}\n\n/**\n * Get the root path for npm modules by executing \"npm root\" command and cache it.\n * @returns The root path for npm modules.\n */\nfunction getNpmRootPath(): string {\n\tnpmRootCache ??= execSync(\"npm root\").toString().trim().replace(/\\\\/g, \"/\");\n\treturn npmRootCache;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAo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,UAAU,CAAC,CAAC;oBAC5C,IAAI,MAAM,EAAE,CAAC;wBACZ,YAAY,GAAG,UAAU,CAAC;oBAC3B,CAAC;gBACF,CAAC;gBAAC,MAAM,CAAC;oBACR,4CAA4C;gBAC7C,CAAC;gBACD,MAAM;YACP,CAAC;QACF,CAAC;QAED,0CAA0C;QAC1C,IAAI,YAAY,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC,CAAC;YACjE,WAAW,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;YACjC,OAAO;gBACN,MAAM;gBACN,UAAU,EAAE,KAAK;aACjB,CAAC;QACH,CAAC;QAED,OAAO;YACN,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,IAAI;SAChB,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc;IACtB,YAAY,KAAK,QAAQ,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC5E,OAAO,YAAY,CAAC;AACrB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { execSync } from \"node:child_process\";\nimport path from \"node:path\";\nimport type { IServerInfo } from \"@twin.org/api-models\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { BaseError, Coerce, EnvHelper, GeneralError, Is, ObjectHelper } from \"@twin.org/core\";\nimport type { Engine } from \"@twin.org/engine\";\nimport type { EngineServer } from \"@twin.org/engine-server\";\nimport type { IEngineServerConfig } from \"@twin.org/engine-server-types\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport * as dotenv from \"dotenv\";\nimport { buildEngineConfiguration } from \"./builders/engineEnvBuilder.js\";\nimport { buildEngineServerConfiguration } from \"./builders/engineServerEnvBuilder.js\";\nimport { extensionsConfiguration } from \"./builders/extensionsBuilder.js\";\nimport { constructCliCommand, parseCommandLineArgs, registerCommands } from \"./cli.js\";\nimport { getEnvDefaults } from \"./defaults.js\";\nimport type { INodeEngineConfig } from \"./models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"./models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"./models/INodeEnvironmentVariables.js\";\nimport type { INodeOptions } from \"./models/INodeOptions.js\";\nimport { ModuleProtocol } from \"./models/moduleProtocol.js\";\nimport { start } from \"./start.js\";\nimport {\n\tcreateModuleImportUrl,\n\tfileExists,\n\tgetExecutionDirectory,\n\tgetExtensionsCacheDir,\n\tgetScriptDirectory,\n\thandleHttpsProtocol,\n\thandleNpmProtocol,\n\tinitialiseLocales,\n\tloadJsonFile,\n\tloadTextFile,\n\tparseModuleProtocol,\n\tresolvePackageEntryPoint\n} from \"./utils.js\";\n\nconst moduleCache: { [id: string]: unknown } = {};\nlet npmRootCache: string | undefined;\n\n/**\n * Run the TWIN Node.\n * @param nodeOptions Optional configuration options for running the server.\n * @param args Optional command line arguments.\n * @returns A promise that resolves when the server is started containing a shutdown method.\n */\nexport async function run(\n\tnodeOptions?: INodeOptions,\n\targs?: string[]\n): Promise<\n\t| {\n\t\t\tengine: Engine<IEngineServerConfig, INodeEngineState>;\n\t\t\tserver: EngineServer;\n\t\t\tshutdown: () => Promise<void>;\n\t }\n\t| undefined\n> {\n\tlet showErrorDetails = true;\n\ttry {\n\t\tnodeOptions ??= {};\n\n\t\tconst serverInfo: IServerInfo = {\n\t\t\tname: nodeOptions?.serverName ?? \"TWIN Node\",\n\t\t\tversion: nodeOptions?.serverVersion ?? \"0.0.3-next.39\" // x-release-please-version\n\t\t};\n\n\t\tCLIDisplay.header(serverInfo.name, serverInfo.version, \"🌩️ \");\n\n\t\tif (!Is.stringValue(nodeOptions?.executionDirectory)) {\n\t\t\tnodeOptions.executionDirectory = getExecutionDirectory();\n\t\t}\n\t\tCLIDisplay.value(\"Execution Directory\", nodeOptions.executionDirectory);\n\n\t\tif (!Is.stringValue(nodeOptions?.scriptDirectory)) {\n\t\t\tnodeOptions.scriptDirectory = getScriptDirectory(args);\n\t\t}\n\t\tCLIDisplay.value(\"Script Directory\", nodeOptions.scriptDirectory);\n\n\t\tnodeOptions.localesDirectory =\n\t\t\tnodeOptions?.localesDirectory ??\n\t\t\tpath.resolve(path.join(nodeOptions.scriptDirectory, \"dist\", \"locales\"));\n\n\t\tCLIDisplay.value(\"Locales Directory\", nodeOptions.localesDirectory);\n\t\tawait initialiseLocales(nodeOptions.localesDirectory);\n\n\t\tnodeOptions.envPrefix ??= \"TWIN_\";\n\n\t\toverrideModuleImport(nodeOptions.executionDirectory ?? \"\");\n\n\t\tconst commandLineArgs = parseCommandLineArgs(args);\n\n\t\tconst hasEnvPrefix = commandLineArgs.options?.find(option => option.key === \"env-prefix\");\n\t\tif (hasEnvPrefix) {\n\t\t\tnodeOptions.envPrefix = Coerce.string(hasEnvPrefix.value) ?? nodeOptions.envPrefix;\n\t\t}\n\n\t\tCLIDisplay.value(\"Environment Variable Prefix\", nodeOptions.envPrefix);\n\n\t\t// This is the only location in the code base that should access process.env directly\n\t\t// So we can safely disable the linting rule here.\n\t\tlet finalEnvVars =\n\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\tprocess.env as {\n\t\t\t\t[id: string]: string;\n\t\t\t};\n\n\t\tif (Is.objectValue(nodeOptions?.envVars)) {\n\t\t\tfinalEnvVars = {\n\t\t\t\t...finalEnvVars,\n\t\t\t\t...nodeOptions.envVars\n\t\t\t};\n\t\t}\n\n\t\tfinalEnvVars = {\n\t\t\t...getEnvDefaults(nodeOptions.envPrefix),\n\t\t\t...finalEnvVars\n\t\t};\n\n\t\tlet cliCommand;\n\t\tif (Is.arrayValue(commandLineArgs.options)) {\n\t\t\tregisterCommands();\n\t\t\tcliCommand = constructCliCommand(finalEnvVars, commandLineArgs);\n\t\t}\n\n\t\tif (Is.object(cliCommand)) {\n\t\t\tfinalEnvVars[`${nodeOptions.envPrefix}SILENT`] ??= \"true\";\n\t\t} else {\n\t\t\tif (Is.empty(nodeOptions?.openApiSpecFile)) {\n\t\t\t\tconst specFile = path.resolve(\n\t\t\t\t\tpath.join(nodeOptions.scriptDirectory ?? \"\", \"docs\", \"open-api\", \"spec.json\")\n\t\t\t\t);\n\t\t\t\tif (await fileExists(specFile)) {\n\t\t\t\t\tnodeOptions ??= {};\n\t\t\t\t\tnodeOptions.openApiSpecFile = specFile;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.stringValue(nodeOptions.openApiSpecFile)) {\n\t\t\t\tCLIDisplay.value(\"OpenAPI Spec File\", nodeOptions.openApiSpecFile);\n\t\t\t}\n\n\t\t\tif (Is.empty(nodeOptions?.favIconFile)) {\n\t\t\t\tconst favIconFile = path.resolve(\n\t\t\t\t\tpath.join(nodeOptions.scriptDirectory ?? \"\", \"static\", \"favicon.png\")\n\t\t\t\t);\n\t\t\t\tif (await fileExists(favIconFile)) {\n\t\t\t\t\tnodeOptions ??= {};\n\t\t\t\t\tnodeOptions.favIconFile = favIconFile;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.stringValue(nodeOptions.favIconFile)) {\n\t\t\t\tCLIDisplay.value(\"Favicon File\", nodeOptions.favIconFile);\n\t\t\t}\n\t\t}\n\n\t\tconst { nodeEngineConfig, nodeEnvVars, availableContextIdKeys } = await buildConfiguration(\n\t\t\tfinalEnvVars,\n\t\t\tnodeOptions,\n\t\t\tserverInfo\n\t\t);\n\n\t\tCLIDisplay.break();\n\n\t\tconst startResult = await start(\n\t\t\tnodeOptions,\n\t\t\tnodeEngineConfig,\n\t\t\tnodeEnvVars,\n\t\t\tcliCommand,\n\t\t\tavailableContextIdKeys\n\t\t);\n\n\t\tif (!Is.empty(startResult)) {\n\t\t\tshowErrorDetails = false;\n\n\t\t\tlet isShuttingDown = false;\n\t\t\tfor (const signal of [\"SIGHUP\", \"SIGINT\", \"SIGTERM\"]) {\n\t\t\t\tprocess.on(signal, async () => {\n\t\t\t\t\tif (!isShuttingDown) {\n\t\t\t\t\t\tisShuttingDown = true;\n\t\t\t\t\t\tCLIDisplay.value(\"Terminate Signal\", signal);\n\t\t\t\t\t\tawait startResult.shutdown();\n\t\t\t\t\t\tprocess.exit(0);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn startResult;\n\t} catch (err) {\n\t\tif (nodeOptions?.disableProcessExitOnFailure ?? false) {\n\t\t\tthrow err;\n\t\t}\n\n\t\tif (showErrorDetails) {\n\t\t\tconst baseError = BaseError.fromError(err);\n\t\t\tif (baseError.source === \"node\") {\n\t\t\t\tObjectHelper.propertyDelete(err, \"stack\");\n\t\t\t}\n\t\t\tCLIDisplay.error(err);\n\t\t}\n\n\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\tprocess.exit(1);\n\t}\n}\n\n/**\n * Build the configuration for the TWIN Node.\n * @param processEnv The environment variables from the process.\n * @param options The options for running the server.\n * @param serverInfo The server information.\n * @returns A promise that resolves to the engine server configuration, environment prefix, environment variables,\n * and options.\n */\nexport async function buildConfiguration(\n\tprocessEnv: {\n\t\t[id: string]: string;\n\t},\n\toptions: INodeOptions,\n\tserverInfo: IServerInfo\n): Promise<{\n\tnodeEnvVars: INodeEnvironmentVariables & { [id: string]: string | unknown };\n\tnodeEngineConfig: INodeEngineConfig;\n\tavailableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[];\n}> {\n\tconst availableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[] = [];\n\n\tlet defaultEnvOnly = false;\n\tif (Is.empty(options?.envFilenames)) {\n\t\tconst envFile = path.resolve(path.join(options.executionDirectory ?? \"\", \".env\"));\n\t\tCLIDisplay.value(\"Default Environment File\", envFile);\n\t\toptions ??= {};\n\t\toptions.envFilenames = [envFile];\n\t\tdefaultEnvOnly = true;\n\t}\n\n\tif (Is.arrayValue(options?.envFilenames)) {\n\t\tconst output = dotenv.config({\n\t\t\tpath: options?.envFilenames,\n\t\t\tquiet: true\n\t\t});\n\n\t\t// We don't want to throw an error if the default environment file is not found.\n\t\t// Only if we have custom environment files.\n\t\tif (!defaultEnvOnly && output.error) {\n\t\t\tthrow output.error;\n\t\t}\n\n\t\tif (Is.objectValue(output.parsed)) {\n\t\t\tfor (const [key, value] of Object.entries(output.parsed)) {\n\t\t\t\t// Only set environment variables that are not already set in\n\t\t\t\t// the process environment or provided via options.envVars\n\t\t\t\tprocessEnv[key] ??= value;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst envVars = EnvHelper.envToJson<{ [id: string]: string | unknown }>(\n\t\tprocessEnv,\n\t\toptions.envPrefix ?? \"\"\n\t);\n\n\t// Expand any environment variables that use the @file: syntax\n\tconst keys = Object.keys(envVars);\n\tfor (const key of keys) {\n\t\tif (\n\t\t\tIs.stringValue(envVars[key]) &&\n\t\t\t(envVars[key].startsWith(\"@text:\") || envVars[key].startsWith(\"@json:\"))\n\t\t) {\n\t\t\tconst filePath = envVars[key].slice(6).trim();\n\t\t\tconst embeddedFile = path.resolve(path.join(options.executionDirectory ?? \"\", filePath));\n\n\t\t\tif (envVars[key].startsWith(\"@text:\")) {\n\t\t\t\tCLIDisplay.value(`Expanding Environment Variable: ${key} from text file`, embeddedFile);\n\t\t\t\tenvVars[key] = await loadTextFile(embeddedFile);\n\t\t\t} else if (envVars[key].startsWith(\"@json:\")) {\n\t\t\t\tCLIDisplay.value(`Expanding Environment Variable: ${key} from JSON file`, embeddedFile);\n\t\t\t\tenvVars[key] = await loadJsonFile(embeddedFile);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Extend the environment variables with any additional custom configuration.\n\tif (Is.function(options?.extendEnvVars)) {\n\t\tCLIDisplay.task(\"Extending Environment Variables\");\n\t\tawait options.extendEnvVars(envVars);\n\t}\n\n\t// Build the engine configuration from the environment variables.\n\tconst coreConfig = await buildEngineConfiguration(envVars, availableContextIdKeys);\n\tconst engineServerConfig = await buildEngineServerConfiguration(\n\t\tenvVars,\n\t\tavailableContextIdKeys,\n\t\tcoreConfig,\n\t\tserverInfo,\n\t\toptions?.openApiSpecFile,\n\t\toptions?.favIconFile\n\t);\n\n\t// Merge any custom configuration provided in the options.\n\tif (Is.arrayValue(options?.configFilenames)) {\n\t\tfor (const configFile of options.configFilenames) {\n\t\t\tCLIDisplay.value(\"Loading Configuration File\", configFile);\n\t\t\tconst configFilePath = path.resolve(path.join(options.executionDirectory ?? \"\", configFile));\n\t\t\tconst config = await loadJsonFile(configFilePath);\n\t\t\tObject.assign(engineServerConfig, config);\n\t\t}\n\t}\n\n\tif (Is.objectValue(options?.config)) {\n\t\tCLIDisplay.task(\"Merging Custom Configuration\");\n\t\tObject.assign(engineServerConfig, options.config);\n\t}\n\n\t// Merge any custom configuration provided in the options.\n\tif (Is.function(options?.extendConfig)) {\n\t\tCLIDisplay.task(\"Extending Configuration\");\n\t\tawait options.extendConfig(envVars, engineServerConfig);\n\t}\n\n\tconst nodeEngineConfig = await extensionsConfiguration(envVars, engineServerConfig);\n\n\treturn { nodeEngineConfig, nodeEnvVars: envVars, availableContextIdKeys };\n}\n\n/**\n * Override module imports to support protocol-based loading (npm:, https:) and local files.\n * @param executionDirectory The execution directory for resolving local module paths.\n * @param envVars The environment variables containing extension configuration (optional, uses defaults if not provided).\n */\nexport function overrideModuleImport(\n\texecutionDirectory: string,\n\tenvVars?: INodeEnvironmentVariables\n): void {\n\tconst maxSizeMb = Coerce.number(envVars?.extensionsMaxSizeMb) ?? 10;\n\tconst cacheDirectory = envVars?.extensionsCacheDirectory;\n\n\tModuleHelper.overrideImport(async moduleName => {\n\t\tif (moduleCache[moduleName]) {\n\t\t\treturn {\n\t\t\t\tmodule: moduleCache[moduleName],\n\t\t\t\tuseDefault: false\n\t\t\t};\n\t\t}\n\n\t\tconst parsed = parseModuleProtocol(moduleName);\n\t\tlet resolvedPath: string | undefined;\n\n\t\tswitch (parsed.protocol) {\n\t\t\tcase ModuleProtocol.Npm: {\n\t\t\t\tconst result = await handleNpmProtocol(\n\t\t\t\t\tparsed.identifier,\n\t\t\t\t\texecutionDirectory,\n\t\t\t\t\tcacheDirectory\n\t\t\t\t);\n\t\t\t\tresolvedPath = result.resolvedPath;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Https: {\n\t\t\t\tconst result = await handleHttpsProtocol(\n\t\t\t\t\tparsed.identifier,\n\t\t\t\t\texecutionDirectory,\n\t\t\t\t\tmaxSizeMb,\n\t\t\t\t\tcacheDirectory,\n\t\t\t\t\tenvVars?.extensionsCacheTtlHours,\n\t\t\t\t\tenvVars?.extensionsForceRefresh\n\t\t\t\t);\n\t\t\t\tresolvedPath = result.resolvedPath;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Http: {\n\t\t\t\tthrow new GeneralError(\"node\", \"insecureProtocol\", { protocol: ModuleProtocol.Http });\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Local: {\n\t\t\t\tlet localFilename = path.resolve(moduleName);\n\n\t\t\t\tlet exists = await fileExists(localFilename);\n\t\t\t\tif (!exists) {\n\t\t\t\t\tlocalFilename = path.resolve(executionDirectory, moduleName);\n\t\t\t\t\texists = await fileExists(localFilename);\n\t\t\t\t}\n\n\t\t\t\tif (exists) {\n\t\t\t\t\tresolvedPath = localFilename;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Default: {\n\t\t\t\ttry {\n\t\t\t\t\tconst packagePath = path.resolve(getNpmRootPath(), moduleName);\n\t\t\t\t\tconst mainFile = await resolvePackageEntryPoint(packagePath, moduleName);\n\t\t\t\t\tconst modulePath = path.resolve(packagePath, mainFile);\n\t\t\t\t\tconst exists = await fileExists(modulePath);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tresolvedPath = modulePath;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Continue to fallback resolution\n\t\t\t\t}\n\n\t\t\t\t// Fallback: resolve from npm protocol cache directory (installed via handleNpmProtocol)\n\t\t\t\ttry {\n\t\t\t\t\tconst cacheNpmRoot = path.resolve(\n\t\t\t\t\t\tgetExtensionsCacheDir(executionDirectory, ModuleProtocol.Npm, cacheDirectory),\n\t\t\t\t\t\t\"node_modules\"\n\t\t\t\t\t);\n\n\t\t\t\t\tconst packagePath = path.resolve(cacheNpmRoot, moduleName);\n\t\t\t\t\tconst mainFile = await resolvePackageEntryPoint(packagePath, moduleName);\n\t\t\t\t\tconst modulePath = path.resolve(packagePath, mainFile);\n\t\t\t\t\tconst exists = await fileExists(modulePath);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tresolvedPath = modulePath;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// No cached resolution either; fall through\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Common module loading and caching logic\n\t\tif (resolvedPath) {\n\t\t\tconst module = await import(createModuleImportUrl(resolvedPath));\n\t\t\tmoduleCache[moduleName] = module;\n\t\t\treturn {\n\t\t\t\tmodule,\n\t\t\t\tuseDefault: false\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tmodule: undefined,\n\t\t\tuseDefault: true\n\t\t};\n\t});\n}\n\n/**\n * Get the root path for npm modules by executing \"npm root\" command and cache it.\n * @returns The root path for npm modules.\n */\nfunction getNpmRootPath(): string {\n\tnpmRootCache ??= execSync(\"npm root\").toString().trim().replace(/\\\\/g, \"/\");\n\treturn npmRootCache;\n}\n"]}
|
|
@@ -15,6 +15,7 @@ export declare function getCommandDefinitionUserCreate(commandDefinitions: {
|
|
|
15
15
|
* @param params The parameters for the command.
|
|
16
16
|
* @param params.userIdentity The DID for the user.
|
|
17
17
|
* @param params.organizationIdentity The organization DID for the user.
|
|
18
|
+
* @param params.tenantId The tenant ID for the user.
|
|
18
19
|
* @param params.email The email for the user.
|
|
19
20
|
* @param params.password The password for the user.
|
|
20
21
|
* @param params.scope The scope for the user.
|
|
@@ -29,6 +30,7 @@ export declare function getCommandDefinitionUserCreate(commandDefinitions: {
|
|
|
29
30
|
export declare function userCreate(engineCore: IEngineCore, envVars: INodeEnvironmentVariables, params: {
|
|
30
31
|
userIdentity?: string;
|
|
31
32
|
organizationIdentity?: string;
|
|
33
|
+
tenantId?: string;
|
|
32
34
|
email?: string;
|
|
33
35
|
password?: string;
|
|
34
36
|
scope?: string;
|
|
@@ -9,12 +9,13 @@ export declare function getCommandDefinitionUserUpdate(commandDefinitions: {
|
|
|
9
9
|
[id: string]: ICliCommandDefinition;
|
|
10
10
|
}): void;
|
|
11
11
|
/**
|
|
12
|
-
* Command for
|
|
12
|
+
* Command for updating a user.
|
|
13
13
|
* @param engineCore The engine core.
|
|
14
14
|
* @param envVars The environment variables for the node.
|
|
15
15
|
* @param params The parameters for the command.
|
|
16
16
|
* @param params.userIdentity The DID for the user.
|
|
17
17
|
* @param params.organizationIdentity The organization DID for the user.
|
|
18
|
+
* @param params.tenantId The tenant ID for the user.
|
|
18
19
|
* @param params.email The email for the user.
|
|
19
20
|
* @param params.scope The scope for the user.
|
|
20
21
|
* @param params.givenName The given name for the user.
|
|
@@ -24,6 +25,7 @@ export declare function getCommandDefinitionUserUpdate(commandDefinitions: {
|
|
|
24
25
|
export declare function userUpdate(engineCore: IEngineCore, envVars: INodeEnvironmentVariables, params: {
|
|
25
26
|
userIdentity?: string;
|
|
26
27
|
organizationIdentity?: string;
|
|
28
|
+
tenantId?: string;
|
|
27
29
|
email?: string;
|
|
28
30
|
scope?: string;
|
|
29
31
|
givenName?: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -18,7 +18,10 @@ export * from "./models/INodeEnvironmentVariables.js";
|
|
|
18
18
|
export * from "./models/INodeOptions.js";
|
|
19
19
|
export * from "./models/IProtocolHandlerResult.js";
|
|
20
20
|
export * from "./models/moduleProtocol.js";
|
|
21
|
-
export * from "./models/
|
|
21
|
+
export * from "./models/nodeExtensionInitialiseEngineMethod.js";
|
|
22
|
+
export * from "./models/nodeExtensionInitialiseEngineServerMethod.js";
|
|
23
|
+
export * from "./models/nodeExtensionInitialiseMethod.js";
|
|
24
|
+
export * from "./models/nodeExtensionShutdownMethod.js";
|
|
22
25
|
export * from "./node.js";
|
|
23
26
|
export * from "./start.js";
|
|
24
27
|
export * from "./utils.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* The type for the initialise engine method of an extension module.
|
|
4
|
+
* This is called when the engine has been constructed but not yet started.
|
|
5
|
+
* @param engineCore The engine core instance.
|
|
6
|
+
*/
|
|
7
|
+
export type NodeExtensionInitialiseEngineMethod = (engineCore: IEngineCore) => Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IEngineCore, IEngineServer } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* The type for the initialise engine server method of an extension module.
|
|
4
|
+
* This is called when the engine server has been constructed but not yet started.
|
|
5
|
+
* @param engineCore The engine core instance.
|
|
6
|
+
* @param engineServer The engine server instance.
|
|
7
|
+
*/
|
|
8
|
+
export type NodeExtensionInitialiseEngineServerMethod = (engineCore: IEngineCore, engineServer: IEngineServer) => Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { INodeEngineConfig } from "./INodeEngineConfig.js";
|
|
2
|
+
import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables.js";
|
|
3
|
+
/**
|
|
4
|
+
* The type for the initialise method of an extension module.
|
|
5
|
+
* @param envVars The environment variables for the node.
|
|
6
|
+
* @param nodeEngineConfig The node engine config.
|
|
7
|
+
*/
|
|
8
|
+
export type NodeExtensionInitialiseMethod = (envVars: INodeEnvironmentVariables, nodeEngineConfig: INodeEngineConfig) => Promise<void>;
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.39](https://github.com/iotaledger/twin-node/compare/node-core-v0.0.3-next.38...node-core-v0.0.3-next.39) (2026-05-21)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* tenant-id in user create and update ([#148](https://github.com/iotaledger/twin-node/issues/148)) ([1143e30](https://github.com/iotaledger/twin-node/commit/1143e30fb0d2056d113367d0c5ea251f07695da1))
|
|
9
|
+
|
|
3
10
|
## [0.0.3-next.38](https://github.com/iotaledger/twin-node/compare/node-core-v0.0.3-next.37...node-core-v0.0.3-next.38) (2026-05-20)
|
|
4
11
|
|
|
5
12
|
|
package/docs/reference/index.md
CHANGED
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
|
|
21
21
|
- [CliCommandParamType](type-aliases/CliCommandParamType.md)
|
|
22
22
|
- [ModuleProtocol](type-aliases/ModuleProtocol.md)
|
|
23
|
-
- [NodeExtensionInitialiseMethod](type-aliases/NodeExtensionInitialiseMethod.md)
|
|
24
23
|
- [NodeExtensionInitialiseEngineMethod](type-aliases/NodeExtensionInitialiseEngineMethod.md)
|
|
25
24
|
- [NodeExtensionInitialiseEngineServerMethod](type-aliases/NodeExtensionInitialiseEngineServerMethod.md)
|
|
25
|
+
- [NodeExtensionInitialiseMethod](type-aliases/NodeExtensionInitialiseMethod.md)
|
|
26
26
|
- [NodeExtensionShutdownMethod](type-aliases/NodeExtensionShutdownMethod.md)
|
|
27
27
|
|
|
28
28
|
## Variables
|
package/locales/en.json
CHANGED
|
@@ -42,7 +42,11 @@
|
|
|
42
42
|
},
|
|
43
43
|
"userCreate": {
|
|
44
44
|
"passwordTooShort": "The password provided is too short, it must be at least {minLength} characters long.",
|
|
45
|
-
"userAlreadyExists": "The user with ID already exists and overwriteMode is set to \"error\"."
|
|
45
|
+
"userAlreadyExists": "The user with ID already exists and overwriteMode is set to \"error\".",
|
|
46
|
+
"tenantIdRequired": "The tenant ID is required when multi-tenancy is enabled."
|
|
47
|
+
},
|
|
48
|
+
"userUpdate": {
|
|
49
|
+
"tenantIdRequired": "The tenant ID is required when multi-tenancy is enabled."
|
|
46
50
|
},
|
|
47
51
|
"vaultKeyCreate": {
|
|
48
52
|
"vaultKeyAlreadyExists": "The vault key with ID already exists and overwriteMode is set to \"error\"."
|
|
@@ -457,6 +461,9 @@
|
|
|
457
461
|
"organization-identity": {
|
|
458
462
|
"description": "The organization DID to associate the user with."
|
|
459
463
|
},
|
|
464
|
+
"tenant-id": {
|
|
465
|
+
"description": "The tenant ID to associate the user with."
|
|
466
|
+
},
|
|
460
467
|
"email": {
|
|
461
468
|
"description": "The email address of the user."
|
|
462
469
|
},
|
|
@@ -512,6 +519,9 @@
|
|
|
512
519
|
"organization-identity": {
|
|
513
520
|
"description": "The organization DID to associate the user with."
|
|
514
521
|
},
|
|
522
|
+
"tenant-id": {
|
|
523
|
+
"description": "The tenant ID to associate the user with."
|
|
524
|
+
},
|
|
515
525
|
"email": {
|
|
516
526
|
"description": "The email address of the user."
|
|
517
527
|
},
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodeExtensionMethods.js","sourceRoot":"","sources":["../../../src/models/nodeExtensionMethods.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEngineCore, IEngineServer } from \"@twin.org/engine-models\";\nimport type { INodeEngineConfig } from \"./INodeEngineConfig.js\";\nimport type { INodeEnvironmentVariables } from \"./INodeEnvironmentVariables.js\";\n\n/**\n * The type for the initialise method of an extension module.\n * @param envVars The environment variables for the node.\n * @param nodeEngineConfig The node engine config.\n */\nexport type NodeExtensionInitialiseMethod = (\n\tenvVars: INodeEnvironmentVariables,\n\tnodeEngineConfig: INodeEngineConfig\n) => Promise<void>;\n\n/**\n * The type for the initialise engine method of an extension module.\n * This is called when the engine has been constructed but not yet started.\n * @param engineCore The engine core instance.\n */\nexport type NodeExtensionInitialiseEngineMethod = (engineCore: IEngineCore) => Promise<void>;\n\n/**\n * The type for the initialise engine server method of an extension module.\n * This is called when the engine server has been constructed but not yet started.\n * @param engineCore The engine core instance.\n * @param engineServer The engine server instance.\n */\nexport type NodeExtensionInitialiseEngineServerMethod = (\n\tengineCore: IEngineCore,\n\tengineServer: IEngineServer\n) => Promise<void>;\n\n/**\n * The type for the shutdown method of an extension module.\n * This is called when the engine is shutting down.\n */\nexport type NodeExtensionShutdownMethod = () => Promise<void>;\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { IEngineCore, IEngineServer } from "@twin.org/engine-models";
|
|
2
|
-
import type { INodeEngineConfig } from "./INodeEngineConfig.js";
|
|
3
|
-
import type { INodeEnvironmentVariables } from "./INodeEnvironmentVariables.js";
|
|
4
|
-
/**
|
|
5
|
-
* The type for the initialise method of an extension module.
|
|
6
|
-
* @param envVars The environment variables for the node.
|
|
7
|
-
* @param nodeEngineConfig The node engine config.
|
|
8
|
-
*/
|
|
9
|
-
export type NodeExtensionInitialiseMethod = (envVars: INodeEnvironmentVariables, nodeEngineConfig: INodeEngineConfig) => Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* The type for the initialise engine method of an extension module.
|
|
12
|
-
* This is called when the engine has been constructed but not yet started.
|
|
13
|
-
* @param engineCore The engine core instance.
|
|
14
|
-
*/
|
|
15
|
-
export type NodeExtensionInitialiseEngineMethod = (engineCore: IEngineCore) => Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* The type for the initialise engine server method of an extension module.
|
|
18
|
-
* This is called when the engine server has been constructed but not yet started.
|
|
19
|
-
* @param engineCore The engine core instance.
|
|
20
|
-
* @param engineServer The engine server instance.
|
|
21
|
-
*/
|
|
22
|
-
export type NodeExtensionInitialiseEngineServerMethod = (engineCore: IEngineCore, engineServer: IEngineServer) => Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* The type for the shutdown method of an extension module.
|
|
25
|
-
* This is called when the engine is shutting down.
|
|
26
|
-
*/
|
|
27
|
-
export type NodeExtensionShutdownMethod = () => Promise<void>;
|