@twin.org/node-core 0.0.3-next.3 â 0.0.3-next.5
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/bootstrap.js +12 -6
- package/dist/es/bootstrap.js.map +1 -1
- package/dist/es/builders/engineEnvBuilder.js +2 -1
- package/dist/es/builders/engineEnvBuilder.js.map +1 -1
- package/dist/es/identity.js +25 -12
- package/dist/es/identity.js.map +1 -1
- package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
- package/dist/es/node.js +1 -1
- package/dist/es/node.js.map +1 -1
- package/dist/types/models/IEngineEnvironmentVariables.d.ts +4 -0
- package/docs/changelog.md +14 -0
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +8 -0
- package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +12 -0
- package/docs/reference/interfaces/INodeEnvironmentVariables.md +12 -0
- package/locales/en.json +2 -2
- package/package.json +1 -1
package/dist/es/bootstrap.js
CHANGED
|
@@ -118,13 +118,15 @@ export async function bootstrapNodeAdminUser(engineCore, context, envVars, featu
|
|
|
118
118
|
if (defaultAuthenticationComponentType.startsWith(AuthenticationComponentType.EntityStorage) &&
|
|
119
119
|
Is.stringValue(context.state.nodeId)) {
|
|
120
120
|
const authUserEntityStorage = EntityStorageConnectorFactory.get("authentication-user");
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
const existingOrganizationId = envVars.organizationIdentity ?? context.state.nodeOrganizationId;
|
|
122
|
+
const orgId = await createIdentity(engineCore, envVars, existingOrganizationId, envVars.organizationMnemonic, existingOrganizationId, "organization", features.includes(NodeFeatures.NodeWallet));
|
|
123
|
+
if (context.state.nodeOrganizationId !== orgId) {
|
|
124
|
+
context.state.nodeOrganizationId = orgId;
|
|
124
125
|
context.stateDirty = true;
|
|
125
126
|
}
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
const userId = await createIdentity(engineCore, envVars, context.state.nodeAdminUserId, envVars.adminUserMnemonic, context.state.nodeOrganizationId, "user", false);
|
|
128
|
+
if (context.state.nodeAdminUserId !== userId) {
|
|
129
|
+
context.state.nodeAdminUserId = userId;
|
|
128
130
|
context.stateDirty = true;
|
|
129
131
|
}
|
|
130
132
|
const adminEmail = envVars.adminUserName ?? DEFAULT_NODE_ADMIN_USERNAME;
|
|
@@ -144,7 +146,11 @@ export async function bootstrapNodeAdminUser(engineCore, context, envVars, featu
|
|
|
144
146
|
organization: context.state.nodeOrganizationId
|
|
145
147
|
};
|
|
146
148
|
engineCore.logInfo(I18n.formatMessage("node.nodeAdminUserEmail", { email: adminEmail }));
|
|
147
|
-
engineCore.
|
|
149
|
+
const defaultVaultConnectorType = engineCore.getRegisteredInstanceType("vaultConnector");
|
|
150
|
+
const vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);
|
|
151
|
+
const vaultKey = `${context.state.nodeAdminUserId}/admin-password`;
|
|
152
|
+
await vaultConnector.setSecret(vaultKey, generatedPassword);
|
|
153
|
+
engineCore.logInfo(I18n.formatMessage("node.nodeAdminUserPassword", { vaultKey }));
|
|
148
154
|
await authUserEntityStorage.set(nodeAdminUser);
|
|
149
155
|
}
|
|
150
156
|
else {
|
package/dist/es/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAA2B,MAAM,2CAA2C,CAAC;AACpG,OAAO,EAAE,cAAc,EAA8B,MAAM,gCAAgC,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAA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CAAC;QACf,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,+BAA+B,EAAE;gBACnD,KAAK,EAAE,uBAAuB;gBAC9B,QAAQ,EAAE,YAAY;aACtB,CAAC,CACF,CAAC;YACF,MAAM,iBAAiB,CAAC,qBAAqB,CAC5C,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,oBAAoB,CACpB,CAAC;QACH,CAAC;aAAM,CAAC;YACP,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,iCAAiC,EAAE;gBACrD,KAAK,EAAE,uBAAuB;gBAC9B,QAAQ,EAAE,YAAY;aACtB,CAAC,CACF,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { PasswordHelper, type AuthenticationUser } from \"@twin.org/api-auth-entity-storage-service\";\nimport { TenantIdHelper, type ITenantAdminComponent } from \"@twin.org/api-tenant-processor\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, Converter, I18n, Is, RandomHelper } from \"@twin.org/core\";\nimport { PasswordGenerator } from \"@twin.org/crypto\";\nimport type { IEngineCore, IEngineCoreContext } from \"@twin.org/engine-models\";\nimport {\n\tAuthenticationComponentType,\n\ttype IEngineServerConfig\n} from \"@twin.org/engine-server-types\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport {\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\tIdentityProfileConnectorFactory,\n\tIdentityResolverConnectorFactory\n} from \"@twin.org/identity-models\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport { VaultConnectorFactory, VaultKeyType } from \"@twin.org/vault-models\";\nimport type { Person, WithContext } from \"schema-dts\";\nimport {\n\tATTESTATION_VERIFICATION_METHOD_ID,\n\tAUTH_SIGNING_KEY_ID,\n\tBLOB_STORAGE_ENCRYPTION_KEY_ID,\n\tIMMUTABLE_PROOF_VERIFICATION_METHOD_ID,\n\tSYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID,\n\tVC_AUTHENTICATION_VERIFICATION_METHOD_ID\n} from \"./defaults.js\";\nimport { createIdentity } from \"./identity.js\";\nimport type { INodeEngineState } from \"./models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"./models/INodeEnvironmentVariables.js\";\nimport { NodeFeatures } from \"./models/nodeFeatures.js\";\nimport { getFeatures } from \"./utils.js\";\n\nconst DEFAULT_NODE_ADMIN_USERNAME = \"admin@node\";\n\n/**\n * Bootstrap the application.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n */\nexport async function bootstrap(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables\n): Promise<void> {\n\tconst features = getFeatures(envVars);\n\n\tawait bootstrapNodeId(engineCore, context, envVars, features);\n\n\tawait ContextIdStore.run(engineCore.getContextIds() ?? {}, async () => {\n\t\tawait bootstrapTenantId(engineCore, context, envVars, features);\n\n\t\tawait bootstrapNodeAdminUser(engineCore, context, envVars, features);\n\t\tawait bootstrapAuth(engineCore, context, envVars, features);\n\t\tawait bootstrapBlobEncryption(engineCore, context, envVars, features);\n\n\t\tconst defaultAttestationConnectorType =\n\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"attestationConnector\");\n\t\tif (\n\t\t\t!Is.empty(defaultAttestationConnectorType) &&\n\t\t\tIs.stringValue(context.state.nodeOrganizationId)\n\t\t) {\n\t\t\tawait addVerificationMethod(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcontext.state.nodeOrganizationId,\n\t\t\t\t\"attestation\",\n\t\t\t\tenvVars.attestationVerificationMethodId ?? ATTESTATION_VERIFICATION_METHOD_ID\n\t\t\t);\n\t\t}\n\n\t\tconst defaultImmutableProofComponentType =\n\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"immutableProofComponent\");\n\n\t\tif (\n\t\t\t!Is.empty(defaultImmutableProofComponentType) &&\n\t\t\tIs.stringValue(context.state.nodeOrganizationId)\n\t\t) {\n\t\t\tawait addVerificationMethod(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcontext.state.nodeOrganizationId,\n\t\t\t\t\"immutable proof\",\n\t\t\t\tenvVars.immutableProofVerificationMethodId ?? IMMUTABLE_PROOF_VERIFICATION_METHOD_ID\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\t(Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) &&\n\t\t\tIs.stringValue(context.state.nodeId)\n\t\t) {\n\t\t\tawait addVerificationMethod(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcontext.state.nodeId,\n\t\t\t\t\"verifiable credential authentication\",\n\t\t\t\tenvVars.vcAuthenticationVerificationMethodId ?? VC_AUTHENTICATION_VERIFICATION_METHOD_ID\n\t\t\t);\n\t\t}\n\n\t\tawait bootstrapSynchronisedStorage(engineCore, context, envVars, features);\n\t});\n}\n\n/**\n * Bootstrap the node creating any necessary resources.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node. The features that are enabled on the node.\n */\nexport async function bootstrapNodeId(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\tif (features.includes(NodeFeatures.NodeId)) {\n\t\tconst existingNodeId = envVars.nodeIdentity ?? context.state.nodeId;\n\n\t\tcontext.state.nodeId = await createIdentity(\n\t\t\tengineCore,\n\t\t\tenvVars,\n\t\t\texistingNodeId,\n\t\t\tenvVars.nodeMnemonic,\n\t\t\texistingNodeId,\n\t\t\t\"node\",\n\t\t\tfeatures.includes(NodeFeatures.NodeWallet)\n\t\t);\n\t\tcontext.stateDirty = true;\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"node.nodeId\", {\n\t\t\t\tidentity: context.state.nodeId\n\t\t\t})\n\t\t);\n\n\t\tengineCore.addContextId(ContextIdKeys.Node, context.state.nodeId);\n\t}\n}\n\n/**\n * Bootstrap the node creating any necessary resources.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node. The features that are enabled on the node.\n */\nexport async function bootstrapTenantId(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\t// If tenants are enabled we need to add a context id for the node\n\t// so that services such a logging have a default tenant context id\n\t// this will get overwritten by any incoming API requests with the tenant context id\n\tif (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tlet tenantId = envVars.tenantId ?? context.state.nodeTenantId;\n\n\t\tif (!Is.stringValue(tenantId)) {\n\t\t\tconst tenantAdminServiceComponentType =\n\t\t\t\tengineCore.getRegisteredInstanceType(\"tenantAdminComponent\");\n\n\t\t\tconst tenantAdminService = ComponentFactory.get<ITenantAdminComponent>(\n\t\t\t\ttenantAdminServiceComponentType\n\t\t\t);\n\n\t\t\ttenantId = TenantIdHelper.generateTenantId();\n\t\t\tconst apiKey = envVars.tenantApiKey ?? TenantIdHelper.generateApiKey();\n\n\t\t\tawait tenantAdminService.set({\n\t\t\t\tid: tenantId,\n\t\t\t\tapiKey,\n\t\t\t\tdateCreated: new Date(Date.now()).toISOString(),\n\t\t\t\tlabel: \"node-tenant\"\n\t\t\t});\n\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.createdTenantId\", {\n\t\t\t\t\tidentity: tenantId,\n\t\t\t\t\tapiKey\n\t\t\t\t})\n\t\t\t);\n\t\t} else {\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.existingTenantId\", {\n\t\t\t\t\tidentity: context.state.nodeTenantId\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tcontext.state.nodeTenantId = tenantId;\n\t\tcontext.stateDirty = true;\n\n\t\tengineCore.addContextId(ContextIdKeys.Tenant, context.state.nodeTenantId);\n\t}\n}\n\n/**\n * Bootstrap the user.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node.\n */\nexport async function bootstrapNodeAdminUser(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\tif (features.includes(NodeFeatures.NodeAdminUser)) {\n\t\tcontext.state.nodeOrganizationId =\n\t\t\tenvVars.organizationIdentity ?? context.state.nodeOrganizationId;\n\t\tcontext.state.nodeAdminUserId = envVars.adminUserIdentity ?? context.state.nodeAdminUserId;\n\n\t\tconst defaultAuthenticationComponentType =\n\t\t\tengineCore.getRegisteredInstanceType(\"authenticationComponent\");\n\t\tif (\n\t\t\tdefaultAuthenticationComponentType.startsWith(AuthenticationComponentType.EntityStorage) &&\n\t\t\tIs.stringValue(context.state.nodeId)\n\t\t) {\n\t\t\tconst authUserEntityStorage =\n\t\t\t\tEntityStorageConnectorFactory.get<IEntityStorageConnector<AuthenticationUser>>(\n\t\t\t\t\tnameofKebabCase<AuthenticationUser>()\n\t\t\t\t);\n\n\t\t\t// If we don't have an organization identity, create one\n\t\t\tif (!Is.stringValue(context.state.nodeOrganizationId)) {\n\t\t\t\tcontext.state.nodeOrganizationId = await createIdentity(\n\t\t\t\t\tengineCore,\n\t\t\t\t\tenvVars,\n\t\t\t\t\tcontext.state.nodeOrganizationId,\n\t\t\t\t\tenvVars.organizationMnemonic,\n\t\t\t\t\tcontext.state.nodeId,\n\t\t\t\t\t\"organization\",\n\t\t\t\t\tfeatures.includes(NodeFeatures.NodeWallet)\n\t\t\t\t);\n\t\t\t\tcontext.stateDirty = true;\n\t\t\t}\n\n\t\t\tif (!Is.stringValue(context.state.nodeAdminUserId)) {\n\t\t\t\tcontext.state.nodeAdminUserId = await createIdentity(\n\t\t\t\t\tengineCore,\n\t\t\t\t\tenvVars,\n\t\t\t\t\tcontext.state.nodeAdminUserId,\n\t\t\t\t\tenvVars.adminUserMnemonic,\n\t\t\t\t\tcontext.state.nodeOrganizationId,\n\t\t\t\t\t\"user\",\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tcontext.stateDirty = true;\n\t\t\t}\n\n\t\t\tconst adminEmail = envVars.adminUserName ?? DEFAULT_NODE_ADMIN_USERNAME;\n\n\t\t\tlet nodeAdminUser = await authUserEntityStorage.get(adminEmail);\n\n\t\t\t// If the node admin user doesn't exist, create it\n\t\t\tif (Is.empty(nodeAdminUser)) {\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.creatingUser\", { email: adminEmail }));\n\n\t\t\t\tconst generatedPassword = envVars.adminUserPassword ?? PasswordGenerator.generate(16);\n\t\t\t\tconst passwordBytes = Converter.utf8ToBytes(generatedPassword);\n\t\t\t\tconst saltBytes = RandomHelper.generate(16);\n\t\t\t\tconst hashedPassword = await PasswordHelper.hashPassword(passwordBytes, saltBytes);\n\n\t\t\t\tnodeAdminUser = {\n\t\t\t\t\temail: adminEmail,\n\t\t\t\t\tpassword: hashedPassword,\n\t\t\t\t\tsalt: Converter.bytesToBase64(saltBytes),\n\t\t\t\t\tidentity: context.state.nodeAdminUserId,\n\t\t\t\t\torganization: context.state.nodeOrganizationId\n\t\t\t\t};\n\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.nodeAdminUserEmail\", { email: adminEmail }));\n\t\t\t\tengineCore.logInfo(\n\t\t\t\t\tI18n.formatMessage(\"node.nodeAdminUserPassword\", { password: generatedPassword })\n\t\t\t\t);\n\n\t\t\t\tawait authUserEntityStorage.set(nodeAdminUser);\n\t\t\t} else {\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingUser\", { email: adminEmail }));\n\n\t\t\t\t// The user already exists, so double check the other details match\n\t\t\t\tlet needsUpdate = false;\n\n\t\t\t\tif (nodeAdminUser.identity !== context.state.nodeAdminUserId) {\n\t\t\t\t\tnodeAdminUser.identity = context.state.nodeAdminUserId;\n\t\t\t\t\tneedsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tif (Is.stringValue(envVars.adminUserPassword)) {\n\t\t\t\t\tconst passwordBytes = Converter.utf8ToBytes(envVars.adminUserPassword);\n\t\t\t\t\tconst saltBytes = Converter.base64ToBytes(nodeAdminUser.salt);\n\t\t\t\t\tconst hashedPassword = await PasswordHelper.hashPassword(passwordBytes, saltBytes);\n\n\t\t\t\t\tif (nodeAdminUser.password !== hashedPassword) {\n\t\t\t\t\t\tnodeAdminUser.password = hashedPassword;\n\t\t\t\t\t\tneedsUpdate = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (needsUpdate) {\n\t\t\t\t\tawait authUserEntityStorage.set(nodeAdminUser);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// We have create a node user, now we need to create a profile for the user\n\t\t\tconst defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\t\t\"identityProfileConnector\"\n\t\t\t);\n\t\t\tconst identityProfileConnector = IdentityProfileConnectorFactory.get(\n\t\t\t\tdefaultIdentityProfileConnectorType\n\t\t\t);\n\n\t\t\tif (identityProfileConnector) {\n\t\t\t\t// Add the organization context id when creating the profile\n\t\t\t\t// so that it is partitioned under the organization\n\t\t\t\tconst contextIds = (await ContextIdStore.getContextIds()) ?? {};\n\t\t\t\tcontextIds[ContextIdKeys.Organization] = context.state.nodeOrganizationId;\n\t\t\t\tawait ContextIdStore.run(contextIds, async () => {\n\t\t\t\t\tlet userProfile;\n\t\t\t\t\tif (Is.stringValue(nodeAdminUser.identity)) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tuserProfile = await identityProfileConnector.get(nodeAdminUser.identity);\n\t\t\t\t\t\t} catch {}\n\t\t\t\t\t}\n\t\t\t\t\tif (Is.empty(userProfile)) {\n\t\t\t\t\t\tengineCore.logInfo(\n\t\t\t\t\t\t\tI18n.formatMessage(\"node.creatingUserProfile\", {\n\t\t\t\t\t\t\t\tidentity: nodeAdminUser.identity\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst publicProfile: WithContext<Person> = {\n\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\tname: \"Node Administrator\"\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst privateProfile: WithContext<Person> = {\n\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\tgivenName: \"Node\",\n\t\t\t\t\t\t\tfamilyName: \"Administrator\",\n\t\t\t\t\t\t\temail: adminEmail\n\t\t\t\t\t\t};\n\t\t\t\t\t\tawait identityProfileConnector.create(\n\t\t\t\t\t\t\tnodeAdminUser.identity,\n\t\t\t\t\t\t\tpublicProfile,\n\t\t\t\t\t\t\tprivateProfile\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tengineCore.logInfo(\n\t\t\t\t\t\t\tI18n.formatMessage(\"node.existingUserProfile\", {\n\t\t\t\t\t\t\t\tidentity: nodeAdminUser.identity\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Bootstrap the immutable proof verification methods.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node.\n */\nexport async function bootstrapImmutableProofMethod(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {}\n\n/**\n * Bootstrap the keys for blob encryption.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node.\n */\nexport async function bootstrapBlobEncryption(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\tif (\n\t\t(Coerce.boolean(envVars.blobStorageEnableEncryption) ?? false) &&\n\t\tIs.stringValue(context.state.nodeOrganizationId)\n\t) {\n\t\t// Create a new key for encrypting blobs\n\t\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\t\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\t\tconst keyName = `${context.state.nodeOrganizationId}/${envVars.blobStorageEncryptionKeyId ?? BLOB_STORAGE_ENCRYPTION_KEY_ID}`;\n\n\t\tlet existingKey;\n\n\t\ttry {\n\t\t\texistingKey = await vaultConnector.getKey(keyName);\n\t\t} catch {}\n\n\t\tif (Is.empty(existingKey)) {\n\t\t\tif (Is.stringBase64(envVars.blobStorageSymmetricEncryptionKey)) {\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.addingBlobEncryptionKey\", { keyName }));\n\t\t\t\tawait vaultConnector.addKey(\n\t\t\t\t\tkeyName,\n\t\t\t\t\tVaultKeyType.ChaCha20Poly1305,\n\t\t\t\t\tConverter.base64ToBytes(envVars.blobStorageSymmetricEncryptionKey)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.creatingBlobEncryptionKey\", { keyName }));\n\t\t\t\tconst key = await vaultConnector.createKey(keyName, VaultKeyType.ChaCha20Poly1305);\n\t\t\t\tengineCore.logInfo(\n\t\t\t\t\tI18n.formatMessage(\"node.createdBlobEncryptionKey\", {\n\t\t\t\t\t\tkeyName,\n\t\t\t\t\t\tkeyValue: Converter.bytesToBase64(key)\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingBlobEncryptionKey\", { keyName }));\n\t\t}\n\t}\n}\n\n/**\n * Bootstrap the JWT signing key.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node.\n */\nexport async function bootstrapAuth(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\tconst defaultAuthenticationComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"authenticationComponent\");\n\tif (\n\t\tIs.stringValue(defaultAuthenticationComponentType) &&\n\t\tdefaultAuthenticationComponentType.startsWith(AuthenticationComponentType.EntityStorage) &&\n\t\tIs.stringValue(context.state.nodeId)\n\t) {\n\t\t// Create a new JWT signing key and a user login for the node\n\t\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\t\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\t\tconst keyName = `${context.state.nodeId}/${envVars.authSigningKeyId ?? AUTH_SIGNING_KEY_ID}`;\n\n\t\tlet existingKey;\n\t\ttry {\n\t\t\texistingKey = await vaultConnector.getKey(keyName);\n\t\t} catch {}\n\n\t\tif (Is.empty(existingKey)) {\n\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.creatingAuthKey\", { keyName }));\n\t\t\tawait vaultConnector.createKey(keyName, VaultKeyType.Ed25519);\n\t\t} else {\n\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingAuthKey\", { keyName }));\n\t\t}\n\t}\n}\n\n/**\n * Bootstrap the synchronised storage blob encryption and verification methods.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node.\n */\nexport async function bootstrapSynchronisedStorage(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\tif (Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false) {\n\t\t// If this is a trusted node we need to add the blob encryption key pair\n\t\tif (Is.stringBase64(envVars.synchronisedStorageBlobStorageKey)) {\n\t\t\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\t\t\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\t\t\tconst keyName =\n\t\t\t\tenvVars.synchronisedStorageBlobStorageEncryptionKeyId ??\n\t\t\t\tSYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID;\n\t\t\tlet existingKey;\n\n\t\t\ttry {\n\t\t\t\texistingKey = await vaultConnector.getKey(keyName);\n\t\t\t} catch {}\n\n\t\t\tif (Is.empty(existingKey)) {\n\t\t\t\tengineCore.logInfo(\n\t\t\t\t\tI18n.formatMessage(\"node.addingSynchronisedStorageBlobEncryptionKey\", { keyName })\n\t\t\t\t);\n\t\t\t\tawait vaultConnector.addKey(\n\t\t\t\t\tkeyName,\n\t\t\t\t\tVaultKeyType.ChaCha20Poly1305,\n\t\t\t\t\tConverter.base64ToBytes(envVars.synchronisedStorageBlobStorageKey)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tengineCore.logInfo(\n\t\t\t\t\tI18n.formatMessage(\"node.existingSynchronisedStorageBlobEncryptionKey\", { keyName })\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Add a verification method if it doesn't exist.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param identity The identity to add the verification method to.\n * @param verificationMethodTitle The verification method title.\n * @param verificationMethodId The verification method ID.\n */\nasync function addVerificationMethod(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tidentity: string,\n\tverificationMethodTitle: string,\n\tverificationMethodId: string | undefined\n): Promise<void> {\n\tif (\n\t\tIs.stringValue(identity) &&\n\t\tIs.arrayValue(context.config.types.identityConnector) &&\n\t\tIs.stringValue(verificationMethodId)\n\t) {\n\t\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\t\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\t\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\t\"identityResolverConnector\"\n\t\t);\n\t\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\t\tdefaultIdentityResolverConnectorType\n\t\t);\n\n\t\tconst identityDocument = await identityResolverConnector.resolveDocument(identity);\n\n\t\tconst fullMethodId = `${identityDocument.id}#${verificationMethodId}`;\n\n\t\tlet exists = false;\n\t\ttry {\n\t\t\tDocumentHelper.getVerificationMethod(identityDocument, fullMethodId, \"assertionMethod\");\n\t\t\texists = true;\n\t\t} catch {}\n\n\t\tif (!exists) {\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.addingVerificationMethod\", {\n\t\t\t\t\ttitle: verificationMethodTitle,\n\t\t\t\t\tmethodId: fullMethodId\n\t\t\t\t})\n\t\t\t);\n\t\t\tawait identityConnector.addVerificationMethod(\n\t\t\t\tidentity,\n\t\t\t\tidentity,\n\t\t\t\t\"assertionMethod\",\n\t\t\t\tverificationMethodId\n\t\t\t);\n\t\t} else {\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.existingVerificationMethod\", {\n\t\t\t\t\ttitle: verificationMethodTitle,\n\t\t\t\t\tmethodId: fullMethodId\n\t\t\t\t})\n\t\t\t);\n\t\t}\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AAE,uBAAuB;gBAC9B,QAAQ,EAAE,YAAY;aACtB,CAAC,CACF,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { PasswordHelper, type AuthenticationUser } from \"@twin.org/api-auth-entity-storage-service\";\nimport { TenantIdHelper, type ITenantAdminComponent } from \"@twin.org/api-tenant-processor\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, Converter, I18n, Is, RandomHelper } from \"@twin.org/core\";\nimport { PasswordGenerator } from \"@twin.org/crypto\";\nimport type { IEngineCore, IEngineCoreContext } from \"@twin.org/engine-models\";\nimport {\n\tAuthenticationComponentType,\n\ttype IEngineServerConfig\n} from \"@twin.org/engine-server-types\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport {\n\tDocumentHelper,\n\tIdentityConnectorFactory,\n\tIdentityProfileConnectorFactory,\n\tIdentityResolverConnectorFactory\n} from \"@twin.org/identity-models\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport { VaultConnectorFactory, VaultKeyType } from \"@twin.org/vault-models\";\nimport type { Person, WithContext } from \"schema-dts\";\nimport {\n\tATTESTATION_VERIFICATION_METHOD_ID,\n\tAUTH_SIGNING_KEY_ID,\n\tBLOB_STORAGE_ENCRYPTION_KEY_ID,\n\tIMMUTABLE_PROOF_VERIFICATION_METHOD_ID,\n\tSYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID,\n\tVC_AUTHENTICATION_VERIFICATION_METHOD_ID\n} from \"./defaults.js\";\nimport { createIdentity } from \"./identity.js\";\nimport type { INodeEngineState } from \"./models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"./models/INodeEnvironmentVariables.js\";\nimport { NodeFeatures } from \"./models/nodeFeatures.js\";\nimport { getFeatures } from \"./utils.js\";\n\nconst DEFAULT_NODE_ADMIN_USERNAME = \"admin@node\";\n\n/**\n * Bootstrap the application.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n */\nexport async function bootstrap(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables\n): Promise<void> {\n\tconst features = getFeatures(envVars);\n\n\tawait bootstrapNodeId(engineCore, context, envVars, features);\n\n\tawait ContextIdStore.run(engineCore.getContextIds() ?? {}, async () => {\n\t\tawait bootstrapTenantId(engineCore, context, envVars, features);\n\n\t\tawait bootstrapNodeAdminUser(engineCore, context, envVars, features);\n\t\tawait bootstrapAuth(engineCore, context, envVars, features);\n\t\tawait bootstrapBlobEncryption(engineCore, context, envVars, features);\n\n\t\tconst defaultAttestationConnectorType =\n\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"attestationConnector\");\n\t\tif (\n\t\t\t!Is.empty(defaultAttestationConnectorType) &&\n\t\t\tIs.stringValue(context.state.nodeOrganizationId)\n\t\t) {\n\t\t\tawait addVerificationMethod(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcontext.state.nodeOrganizationId,\n\t\t\t\t\"attestation\",\n\t\t\t\tenvVars.attestationVerificationMethodId ?? ATTESTATION_VERIFICATION_METHOD_ID\n\t\t\t);\n\t\t}\n\n\t\tconst defaultImmutableProofComponentType =\n\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"immutableProofComponent\");\n\n\t\tif (\n\t\t\t!Is.empty(defaultImmutableProofComponentType) &&\n\t\t\tIs.stringValue(context.state.nodeOrganizationId)\n\t\t) {\n\t\t\tawait addVerificationMethod(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcontext.state.nodeOrganizationId,\n\t\t\t\t\"immutable proof\",\n\t\t\t\tenvVars.immutableProofVerificationMethodId ?? IMMUTABLE_PROOF_VERIFICATION_METHOD_ID\n\t\t\t);\n\t\t}\n\n\t\tif (\n\t\t\t(Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) &&\n\t\t\tIs.stringValue(context.state.nodeId)\n\t\t) {\n\t\t\tawait addVerificationMethod(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcontext.state.nodeId,\n\t\t\t\t\"verifiable credential authentication\",\n\t\t\t\tenvVars.vcAuthenticationVerificationMethodId ?? VC_AUTHENTICATION_VERIFICATION_METHOD_ID\n\t\t\t);\n\t\t}\n\n\t\tawait bootstrapSynchronisedStorage(engineCore, context, envVars, features);\n\t});\n}\n\n/**\n * Bootstrap the node creating any necessary resources.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node. The features that are enabled on the node.\n */\nexport async function bootstrapNodeId(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\tif (features.includes(NodeFeatures.NodeId)) {\n\t\tconst existingNodeId = envVars.nodeIdentity ?? context.state.nodeId;\n\n\t\tcontext.state.nodeId = await createIdentity(\n\t\t\tengineCore,\n\t\t\tenvVars,\n\t\t\texistingNodeId,\n\t\t\tenvVars.nodeMnemonic,\n\t\t\texistingNodeId,\n\t\t\t\"node\",\n\t\t\tfeatures.includes(NodeFeatures.NodeWallet)\n\t\t);\n\t\tcontext.stateDirty = true;\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"node.nodeId\", {\n\t\t\t\tidentity: context.state.nodeId\n\t\t\t})\n\t\t);\n\n\t\tengineCore.addContextId(ContextIdKeys.Node, context.state.nodeId);\n\t}\n}\n\n/**\n * Bootstrap the node creating any necessary resources.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node. The features that are enabled on the node.\n */\nexport async function bootstrapTenantId(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\t// If tenants are enabled we need to add a context id for the node\n\t// so that services such a logging have a default tenant context id\n\t// this will get overwritten by any incoming API requests with the tenant context id\n\tif (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tlet tenantId = envVars.tenantId ?? context.state.nodeTenantId;\n\n\t\tif (!Is.stringValue(tenantId)) {\n\t\t\tconst tenantAdminServiceComponentType =\n\t\t\t\tengineCore.getRegisteredInstanceType(\"tenantAdminComponent\");\n\n\t\t\tconst tenantAdminService = ComponentFactory.get<ITenantAdminComponent>(\n\t\t\t\ttenantAdminServiceComponentType\n\t\t\t);\n\n\t\t\ttenantId = TenantIdHelper.generateTenantId();\n\t\t\tconst apiKey = envVars.tenantApiKey ?? TenantIdHelper.generateApiKey();\n\n\t\t\tawait tenantAdminService.set({\n\t\t\t\tid: tenantId,\n\t\t\t\tapiKey,\n\t\t\t\tdateCreated: new Date(Date.now()).toISOString(),\n\t\t\t\tlabel: \"node-tenant\"\n\t\t\t});\n\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.createdTenantId\", {\n\t\t\t\t\tidentity: tenantId,\n\t\t\t\t\tapiKey\n\t\t\t\t})\n\t\t\t);\n\t\t} else {\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.existingTenantId\", {\n\t\t\t\t\tidentity: context.state.nodeTenantId\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tcontext.state.nodeTenantId = tenantId;\n\t\tcontext.stateDirty = true;\n\n\t\tengineCore.addContextId(ContextIdKeys.Tenant, context.state.nodeTenantId);\n\t}\n}\n\n/**\n * Bootstrap the user.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node.\n */\nexport async function bootstrapNodeAdminUser(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\tif (features.includes(NodeFeatures.NodeAdminUser)) {\n\t\tcontext.state.nodeOrganizationId =\n\t\t\tenvVars.organizationIdentity ?? context.state.nodeOrganizationId;\n\t\tcontext.state.nodeAdminUserId = envVars.adminUserIdentity ?? context.state.nodeAdminUserId;\n\n\t\tconst defaultAuthenticationComponentType =\n\t\t\tengineCore.getRegisteredInstanceType(\"authenticationComponent\");\n\t\tif (\n\t\t\tdefaultAuthenticationComponentType.startsWith(AuthenticationComponentType.EntityStorage) &&\n\t\t\tIs.stringValue(context.state.nodeId)\n\t\t) {\n\t\t\tconst authUserEntityStorage =\n\t\t\t\tEntityStorageConnectorFactory.get<IEntityStorageConnector<AuthenticationUser>>(\n\t\t\t\t\tnameofKebabCase<AuthenticationUser>()\n\t\t\t\t);\n\n\t\t\tconst existingOrganizationId =\n\t\t\t\tenvVars.organizationIdentity ?? context.state.nodeOrganizationId;\n\n\t\t\tconst orgId = await createIdentity(\n\t\t\t\tengineCore,\n\t\t\t\tenvVars,\n\t\t\t\texistingOrganizationId,\n\t\t\t\tenvVars.organizationMnemonic,\n\t\t\t\texistingOrganizationId,\n\t\t\t\t\"organization\",\n\t\t\t\tfeatures.includes(NodeFeatures.NodeWallet)\n\t\t\t);\n\t\t\tif (context.state.nodeOrganizationId !== orgId) {\n\t\t\t\tcontext.state.nodeOrganizationId = orgId;\n\t\t\t\tcontext.stateDirty = true;\n\t\t\t}\n\n\t\t\tconst userId = await createIdentity(\n\t\t\t\tengineCore,\n\t\t\t\tenvVars,\n\t\t\t\tcontext.state.nodeAdminUserId,\n\t\t\t\tenvVars.adminUserMnemonic,\n\t\t\t\tcontext.state.nodeOrganizationId,\n\t\t\t\t\"user\",\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tif (context.state.nodeAdminUserId !== userId) {\n\t\t\t\tcontext.state.nodeAdminUserId = userId;\n\t\t\t\tcontext.stateDirty = true;\n\t\t\t}\n\n\t\t\tconst adminEmail = envVars.adminUserName ?? DEFAULT_NODE_ADMIN_USERNAME;\n\n\t\t\tlet nodeAdminUser = await authUserEntityStorage.get(adminEmail);\n\n\t\t\t// If the node admin user doesn't exist, create it\n\t\t\tif (Is.empty(nodeAdminUser)) {\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.creatingUser\", { email: adminEmail }));\n\n\t\t\t\tconst generatedPassword = envVars.adminUserPassword ?? PasswordGenerator.generate(16);\n\t\t\t\tconst passwordBytes = Converter.utf8ToBytes(generatedPassword);\n\t\t\t\tconst saltBytes = RandomHelper.generate(16);\n\t\t\t\tconst hashedPassword = await PasswordHelper.hashPassword(passwordBytes, saltBytes);\n\n\t\t\t\tnodeAdminUser = {\n\t\t\t\t\temail: adminEmail,\n\t\t\t\t\tpassword: hashedPassword,\n\t\t\t\t\tsalt: Converter.bytesToBase64(saltBytes),\n\t\t\t\t\tidentity: context.state.nodeAdminUserId,\n\t\t\t\t\torganization: context.state.nodeOrganizationId\n\t\t\t\t};\n\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.nodeAdminUserEmail\", { email: adminEmail }));\n\n\t\t\t\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\t\t\t\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\t\t\t\tconst vaultKey = `${context.state.nodeAdminUserId}/admin-password`;\n\t\t\t\tawait vaultConnector.setSecret<string>(vaultKey, generatedPassword);\n\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.nodeAdminUserPassword\", { vaultKey }));\n\n\t\t\t\tawait authUserEntityStorage.set(nodeAdminUser);\n\t\t\t} else {\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingUser\", { email: adminEmail }));\n\n\t\t\t\t// The user already exists, so double check the other details match\n\t\t\t\tlet needsUpdate = false;\n\n\t\t\t\tif (nodeAdminUser.identity !== context.state.nodeAdminUserId) {\n\t\t\t\t\tnodeAdminUser.identity = context.state.nodeAdminUserId;\n\t\t\t\t\tneedsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tif (Is.stringValue(envVars.adminUserPassword)) {\n\t\t\t\t\tconst passwordBytes = Converter.utf8ToBytes(envVars.adminUserPassword);\n\t\t\t\t\tconst saltBytes = Converter.base64ToBytes(nodeAdminUser.salt);\n\t\t\t\t\tconst hashedPassword = await PasswordHelper.hashPassword(passwordBytes, saltBytes);\n\n\t\t\t\t\tif (nodeAdminUser.password !== hashedPassword) {\n\t\t\t\t\t\tnodeAdminUser.password = hashedPassword;\n\t\t\t\t\t\tneedsUpdate = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (needsUpdate) {\n\t\t\t\t\tawait authUserEntityStorage.set(nodeAdminUser);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// We have create a node user, now we need to create a profile for the user\n\t\t\tconst defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\t\t\"identityProfileConnector\"\n\t\t\t);\n\t\t\tconst identityProfileConnector = IdentityProfileConnectorFactory.get(\n\t\t\t\tdefaultIdentityProfileConnectorType\n\t\t\t);\n\n\t\t\tif (identityProfileConnector) {\n\t\t\t\t// Add the organization context id when creating the profile\n\t\t\t\t// so that it is partitioned under the organization\n\t\t\t\tconst contextIds = (await ContextIdStore.getContextIds()) ?? {};\n\t\t\t\tcontextIds[ContextIdKeys.Organization] = context.state.nodeOrganizationId;\n\t\t\t\tawait ContextIdStore.run(contextIds, async () => {\n\t\t\t\t\tlet userProfile;\n\t\t\t\t\tif (Is.stringValue(nodeAdminUser.identity)) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tuserProfile = await identityProfileConnector.get(nodeAdminUser.identity);\n\t\t\t\t\t\t} catch {}\n\t\t\t\t\t}\n\t\t\t\t\tif (Is.empty(userProfile)) {\n\t\t\t\t\t\tengineCore.logInfo(\n\t\t\t\t\t\t\tI18n.formatMessage(\"node.creatingUserProfile\", {\n\t\t\t\t\t\t\t\tidentity: nodeAdminUser.identity\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst publicProfile: WithContext<Person> = {\n\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\tname: \"Node Administrator\"\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst privateProfile: WithContext<Person> = {\n\t\t\t\t\t\t\t\"@context\": \"https://schema.org\",\n\t\t\t\t\t\t\t\"@type\": \"Person\",\n\t\t\t\t\t\t\tgivenName: \"Node\",\n\t\t\t\t\t\t\tfamilyName: \"Administrator\",\n\t\t\t\t\t\t\temail: adminEmail\n\t\t\t\t\t\t};\n\t\t\t\t\t\tawait identityProfileConnector.create(\n\t\t\t\t\t\t\tnodeAdminUser.identity,\n\t\t\t\t\t\t\tpublicProfile,\n\t\t\t\t\t\t\tprivateProfile\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tengineCore.logInfo(\n\t\t\t\t\t\t\tI18n.formatMessage(\"node.existingUserProfile\", {\n\t\t\t\t\t\t\t\tidentity: nodeAdminUser.identity\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Bootstrap the immutable proof verification methods.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node.\n */\nexport async function bootstrapImmutableProofMethod(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {}\n\n/**\n * Bootstrap the keys for blob encryption.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node.\n */\nexport async function bootstrapBlobEncryption(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\tif (\n\t\t(Coerce.boolean(envVars.blobStorageEnableEncryption) ?? false) &&\n\t\tIs.stringValue(context.state.nodeOrganizationId)\n\t) {\n\t\t// Create a new key for encrypting blobs\n\t\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\t\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\t\tconst keyName = `${context.state.nodeOrganizationId}/${envVars.blobStorageEncryptionKeyId ?? BLOB_STORAGE_ENCRYPTION_KEY_ID}`;\n\n\t\tlet existingKey;\n\n\t\ttry {\n\t\t\texistingKey = await vaultConnector.getKey(keyName);\n\t\t} catch {}\n\n\t\tif (Is.empty(existingKey)) {\n\t\t\tif (Is.stringBase64(envVars.blobStorageSymmetricEncryptionKey)) {\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.addingBlobEncryptionKey\", { keyName }));\n\t\t\t\tawait vaultConnector.addKey(\n\t\t\t\t\tkeyName,\n\t\t\t\t\tVaultKeyType.ChaCha20Poly1305,\n\t\t\t\t\tConverter.base64ToBytes(envVars.blobStorageSymmetricEncryptionKey)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.creatingBlobEncryptionKey\", { keyName }));\n\t\t\t\tconst key = await vaultConnector.createKey(keyName, VaultKeyType.ChaCha20Poly1305);\n\t\t\t\tengineCore.logInfo(\n\t\t\t\t\tI18n.formatMessage(\"node.createdBlobEncryptionKey\", {\n\t\t\t\t\t\tkeyName,\n\t\t\t\t\t\tkeyValue: Converter.bytesToBase64(key)\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingBlobEncryptionKey\", { keyName }));\n\t\t}\n\t}\n}\n\n/**\n * Bootstrap the JWT signing key.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node.\n */\nexport async function bootstrapAuth(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\tconst defaultAuthenticationComponentType =\n\t\tengineCore.getRegisteredInstanceTypeOptional(\"authenticationComponent\");\n\tif (\n\t\tIs.stringValue(defaultAuthenticationComponentType) &&\n\t\tdefaultAuthenticationComponentType.startsWith(AuthenticationComponentType.EntityStorage) &&\n\t\tIs.stringValue(context.state.nodeId)\n\t) {\n\t\t// Create a new JWT signing key and a user login for the node\n\t\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\t\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\t\tconst keyName = `${context.state.nodeId}/${envVars.authSigningKeyId ?? AUTH_SIGNING_KEY_ID}`;\n\n\t\tlet existingKey;\n\t\ttry {\n\t\t\texistingKey = await vaultConnector.getKey(keyName);\n\t\t} catch {}\n\n\t\tif (Is.empty(existingKey)) {\n\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.creatingAuthKey\", { keyName }));\n\t\t\tawait vaultConnector.createKey(keyName, VaultKeyType.Ed25519);\n\t\t} else {\n\t\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingAuthKey\", { keyName }));\n\t\t}\n\t}\n}\n\n/**\n * Bootstrap the synchronised storage blob encryption and verification methods.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param envVars The environment variables for the node.\n * @param features The features that are enabled on the node.\n */\nexport async function bootstrapSynchronisedStorage(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\tfeatures: NodeFeatures[]\n): Promise<void> {\n\tif (Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false) {\n\t\t// If this is a trusted node we need to add the blob encryption key pair\n\t\tif (Is.stringBase64(envVars.synchronisedStorageBlobStorageKey)) {\n\t\t\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\t\t\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\t\t\tconst keyName =\n\t\t\t\tenvVars.synchronisedStorageBlobStorageEncryptionKeyId ??\n\t\t\t\tSYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID;\n\t\t\tlet existingKey;\n\n\t\t\ttry {\n\t\t\t\texistingKey = await vaultConnector.getKey(keyName);\n\t\t\t} catch {}\n\n\t\t\tif (Is.empty(existingKey)) {\n\t\t\t\tengineCore.logInfo(\n\t\t\t\t\tI18n.formatMessage(\"node.addingSynchronisedStorageBlobEncryptionKey\", { keyName })\n\t\t\t\t);\n\t\t\t\tawait vaultConnector.addKey(\n\t\t\t\t\tkeyName,\n\t\t\t\t\tVaultKeyType.ChaCha20Poly1305,\n\t\t\t\t\tConverter.base64ToBytes(envVars.synchronisedStorageBlobStorageKey)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tengineCore.logInfo(\n\t\t\t\t\tI18n.formatMessage(\"node.existingSynchronisedStorageBlobEncryptionKey\", { keyName })\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Add a verification method if it doesn't exist.\n * @param engineCore The engine core for the node.\n * @param context The context for the node.\n * @param identity The identity to add the verification method to.\n * @param verificationMethodTitle The verification method title.\n * @param verificationMethodId The verification method ID.\n */\nasync function addVerificationMethod(\n\tengineCore: IEngineCore,\n\tcontext: IEngineCoreContext<IEngineServerConfig, INodeEngineState>,\n\tidentity: string,\n\tverificationMethodTitle: string,\n\tverificationMethodId: string | undefined\n): Promise<void> {\n\tif (\n\t\tIs.stringValue(identity) &&\n\t\tIs.arrayValue(context.config.types.identityConnector) &&\n\t\tIs.stringValue(verificationMethodId)\n\t) {\n\t\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\t\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\t\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\t\"identityResolverConnector\"\n\t\t);\n\t\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\t\tdefaultIdentityResolverConnectorType\n\t\t);\n\n\t\tconst identityDocument = await identityResolverConnector.resolveDocument(identity);\n\n\t\tconst fullMethodId = `${identityDocument.id}#${verificationMethodId}`;\n\n\t\tlet exists = false;\n\t\ttry {\n\t\t\tDocumentHelper.getVerificationMethod(identityDocument, fullMethodId, \"assertionMethod\");\n\t\t\texists = true;\n\t\t} catch {}\n\n\t\tif (!exists) {\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.addingVerificationMethod\", {\n\t\t\t\t\ttitle: verificationMethodTitle,\n\t\t\t\t\tmethodId: fullMethodId\n\t\t\t\t})\n\t\t\t);\n\t\t\tawait identityConnector.addVerificationMethod(\n\t\t\t\tidentity,\n\t\t\t\tidentity,\n\t\t\t\t\"assertionMethod\",\n\t\t\t\tverificationMethodId\n\t\t\t);\n\t\t} else {\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.existingVerificationMethod\", {\n\t\t\t\t\ttitle: verificationMethodTitle,\n\t\t\t\t\tmethodId: fullMethodId\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -84,7 +84,8 @@ async function configureEntityStorage(coreConfig, envVars) {
|
|
|
84
84
|
authMode: envVars.awsDynamodbAuthMode,
|
|
85
85
|
accessKeyId: envVars.awsDynamodbAccessKeyId,
|
|
86
86
|
secretAccessKey: envVars.awsDynamodbSecretAccessKey,
|
|
87
|
-
endpoint: envVars.awsDynamodbEndpoint
|
|
87
|
+
endpoint: envVars.awsDynamodbEndpoint,
|
|
88
|
+
connectionTimeoutMs: Coerce.integer(envVars.awsDynamodbConnectionTimeoutMs)
|
|
88
89
|
},
|
|
89
90
|
tablePrefix: envVars.entityStorageTablePrefix
|
|
90
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engineEnvBuilder.js","sourceRoot":"","sources":["../../../src/builders/engineEnvBuilder.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAG5C,OAAO,EACN,wBAAwB,EACxB,wBAAwB,EACxB,+BAA+B,EAC/B,gCAAgC,EAChC,oCAAoC,EACpC,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,+BAA+B,EAE/B,aAAa,EACb,+BAA+B,EAC/B,gBAAgB,EAChB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,+BAA+B,EAC/B,qBAAqB,EACrB,qBAAqB,EACrB,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAE7B,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,sCAAsC,EACtC,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,gCAAgC,EAChC,gCAAgC,EAChC,gCAAgC,EAChC,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,gCAAgC,EAChC,gCAAgC,EAChC,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB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AAC;IACJ,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,YAAY,CAC1B,UAAyB,EACzB,OAAoC;IAEpC,oFAAoF;IACpF,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACrF,UAAU,CAAC,KAAK,CAAC,SAAS,KAAK,EAAE,CAAC;QAElC,MAAM,gBAAgB,GACrB,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,sBAAsB,CAAC;YAC9C,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,uBAAuB,CAAC;YAC9C,CAAC,CAAC;gBACA,aAAa,EAAE,OAAO,CAAC,sBAAsB;gBAC7C,mBAAmB,EAAE,OAAO,CAAC,uBAAuB;aACpD;YACF,CAAC,CAAC,SAAS,CAAC;QAEd,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;YAC/B,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,SAAS,EAAE,IAAI;YACf,OAAO,EAAE;gBACR,MAAM,EAAE;oBACP,aAAa,EAAE;wBACd,GAAG,EAAE,OAAO,CAAC,gBAAgB,IAAI,EAAE;qBACnC;oBACD,OAAO,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;oBAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;oBAC7C,UAAU,EAAE,gBAAgB;iBAC5B;aACD;SACD,CAAC,CAAC;IACJ,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport { Coerce, Is } from \"@twin.org/core\";\nimport type { IIotaConfig } from \"@twin.org/dlt-iota\";\nimport type { IEngineModuleConfig } from \"@twin.org/engine-models\";\nimport {\n\tAttestationComponentType,\n\tAttestationConnectorType,\n\tAuditableItemGraphComponentType,\n\tAuditableItemStreamComponentType,\n\tAuthenticationGeneratorComponentType,\n\tBackgroundTaskConnectorType,\n\tBlobStorageComponentType,\n\tBlobStorageConnectorType,\n\tContextIdHandlerComponentType,\n\tDataConverterConnectorType,\n\tDataExtractorConnectorType,\n\tDataProcessingComponentType,\n\tDataSpaceConnectorComponentType,\n\ttype DltConfig,\n\tDltConfigType,\n\tDocumentManagementComponentType,\n\tEngineTypeHelper,\n\tEntityStorageConnectorType,\n\tEventBusComponentType,\n\tEventBusConnectorType,\n\tFaucetConnectorType,\n\tFederatedCatalogueComponentType,\n\tIdentityComponentType,\n\tIdentityConnectorType,\n\tIdentityProfileComponentType,\n\tIdentityProfileConnectorType,\n\tIdentityResolverComponentType,\n\tIdentityResolverConnectorType,\n\ttype IEngineConfig,\n\tImmutableProofComponentType,\n\tLoggingComponentType,\n\tLoggingConnectorType,\n\tMessagingAdminComponentType,\n\tMessagingComponentType,\n\tMessagingEmailConnectorType,\n\tMessagingPushNotificationConnectorType,\n\tMessagingSmsConnectorType,\n\tNftComponentType,\n\tNftConnectorType,\n\tRightsManagementDapComponentType,\n\tRightsManagementDarpComponentType,\n\tRightsManagementPapComponentType,\n\tRightsManagementPdpComponentType,\n\tRightsManagementPepComponentType,\n\tRightsManagementPipComponentType,\n\tRightsManagementPmpComponentType,\n\tRightsManagementPnapComponentType,\n\tRightsManagementPnpComponentType,\n\tRightsManagementPxpComponentType,\n\tSynchronisedStorageComponentType,\n\tTaskSchedulerComponentType,\n\tTelemetryComponentType,\n\tTelemetryConnectorType,\n\tTenantAdminComponentType,\n\tVaultConnectorType,\n\tVerifiableStorageComponentType,\n\tVerifiableStorageConnectorType,\n\tWalletConnectorType\n} from \"@twin.org/engine-types\";\nimport {\n\tDataAccessPointRestClient,\n\tPolicyNegotiationPointRestClient\n} from \"@twin.org/rights-management-rest-client\";\nimport type { IOdrlOffer } from \"@twin.org/standards-w3c-odrl\";\nimport {\n\tATTESTATION_VERIFICATION_METHOD_ID,\n\tBLOB_STORAGE_ENCRYPTION_KEY_ID,\n\tCONTEXT_ID_HANDLER_FEATURE_DID,\n\tCONTEXT_ID_HANDLER_FEATURE_TENANT,\n\tIMMUTABLE_PROOF_VERIFICATION_METHOD_ID,\n\tSYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID,\n\tVC_AUTHENTICATION_VERIFICATION_METHOD_ID\n} from \"../defaults.js\";\nimport type { IEngineEnvironmentVariables } from \"../models/IEngineEnvironmentVariables.js\";\n\n/**\n * Build the engine core configuration from environment variables.\n * @param envVars The environment variables.\n * @param contextIdKeys The context ID keys.\n * @returns The config for the core.\n */\nexport async function buildEngineConfiguration(\n\tenvVars: IEngineEnvironmentVariables,\n\tcontextIdKeys: { key: string; componentFeatures: string[] }[]\n): Promise<IEngineConfig> {\n\tif (Is.stringValue(envVars.storageFileRoot)) {\n\t\tenvVars.stateFilename ??= \"engine-state.json\";\n\t\tenvVars.storageFileRoot = path.resolve(envVars.storageFileRoot);\n\t\tenvVars.stateFilename = path.join(envVars.storageFileRoot, envVars.stateFilename);\n\t}\n\n\tconst coreConfig: IEngineConfig = {\n\t\tdebug: Coerce.boolean(envVars.debug) ?? false,\n\t\ttypes: {}\n\t};\n\n\tawait configureTenant(coreConfig, envVars);\n\tawait configureContextIdHandlers(coreConfig, envVars);\n\n\tawait configureEntityStorage(coreConfig, envVars);\n\tawait configureBlobStorage(coreConfig, envVars);\n\tawait configureVault(coreConfig, envVars);\n\tawait configureDlt(coreConfig, envVars);\n\n\tawait configureLogging(coreConfig, envVars);\n\tawait configureBackgroundTask(coreConfig, envVars);\n\tawait configureTaskScheduler(coreConfig, envVars);\n\tawait configureEventBus(coreConfig, envVars);\n\tawait configureTelemetry(coreConfig, envVars);\n\tawait configureMessaging(coreConfig, envVars);\n\n\tawait configureFaucet(coreConfig, envVars);\n\tawait configureWallet(coreConfig, envVars);\n\tawait configureNft(coreConfig, envVars);\n\tawait configureVerifiableStorage(coreConfig, envVars);\n\tawait configureIdentity(coreConfig, envVars);\n\tawait configureIdentityResolver(coreConfig, envVars);\n\tawait configureIdentityProfile(coreConfig, envVars);\n\tawait configureAttestation(coreConfig, envVars);\n\tawait configureDataProcessing(coreConfig, envVars);\n\n\tawait configureAuditableItemGraph(coreConfig, envVars);\n\tawait configureAuditableItemStream(coreConfig, envVars);\n\tawait configureDocumentManagement(coreConfig, envVars);\n\tawait configureVerifiableCredentialAuthentication(coreConfig, envVars);\n\tawait configureRightsManagement(coreConfig, envVars);\n\tawait configureSynchronisedStorage(coreConfig, envVars);\n\tawait configureFederatedCatalogue(coreConfig, envVars);\n\tawait configureDataSpaceConnector(coreConfig, envVars);\n\n\treturn coreConfig;\n}\n\n/**\n * Configures the entity storage.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureEntityStorage(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types ??= {};\n\tcoreConfig.types.entityStorageConnector ??= [];\n\n\tconst entityStorageConnectorTypes = envVars.entityStorageConnectorType?.split(\",\") ?? [];\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.Memory)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.Memory\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.File)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.File,\n\t\t\toptions: {\n\t\t\t\tconfig: { directory: envVars.storageFileRoot ?? \"\" },\n\t\t\t\tfolderPrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.AwsDynamoDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.AwsDynamoDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tregion: envVars.awsDynamodbRegion ?? \"\",\n\t\t\t\t\tauthMode: envVars.awsDynamodbAuthMode as \"credentials\" | \"pod\",\n\t\t\t\t\taccessKeyId: envVars.awsDynamodbAccessKeyId,\n\t\t\t\t\tsecretAccessKey: envVars.awsDynamodbSecretAccessKey,\n\t\t\t\t\tendpoint: envVars.awsDynamodbEndpoint\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.AzureCosmosDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.AzureCosmosDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tendpoint: envVars.azureCosmosdbEndpoint ?? \"\",\n\t\t\t\t\tkey: envVars.azureCosmosdbKey ?? \"\",\n\t\t\t\t\tdatabaseId: envVars.azureCosmosdbDatabaseId ?? \"\",\n\t\t\t\t\tcontainerId: envVars.azureCosmosdbContainerId ?? \"\"\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.GcpFirestoreDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.GcpFirestoreDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tprojectId: envVars.gcpFirestoreProjectId ?? \"\",\n\t\t\t\t\tcredentials: envVars.gcpFirestoreCredentials ?? \"\",\n\t\t\t\t\tdatabaseId: envVars.gcpFirestoreDatabaseId ?? \"\",\n\t\t\t\t\tcollectionName: envVars.gcpFirestoreCollectionName ?? \"\",\n\t\t\t\t\tendpoint: envVars.gcpFirestoreApiEndpoint ?? \"\"\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.ScyllaDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.ScyllaDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\thosts: envVars.scylladbHosts?.split(\",\") ?? [],\n\t\t\t\t\tlocalDataCenter: envVars.scylladbLocalDataCenter ?? \"\",\n\t\t\t\t\tkeyspace: envVars.scylladbKeyspace ?? \"\",\n\t\t\t\t\tport: Coerce.integer(envVars.scylladbPort)\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.MySqlDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.MySqlDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\thost: envVars.mySqlHost ?? \"\",\n\t\t\t\t\tport: Coerce.integer(envVars.mySqlPort),\n\t\t\t\t\tuser: envVars.mySqlUser ?? \"\",\n\t\t\t\t\tpassword: envVars.mySqlPassword ?? \"\",\n\t\t\t\t\tdatabase: envVars.mySqlDatabase ?? \"\"\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.MongoDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.MongoDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\thost: envVars.mongoDbHost ?? \"\",\n\t\t\t\t\tport: Coerce.integer(envVars.mongoDbPort),\n\t\t\t\t\tuser: envVars.mongoDbUser ?? \"\",\n\t\t\t\t\tpassword: envVars.mongoDbPassword ?? \"\",\n\t\t\t\t\tdatabase: envVars.mongoDbDatabase ?? \"\"\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.PostgreSql)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.PostgreSql,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\thost: envVars.postgreSqlHost ?? \"\",\n\t\t\t\t\tport: Coerce.integer(envVars.postgreSqlPort),\n\t\t\t\t\tuser: envVars.postgreSqlUser ?? \"\",\n\t\t\t\t\tpassword: envVars.postgreSqlPassword ?? \"\",\n\t\t\t\t\tdatabase: envVars.postgreSqlDatabase ?? \"\"\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tconst defaultEntityStorageConnectorType =\n\t\tenvVars.entityStorageConnectorDefault ?? entityStorageConnectorTypes[0];\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.Synchronised)) {\n\t\t// For synchronised storage we use the default connector as the one we wrap for real DB operations\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.Synchronised,\n\t\t\toptions: {\n\t\t\t\tentityStorageConnectorType: defaultEntityStorageConnectorType\n\t\t\t}\n\t\t});\n\t}\n\n\tif (Is.arrayValue(entityStorageConnectorTypes)) {\n\t\tfor (const config of coreConfig.types.entityStorageConnector) {\n\t\t\tif (config.type === defaultEntityStorageConnectorType) {\n\t\t\t\tconfig.isDefault = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Configures the blob storage.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureBlobStorage(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.blobStorageConnector ??= [];\n\n\tconst blobStorageConnectorTypes = envVars.blobStorageConnectorType?.split(\",\") ?? [];\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.Memory)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.Memory\n\t\t});\n\t}\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.File)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.File,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tdirectory: Is.stringValue(envVars.storageFileRoot)\n\t\t\t\t\t\t? path.join(envVars.storageFileRoot, \"blob-storage\")\n\t\t\t\t\t\t: \"\"\n\t\t\t\t},\n\t\t\t\tstoragePrefix: envVars.blobStoragePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.Ipfs)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.Ipfs,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tapiUrl: envVars.ipfsApiUrl ?? \"\",\n\t\t\t\t\tbearerToken: envVars.ipfsBearerToken\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.AwsS3)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.AwsS3,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tregion: envVars.awsS3Region ?? \"\",\n\t\t\t\t\tbucketName: envVars.awsS3BucketName ?? \"\",\n\t\t\t\t\tauthMode: envVars.awsS3AuthMode as \"credentials\" | \"pod\",\n\t\t\t\t\taccessKeyId: envVars.awsS3AccessKeyId,\n\t\t\t\t\tsecretAccessKey: envVars.awsS3SecretAccessKey,\n\t\t\t\t\tendpoint: envVars.awsS3Endpoint\n\t\t\t\t},\n\t\t\t\tstoragePrefix: envVars.blobStoragePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.AzureStorage)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.AzureStorage,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\taccountName: envVars.azureStorageAccountName ?? \"\",\n\t\t\t\t\taccountKey: envVars.azureStorageAccountKey ?? \"\",\n\t\t\t\t\tcontainerName: envVars.azureStorageContainerName ?? \"\",\n\t\t\t\t\tendpoint: envVars.azureStorageEndpoint ?? \"\"\n\t\t\t\t},\n\t\t\t\tstoragePrefix: envVars.blobStoragePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.GcpStorage)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.GcpStorage,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tprojectId: envVars.gcpStorageProjectId ?? \"\",\n\t\t\t\t\tcredentials: envVars.gcpStorageCredentials ?? \"\",\n\t\t\t\t\tbucketName: envVars.gcpStorageBucketName ?? \"\",\n\t\t\t\t\tapiEndpoint: envVars.gcpFirestoreApiEndpoint\n\t\t\t\t},\n\t\t\t\tstoragePrefix: envVars.blobStoragePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (Is.arrayValue(blobStorageConnectorTypes)) {\n\t\tconst defaultStorageConnectorType =\n\t\t\tenvVars.blobStorageConnectorDefault ?? blobStorageConnectorTypes[0];\n\t\tfor (const config of coreConfig.types.blobStorageConnector) {\n\t\t\tif (config.type === defaultStorageConnectorType) {\n\t\t\t\tconfig.isDefault = true;\n\t\t\t}\n\t\t\t// If this blob storage connector is the one to use for public access\n\t\t\t// then add it as a feature\n\t\t\tif (\n\t\t\t\tIs.stringValue(envVars.blobStorageConnectorPublic) &&\n\t\t\t\tconfig.type === envVars.blobStorageConnectorPublic\n\t\t\t) {\n\t\t\t\tconfig.features ??= [];\n\t\t\t\tconfig.features.push(\"public\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (coreConfig.types.blobStorageConnector.length > 0) {\n\t\tcoreConfig.types.blobStorageComponent ??= [];\n\t\tcoreConfig.types.blobStorageComponent.push({\n\t\t\ttype: BlobStorageComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tvaultKeyId:\n\t\t\t\t\t\t(envVars.blobStorageEnableEncryption ?? false)\n\t\t\t\t\t\t\t? (envVars.blobStorageEncryptionKeyId ?? BLOB_STORAGE_ENCRYPTION_KEY_ID)\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the logging.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureLogging(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.loggingConnector ??= [];\n\n\tconst loggingConnectorTypes = (envVars.loggingConnector ?? \"\").split(\",\");\n\tlet additionalConnectorCount = 0;\n\n\tfor (const loggingConnector of loggingConnectorTypes) {\n\t\tif (loggingConnector === LoggingConnectorType.Console) {\n\t\t\tcoreConfig.types.loggingConnector.push({\n\t\t\t\ttype: LoggingConnectorType.Console,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\ttranslateMessages: true,\n\t\t\t\t\t\thideGroups: true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tadditionalConnectorCount++;\n\t\t} else if (loggingConnector === LoggingConnectorType.EntityStorage) {\n\t\t\tcoreConfig.types.loggingConnector.push({\n\t\t\t\ttype: LoggingConnectorType.EntityStorage\n\t\t\t});\n\t\t\tadditionalConnectorCount++;\n\t\t}\n\t}\n\n\t// If more than one logging connector, then we need to add a multi connector\n\t// and set it as the default one\n\tif (additionalConnectorCount > 1) {\n\t\tcoreConfig.types.loggingConnector.push({\n\t\t\ttype: LoggingConnectorType.Multi,\n\t\t\toptions: {\n\t\t\t\tloggingConnectorTypes\n\t\t\t},\n\t\t\tisDefault: true\n\t\t});\n\t} else if (additionalConnectorCount > 0) {\n\t\t// If only one connector, then we set it as the default one\n\t\tcoreConfig.types.loggingConnector[coreConfig.types.loggingConnector.length - 1].isDefault =\n\t\t\ttrue;\n\t}\n\n\tif (additionalConnectorCount > 0) {\n\t\tcoreConfig.types.loggingComponent ??= [];\n\t\t// We set the isDefault flag so that other components will get this service by default\n\t\t// and not the generic one from the engine core\n\t\tcoreConfig.types.loggingComponent.push({ type: LoggingComponentType.Service, isDefault: true });\n\t}\n}\n\n/**\n * Configures the vault.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureVault(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.vaultConnector ??= [];\n\n\tif (envVars.vaultConnector === VaultConnectorType.EntityStorage) {\n\t\tcoreConfig.types.vaultConnector.push({\n\t\t\ttype: VaultConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.vaultConnector === VaultConnectorType.Hashicorp) {\n\t\tcoreConfig.types.vaultConnector.push({\n\t\t\ttype: VaultConnectorType.Hashicorp,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tendpoint: envVars.hashicorpVaultEndpoint ?? \"\",\n\t\t\t\t\ttoken: envVars.hashicorpVaultToken ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the background task.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureBackgroundTask(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.backgroundTaskConnector ??= [];\n\n\tif (envVars.backgroundTaskConnector === BackgroundTaskConnectorType.EntityStorage) {\n\t\tcoreConfig.types.backgroundTaskConnector.push({\n\t\t\ttype: BackgroundTaskConnectorType.EntityStorage\n\t\t});\n\t}\n}\n\n/**\n * Configures the event bud.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureEventBus(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.eventBusConnector ??= [];\n\n\tif (envVars.eventBusConnector === EventBusConnectorType.Local) {\n\t\tcoreConfig.types.eventBusConnector.push({\n\t\t\ttype: EventBusConnectorType.Local\n\t\t});\n\t}\n\n\tif (coreConfig.types.eventBusConnector.length > 0) {\n\t\tcoreConfig.types.eventBusComponent ??= [];\n\t\tcoreConfig.types.eventBusComponent.push({ type: EventBusComponentType.Service });\n\t}\n}\n\n/**\n * Configures the telemetry.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureTelemetry(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.telemetryConnector ??= [];\n\n\tif (envVars.telemetryConnector === TelemetryConnectorType.EntityStorage) {\n\t\tcoreConfig.types.telemetryConnector.push({\n\t\t\ttype: TelemetryConnectorType.EntityStorage\n\t\t});\n\t}\n\n\tif (coreConfig.types.telemetryConnector.length > 0) {\n\t\tcoreConfig.types.telemetryComponent ??= [];\n\t\tcoreConfig.types.telemetryComponent.push({ type: TelemetryComponentType.Service });\n\t}\n}\n\n/**\n * Configures the tenant.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureTenant(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tcoreConfig.types.tenantAdminComponent ??= [];\n\t\tcoreConfig.types.tenantAdminComponent.push({\n\t\t\ttype: TenantAdminComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.tenantComponent ??= [];\n\t\tcoreConfig.types.tenantComponent.push({ type: TenantAdminComponentType.Service });\n\t}\n}\n\n/**\n * Configures the context id handlers.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureContextIdHandlers(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.contextIdHandlerComponent ??= [];\n\tcoreConfig.types.contextIdHandlerComponent.push({\n\t\ttype: ContextIdHandlerComponentType.Did,\n\t\tfeatures: [CONTEXT_ID_HANDLER_FEATURE_DID]\n\t});\n\tif (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tcoreConfig.types.contextIdHandlerComponent.push({\n\t\t\ttype: ContextIdHandlerComponentType.Tenant,\n\t\t\tfeatures: [CONTEXT_ID_HANDLER_FEATURE_TENANT]\n\t\t});\n\t}\n}\n\n/**\n * Configures the messaging.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureMessaging(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.messagingEnabled) ?? false) {\n\t\tcoreConfig.types.messagingEmailConnector ??= [];\n\t\tcoreConfig.types.messagingSmsConnector ??= [];\n\t\tcoreConfig.types.messagingPushNotificationConnector ??= [];\n\n\t\tif (envVars.messagingEmailConnector === MessagingEmailConnectorType.EntityStorage) {\n\t\t\tcoreConfig.types.messagingEmailConnector.push({\n\t\t\t\ttype: MessagingEmailConnectorType.EntityStorage\n\t\t\t});\n\t\t} else if (envVars.messagingEmailConnector === MessagingEmailConnectorType.Aws) {\n\t\t\tcoreConfig.types.messagingEmailConnector.push({\n\t\t\t\ttype: MessagingEmailConnectorType.Aws,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tregion: envVars.awsSesRegion ?? \"\",\n\t\t\t\t\t\tauthMode: envVars.awsSesAuthMode as \"credentials\" | \"pod\",\n\t\t\t\t\t\taccessKeyId: envVars.awsSesAccessKeyId,\n\t\t\t\t\t\tsecretAccessKey: envVars.awsSesSecretAccessKey,\n\t\t\t\t\t\tendpoint: envVars.awsSesEndpoint\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (envVars.messagingSmsConnector === MessagingSmsConnectorType.EntityStorage) {\n\t\t\tcoreConfig.types.messagingSmsConnector.push({\n\t\t\t\ttype: MessagingSmsConnectorType.EntityStorage\n\t\t\t});\n\t\t} else if (envVars.messagingSmsConnector === MessagingSmsConnectorType.Aws) {\n\t\t\tcoreConfig.types.messagingSmsConnector.push({\n\t\t\t\ttype: MessagingSmsConnectorType.Aws,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tregion: envVars.awsSesRegion ?? \"\",\n\t\t\t\t\t\tauthMode: envVars.awsSesAuthMode as \"credentials\" | \"pod\",\n\t\t\t\t\t\taccessKeyId: envVars.awsSesAccessKeyId,\n\t\t\t\t\t\tsecretAccessKey: envVars.awsSesSecretAccessKey,\n\t\t\t\t\t\tendpoint: envVars.awsSesEndpoint\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (\n\t\t\tenvVars.messagingPushNotificationConnector ===\n\t\t\tMessagingPushNotificationConnectorType.EntityStorage\n\t\t) {\n\t\t\tcoreConfig.types.messagingPushNotificationConnector.push({\n\t\t\t\ttype: MessagingPushNotificationConnectorType.EntityStorage\n\t\t\t});\n\t\t} else if (\n\t\t\tenvVars.messagingPushNotificationConnector === MessagingPushNotificationConnectorType.Aws\n\t\t) {\n\t\t\tcoreConfig.types.messagingPushNotificationConnector.push({\n\t\t\t\ttype: MessagingPushNotificationConnectorType.Aws,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tregion: envVars.awsSesRegion ?? \"\",\n\t\t\t\t\t\tauthMode: envVars.awsSesAuthMode as \"credentials\" | \"pod\",\n\t\t\t\t\t\taccessKeyId: envVars.awsSesAccessKeyId,\n\t\t\t\t\t\tsecretAccessKey: envVars.awsSesSecretAccessKey,\n\t\t\t\t\t\tendpoint: envVars.awsSesEndpoint,\n\t\t\t\t\t\tapplicationsSettings: Is.json(envVars.awsMessagingPushNotificationApplications)\n\t\t\t\t\t\t\t? JSON.parse(envVars.awsMessagingPushNotificationApplications)\n\t\t\t\t\t\t\t: []\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tcoreConfig.types.messagingAdminComponent ??= [];\n\t\tcoreConfig.types.messagingAdminComponent.push({\n\t\t\ttype: MessagingAdminComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.messagingComponent ??= [];\n\t\tcoreConfig.types.messagingComponent.push({ type: MessagingComponentType.Service });\n\t}\n}\n\n/**\n * Configures the faucet.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureFaucet(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.faucetConnector ??= [];\n\n\tif (envVars.faucetConnector === FaucetConnectorType.EntityStorage) {\n\t\tcoreConfig.types.faucetConnector.push({\n\t\t\ttype: FaucetConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.faucetConnector === FaucetConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.faucetConnector.push({\n\t\t\ttype: FaucetConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tendpoint: envVars.iotaFaucetEndpoint ?? \"\",\n\t\t\t\t\tclientOptions: dltConfig?.options?.config?.clientOptions ?? { url: \"\" },\n\t\t\t\t\tnetwork: dltConfig?.options?.config?.network ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the wallet.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureWallet(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.walletConnector ??= [];\n\n\tif (envVars.walletConnector === WalletConnectorType.EntityStorage) {\n\t\tcoreConfig.types.walletConnector.push({\n\t\t\ttype: WalletConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.walletConnector === WalletConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.walletConnector.push({\n\t\t\ttype: WalletConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: dltConfig?.options?.config ?? ({} as IIotaConfig)\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the NFT.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureNft(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.nftConnector ??= [];\n\n\tif (envVars.nftConnector === NftConnectorType.EntityStorage) {\n\t\tcoreConfig.types.nftConnector.push({\n\t\t\ttype: NftConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.nftConnector === NftConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.nftConnector.push({\n\t\t\ttype: NftConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: dltConfig?.options?.config ?? ({} as IIotaConfig)\n\t\t\t}\n\t\t});\n\t}\n\n\tif (coreConfig.types.nftConnector.length > 0) {\n\t\tcoreConfig.types.nftComponent ??= [];\n\t\tcoreConfig.types.nftComponent.push({ type: NftComponentType.Service });\n\t}\n}\n\n/**\n * Configures the verifiable storage.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureVerifiableStorage(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.verifiableStorageConnector ??= [];\n\n\tif (envVars.verifiableStorageConnector === VerifiableStorageConnectorType.EntityStorage) {\n\t\tcoreConfig.types.verifiableStorageConnector.push({\n\t\t\ttype: VerifiableStorageConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.verifiableStorageConnector === VerifiableStorageConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.verifiableStorageConnector.push({\n\t\t\ttype: VerifiableStorageConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: dltConfig?.options?.config ?? ({} as IIotaConfig)\n\t\t\t}\n\t\t});\n\t}\n\n\tif (coreConfig.types.verifiableStorageConnector.length > 0) {\n\t\tcoreConfig.types.verifiableStorageComponent ??= [];\n\t\tcoreConfig.types.verifiableStorageComponent.push({\n\t\t\ttype: VerifiableStorageComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.immutableProofComponent ??= [];\n\t\tcoreConfig.types.immutableProofComponent.push({\n\t\t\ttype: ImmutableProofComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tverificationMethodId:\n\t\t\t\t\t\tenvVars.immutableProofVerificationMethodId ?? IMMUTABLE_PROOF_VERIFICATION_METHOD_ID\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the identity.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureIdentity(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.identityConnector ??= [];\n\n\tif (envVars.identityConnector === IdentityConnectorType.EntityStorage) {\n\t\tcoreConfig.types.identityConnector.push({\n\t\t\ttype: IdentityConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.identityConnector === IdentityConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.identityConnector.push({\n\t\t\ttype: IdentityConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: dltConfig?.options?.config ?? ({} as IIotaConfig)\n\t\t\t}\n\t\t});\n\t}\n\n\tif (coreConfig.types.identityConnector.length > 0) {\n\t\tcoreConfig.types.identityComponent ??= [];\n\t\tcoreConfig.types.identityComponent.push({ type: IdentityComponentType.Service });\n\t}\n}\n\n/**\n * Configures the identity resolver.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureIdentityResolver(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.identityResolverConnector ??= [];\n\n\tif (envVars.identityResolverConnector === IdentityResolverConnectorType.EntityStorage) {\n\t\tcoreConfig.types.identityResolverConnector.push({\n\t\t\ttype: IdentityResolverConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.identityResolverConnector === IdentityResolverConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.identityResolverConnector.push({\n\t\t\ttype: IdentityResolverConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: dltConfig?.options?.config ?? ({} as IIotaConfig)\n\t\t\t}\n\t\t});\n\t} else if (envVars.identityResolverConnector === IdentityResolverConnectorType.Universal) {\n\t\tcoreConfig.types.identityResolverConnector.push({\n\t\t\ttype: IdentityResolverConnectorType.Universal,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tendpoint: envVars.universalResolverEndpoint ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tif (coreConfig.types.identityResolverConnector.length > 0) {\n\t\tcoreConfig.types.identityResolverComponent ??= [];\n\t\tcoreConfig.types.identityResolverComponent.push({\n\t\t\ttype: IdentityResolverComponentType.Service\n\t\t});\n\t}\n}\n\n/**\n * Configures the identity profile.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureIdentityProfile(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.identityProfileConnector ??= [];\n\n\tif (envVars.identityProfileConnector === IdentityConnectorType.EntityStorage) {\n\t\tcoreConfig.types.identityProfileConnector.push({\n\t\t\ttype: IdentityProfileConnectorType.EntityStorage\n\t\t});\n\t}\n\n\tif (coreConfig.types.identityProfileConnector.length > 0) {\n\t\tcoreConfig.types.identityProfileComponent ??= [];\n\t\tcoreConfig.types.identityProfileComponent.push({ type: IdentityProfileComponentType.Service });\n\t}\n}\n\n/**\n * Configures the attestation.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureAttestation(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.attestationConnector ??= [];\n\n\tif (envVars.attestationConnector === AttestationConnectorType.Nft) {\n\t\tcoreConfig.types.attestationConnector.push({\n\t\t\ttype: AttestationConnectorType.Nft\n\t\t});\n\t}\n\n\tif (coreConfig.types.attestationConnector.length > 0) {\n\t\tcoreConfig.types.attestationComponent ??= [];\n\t\tcoreConfig.types.attestationComponent.push({\n\t\t\ttype: AttestationComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tverificationMethodId:\n\t\t\t\t\t\tenvVars.attestationVerificationMethodId ?? ATTESTATION_VERIFICATION_METHOD_ID\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the auditable item graph.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureAuditableItemGraph(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.auditableItemGraphEnabled) ?? false) {\n\t\tcoreConfig.types.auditableItemGraphComponent ??= [];\n\t\tcoreConfig.types.auditableItemGraphComponent.push({\n\t\t\ttype: AuditableItemGraphComponentType.Service\n\t\t});\n\t}\n}\n\n/**\n * Configures the auditable item stream.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureAuditableItemStream(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.auditableItemStreamEnabled) ?? false) {\n\t\tcoreConfig.types.auditableItemStreamComponent ??= [];\n\t\tcoreConfig.types.auditableItemStreamComponent.push({\n\t\t\ttype: AuditableItemStreamComponentType.Service\n\t\t});\n\t}\n}\n\n/**\n * Configures the data processing.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureDataProcessing(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.dataProcessingEnabled) ?? false) {\n\t\tcoreConfig.types.dataProcessingComponent ??= [];\n\t\tcoreConfig.types.dataProcessingComponent.push({ type: DataProcessingComponentType.Service });\n\n\t\tcoreConfig.types.dataConverterConnector ??= [];\n\n\t\tconst converterConnectors = envVars.dataConverterConnectors?.split(\",\") ?? [];\n\t\tfor (const converterConnector of converterConnectors) {\n\t\t\tif (converterConnector === DataConverterConnectorType.Json) {\n\t\t\t\tcoreConfig.types.dataConverterConnector.push({\n\t\t\t\t\ttype: DataConverterConnectorType.Json\n\t\t\t\t});\n\t\t\t} else if (converterConnector === DataConverterConnectorType.Xml) {\n\t\t\t\tcoreConfig.types.dataConverterConnector.push({\n\t\t\t\t\ttype: DataConverterConnectorType.Xml\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tcoreConfig.types.dataExtractorConnector ??= [];\n\t\tconst extractorConnectors = envVars.dataExtractorConnectors?.split(\",\") ?? [];\n\t\tfor (const extractorConnector of extractorConnectors) {\n\t\t\tif (extractorConnector === DataExtractorConnectorType.JsonPath) {\n\t\t\t\tcoreConfig.types.dataExtractorConnector.push({\n\t\t\t\t\ttype: DataExtractorConnectorType.JsonPath\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Configures the document management.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureDocumentManagement(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.documentManagementEnabled) ?? false) {\n\t\tcoreConfig.types.documentManagementComponent ??= [];\n\t\tcoreConfig.types.documentManagementComponent.push({\n\t\t\ttype: DocumentManagementComponentType.Service\n\t\t});\n\t}\n}\n\n/**\n * Configures the verifiable credential authentication.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureVerifiableCredentialAuthentication(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {\n\t\t// Can only perform VC authentication if identity component is available\n\t\tcoreConfig.types.authenticationGeneratorComponent ??= [];\n\t\tcoreConfig.types.authenticationGeneratorComponent.push({\n\t\t\ttype: AuthenticationGeneratorComponentType.VerifiableCredential,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tverificationMethodId:\n\t\t\t\t\t\tenvVars.vcAuthenticationVerificationMethodId ?? VC_AUTHENTICATION_VERIFICATION_METHOD_ID\n\t\t\t\t}\n\t\t\t},\n\t\t\tfeatures: [\"verifiable-credential\"]\n\t\t});\n\t}\n}\n\n/**\n * Configures the rights management.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureRightsManagement(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.rightsManagementEnabled) ?? false) {\n\t\tcoreConfig.types.rightsManagementPapComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPapComponent.push({\n\t\t\ttype: RightsManagementPapComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPmpComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPmpComponent.push({\n\t\t\ttype: RightsManagementPmpComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPipComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPipComponent.push({\n\t\t\ttype: RightsManagementPipComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tinformationModulesConfig: Is.arrayValue<IEngineModuleConfig>(\n\t\t\t\t\tenvVars.rightsManagementInformationSources\n\t\t\t\t)\n\t\t\t\t\t? envVars.rightsManagementInformationSources\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPxpComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPxpComponent.push({\n\t\t\ttype: RightsManagementPxpComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tactionModulesConfig: Is.arrayValue<IEngineModuleConfig>(\n\t\t\t\t\tenvVars.rightsManagementExecutionActions\n\t\t\t\t)\n\t\t\t\t\t? envVars.rightsManagementExecutionActions\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPdpComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPdpComponent.push({\n\t\t\ttype: RightsManagementPdpComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tarbiterModulesConfig: Is.arrayValue<IEngineModuleConfig>(envVars.rightsManagementArbiters)\n\t\t\t\t\t? envVars.rightsManagementArbiters\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPepComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPepComponent.push({\n\t\t\ttype: RightsManagementPepComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tprocessorModulesConfig: Is.arrayValue<IEngineModuleConfig>(\n\t\t\t\t\tenvVars.rightsManagementEnforcementProcessors\n\t\t\t\t)\n\t\t\t\t\t? envVars.rightsManagementEnforcementProcessors\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPnpComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPnpComponent.push({\n\t\t\ttype: RightsManagementPnpComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tnegotiatorModulesConfig: Is.arrayValue<IEngineModuleConfig>(\n\t\t\t\t\tenvVars.rightsManagementNegotiators\n\t\t\t\t)\n\t\t\t\t\t? envVars.rightsManagementNegotiators\n\t\t\t\t\t: undefined,\n\t\t\t\trequesterModulesConfig: Is.arrayValue<IEngineModuleConfig>(\n\t\t\t\t\tenvVars.rightsManagementRequesters\n\t\t\t\t)\n\t\t\t\t\t? envVars.rightsManagementRequesters\n\t\t\t\t\t: undefined,\n\t\t\t\tconfig: {\n\t\t\t\t\tbaseCallbackUrl: envVars.rightsManagementBaseCallbackUrl ?? \"\",\n\t\t\t\t\toffers: Is.arrayValue<IOdrlOffer>(envVars.rightsManagementOffers)\n\t\t\t\t\t\t? envVars.rightsManagementOffers\n\t\t\t\t\t\t: [],\n\t\t\t\t\tnegotiationComponentCreator: async url =>\n\t\t\t\t\t\tnew PolicyNegotiationPointRestClient({ endpoint: url })\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPnapComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPnapComponent.push({\n\t\t\ttype: RightsManagementPnapComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementDapComponent ??= [];\n\t\tcoreConfig.types.rightsManagementDapComponent.push({\n\t\t\ttype: RightsManagementDapComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementDarpComponent ??= [];\n\t\tcoreConfig.types.rightsManagementDarpComponent.push({\n\t\t\ttype: RightsManagementDarpComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tdataAccessComponentCreator: async url => new DataAccessPointRestClient({ endpoint: url })\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the task scheduler.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureTaskScheduler(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.taskSchedulerEnabled) ?? false) {\n\t\tcoreConfig.types.taskSchedulerComponent ??= [];\n\t\tcoreConfig.types.taskSchedulerComponent.push({\n\t\t\ttype: TaskSchedulerComponentType.Service\n\t\t});\n\t}\n}\n\n/**\n * Configures the synchronised storage.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureSynchronisedStorage(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (\n\t\tIs.arrayValue(coreConfig.types.identityResolverComponent) &&\n\t\t(Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false)\n\t) {\n\t\t// Check if the config provides a custom verifiable storage key id\n\t\tlet verifiableStorageKeyId = Coerce.string(envVars.synchronisedStorageVerifiableStorageKeyId);\n\n\t\tif (!Is.stringValue(verifiableStorageKeyId)) {\n\t\t\t// No custom key so default to the network setting\n\t\t\tverifiableStorageKeyId = envVars.iotaNetwork;\n\t\t}\n\t\tcoreConfig.types.synchronisedStorageComponent ??= [];\n\t\tcoreConfig.types.synchronisedStorageComponent.push({\n\t\t\ttype: SynchronisedStorageComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tverifiableStorageKeyId: verifiableStorageKeyId ?? \"\",\n\t\t\t\t\tblobStorageEncryptionKeyId:\n\t\t\t\t\t\tenvVars.synchronisedStorageBlobStorageEncryptionKeyId ??\n\t\t\t\t\t\tSYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID,\n\t\t\t\t\tentityUpdateIntervalMinutes: Coerce.number(\n\t\t\t\t\t\tenvVars.synchronisedStorageEntityUpdateIntervalMinutes\n\t\t\t\t\t),\n\t\t\t\t\tconsolidationIntervalMinutes: Coerce.number(\n\t\t\t\t\t\tenvVars.synchronisedStorageConsolidationIntervalMinutes\n\t\t\t\t\t),\n\t\t\t\t\tconsolidationBatchSize: Coerce.number(envVars.synchronisedStorageConsolidationBatchSize),\n\t\t\t\t\tmaxConsolidations: Coerce.number(envVars.synchronisedStorageMaxConsolidations)\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// If there is a trusted url set, we need to add a client\n\t\t// and give it a feature of trusted so that when the synchronised\n\t\t// storage is created it can pickup the correct component\n\t\tif (Is.stringValue(envVars.synchronisedStorageTrustedUrl)) {\n\t\t\tcoreConfig.types.synchronisedStorageComponent.push({\n\t\t\t\ttype: SynchronisedStorageComponentType.RestClient,\n\t\t\t\toptions: {\n\t\t\t\t\tendpoint: envVars.synchronisedStorageTrustedUrl\n\t\t\t\t},\n\t\t\t\tfeatures: [\"trusted\"]\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Configures the federated catalogue.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureFederatedCatalogue(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false) {\n\t\tcoreConfig.types.federatedCatalogueComponent ??= [];\n\t\tcoreConfig.types.federatedCatalogueComponent.push({\n\t\t\ttype: FederatedCatalogueComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tsubResourceCacheTtlMs: Coerce.number(envVars.federatedCatalogueCacheTtlMs),\n\t\t\t\t\tclearingHouseApproverList:\n\t\t\t\t\t\tCoerce.object<string[]>(envVars.federatedCatalogueClearingHouseApproverList) ?? []\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the data space connector.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureDataSpaceConnector(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.dataSpaceConnectorEnabled) ?? false) {\n\t\tcoreConfig.types.dataSpaceConnectorComponent ??= [];\n\t\tcoreConfig.types.dataSpaceConnectorComponent.push({\n\t\t\ttype: DataSpaceConnectorComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tretainActivityLogsFor: Coerce.number(envVars.dataSpaceConnectorRetainActivityLogsFor),\n\t\t\t\t\tactivityLogsCleanUpInterval: Coerce.number(\n\t\t\t\t\t\tenvVars.dataSpaceConnectorActivityLogsCleanUpInterval\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the DLT.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureDlt(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\t// Create centralized DLT configuration for IOTA if essential IOTA variables are set\n\tif (Is.stringValue(envVars.iotaNodeEndpoint) && Is.stringValue(envVars.iotaNetwork)) {\n\t\tcoreConfig.types.dltConfig ??= [];\n\n\t\tconst gasStationConfig =\n\t\t\tIs.stringValue(envVars.iotaGasStationEndpoint) &&\n\t\t\tIs.stringValue(envVars.iotaGasStationAuthToken)\n\t\t\t\t? {\n\t\t\t\t\t\tgasStationUrl: envVars.iotaGasStationEndpoint,\n\t\t\t\t\t\tgasStationAuthToken: envVars.iotaGasStationAuthToken\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\n\t\tcoreConfig.types.dltConfig.push({\n\t\t\ttype: DltConfigType.Iota,\n\t\t\tisDefault: true,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tclientOptions: {\n\t\t\t\t\t\turl: envVars.iotaNodeEndpoint ?? \"\"\n\t\t\t\t\t},\n\t\t\t\t\tnetwork: envVars.iotaNetwork ?? \"\",\n\t\t\t\t\tcoinType: Coerce.number(envVars.iotaCoinType),\n\t\t\t\t\tgasStation: gasStationConfig\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"engineEnvBuilder.js","sourceRoot":"","sources":["../../../src/builders/engineEnvBuilder.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAG5C,OAAO,EACN,wBAAwB,EACxB,wBAAwB,EACxB,+BAA+B,EAC/B,gCAAgC,EAChC,oCAAoC,EACpC,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,+BAA+B,EAE/B,aAAa,EACb,+BAA+B,EAC/B,gBAAgB,EAChB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,+BAA+B,EAC/B,qBAAqB,EACrB,qBAAqB,EACrB,4BAA4B,EAC5B,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAE7B,2BAA2B,EAC3B,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,sCAAsC,EACtC,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,gCAAgC,EAChC,gCAAgC,EAChC,gCAAgC,EAChC,gCAAgC,EAChC,iCAAiC,EACjC,gCAAgC,EAChC,gCAAgC,EAChC,gCAAgC,EAChC,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,8BAA8B,EAC9B,8BAA8B,EAC9B,mBAAmB,EACnB,MAAM,wBAAw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D;SACD,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,YAAY,CAC1B,UAAyB,EACzB,OAAoC;IAEpC,oFAAoF;IACpF,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACrF,UAAU,CAAC,KAAK,CAAC,SAAS,KAAK,EAAE,CAAC;QAElC,MAAM,gBAAgB,GACrB,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,sBAAsB,CAAC;YAC9C,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,uBAAuB,CAAC;YAC9C,CAAC,CAAC;gBACA,aAAa,EAAE,OAAO,CAAC,sBAAsB;gBAC7C,mBAAmB,EAAE,OAAO,CAAC,uBAAuB;aACpD;YACF,CAAC,CAAC,SAAS,CAAC;QAEd,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;YAC/B,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,SAAS,EAAE,IAAI;YACf,OAAO,EAAE;gBACR,MAAM,EAAE;oBACP,aAAa,EAAE;wBACd,GAAG,EAAE,OAAO,CAAC,gBAAgB,IAAI,EAAE;qBACnC;oBACD,OAAO,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;oBAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;oBAC7C,UAAU,EAAE,gBAAgB;iBAC5B;aACD;SACD,CAAC,CAAC;IACJ,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport { Coerce, Is } from \"@twin.org/core\";\nimport type { IIotaConfig } from \"@twin.org/dlt-iota\";\nimport type { IEngineModuleConfig } from \"@twin.org/engine-models\";\nimport {\n\tAttestationComponentType,\n\tAttestationConnectorType,\n\tAuditableItemGraphComponentType,\n\tAuditableItemStreamComponentType,\n\tAuthenticationGeneratorComponentType,\n\tBackgroundTaskConnectorType,\n\tBlobStorageComponentType,\n\tBlobStorageConnectorType,\n\tContextIdHandlerComponentType,\n\tDataConverterConnectorType,\n\tDataExtractorConnectorType,\n\tDataProcessingComponentType,\n\tDataSpaceConnectorComponentType,\n\ttype DltConfig,\n\tDltConfigType,\n\tDocumentManagementComponentType,\n\tEngineTypeHelper,\n\tEntityStorageConnectorType,\n\tEventBusComponentType,\n\tEventBusConnectorType,\n\tFaucetConnectorType,\n\tFederatedCatalogueComponentType,\n\tIdentityComponentType,\n\tIdentityConnectorType,\n\tIdentityProfileComponentType,\n\tIdentityProfileConnectorType,\n\tIdentityResolverComponentType,\n\tIdentityResolverConnectorType,\n\ttype IEngineConfig,\n\tImmutableProofComponentType,\n\tLoggingComponentType,\n\tLoggingConnectorType,\n\tMessagingAdminComponentType,\n\tMessagingComponentType,\n\tMessagingEmailConnectorType,\n\tMessagingPushNotificationConnectorType,\n\tMessagingSmsConnectorType,\n\tNftComponentType,\n\tNftConnectorType,\n\tRightsManagementDapComponentType,\n\tRightsManagementDarpComponentType,\n\tRightsManagementPapComponentType,\n\tRightsManagementPdpComponentType,\n\tRightsManagementPepComponentType,\n\tRightsManagementPipComponentType,\n\tRightsManagementPmpComponentType,\n\tRightsManagementPnapComponentType,\n\tRightsManagementPnpComponentType,\n\tRightsManagementPxpComponentType,\n\tSynchronisedStorageComponentType,\n\tTaskSchedulerComponentType,\n\tTelemetryComponentType,\n\tTelemetryConnectorType,\n\tTenantAdminComponentType,\n\tVaultConnectorType,\n\tVerifiableStorageComponentType,\n\tVerifiableStorageConnectorType,\n\tWalletConnectorType\n} from \"@twin.org/engine-types\";\nimport {\n\tDataAccessPointRestClient,\n\tPolicyNegotiationPointRestClient\n} from \"@twin.org/rights-management-rest-client\";\nimport type { IOdrlOffer } from \"@twin.org/standards-w3c-odrl\";\nimport {\n\tATTESTATION_VERIFICATION_METHOD_ID,\n\tBLOB_STORAGE_ENCRYPTION_KEY_ID,\n\tCONTEXT_ID_HANDLER_FEATURE_DID,\n\tCONTEXT_ID_HANDLER_FEATURE_TENANT,\n\tIMMUTABLE_PROOF_VERIFICATION_METHOD_ID,\n\tSYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID,\n\tVC_AUTHENTICATION_VERIFICATION_METHOD_ID\n} from \"../defaults.js\";\nimport type { IEngineEnvironmentVariables } from \"../models/IEngineEnvironmentVariables.js\";\n\n/**\n * Build the engine core configuration from environment variables.\n * @param envVars The environment variables.\n * @param contextIdKeys The context ID keys.\n * @returns The config for the core.\n */\nexport async function buildEngineConfiguration(\n\tenvVars: IEngineEnvironmentVariables,\n\tcontextIdKeys: { key: string; componentFeatures: string[] }[]\n): Promise<IEngineConfig> {\n\tif (Is.stringValue(envVars.storageFileRoot)) {\n\t\tenvVars.stateFilename ??= \"engine-state.json\";\n\t\tenvVars.storageFileRoot = path.resolve(envVars.storageFileRoot);\n\t\tenvVars.stateFilename = path.join(envVars.storageFileRoot, envVars.stateFilename);\n\t}\n\n\tconst coreConfig: IEngineConfig = {\n\t\tdebug: Coerce.boolean(envVars.debug) ?? false,\n\t\ttypes: {}\n\t};\n\n\tawait configureTenant(coreConfig, envVars);\n\tawait configureContextIdHandlers(coreConfig, envVars);\n\n\tawait configureEntityStorage(coreConfig, envVars);\n\tawait configureBlobStorage(coreConfig, envVars);\n\tawait configureVault(coreConfig, envVars);\n\tawait configureDlt(coreConfig, envVars);\n\n\tawait configureLogging(coreConfig, envVars);\n\tawait configureBackgroundTask(coreConfig, envVars);\n\tawait configureTaskScheduler(coreConfig, envVars);\n\tawait configureEventBus(coreConfig, envVars);\n\tawait configureTelemetry(coreConfig, envVars);\n\tawait configureMessaging(coreConfig, envVars);\n\n\tawait configureFaucet(coreConfig, envVars);\n\tawait configureWallet(coreConfig, envVars);\n\tawait configureNft(coreConfig, envVars);\n\tawait configureVerifiableStorage(coreConfig, envVars);\n\tawait configureIdentity(coreConfig, envVars);\n\tawait configureIdentityResolver(coreConfig, envVars);\n\tawait configureIdentityProfile(coreConfig, envVars);\n\tawait configureAttestation(coreConfig, envVars);\n\tawait configureDataProcessing(coreConfig, envVars);\n\n\tawait configureAuditableItemGraph(coreConfig, envVars);\n\tawait configureAuditableItemStream(coreConfig, envVars);\n\tawait configureDocumentManagement(coreConfig, envVars);\n\tawait configureVerifiableCredentialAuthentication(coreConfig, envVars);\n\tawait configureRightsManagement(coreConfig, envVars);\n\tawait configureSynchronisedStorage(coreConfig, envVars);\n\tawait configureFederatedCatalogue(coreConfig, envVars);\n\tawait configureDataSpaceConnector(coreConfig, envVars);\n\n\treturn coreConfig;\n}\n\n/**\n * Configures the entity storage.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureEntityStorage(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types ??= {};\n\tcoreConfig.types.entityStorageConnector ??= [];\n\n\tconst entityStorageConnectorTypes = envVars.entityStorageConnectorType?.split(\",\") ?? [];\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.Memory)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.Memory\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.File)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.File,\n\t\t\toptions: {\n\t\t\t\tconfig: { directory: envVars.storageFileRoot ?? \"\" },\n\t\t\t\tfolderPrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.AwsDynamoDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.AwsDynamoDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tregion: envVars.awsDynamodbRegion ?? \"\",\n\t\t\t\t\tauthMode: envVars.awsDynamodbAuthMode as \"credentials\" | \"pod\",\n\t\t\t\t\taccessKeyId: envVars.awsDynamodbAccessKeyId,\n\t\t\t\t\tsecretAccessKey: envVars.awsDynamodbSecretAccessKey,\n\t\t\t\t\tendpoint: envVars.awsDynamodbEndpoint,\n\t\t\t\t\tconnectionTimeoutMs: Coerce.integer(envVars.awsDynamodbConnectionTimeoutMs)\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.AzureCosmosDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.AzureCosmosDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tendpoint: envVars.azureCosmosdbEndpoint ?? \"\",\n\t\t\t\t\tkey: envVars.azureCosmosdbKey ?? \"\",\n\t\t\t\t\tdatabaseId: envVars.azureCosmosdbDatabaseId ?? \"\",\n\t\t\t\t\tcontainerId: envVars.azureCosmosdbContainerId ?? \"\"\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.GcpFirestoreDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.GcpFirestoreDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tprojectId: envVars.gcpFirestoreProjectId ?? \"\",\n\t\t\t\t\tcredentials: envVars.gcpFirestoreCredentials ?? \"\",\n\t\t\t\t\tdatabaseId: envVars.gcpFirestoreDatabaseId ?? \"\",\n\t\t\t\t\tcollectionName: envVars.gcpFirestoreCollectionName ?? \"\",\n\t\t\t\t\tendpoint: envVars.gcpFirestoreApiEndpoint ?? \"\"\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.ScyllaDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.ScyllaDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\thosts: envVars.scylladbHosts?.split(\",\") ?? [],\n\t\t\t\t\tlocalDataCenter: envVars.scylladbLocalDataCenter ?? \"\",\n\t\t\t\t\tkeyspace: envVars.scylladbKeyspace ?? \"\",\n\t\t\t\t\tport: Coerce.integer(envVars.scylladbPort)\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.MySqlDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.MySqlDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\thost: envVars.mySqlHost ?? \"\",\n\t\t\t\t\tport: Coerce.integer(envVars.mySqlPort),\n\t\t\t\t\tuser: envVars.mySqlUser ?? \"\",\n\t\t\t\t\tpassword: envVars.mySqlPassword ?? \"\",\n\t\t\t\t\tdatabase: envVars.mySqlDatabase ?? \"\"\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.MongoDb)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.MongoDb,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\thost: envVars.mongoDbHost ?? \"\",\n\t\t\t\t\tport: Coerce.integer(envVars.mongoDbPort),\n\t\t\t\t\tuser: envVars.mongoDbUser ?? \"\",\n\t\t\t\t\tpassword: envVars.mongoDbPassword ?? \"\",\n\t\t\t\t\tdatabase: envVars.mongoDbDatabase ?? \"\"\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.PostgreSql)) {\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.PostgreSql,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\thost: envVars.postgreSqlHost ?? \"\",\n\t\t\t\t\tport: Coerce.integer(envVars.postgreSqlPort),\n\t\t\t\t\tuser: envVars.postgreSqlUser ?? \"\",\n\t\t\t\t\tpassword: envVars.postgreSqlPassword ?? \"\",\n\t\t\t\t\tdatabase: envVars.postgreSqlDatabase ?? \"\"\n\t\t\t\t},\n\t\t\t\ttablePrefix: envVars.entityStorageTablePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tconst defaultEntityStorageConnectorType =\n\t\tenvVars.entityStorageConnectorDefault ?? entityStorageConnectorTypes[0];\n\n\tif (entityStorageConnectorTypes.includes(EntityStorageConnectorType.Synchronised)) {\n\t\t// For synchronised storage we use the default connector as the one we wrap for real DB operations\n\t\tcoreConfig.types.entityStorageConnector.push({\n\t\t\ttype: EntityStorageConnectorType.Synchronised,\n\t\t\toptions: {\n\t\t\t\tentityStorageConnectorType: defaultEntityStorageConnectorType\n\t\t\t}\n\t\t});\n\t}\n\n\tif (Is.arrayValue(entityStorageConnectorTypes)) {\n\t\tfor (const config of coreConfig.types.entityStorageConnector) {\n\t\t\tif (config.type === defaultEntityStorageConnectorType) {\n\t\t\t\tconfig.isDefault = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Configures the blob storage.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureBlobStorage(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.blobStorageConnector ??= [];\n\n\tconst blobStorageConnectorTypes = envVars.blobStorageConnectorType?.split(\",\") ?? [];\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.Memory)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.Memory\n\t\t});\n\t}\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.File)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.File,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tdirectory: Is.stringValue(envVars.storageFileRoot)\n\t\t\t\t\t\t? path.join(envVars.storageFileRoot, \"blob-storage\")\n\t\t\t\t\t\t: \"\"\n\t\t\t\t},\n\t\t\t\tstoragePrefix: envVars.blobStoragePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.Ipfs)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.Ipfs,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tapiUrl: envVars.ipfsApiUrl ?? \"\",\n\t\t\t\t\tbearerToken: envVars.ipfsBearerToken\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.AwsS3)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.AwsS3,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tregion: envVars.awsS3Region ?? \"\",\n\t\t\t\t\tbucketName: envVars.awsS3BucketName ?? \"\",\n\t\t\t\t\tauthMode: envVars.awsS3AuthMode as \"credentials\" | \"pod\",\n\t\t\t\t\taccessKeyId: envVars.awsS3AccessKeyId,\n\t\t\t\t\tsecretAccessKey: envVars.awsS3SecretAccessKey,\n\t\t\t\t\tendpoint: envVars.awsS3Endpoint\n\t\t\t\t},\n\t\t\t\tstoragePrefix: envVars.blobStoragePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.AzureStorage)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.AzureStorage,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\taccountName: envVars.azureStorageAccountName ?? \"\",\n\t\t\t\t\taccountKey: envVars.azureStorageAccountKey ?? \"\",\n\t\t\t\t\tcontainerName: envVars.azureStorageContainerName ?? \"\",\n\t\t\t\t\tendpoint: envVars.azureStorageEndpoint ?? \"\"\n\t\t\t\t},\n\t\t\t\tstoragePrefix: envVars.blobStoragePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (blobStorageConnectorTypes.includes(BlobStorageConnectorType.GcpStorage)) {\n\t\tcoreConfig.types.blobStorageConnector.push({\n\t\t\ttype: BlobStorageConnectorType.GcpStorage,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tprojectId: envVars.gcpStorageProjectId ?? \"\",\n\t\t\t\t\tcredentials: envVars.gcpStorageCredentials ?? \"\",\n\t\t\t\t\tbucketName: envVars.gcpStorageBucketName ?? \"\",\n\t\t\t\t\tapiEndpoint: envVars.gcpFirestoreApiEndpoint\n\t\t\t\t},\n\t\t\t\tstoragePrefix: envVars.blobStoragePrefix\n\t\t\t}\n\t\t});\n\t}\n\n\tif (Is.arrayValue(blobStorageConnectorTypes)) {\n\t\tconst defaultStorageConnectorType =\n\t\t\tenvVars.blobStorageConnectorDefault ?? blobStorageConnectorTypes[0];\n\t\tfor (const config of coreConfig.types.blobStorageConnector) {\n\t\t\tif (config.type === defaultStorageConnectorType) {\n\t\t\t\tconfig.isDefault = true;\n\t\t\t}\n\t\t\t// If this blob storage connector is the one to use for public access\n\t\t\t// then add it as a feature\n\t\t\tif (\n\t\t\t\tIs.stringValue(envVars.blobStorageConnectorPublic) &&\n\t\t\t\tconfig.type === envVars.blobStorageConnectorPublic\n\t\t\t) {\n\t\t\t\tconfig.features ??= [];\n\t\t\t\tconfig.features.push(\"public\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (coreConfig.types.blobStorageConnector.length > 0) {\n\t\tcoreConfig.types.blobStorageComponent ??= [];\n\t\tcoreConfig.types.blobStorageComponent.push({\n\t\t\ttype: BlobStorageComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tvaultKeyId:\n\t\t\t\t\t\t(envVars.blobStorageEnableEncryption ?? false)\n\t\t\t\t\t\t\t? (envVars.blobStorageEncryptionKeyId ?? BLOB_STORAGE_ENCRYPTION_KEY_ID)\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the logging.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureLogging(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.loggingConnector ??= [];\n\n\tconst loggingConnectorTypes = (envVars.loggingConnector ?? \"\").split(\",\");\n\tlet additionalConnectorCount = 0;\n\n\tfor (const loggingConnector of loggingConnectorTypes) {\n\t\tif (loggingConnector === LoggingConnectorType.Console) {\n\t\t\tcoreConfig.types.loggingConnector.push({\n\t\t\t\ttype: LoggingConnectorType.Console,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\ttranslateMessages: true,\n\t\t\t\t\t\thideGroups: true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tadditionalConnectorCount++;\n\t\t} else if (loggingConnector === LoggingConnectorType.EntityStorage) {\n\t\t\tcoreConfig.types.loggingConnector.push({\n\t\t\t\ttype: LoggingConnectorType.EntityStorage\n\t\t\t});\n\t\t\tadditionalConnectorCount++;\n\t\t}\n\t}\n\n\t// If more than one logging connector, then we need to add a multi connector\n\t// and set it as the default one\n\tif (additionalConnectorCount > 1) {\n\t\tcoreConfig.types.loggingConnector.push({\n\t\t\ttype: LoggingConnectorType.Multi,\n\t\t\toptions: {\n\t\t\t\tloggingConnectorTypes\n\t\t\t},\n\t\t\tisDefault: true\n\t\t});\n\t} else if (additionalConnectorCount > 0) {\n\t\t// If only one connector, then we set it as the default one\n\t\tcoreConfig.types.loggingConnector[coreConfig.types.loggingConnector.length - 1].isDefault =\n\t\t\ttrue;\n\t}\n\n\tif (additionalConnectorCount > 0) {\n\t\tcoreConfig.types.loggingComponent ??= [];\n\t\t// We set the isDefault flag so that other components will get this service by default\n\t\t// and not the generic one from the engine core\n\t\tcoreConfig.types.loggingComponent.push({ type: LoggingComponentType.Service, isDefault: true });\n\t}\n}\n\n/**\n * Configures the vault.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureVault(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.vaultConnector ??= [];\n\n\tif (envVars.vaultConnector === VaultConnectorType.EntityStorage) {\n\t\tcoreConfig.types.vaultConnector.push({\n\t\t\ttype: VaultConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.vaultConnector === VaultConnectorType.Hashicorp) {\n\t\tcoreConfig.types.vaultConnector.push({\n\t\t\ttype: VaultConnectorType.Hashicorp,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tendpoint: envVars.hashicorpVaultEndpoint ?? \"\",\n\t\t\t\t\ttoken: envVars.hashicorpVaultToken ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the background task.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureBackgroundTask(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.backgroundTaskConnector ??= [];\n\n\tif (envVars.backgroundTaskConnector === BackgroundTaskConnectorType.EntityStorage) {\n\t\tcoreConfig.types.backgroundTaskConnector.push({\n\t\t\ttype: BackgroundTaskConnectorType.EntityStorage\n\t\t});\n\t}\n}\n\n/**\n * Configures the event bud.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureEventBus(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.eventBusConnector ??= [];\n\n\tif (envVars.eventBusConnector === EventBusConnectorType.Local) {\n\t\tcoreConfig.types.eventBusConnector.push({\n\t\t\ttype: EventBusConnectorType.Local\n\t\t});\n\t}\n\n\tif (coreConfig.types.eventBusConnector.length > 0) {\n\t\tcoreConfig.types.eventBusComponent ??= [];\n\t\tcoreConfig.types.eventBusComponent.push({ type: EventBusComponentType.Service });\n\t}\n}\n\n/**\n * Configures the telemetry.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureTelemetry(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.telemetryConnector ??= [];\n\n\tif (envVars.telemetryConnector === TelemetryConnectorType.EntityStorage) {\n\t\tcoreConfig.types.telemetryConnector.push({\n\t\t\ttype: TelemetryConnectorType.EntityStorage\n\t\t});\n\t}\n\n\tif (coreConfig.types.telemetryConnector.length > 0) {\n\t\tcoreConfig.types.telemetryComponent ??= [];\n\t\tcoreConfig.types.telemetryComponent.push({ type: TelemetryComponentType.Service });\n\t}\n}\n\n/**\n * Configures the tenant.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureTenant(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tcoreConfig.types.tenantAdminComponent ??= [];\n\t\tcoreConfig.types.tenantAdminComponent.push({\n\t\t\ttype: TenantAdminComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.tenantComponent ??= [];\n\t\tcoreConfig.types.tenantComponent.push({ type: TenantAdminComponentType.Service });\n\t}\n}\n\n/**\n * Configures the context id handlers.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureContextIdHandlers(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.contextIdHandlerComponent ??= [];\n\tcoreConfig.types.contextIdHandlerComponent.push({\n\t\ttype: ContextIdHandlerComponentType.Did,\n\t\tfeatures: [CONTEXT_ID_HANDLER_FEATURE_DID]\n\t});\n\tif (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tcoreConfig.types.contextIdHandlerComponent.push({\n\t\t\ttype: ContextIdHandlerComponentType.Tenant,\n\t\t\tfeatures: [CONTEXT_ID_HANDLER_FEATURE_TENANT]\n\t\t});\n\t}\n}\n\n/**\n * Configures the messaging.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureMessaging(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.messagingEnabled) ?? false) {\n\t\tcoreConfig.types.messagingEmailConnector ??= [];\n\t\tcoreConfig.types.messagingSmsConnector ??= [];\n\t\tcoreConfig.types.messagingPushNotificationConnector ??= [];\n\n\t\tif (envVars.messagingEmailConnector === MessagingEmailConnectorType.EntityStorage) {\n\t\t\tcoreConfig.types.messagingEmailConnector.push({\n\t\t\t\ttype: MessagingEmailConnectorType.EntityStorage\n\t\t\t});\n\t\t} else if (envVars.messagingEmailConnector === MessagingEmailConnectorType.Aws) {\n\t\t\tcoreConfig.types.messagingEmailConnector.push({\n\t\t\t\ttype: MessagingEmailConnectorType.Aws,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tregion: envVars.awsSesRegion ?? \"\",\n\t\t\t\t\t\tauthMode: envVars.awsSesAuthMode as \"credentials\" | \"pod\",\n\t\t\t\t\t\taccessKeyId: envVars.awsSesAccessKeyId,\n\t\t\t\t\t\tsecretAccessKey: envVars.awsSesSecretAccessKey,\n\t\t\t\t\t\tendpoint: envVars.awsSesEndpoint\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (envVars.messagingSmsConnector === MessagingSmsConnectorType.EntityStorage) {\n\t\t\tcoreConfig.types.messagingSmsConnector.push({\n\t\t\t\ttype: MessagingSmsConnectorType.EntityStorage\n\t\t\t});\n\t\t} else if (envVars.messagingSmsConnector === MessagingSmsConnectorType.Aws) {\n\t\t\tcoreConfig.types.messagingSmsConnector.push({\n\t\t\t\ttype: MessagingSmsConnectorType.Aws,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tregion: envVars.awsSesRegion ?? \"\",\n\t\t\t\t\t\tauthMode: envVars.awsSesAuthMode as \"credentials\" | \"pod\",\n\t\t\t\t\t\taccessKeyId: envVars.awsSesAccessKeyId,\n\t\t\t\t\t\tsecretAccessKey: envVars.awsSesSecretAccessKey,\n\t\t\t\t\t\tendpoint: envVars.awsSesEndpoint\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tif (\n\t\t\tenvVars.messagingPushNotificationConnector ===\n\t\t\tMessagingPushNotificationConnectorType.EntityStorage\n\t\t) {\n\t\t\tcoreConfig.types.messagingPushNotificationConnector.push({\n\t\t\t\ttype: MessagingPushNotificationConnectorType.EntityStorage\n\t\t\t});\n\t\t} else if (\n\t\t\tenvVars.messagingPushNotificationConnector === MessagingPushNotificationConnectorType.Aws\n\t\t) {\n\t\t\tcoreConfig.types.messagingPushNotificationConnector.push({\n\t\t\t\ttype: MessagingPushNotificationConnectorType.Aws,\n\t\t\t\toptions: {\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\tregion: envVars.awsSesRegion ?? \"\",\n\t\t\t\t\t\tauthMode: envVars.awsSesAuthMode as \"credentials\" | \"pod\",\n\t\t\t\t\t\taccessKeyId: envVars.awsSesAccessKeyId,\n\t\t\t\t\t\tsecretAccessKey: envVars.awsSesSecretAccessKey,\n\t\t\t\t\t\tendpoint: envVars.awsSesEndpoint,\n\t\t\t\t\t\tapplicationsSettings: Is.json(envVars.awsMessagingPushNotificationApplications)\n\t\t\t\t\t\t\t? JSON.parse(envVars.awsMessagingPushNotificationApplications)\n\t\t\t\t\t\t\t: []\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tcoreConfig.types.messagingAdminComponent ??= [];\n\t\tcoreConfig.types.messagingAdminComponent.push({\n\t\t\ttype: MessagingAdminComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.messagingComponent ??= [];\n\t\tcoreConfig.types.messagingComponent.push({ type: MessagingComponentType.Service });\n\t}\n}\n\n/**\n * Configures the faucet.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureFaucet(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.faucetConnector ??= [];\n\n\tif (envVars.faucetConnector === FaucetConnectorType.EntityStorage) {\n\t\tcoreConfig.types.faucetConnector.push({\n\t\t\ttype: FaucetConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.faucetConnector === FaucetConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.faucetConnector.push({\n\t\t\ttype: FaucetConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tendpoint: envVars.iotaFaucetEndpoint ?? \"\",\n\t\t\t\t\tclientOptions: dltConfig?.options?.config?.clientOptions ?? { url: \"\" },\n\t\t\t\t\tnetwork: dltConfig?.options?.config?.network ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the wallet.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureWallet(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.walletConnector ??= [];\n\n\tif (envVars.walletConnector === WalletConnectorType.EntityStorage) {\n\t\tcoreConfig.types.walletConnector.push({\n\t\t\ttype: WalletConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.walletConnector === WalletConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.walletConnector.push({\n\t\t\ttype: WalletConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: dltConfig?.options?.config ?? ({} as IIotaConfig)\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the NFT.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureNft(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.nftConnector ??= [];\n\n\tif (envVars.nftConnector === NftConnectorType.EntityStorage) {\n\t\tcoreConfig.types.nftConnector.push({\n\t\t\ttype: NftConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.nftConnector === NftConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.nftConnector.push({\n\t\t\ttype: NftConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: dltConfig?.options?.config ?? ({} as IIotaConfig)\n\t\t\t}\n\t\t});\n\t}\n\n\tif (coreConfig.types.nftConnector.length > 0) {\n\t\tcoreConfig.types.nftComponent ??= [];\n\t\tcoreConfig.types.nftComponent.push({ type: NftComponentType.Service });\n\t}\n}\n\n/**\n * Configures the verifiable storage.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureVerifiableStorage(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.verifiableStorageConnector ??= [];\n\n\tif (envVars.verifiableStorageConnector === VerifiableStorageConnectorType.EntityStorage) {\n\t\tcoreConfig.types.verifiableStorageConnector.push({\n\t\t\ttype: VerifiableStorageConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.verifiableStorageConnector === VerifiableStorageConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.verifiableStorageConnector.push({\n\t\t\ttype: VerifiableStorageConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: dltConfig?.options?.config ?? ({} as IIotaConfig)\n\t\t\t}\n\t\t});\n\t}\n\n\tif (coreConfig.types.verifiableStorageConnector.length > 0) {\n\t\tcoreConfig.types.verifiableStorageComponent ??= [];\n\t\tcoreConfig.types.verifiableStorageComponent.push({\n\t\t\ttype: VerifiableStorageComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.immutableProofComponent ??= [];\n\t\tcoreConfig.types.immutableProofComponent.push({\n\t\t\ttype: ImmutableProofComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tverificationMethodId:\n\t\t\t\t\t\tenvVars.immutableProofVerificationMethodId ?? IMMUTABLE_PROOF_VERIFICATION_METHOD_ID\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the identity.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureIdentity(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.identityConnector ??= [];\n\n\tif (envVars.identityConnector === IdentityConnectorType.EntityStorage) {\n\t\tcoreConfig.types.identityConnector.push({\n\t\t\ttype: IdentityConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.identityConnector === IdentityConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.identityConnector.push({\n\t\t\ttype: IdentityConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: dltConfig?.options?.config ?? ({} as IIotaConfig)\n\t\t\t}\n\t\t});\n\t}\n\n\tif (coreConfig.types.identityConnector.length > 0) {\n\t\tcoreConfig.types.identityComponent ??= [];\n\t\tcoreConfig.types.identityComponent.push({ type: IdentityComponentType.Service });\n\t}\n}\n\n/**\n * Configures the identity resolver.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureIdentityResolver(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.identityResolverConnector ??= [];\n\n\tif (envVars.identityResolverConnector === IdentityResolverConnectorType.EntityStorage) {\n\t\tcoreConfig.types.identityResolverConnector.push({\n\t\t\ttype: IdentityResolverConnectorType.EntityStorage\n\t\t});\n\t} else if (envVars.identityResolverConnector === IdentityResolverConnectorType.Iota) {\n\t\tconst dltConfig = EngineTypeHelper.getConfigOfType<DltConfig>(\n\t\t\tcoreConfig,\n\t\t\t\"dltConfig\",\n\t\t\tDltConfigType.Iota\n\t\t);\n\t\tcoreConfig.types.identityResolverConnector.push({\n\t\t\ttype: IdentityResolverConnectorType.Iota,\n\t\t\toptions: {\n\t\t\t\tconfig: dltConfig?.options?.config ?? ({} as IIotaConfig)\n\t\t\t}\n\t\t});\n\t} else if (envVars.identityResolverConnector === IdentityResolverConnectorType.Universal) {\n\t\tcoreConfig.types.identityResolverConnector.push({\n\t\t\ttype: IdentityResolverConnectorType.Universal,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tendpoint: envVars.universalResolverEndpoint ?? \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tif (coreConfig.types.identityResolverConnector.length > 0) {\n\t\tcoreConfig.types.identityResolverComponent ??= [];\n\t\tcoreConfig.types.identityResolverComponent.push({\n\t\t\ttype: IdentityResolverComponentType.Service\n\t\t});\n\t}\n}\n\n/**\n * Configures the identity profile.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureIdentityProfile(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.identityProfileConnector ??= [];\n\n\tif (envVars.identityProfileConnector === IdentityConnectorType.EntityStorage) {\n\t\tcoreConfig.types.identityProfileConnector.push({\n\t\t\ttype: IdentityProfileConnectorType.EntityStorage\n\t\t});\n\t}\n\n\tif (coreConfig.types.identityProfileConnector.length > 0) {\n\t\tcoreConfig.types.identityProfileComponent ??= [];\n\t\tcoreConfig.types.identityProfileComponent.push({ type: IdentityProfileComponentType.Service });\n\t}\n}\n\n/**\n * Configures the attestation.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureAttestation(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tcoreConfig.types.attestationConnector ??= [];\n\n\tif (envVars.attestationConnector === AttestationConnectorType.Nft) {\n\t\tcoreConfig.types.attestationConnector.push({\n\t\t\ttype: AttestationConnectorType.Nft\n\t\t});\n\t}\n\n\tif (coreConfig.types.attestationConnector.length > 0) {\n\t\tcoreConfig.types.attestationComponent ??= [];\n\t\tcoreConfig.types.attestationComponent.push({\n\t\t\ttype: AttestationComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tverificationMethodId:\n\t\t\t\t\t\tenvVars.attestationVerificationMethodId ?? ATTESTATION_VERIFICATION_METHOD_ID\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the auditable item graph.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureAuditableItemGraph(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.auditableItemGraphEnabled) ?? false) {\n\t\tcoreConfig.types.auditableItemGraphComponent ??= [];\n\t\tcoreConfig.types.auditableItemGraphComponent.push({\n\t\t\ttype: AuditableItemGraphComponentType.Service\n\t\t});\n\t}\n}\n\n/**\n * Configures the auditable item stream.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureAuditableItemStream(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.auditableItemStreamEnabled) ?? false) {\n\t\tcoreConfig.types.auditableItemStreamComponent ??= [];\n\t\tcoreConfig.types.auditableItemStreamComponent.push({\n\t\t\ttype: AuditableItemStreamComponentType.Service\n\t\t});\n\t}\n}\n\n/**\n * Configures the data processing.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureDataProcessing(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.dataProcessingEnabled) ?? false) {\n\t\tcoreConfig.types.dataProcessingComponent ??= [];\n\t\tcoreConfig.types.dataProcessingComponent.push({ type: DataProcessingComponentType.Service });\n\n\t\tcoreConfig.types.dataConverterConnector ??= [];\n\n\t\tconst converterConnectors = envVars.dataConverterConnectors?.split(\",\") ?? [];\n\t\tfor (const converterConnector of converterConnectors) {\n\t\t\tif (converterConnector === DataConverterConnectorType.Json) {\n\t\t\t\tcoreConfig.types.dataConverterConnector.push({\n\t\t\t\t\ttype: DataConverterConnectorType.Json\n\t\t\t\t});\n\t\t\t} else if (converterConnector === DataConverterConnectorType.Xml) {\n\t\t\t\tcoreConfig.types.dataConverterConnector.push({\n\t\t\t\t\ttype: DataConverterConnectorType.Xml\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tcoreConfig.types.dataExtractorConnector ??= [];\n\t\tconst extractorConnectors = envVars.dataExtractorConnectors?.split(\",\") ?? [];\n\t\tfor (const extractorConnector of extractorConnectors) {\n\t\t\tif (extractorConnector === DataExtractorConnectorType.JsonPath) {\n\t\t\t\tcoreConfig.types.dataExtractorConnector.push({\n\t\t\t\t\ttype: DataExtractorConnectorType.JsonPath\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Configures the document management.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureDocumentManagement(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.documentManagementEnabled) ?? false) {\n\t\tcoreConfig.types.documentManagementComponent ??= [];\n\t\tcoreConfig.types.documentManagementComponent.push({\n\t\t\ttype: DocumentManagementComponentType.Service\n\t\t});\n\t}\n}\n\n/**\n * Configures the verifiable credential authentication.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureVerifiableCredentialAuthentication(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {\n\t\t// Can only perform VC authentication if identity component is available\n\t\tcoreConfig.types.authenticationGeneratorComponent ??= [];\n\t\tcoreConfig.types.authenticationGeneratorComponent.push({\n\t\t\ttype: AuthenticationGeneratorComponentType.VerifiableCredential,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tverificationMethodId:\n\t\t\t\t\t\tenvVars.vcAuthenticationVerificationMethodId ?? VC_AUTHENTICATION_VERIFICATION_METHOD_ID\n\t\t\t\t}\n\t\t\t},\n\t\t\tfeatures: [\"verifiable-credential\"]\n\t\t});\n\t}\n}\n\n/**\n * Configures the rights management.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureRightsManagement(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.rightsManagementEnabled) ?? false) {\n\t\tcoreConfig.types.rightsManagementPapComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPapComponent.push({\n\t\t\ttype: RightsManagementPapComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPmpComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPmpComponent.push({\n\t\t\ttype: RightsManagementPmpComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPipComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPipComponent.push({\n\t\t\ttype: RightsManagementPipComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tinformationModulesConfig: Is.arrayValue<IEngineModuleConfig>(\n\t\t\t\t\tenvVars.rightsManagementInformationSources\n\t\t\t\t)\n\t\t\t\t\t? envVars.rightsManagementInformationSources\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPxpComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPxpComponent.push({\n\t\t\ttype: RightsManagementPxpComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tactionModulesConfig: Is.arrayValue<IEngineModuleConfig>(\n\t\t\t\t\tenvVars.rightsManagementExecutionActions\n\t\t\t\t)\n\t\t\t\t\t? envVars.rightsManagementExecutionActions\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPdpComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPdpComponent.push({\n\t\t\ttype: RightsManagementPdpComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tarbiterModulesConfig: Is.arrayValue<IEngineModuleConfig>(envVars.rightsManagementArbiters)\n\t\t\t\t\t? envVars.rightsManagementArbiters\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPepComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPepComponent.push({\n\t\t\ttype: RightsManagementPepComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tprocessorModulesConfig: Is.arrayValue<IEngineModuleConfig>(\n\t\t\t\t\tenvVars.rightsManagementEnforcementProcessors\n\t\t\t\t)\n\t\t\t\t\t? envVars.rightsManagementEnforcementProcessors\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPnpComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPnpComponent.push({\n\t\t\ttype: RightsManagementPnpComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tnegotiatorModulesConfig: Is.arrayValue<IEngineModuleConfig>(\n\t\t\t\t\tenvVars.rightsManagementNegotiators\n\t\t\t\t)\n\t\t\t\t\t? envVars.rightsManagementNegotiators\n\t\t\t\t\t: undefined,\n\t\t\t\trequesterModulesConfig: Is.arrayValue<IEngineModuleConfig>(\n\t\t\t\t\tenvVars.rightsManagementRequesters\n\t\t\t\t)\n\t\t\t\t\t? envVars.rightsManagementRequesters\n\t\t\t\t\t: undefined,\n\t\t\t\tconfig: {\n\t\t\t\t\tbaseCallbackUrl: envVars.rightsManagementBaseCallbackUrl ?? \"\",\n\t\t\t\t\toffers: Is.arrayValue<IOdrlOffer>(envVars.rightsManagementOffers)\n\t\t\t\t\t\t? envVars.rightsManagementOffers\n\t\t\t\t\t\t: [],\n\t\t\t\t\tnegotiationComponentCreator: async url =>\n\t\t\t\t\t\tnew PolicyNegotiationPointRestClient({ endpoint: url })\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementPnapComponent ??= [];\n\t\tcoreConfig.types.rightsManagementPnapComponent.push({\n\t\t\ttype: RightsManagementPnapComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementDapComponent ??= [];\n\t\tcoreConfig.types.rightsManagementDapComponent.push({\n\t\t\ttype: RightsManagementDapComponentType.Service\n\t\t});\n\n\t\tcoreConfig.types.rightsManagementDarpComponent ??= [];\n\t\tcoreConfig.types.rightsManagementDarpComponent.push({\n\t\t\ttype: RightsManagementDarpComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tdataAccessComponentCreator: async url => new DataAccessPointRestClient({ endpoint: url })\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the task scheduler.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureTaskScheduler(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.taskSchedulerEnabled) ?? false) {\n\t\tcoreConfig.types.taskSchedulerComponent ??= [];\n\t\tcoreConfig.types.taskSchedulerComponent.push({\n\t\t\ttype: TaskSchedulerComponentType.Service\n\t\t});\n\t}\n}\n\n/**\n * Configures the synchronised storage.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureSynchronisedStorage(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (\n\t\tIs.arrayValue(coreConfig.types.identityResolverComponent) &&\n\t\t(Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false)\n\t) {\n\t\t// Check if the config provides a custom verifiable storage key id\n\t\tlet verifiableStorageKeyId = Coerce.string(envVars.synchronisedStorageVerifiableStorageKeyId);\n\n\t\tif (!Is.stringValue(verifiableStorageKeyId)) {\n\t\t\t// No custom key so default to the network setting\n\t\t\tverifiableStorageKeyId = envVars.iotaNetwork;\n\t\t}\n\t\tcoreConfig.types.synchronisedStorageComponent ??= [];\n\t\tcoreConfig.types.synchronisedStorageComponent.push({\n\t\t\ttype: SynchronisedStorageComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tverifiableStorageKeyId: verifiableStorageKeyId ?? \"\",\n\t\t\t\t\tblobStorageEncryptionKeyId:\n\t\t\t\t\t\tenvVars.synchronisedStorageBlobStorageEncryptionKeyId ??\n\t\t\t\t\t\tSYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID,\n\t\t\t\t\tentityUpdateIntervalMinutes: Coerce.number(\n\t\t\t\t\t\tenvVars.synchronisedStorageEntityUpdateIntervalMinutes\n\t\t\t\t\t),\n\t\t\t\t\tconsolidationIntervalMinutes: Coerce.number(\n\t\t\t\t\t\tenvVars.synchronisedStorageConsolidationIntervalMinutes\n\t\t\t\t\t),\n\t\t\t\t\tconsolidationBatchSize: Coerce.number(envVars.synchronisedStorageConsolidationBatchSize),\n\t\t\t\t\tmaxConsolidations: Coerce.number(envVars.synchronisedStorageMaxConsolidations)\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// If there is a trusted url set, we need to add a client\n\t\t// and give it a feature of trusted so that when the synchronised\n\t\t// storage is created it can pickup the correct component\n\t\tif (Is.stringValue(envVars.synchronisedStorageTrustedUrl)) {\n\t\t\tcoreConfig.types.synchronisedStorageComponent.push({\n\t\t\t\ttype: SynchronisedStorageComponentType.RestClient,\n\t\t\t\toptions: {\n\t\t\t\t\tendpoint: envVars.synchronisedStorageTrustedUrl\n\t\t\t\t},\n\t\t\t\tfeatures: [\"trusted\"]\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Configures the federated catalogue.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureFederatedCatalogue(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false) {\n\t\tcoreConfig.types.federatedCatalogueComponent ??= [];\n\t\tcoreConfig.types.federatedCatalogueComponent.push({\n\t\t\ttype: FederatedCatalogueComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tsubResourceCacheTtlMs: Coerce.number(envVars.federatedCatalogueCacheTtlMs),\n\t\t\t\t\tclearingHouseApproverList:\n\t\t\t\t\t\tCoerce.object<string[]>(envVars.federatedCatalogueClearingHouseApproverList) ?? []\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the data space connector.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureDataSpaceConnector(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\tif (Coerce.boolean(envVars.dataSpaceConnectorEnabled) ?? false) {\n\t\tcoreConfig.types.dataSpaceConnectorComponent ??= [];\n\t\tcoreConfig.types.dataSpaceConnectorComponent.push({\n\t\t\ttype: DataSpaceConnectorComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tretainActivityLogsFor: Coerce.number(envVars.dataSpaceConnectorRetainActivityLogsFor),\n\t\t\t\t\tactivityLogsCleanUpInterval: Coerce.number(\n\t\t\t\t\t\tenvVars.dataSpaceConnectorActivityLogsCleanUpInterval\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Configures the DLT.\n * @param coreConfig The core config.\n * @param envVars The environment variables.\n */\nasync function configureDlt(\n\tcoreConfig: IEngineConfig,\n\tenvVars: IEngineEnvironmentVariables\n): Promise<void> {\n\t// Create centralized DLT configuration for IOTA if essential IOTA variables are set\n\tif (Is.stringValue(envVars.iotaNodeEndpoint) && Is.stringValue(envVars.iotaNetwork)) {\n\t\tcoreConfig.types.dltConfig ??= [];\n\n\t\tconst gasStationConfig =\n\t\t\tIs.stringValue(envVars.iotaGasStationEndpoint) &&\n\t\t\tIs.stringValue(envVars.iotaGasStationAuthToken)\n\t\t\t\t? {\n\t\t\t\t\t\tgasStationUrl: envVars.iotaGasStationEndpoint,\n\t\t\t\t\t\tgasStationAuthToken: envVars.iotaGasStationAuthToken\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\n\t\tcoreConfig.types.dltConfig.push({\n\t\t\ttype: DltConfigType.Iota,\n\t\t\tisDefault: true,\n\t\t\toptions: {\n\t\t\t\tconfig: {\n\t\t\t\t\tclientOptions: {\n\t\t\t\t\t\turl: envVars.iotaNodeEndpoint ?? \"\"\n\t\t\t\t\t},\n\t\t\t\t\tnetwork: envVars.iotaNetwork ?? \"\",\n\t\t\t\t\tcoinType: Coerce.number(envVars.iotaCoinType),\n\t\t\t\t\tgasStation: gasStationConfig\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
|
package/dist/es/identity.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
-
import { Converter, I18n, Is, RandomHelper, Urn } from "@twin.org/core";
|
|
3
|
+
import { Converter, I18n, Is, RandomHelper, StringHelper, Urn } from "@twin.org/core";
|
|
4
4
|
import { Bip39 } from "@twin.org/crypto";
|
|
5
5
|
import { IdentityConnectorType, WalletConnectorType } from "@twin.org/engine-types";
|
|
6
6
|
import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
|
|
@@ -27,9 +27,12 @@ export async function createIdentity(engineCore, envVars, configIdentity, config
|
|
|
27
27
|
const vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);
|
|
28
28
|
const workingIdentity = configIdentity ?? `bootstrap-temp-${Converter.bytesToHex(RandomHelper.generate(16))}`;
|
|
29
29
|
const workingController = controller ?? workingIdentity;
|
|
30
|
-
await bootstrapMnemonic(engineCore, vaultConnector, workingIdentity, configMnemonic);
|
|
30
|
+
const mnemonicStored = await bootstrapMnemonic(engineCore, vaultConnector, workingIdentity, configMnemonic);
|
|
31
31
|
const addresses = addWallet ? await generateWallet(engineCore, envVars, workingIdentity) : [];
|
|
32
32
|
const finalIdentity = await generateIdentity(engineCore, envVars, workingController, workingIdentity, identityType);
|
|
33
|
+
if (mnemonicStored) {
|
|
34
|
+
engineCore.logInfo(I18n.formatMessage("node.finalMnemonic", { vaultKey: `${finalIdentity}/mnemonic` }));
|
|
35
|
+
}
|
|
33
36
|
await finaliseWallet(engineCore, envVars, finalIdentity, addresses);
|
|
34
37
|
await finaliseMnemonic(vaultConnector, workingIdentity, finalIdentity);
|
|
35
38
|
return finalIdentity;
|
|
@@ -40,14 +43,21 @@ export async function createIdentity(engineCore, envVars, configIdentity, config
|
|
|
40
43
|
* @param vaultConnector The vault connector to use.
|
|
41
44
|
* @param identity The identity of the node.
|
|
42
45
|
* @param existingMnemonic An existing mnemonic to use.
|
|
46
|
+
* @returns Whether the mnemonic was stored.
|
|
43
47
|
*/
|
|
44
48
|
async function bootstrapMnemonic(engineCore, vaultConnector, identity, existingMnemonic) {
|
|
45
49
|
let mnemonic = existingMnemonic;
|
|
46
50
|
let storeMnemonic = false;
|
|
51
|
+
const mnemonicKey = `${identity}/mnemonic`;
|
|
47
52
|
try {
|
|
48
|
-
const storedMnemonic = await vaultConnector.getSecret(
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
const storedMnemonic = await vaultConnector.getSecret(mnemonicKey);
|
|
54
|
+
if (Is.stringValue(storedMnemonic)) {
|
|
55
|
+
storeMnemonic = storedMnemonic !== mnemonic && !Is.empty(mnemonic);
|
|
56
|
+
mnemonic = storedMnemonic;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
storeMnemonic = true;
|
|
60
|
+
}
|
|
51
61
|
}
|
|
52
62
|
catch {
|
|
53
63
|
storeMnemonic = true;
|
|
@@ -56,16 +66,16 @@ async function bootstrapMnemonic(engineCore, vaultConnector, identity, existingM
|
|
|
56
66
|
if (Is.empty(mnemonic)) {
|
|
57
67
|
mnemonic = Bip39.randomMnemonic();
|
|
58
68
|
storeMnemonic = true;
|
|
59
|
-
engineCore.logInfo(I18n.formatMessage("node.generatingMnemonic", { mnemonic }));
|
|
60
69
|
}
|
|
61
70
|
// If there is no mnemonic stored in the vault then we need to store it
|
|
62
71
|
if (storeMnemonic) {
|
|
63
72
|
engineCore.logInfo(I18n.formatMessage("node.storingMnemonic"));
|
|
64
|
-
await vaultConnector.setSecret(
|
|
73
|
+
await vaultConnector.setSecret(mnemonicKey, mnemonic);
|
|
65
74
|
}
|
|
66
75
|
else {
|
|
67
76
|
engineCore.logInfo(I18n.formatMessage("node.existingMnemonic"));
|
|
68
77
|
}
|
|
78
|
+
return storeMnemonic;
|
|
69
79
|
}
|
|
70
80
|
/**
|
|
71
81
|
* Finalise the mnemonic for the node identity.
|
|
@@ -118,8 +128,9 @@ async function generateWallet(engineCore, envVars, identity) {
|
|
|
118
128
|
const balance = await walletConnector.getBalance(identity, addresses[0]);
|
|
119
129
|
if (balance === 0n) {
|
|
120
130
|
let address0 = addresses[0];
|
|
121
|
-
if (defaultWalletConnectorType.startsWith(WalletConnectorType.Iota)
|
|
122
|
-
|
|
131
|
+
if (defaultWalletConnectorType.startsWith(WalletConnectorType.Iota) &&
|
|
132
|
+
Is.stringValue(envVars.iotaExplorerEndpoint)) {
|
|
133
|
+
address0 = `${StringHelper.trimTrailingSlashes(envVars.iotaExplorerEndpoint)}/address/${address0}?network=${envVars.iotaNetwork}`;
|
|
123
134
|
}
|
|
124
135
|
engineCore.logInfo(I18n.formatMessage("node.fundingWallet", { address: address0 }));
|
|
125
136
|
// Add some funds to the wallet from the faucet
|
|
@@ -160,9 +171,11 @@ async function generateIdentity(engineCore, envVars, controller, identity, ident
|
|
|
160
171
|
const didUrn = Urn.fromValidString(identityDocument.id);
|
|
161
172
|
const didParts = didUrn.parts();
|
|
162
173
|
const objectId = didParts[3];
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
174
|
+
if (Is.stringValue(envVars.iotaExplorerEndpoint)) {
|
|
175
|
+
engineCore.logInfo(I18n.formatMessage("node.identityExplorer", {
|
|
176
|
+
url: `${StringHelper.trimTrailingSlashes(envVars.iotaExplorerEndpoint)}/object/${objectId}?network=${envVars.iotaNetwork}`
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
166
179
|
}
|
|
167
180
|
return identityDocument.id;
|
|
168
181
|
}
|
package/dist/es/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
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,eAAe,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACxD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE7B,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,uBAAuB,EAAE;YAC3C,GAAG,EAAE,GAAG,OAAO,CAAC,oBAAoB,UAAU,QAAQ,YAAY,OAAO,CAAC,WAAW,EAAE;SACvF,CAAC,CACF,CAAC;IACH,CAAC;IACD,OAAO,gBAAgB,CAAC,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, I18n, Is, RandomHelper, Urn } from \"@twin.org/core\";\nimport { Bip39 } from \"@twin.org/crypto\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { IdentityConnectorType, WalletConnectorType } from \"@twin.org/engine-types\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport {\n\tIdentityConnectorFactory,\n\tIdentityResolverConnectorFactory\n} from \"@twin.org/identity-models\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport { type IVaultConnector, VaultConnectorFactory } from \"@twin.org/vault-models\";\nimport type { WalletAddress } from \"@twin.org/wallet-connector-entity-storage\";\nimport { WalletConnectorFactory } from \"@twin.org/wallet-models\";\nimport type { INodeEnvironmentVariables } from \"./models/INodeEnvironmentVariables.js\";\n\n/**\n * Generate an identity and fund it.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param configIdentity A identity from config to use.\n * @param configMnemonic A mnemonic from config to use.\n * @param controller The controller for the identity.\n * @param identityType The type of identity.\n * @param addWallet Whether to add a wallet for the identity.\n * @returns The identity that was generated.\n */\nexport async function createIdentity(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tconfigIdentity: string | undefined,\n\tconfigMnemonic: string | undefined,\n\tcontroller: string | undefined,\n\tidentityType: \"node\" | \"organization\" | \"user\",\n\taddWallet: boolean\n): Promise<string> {\n\tengineCore.logInfo(I18n.formatMessage(\"node.processingIdentity\", { identityType }));\n\n\t// We have a chicken and egg problem in that we can't create the identity\n\t// to store the mnemonic in the vault without an identity. We use a temporary identity\n\t// and then replace it with the new identity later in the process.\n\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\tconst workingIdentity =\n\t\tconfigIdentity ?? `bootstrap-temp-${Converter.bytesToHex(RandomHelper.generate(16))}`;\n\tconst workingController = controller ?? workingIdentity;\n\n\tawait bootstrapMnemonic(engineCore, vaultConnector, workingIdentity, configMnemonic);\n\n\tconst addresses = addWallet ? await generateWallet(engineCore, envVars, workingIdentity) : [];\n\n\tconst finalIdentity = await generateIdentity(\n\t\tengineCore,\n\t\tenvVars,\n\t\tworkingController,\n\t\tworkingIdentity,\n\t\tidentityType\n\t);\n\n\tawait finaliseWallet(engineCore, envVars, finalIdentity, addresses);\n\n\tawait finaliseMnemonic(vaultConnector, workingIdentity, finalIdentity);\n\n\treturn finalIdentity;\n}\n\n/**\n * Generate a mnemonic for the node identity.\n * @param engineCore The engine core for the node.\n * @param vaultConnector The vault connector to use.\n * @param identity The identity of the node.\n * @param existingMnemonic An existing mnemonic to use.\n */\nasync function bootstrapMnemonic(\n\tengineCore: IEngineCore,\n\tvaultConnector: IVaultConnector,\n\tidentity: string,\n\texistingMnemonic?: string\n): Promise<void> {\n\tlet mnemonic = existingMnemonic;\n\tlet storeMnemonic = false;\n\n\ttry {\n\t\tconst storedMnemonic = await vaultConnector.getSecret<string>(`${identity}/mnemonic`);\n\t\tstoreMnemonic = storedMnemonic !== mnemonic;\n\t\tmnemonic = storedMnemonic;\n\t} catch {\n\t\tstoreMnemonic = true;\n\t}\n\n\t// If there is no mnemonic then we need to generate one\n\tif (Is.empty(mnemonic)) {\n\t\tmnemonic = Bip39.randomMnemonic();\n\t\tstoreMnemonic = true;\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.generatingMnemonic\", { mnemonic }));\n\t}\n\n\t// If there is no mnemonic stored in the vault then we need to store it\n\tif (storeMnemonic) {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.storingMnemonic\"));\n\t\tawait vaultConnector.setSecret(`${identity}/mnemonic`, mnemonic);\n\t} else {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingMnemonic\"));\n\t}\n}\n\n/**\n * Finalise the mnemonic for the node identity.\n * @param vaultConnector The vault connector to use.\n * @param workingIdentity The identity of the node.\n * @param finalIdentity The final identity for the node.\n */\nasync function finaliseMnemonic(\n\tvaultConnector: IVaultConnector,\n\tworkingIdentity: string,\n\tfinalIdentity: string\n): Promise<void> {\n\t// Now that we have an identity we can remove the temporary one\n\t// and store the mnemonic with the new identity\n\tif (workingIdentity.startsWith(\"bootstrap-temp-\") && workingIdentity !== finalIdentity) {\n\t\tconst mnemonic = await vaultConnector.getSecret(`${workingIdentity}/mnemonic`);\n\t\tawait vaultConnector.setSecret(`${finalIdentity}/mnemonic`, mnemonic);\n\t\tawait vaultConnector.removeSecret(`${workingIdentity}/mnemonic`);\n\t}\n}\n\n/**\n * Bootstrap the identity for the node.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param finalIdentity The identity of the node.\n * @param addresses The addresses for the wallet.\n */\nasync function finaliseWallet(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tfinalIdentity: string,\n\taddresses: string[]\n): Promise<void> {\n\tif (Is.arrayValue(addresses)) {\n\t\tconst defaultWalletConnectorType = engineCore.getRegisteredInstanceType(\"walletConnector\");\n\n\t\t// If we are using entity storage for wallet the identity associated with the\n\t\t// address will be wrong, so fix it\n\t\tif (defaultWalletConnectorType.startsWith(WalletConnectorType.EntityStorage)) {\n\t\t\tconst walletAddress =\n\t\t\t\tEntityStorageConnectorFactory.get<IEntityStorageConnector<WalletAddress>>(\n\t\t\t\t\tnameofKebabCase<WalletAddress>()\n\t\t\t\t);\n\t\t\tconst addr = await walletAddress.get(addresses[0]);\n\t\t\tif (!Is.empty(addr)) {\n\t\t\t\taddr.identity = finalIdentity;\n\t\t\t\tawait walletAddress.set(addr);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Bootstrap the wallet for the node.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param identity The identity to create the wallet for.\n * @returns The addresses for the wallet.\n */\nasync function generateWallet(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tidentity: string\n): Promise<string[]> {\n\tconst defaultWalletConnectorType = engineCore.getRegisteredInstanceType(\"walletConnector\");\n\n\tconst walletConnector = WalletConnectorFactory.get(defaultWalletConnectorType);\n\tconst addresses = await walletConnector.getAddresses(identity, 0, 0, 5);\n\n\tconst balance = await walletConnector.getBalance(identity, addresses[0]);\n\tif (balance === 0n) {\n\t\tlet address0 = addresses[0];\n\n\t\tif (defaultWalletConnectorType.startsWith(WalletConnectorType.Iota)) {\n\t\t\taddress0 = `${envVars.iotaExplorerEndpoint}address/${address0}?network=${envVars.iotaNetwork}`;\n\t\t}\n\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.fundingWallet\", { address: address0 }));\n\n\t\t// Add some funds to the wallet from the faucet\n\t\tawait walletConnector.ensureBalance(identity, addresses[0], 1000000000n);\n\t} else {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.fundedWallet\"));\n\t}\n\treturn addresses;\n}\n\n/**\n * Bootstrap the identity for the node.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param controller The controller for the identity.\n * @param identity The existing identity if there is one.\n * @param identityType The type of identity.\n * @returns The addresses for the wallet.\n */\nasync function generateIdentity(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tcontroller: string,\n\tidentity: string,\n\tidentityType: \"node\" | \"organization\" | \"user\"\n): Promise<string> {\n\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\n\t// Now create an identity for the node controlled by the address we just funded\n\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\tlet identityDocument;\n\n\ttry {\n\t\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\t\"identityResolverConnector\"\n\t\t);\n\n\t\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\t\tdefaultIdentityResolverConnectorType\n\t\t);\n\t\tidentityDocument = await identityResolverConnector.resolveDocument(identity);\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingIdentity\", { identity }));\n\t} catch {}\n\n\tif (Is.empty(identityDocument)) {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.generatingIdentity\", { identityType }));\n\n\t\tidentityDocument = await identityConnector.createDocument(controller);\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"node.createdIdentity\", { identity: identityDocument.id })\n\t\t);\n\t}\n\n\tif (defaultIdentityConnectorType.startsWith(IdentityConnectorType.Iota)) {\n\t\tconst didUrn = Urn.fromValidString(identityDocument.id);\n\t\tconst didParts = didUrn.parts();\n\t\tconst objectId = didParts[3];\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"node.identityExplorer\", {\n\t\t\t\turl: `${envVars.iotaExplorerEndpoint}object/${objectId}?network=${envVars.iotaNetwork}`\n\t\t\t})\n\t\t);\n\t}\n\treturn identityDocument.id;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,KAAK,EA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BAAgB,CAAC,EAAE,EAAE,CAAC,CAC7E,CAAC;IACH,CAAC;IAED,IAAI,4BAA4B,CAAC,UAAU,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;QACzE,MAAM,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACxD,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE7B,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;YAClD,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,uBAAuB,EAAE;gBAC3C,GAAG,EAAE,GAAG,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,oBAAoB,CAAC,WAAW,QAAQ,YAAY,OAAO,CAAC,WAAW,EAAE;aAC1H,CAAC,CACF,CAAC;QACH,CAAC;IACF,CAAC;IACD,OAAO,gBAAgB,CAAC,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, I18n, Is, RandomHelper, StringHelper, Urn } from \"@twin.org/core\";\nimport { Bip39 } from \"@twin.org/crypto\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { IdentityConnectorType, WalletConnectorType } from \"@twin.org/engine-types\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport {\n\tIdentityConnectorFactory,\n\tIdentityResolverConnectorFactory\n} from \"@twin.org/identity-models\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport { type IVaultConnector, VaultConnectorFactory } from \"@twin.org/vault-models\";\nimport type { WalletAddress } from \"@twin.org/wallet-connector-entity-storage\";\nimport { WalletConnectorFactory } from \"@twin.org/wallet-models\";\nimport type { INodeEnvironmentVariables } from \"./models/INodeEnvironmentVariables.js\";\n\n/**\n * Generate an identity and fund it.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param configIdentity A identity from config to use.\n * @param configMnemonic A mnemonic from config to use.\n * @param controller The controller for the identity.\n * @param identityType The type of identity.\n * @param addWallet Whether to add a wallet for the identity.\n * @returns The identity that was generated.\n */\nexport async function createIdentity(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tconfigIdentity: string | undefined,\n\tconfigMnemonic: string | undefined,\n\tcontroller: string | undefined,\n\tidentityType: \"node\" | \"organization\" | \"user\",\n\taddWallet: boolean\n): Promise<string> {\n\tengineCore.logInfo(I18n.formatMessage(\"node.processingIdentity\", { identityType }));\n\n\t// We have a chicken and egg problem in that we can't create the identity\n\t// to store the mnemonic in the vault without an identity. We use a temporary identity\n\t// and then replace it with the new identity later in the process.\n\tconst defaultVaultConnectorType = engineCore.getRegisteredInstanceType(\"vaultConnector\");\n\tconst vaultConnector = VaultConnectorFactory.get(defaultVaultConnectorType);\n\n\tconst workingIdentity =\n\t\tconfigIdentity ?? `bootstrap-temp-${Converter.bytesToHex(RandomHelper.generate(16))}`;\n\tconst workingController = controller ?? workingIdentity;\n\n\tconst mnemonicStored = await bootstrapMnemonic(\n\t\tengineCore,\n\t\tvaultConnector,\n\t\tworkingIdentity,\n\t\tconfigMnemonic\n\t);\n\n\tconst addresses = addWallet ? await generateWallet(engineCore, envVars, workingIdentity) : [];\n\n\tconst finalIdentity = await generateIdentity(\n\t\tengineCore,\n\t\tenvVars,\n\t\tworkingController,\n\t\tworkingIdentity,\n\t\tidentityType\n\t);\n\n\tif (mnemonicStored) {\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"node.finalMnemonic\", { vaultKey: `${finalIdentity}/mnemonic` })\n\t\t);\n\t}\n\n\tawait finaliseWallet(engineCore, envVars, finalIdentity, addresses);\n\n\tawait finaliseMnemonic(vaultConnector, workingIdentity, finalIdentity);\n\n\treturn finalIdentity;\n}\n\n/**\n * Generate a mnemonic for the node identity.\n * @param engineCore The engine core for the node.\n * @param vaultConnector The vault connector to use.\n * @param identity The identity of the node.\n * @param existingMnemonic An existing mnemonic to use.\n * @returns Whether the mnemonic was stored.\n */\nasync function bootstrapMnemonic(\n\tengineCore: IEngineCore,\n\tvaultConnector: IVaultConnector,\n\tidentity: string,\n\texistingMnemonic?: string\n): Promise<boolean> {\n\tlet mnemonic = existingMnemonic;\n\tlet storeMnemonic = false;\n\n\tconst mnemonicKey = `${identity}/mnemonic`;\n\n\ttry {\n\t\tconst storedMnemonic = await vaultConnector.getSecret<string>(mnemonicKey);\n\t\tif (Is.stringValue(storedMnemonic)) {\n\t\t\tstoreMnemonic = storedMnemonic !== mnemonic && !Is.empty(mnemonic);\n\t\t\tmnemonic = storedMnemonic;\n\t\t} else {\n\t\t\tstoreMnemonic = true;\n\t\t}\n\t} catch {\n\t\tstoreMnemonic = true;\n\t}\n\n\t// If there is no mnemonic then we need to generate one\n\tif (Is.empty(mnemonic)) {\n\t\tmnemonic = Bip39.randomMnemonic();\n\t\tstoreMnemonic = true;\n\t}\n\n\t// If there is no mnemonic stored in the vault then we need to store it\n\tif (storeMnemonic) {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.storingMnemonic\"));\n\t\tawait vaultConnector.setSecret(mnemonicKey, mnemonic);\n\t} else {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingMnemonic\"));\n\t}\n\n\treturn storeMnemonic;\n}\n\n/**\n * Finalise the mnemonic for the node identity.\n * @param vaultConnector The vault connector to use.\n * @param workingIdentity The identity of the node.\n * @param finalIdentity The final identity for the node.\n */\nasync function finaliseMnemonic(\n\tvaultConnector: IVaultConnector,\n\tworkingIdentity: string,\n\tfinalIdentity: string\n): Promise<void> {\n\t// Now that we have an identity we can remove the temporary one\n\t// and store the mnemonic with the new identity\n\tif (workingIdentity.startsWith(\"bootstrap-temp-\") && workingIdentity !== finalIdentity) {\n\t\tconst mnemonic = await vaultConnector.getSecret(`${workingIdentity}/mnemonic`);\n\t\tawait vaultConnector.setSecret(`${finalIdentity}/mnemonic`, mnemonic);\n\t\tawait vaultConnector.removeSecret(`${workingIdentity}/mnemonic`);\n\t}\n}\n\n/**\n * Bootstrap the identity for the node.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param finalIdentity The identity of the node.\n * @param addresses The addresses for the wallet.\n */\nasync function finaliseWallet(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tfinalIdentity: string,\n\taddresses: string[]\n): Promise<void> {\n\tif (Is.arrayValue(addresses)) {\n\t\tconst defaultWalletConnectorType = engineCore.getRegisteredInstanceType(\"walletConnector\");\n\n\t\t// If we are using entity storage for wallet the identity associated with the\n\t\t// address will be wrong, so fix it\n\t\tif (defaultWalletConnectorType.startsWith(WalletConnectorType.EntityStorage)) {\n\t\t\tconst walletAddress =\n\t\t\t\tEntityStorageConnectorFactory.get<IEntityStorageConnector<WalletAddress>>(\n\t\t\t\t\tnameofKebabCase<WalletAddress>()\n\t\t\t\t);\n\t\t\tconst addr = await walletAddress.get(addresses[0]);\n\t\t\tif (!Is.empty(addr)) {\n\t\t\t\taddr.identity = finalIdentity;\n\t\t\t\tawait walletAddress.set(addr);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Bootstrap the wallet for the node.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param identity The identity to create the wallet for.\n * @returns The addresses for the wallet.\n */\nasync function generateWallet(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tidentity: string\n): Promise<string[]> {\n\tconst defaultWalletConnectorType = engineCore.getRegisteredInstanceType(\"walletConnector\");\n\n\tconst walletConnector = WalletConnectorFactory.get(defaultWalletConnectorType);\n\tconst addresses = await walletConnector.getAddresses(identity, 0, 0, 5);\n\n\tconst balance = await walletConnector.getBalance(identity, addresses[0]);\n\tif (balance === 0n) {\n\t\tlet address0 = addresses[0];\n\n\t\tif (\n\t\t\tdefaultWalletConnectorType.startsWith(WalletConnectorType.Iota) &&\n\t\t\tIs.stringValue(envVars.iotaExplorerEndpoint)\n\t\t) {\n\t\t\taddress0 = `${StringHelper.trimTrailingSlashes(envVars.iotaExplorerEndpoint)}/address/${address0}?network=${envVars.iotaNetwork}`;\n\t\t}\n\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.fundingWallet\", { address: address0 }));\n\n\t\t// Add some funds to the wallet from the faucet\n\t\tawait walletConnector.ensureBalance(identity, addresses[0], 1000000000n);\n\t} else {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.fundedWallet\"));\n\t}\n\treturn addresses;\n}\n\n/**\n * Bootstrap the identity for the node.\n * @param engineCore The engine core for the node.\n * @param envVars The environment variables for the node.\n * @param controller The controller for the identity.\n * @param identity The existing identity if there is one.\n * @param identityType The type of identity.\n * @returns The addresses for the wallet.\n */\nasync function generateIdentity(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tcontroller: string,\n\tidentity: string,\n\tidentityType: \"node\" | \"organization\" | \"user\"\n): Promise<string> {\n\tconst defaultIdentityConnectorType = engineCore.getRegisteredInstanceType(\"identityConnector\");\n\n\t// Now create an identity for the node controlled by the address we just funded\n\tconst identityConnector = IdentityConnectorFactory.get(defaultIdentityConnectorType);\n\n\tlet identityDocument;\n\n\ttry {\n\t\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\t\"identityResolverConnector\"\n\t\t);\n\n\t\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\t\tdefaultIdentityResolverConnectorType\n\t\t);\n\t\tidentityDocument = await identityResolverConnector.resolveDocument(identity);\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.existingIdentity\", { identity }));\n\t} catch {}\n\n\tif (Is.empty(identityDocument)) {\n\t\tengineCore.logInfo(I18n.formatMessage(\"node.generatingIdentity\", { identityType }));\n\n\t\tidentityDocument = await identityConnector.createDocument(controller);\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"node.createdIdentity\", { identity: identityDocument.id })\n\t\t);\n\t}\n\n\tif (defaultIdentityConnectorType.startsWith(IdentityConnectorType.Iota)) {\n\t\tconst didUrn = Urn.fromValidString(identityDocument.id);\n\t\tconst didParts = didUrn.parts();\n\t\tconst objectId = didParts[3];\n\n\t\tif (Is.stringValue(envVars.iotaExplorerEndpoint)) {\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.identityExplorer\", {\n\t\t\t\t\turl: `${StringHelper.trimTrailingSlashes(envVars.iotaExplorerEndpoint)}/object/${objectId}?network=${envVars.iotaNetwork}`\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t}\n\treturn identityDocument.id;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IEngineEnvironmentVariables.js","sourceRoot":"","sources":["../../../src/models/IEngineEnvironmentVariables.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The engine core environment variables.\n */\nexport interface IEngineEnvironmentVariables {\n\t/**\n\t * Start the engine in debug mode.\n\t */\n\tdebug?: string;\n\n\t/**\n\t * The root directory for storing items like state file.\n\t */\n\tstorageFileRoot?: string;\n\n\t/**\n\t * The name of the state file.\n\t */\n\tstateFilename?: string;\n\n\t/**\n\t * Is multi-tenant support enabled, defaults to false.\n\t */\n\ttenantEnabled?: string;\n\n\t/**\n\t * A tenant id to use as a default for the node.\n\t */\n\ttenantId?: string;\n\n\t/**\n\t * A tenant api key to use as a default for the node.\n\t */\n\ttenantApiKey?: string;\n\n\t/**\n\t * The type of the entity storage to create, comma separate for more than one connector.\n\t * values: file, memory, aws-dynamodb, azure-cosmosdb, gcp-firestoredb, scylladb, mysql, mongodb, postgresql\n\t */\n\tentityStorageConnectorType?: string;\n\n\t/**\n\t * The default entity storage connector to use, defaults to the first one in the list.\n\t */\n\tentityStorageConnectorDefault?: string;\n\n\t/**\n\t * A prefix for all the table in entity-storage, can be empty.\n\t */\n\tentityStorageTablePrefix?: string;\n\n\t/**\n\t * AWS DynamoDB auth mode, either credentials or pod.\n\t */\n\tawsDynamodbAuthMode?: string;\n\n\t/**\n\t * AWS Dynamo DB access key id.\n\t */\n\tawsDynamodbAccessKeyId?: string;\n\n\t/**\n\t * AWS Dynamo DB Endpoint if running local instance.\n\t */\n\tawsDynamodbEndpoint?: string;\n\n\t/**\n\t * AWS Dynamo DB region.\n\t */\n\tawsDynamodbRegion?: string;\n\n\t/**\n\t * AWS Dynamo DB secret access key.\n\t */\n\tawsDynamodbSecretAccessKey?: string;\n\n\t/**\n\t * Azure Cosmos DB key.\n\t */\n\tazureCosmosdbKey?: string;\n\n\t/**\n\t * Azure Cosmos DB container id.\n\t */\n\tazureCosmosdbContainerId?: string;\n\n\t/**\n\t * Azure Cosmos DB database id.\n\t */\n\tazureCosmosdbDatabaseId?: string;\n\n\t/**\n\t * Azure Cosmos DB endpoint.\n\t */\n\tazureCosmosdbEndpoint?: string;\n\n\t/**\n\t * GCP Firestore collection name.\n\t */\n\tgcpFirestoreCollectionName?: string;\n\n\t/**\n\t * GCP Firestore credentials.\n\t */\n\tgcpFirestoreCredentials?: string;\n\n\t/**\n\t * GCP Firestore database id.\n\t */\n\tgcpFirestoreDatabaseId?: string;\n\n\t/**\n\t * GCP Firestore endpoint.\n\t */\n\tgcpFirestoreApiEndpoint?: string;\n\n\t/**\n\t * GCP Firestore project id.\n\t */\n\tgcpFirestoreProjectId?: string;\n\n\t/**\n\t * ScyllaDB hosts as comma separated string.\n\t */\n\tscylladbHosts?: string;\n\n\t/**\n\t * ScyllaDB keyspace.\n\t */\n\tscylladbKeyspace?: string;\n\n\t/**\n\t * ScyllaDB local data center.\n\t */\n\tscylladbLocalDataCenter?: string;\n\n\t/**\n\t * ScyllaDB port.\n\t */\n\tscylladbPort?: string;\n\n\t/**\n\t * MySQL host.\n\t */\n\tmySqlHost?: string;\n\n\t/**\n\t * MySQL port.\n\t */\n\tmySqlPort?: number;\n\n\t/**\n\t * MySQL username.\n\t */\n\tmySqlUser?: string;\n\n\t/**\n\t * MySQL password.\n\t */\n\tmySqlPassword?: string;\n\n\t/**\n\t * MySQL Database.\n\t */\n\tmySqlDatabase?: string;\n\n\t/**\n\t * MongoDB host.\n\t */\n\tmongoDbHost?: string;\n\n\t/**\n\t * MongoDB port.\n\t */\n\tmongoDbPort?: number;\n\n\t/**\n\t * MongoDB username.\n\t */\n\tmongoDbUser?: string;\n\n\t/**\n\t * MongoDB password.\n\t */\n\tmongoDbPassword?: string;\n\n\t/**\n\t * MongoDB Database.\n\t */\n\tmongoDbDatabase?: string;\n\n\t/**\n\t * PostgreSQl host.\n\t */\n\tpostgreSqlHost?: string;\n\n\t/**\n\t * PostgreSQl port.\n\t */\n\tpostgreSqlPort?: number;\n\n\t/**\n\t * PostgreSQl username.\n\t */\n\tpostgreSqlUser?: string;\n\n\t/**\n\t * PostgreSQl password.\n\t */\n\tpostgreSqlPassword?: string;\n\n\t/**\n\t * PostgreSQl Database.\n\t */\n\tpostgreSqlDatabase?: string;\n\n\t/**\n\t * The security token for accessing IPFS API.\n\t */\n\tipfsBearerToken?: string;\n\n\t/**\n\t * The url for accessing IPFS API.\n\t */\n\tipfsApiUrl?: string;\n\n\t/**\n\t * The type of the entity storage to create, comma separate for more than one connector.\n\t * values: memory, file, ipfs, aws-s3, azure-storage, gcp-storage.\n\t */\n\tblobStorageConnectorType?: string;\n\n\t/**\n\t * The default blob storage connector to use, defaults to the first one in the list.\n\t */\n\tblobStorageConnectorDefault?: string;\n\n\t/**\n\t * Blog storage connector which has public access.\n\t */\n\tblobStorageConnectorPublic?: string;\n\n\t/**\n\t * Enable encryption for the blob storage.\n\t */\n\tblobStorageEnableEncryption?: string;\n\n\t/**\n\t * The id of the encryption key for the blob storage.\n\t */\n\tblobStorageEncryptionKeyId?: string;\n\n\t/**\n\t * A symmetric encryption key for the blob storage, should be ChaCha20Poly1305 in base64 format.\n\t * If encryption is enabled but a key is not provided one will be generated.\n\t */\n\tblobStorageSymmetricEncryptionKey?: string;\n\n\t/**\n\t * A prefix for all the blobs in blob-storage, can be empty.\n\t */\n\tblobStoragePrefix?: string;\n\n\t/**\n\t * AWS S3 region.\n\t */\n\tawsS3Region?: string;\n\n\t/**\n\t * AWS S3 bucket name.\n\t */\n\tawsS3BucketName?: string;\n\n\t/**\n\t * AWS S3 auth mode, either credentials or pod, defaults to credentials.\n\t */\n\tawsS3AuthMode?: string;\n\n\t/**\n\t * AWS S3 access key id.\n\t */\n\tawsS3AccessKeyId?: string;\n\n\t/**\n\t * AWS S3 secret access key.\n\t */\n\tawsS3SecretAccessKey?: string;\n\n\t/**\n\t * AWS S3 endpoint.\n\t */\n\tawsS3Endpoint?: string;\n\n\t/**\n\t * Azure Storage account key.\n\t */\n\tazureStorageAccountKey?: string;\n\n\t/**\n\t * Azure Storage account name.\n\t */\n\tazureStorageAccountName?: string;\n\n\t/**\n\t * Azure Storage container.\n\t */\n\tazureStorageContainerName?: string;\n\n\t/**\n\t * Azure Storage endpoint.\n\t */\n\tazureStorageEndpoint?: string;\n\n\t/**\n\t * GCP Storage bucket.\n\t */\n\tgcpStorageBucketName?: string;\n\n\t/**\n\t * GCP Storage credentials.\n\t */\n\tgcpStorageCredentials?: string;\n\n\t/**\n\t * GCP Storage endpoint.\n\t */\n\tgcpStorageEndpoint?: string;\n\n\t/**\n\t * GCP Storage project id.\n\t */\n\tgcpStorageProjectId?: string;\n\n\t/**\n\t * The type of the default vault connector: entity-storage, hashicorp.\n\t */\n\tvaultConnector?: string;\n\n\t/**\n\t * Hashicorp Vault token.\n\t */\n\thashicorpVaultToken?: string;\n\n\t/**\n\t * Hashicorp Vault endpoint.\n\t */\n\thashicorpVaultEndpoint?: string;\n\n\t/**\n\t * The type of logging task connector, can be a comma separated list: console, entity-storage.\n\t */\n\tloggingConnector?: string;\n\n\t/**\n\t * The type of background task connector: entity-storage.\n\t */\n\tbackgroundTaskConnector?: string;\n\n\t/**\n\t * The type of event bus connector: local.\n\t */\n\teventBusConnector?: string;\n\n\t/**\n\t * The type of event bus component: service.\n\t */\n\teventBusComponent?: string;\n\n\t/**\n\t * Are the messaging components enabled, defaults to false.\n\t */\n\tmessagingEnabled?: string;\n\n\t/**\n\t * AWS SES region.\n\t */\n\tawsSesRegion?: string;\n\n\t/**\n\t * AWS SES auth mode, either credentials or pod, defaults to credentials.\n\t */\n\tawsSesAuthMode?: string;\n\n\t/**\n\t * AWS SES secret access key.\n\t */\n\tawsSesSecretAccessKey?: string;\n\n\t/**\n\t * AWS SES access key id.\n\t */\n\tawsSesAccessKeyId?: string;\n\n\t/**\n\t * AWS SES endpoint.\n\t */\n\tawsSesEndpoint?: string;\n\n\t/**\n\t * The applications for the push notifications JSON stringified array of IAwsApplicationSettings.\n\t */\n\tawsMessagingPushNotificationApplications?: string;\n\n\t/**\n\t * The type of messaging email connector: entity-storage, aws.\n\t */\n\tmessagingEmailConnector?: string;\n\n\t/**\n\t * The type of messaging sms connector: entity-storage, aws.\n\t */\n\tmessagingSmsConnector?: string;\n\n\t/**\n\t * The type of messaging push notification connector: entity-storage, aws.\n\t */\n\tmessagingPushNotificationConnector?: string;\n\n\t/**\n\t * The type of telemetry connector: entity-storage.\n\t */\n\ttelemetryConnector?: string;\n\n\t/**\n\t * The type of faucet connector: entity-storage, iota.\n\t */\n\tfaucetConnector?: string;\n\n\t/**\n\t * The type of wallet connector: entity-storage, iota.\n\t */\n\twalletConnector?: string;\n\n\t/**\n\t * The type of NFT connector: entity-storage, iota.\n\t */\n\tnftConnector?: string;\n\n\t/**\n\t * The type of identity connector: entity-storage, iota.\n\t */\n\tidentityConnector?: string;\n\n\t/**\n\t * The type of identity resolver connector: entity-storage, iota.\n\t */\n\tidentityResolverConnector?: string;\n\n\t/**\n\t * The type of verifiable storage connector: entity-storage, iota.\n\t */\n\tverifiableStorageConnector?: string;\n\n\t/**\n\t * IOTA Faucet Endpoint.\n\t */\n\tiotaFaucetEndpoint?: string;\n\n\t/**\n\t * IOTA Node Endpoint.\n\t */\n\tiotaNodeEndpoint?: string;\n\n\t/**\n\t * IOTA network.\n\t */\n\tiotaNetwork?: string;\n\n\t/**\n\t * IOTA coin type.\n\t */\n\tiotaCoinType?: string;\n\n\t/**\n\t * IOTA Explorer Endpoint.\n\t */\n\tiotaExplorerEndpoint?: string;\n\n\t/**\n\t * IOTA Gas Station Endpoint.\n\t */\n\tiotaGasStationEndpoint?: string;\n\n\t/**\n\t * IOTA Gas Station Authentication Token.\n\t */\n\tiotaGasStationAuthToken?: string;\n\n\t/**\n\t * Universal Resolver Endpoint.\n\t */\n\tuniversalResolverEndpoint?: string;\n\n\t/**\n\t * The type of identity profile connector: entity-storage.\n\t */\n\tidentityProfileConnector?: string;\n\n\t/**\n\t * The identity verification method id to use with immutable proofs.\n\t */\n\timmutableProofVerificationMethodId?: string;\n\n\t/**\n\t * The type of attestation connector: entity-storage, iota.\n\t */\n\tattestationConnector?: string;\n\n\t/**\n\t * The identity verification method id to use with attestation.\n\t */\n\tattestationVerificationMethodId?: string;\n\n\t/**\n\t * Is the data processing enabled, defaults to false.\n\t */\n\tdataProcessingEnabled?: string;\n\n\t/**\n\t * The type of the default data converters, can be a comma separated list: json, xml.\n\t */\n\tdataConverterConnectors?: string;\n\n\t/**\n\t * The type of the default data extractor, can be a comma separated list: json-path.\n\t */\n\tdataExtractorConnectors?: string;\n\n\t/**\n\t * Is the auditable item graph enabled, defaults to false.\n\t */\n\tauditableItemGraphEnabled?: string;\n\n\t/**\n\t * Is the auditable item stream enabled, defaults to false.\n\t */\n\tauditableItemStreamEnabled?: string;\n\n\t/**\n\t * Is the document management enabled, defaults to false.\n\t */\n\tdocumentManagementEnabled?: string;\n\n\t/**\n\t * Is the synchronised storage enabled, defaults to false.\n\t */\n\tsynchronisedStorageEnabled?: string;\n\n\t/**\n\t * Url which points to the api for a trusted synchronised storage node, not required if this is a trusted node.\n\t */\n\tsynchronisedStorageTrustedUrl?: string;\n\n\t/**\n\t * The key for the smart contract which contains the verifiable storage pointer store for synchronised storage.\n\t * This only required if using a custom verifiable storage item, otherwise it will default to the network name.\n\t */\n\tsynchronisedStorageVerifiableStorageKeyId?: string;\n\n\t/**\n\t * The key from the vault which is used to encrypt the synchronised storage blobs.\n\t * Only required for trusted nodes, as regular nodes will request from the trusted nodes.\n\t * Defaults to synchronised-storage-blob-encryption\n\t */\n\tsynchronisedStorageBlobStorageEncryptionKeyId?: string;\n\n\t/**\n\t * The key used for blob encryption, should be ChaCha20Poly1305 encoded as base64.\n\t * Only required for trusted nodes, as regular nodes will not write encrypted data.\n\t */\n\tsynchronisedStorageBlobStorageKey?: string;\n\n\t/**\n\t * How often to check for entity updates in minutes.\n\t * @default 5\n\t */\n\tsynchronisedStorageEntityUpdateIntervalMinutes?: string;\n\n\t/**\n\t * Interval to perform consolidation of changesets, only used if this is a trusted node.\n\t * @default 60\n\t */\n\tsynchronisedStorageConsolidationIntervalMinutes?: string;\n\n\t/**\n\t * The number of entities to process in a single consolidation batch, only used if this is a trusted node.\n\t * @default 1000\n\t */\n\tsynchronisedStorageConsolidationBatchSize?: string;\n\n\t/**\n\t * The maximum number of consolidations to keep in storage, only used if this is a trusted node.\n\t * @default 5\n\t */\n\tsynchronisedStorageMaxConsolidations?: string;\n\n\t/**\n\t * Is the federated catalogue enabled, defaults to false.\n\t */\n\tfederatedCatalogueEnabled?: string;\n\n\t/**\n\t * Federated catalog TTL for the cache.\n\t */\n\tfederatedCatalogueCacheTtlMs?: number;\n\n\t/**\n\t * Federated catalog clearing house approver list, stringified array of DIDs.\n\t */\n\tfederatedCatalogueClearingHouseApproverList?: string;\n\n\t/**\n\t * Is the rights management enabled, defaults to false.\n\t */\n\trightsManagementEnabled?: string;\n\n\t/**\n\t * What is the base callback url for rights management negotiations e.g. https://my-node/rights-management.\n\t */\n\trightsManagementBaseCallbackUrl?: string;\n\n\t/**\n\t * The rights management configuration which includes the information sources modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementInformationSources?: string;\n\n\t/**\n\t * The rights management configuration which includes the negotiator modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementNegotiators?: string;\n\n\t/**\n\t * The rights management configuration which includes the requester modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementRequesters?: string;\n\n\t/**\n\t * The rights management configuration which includes the execution actions modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementExecutionActions?: string;\n\n\t/**\n\t * The rights management configuration which includes the enforcement processor modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementEnforcementProcessors?: string;\n\n\t/**\n\t * The rights management configuration which includes the arbiter modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementArbiters?: string;\n\n\t/**\n\t * The rights management configuration which includes the offer modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementOffers?: string;\n\n\t/**\n\t * Is the task scheduler enabled, defaults to false.\n\t */\n\ttaskSchedulerEnabled?: string;\n\n\t/**\n\t * Is the data space connector enabled, defaults to false.\n\t */\n\tdataSpaceConnectorEnabled?: string;\n\n\t/**\n\t * The length of time to retain the activity logs for in minutes, set to -1 to keep forever.\n\t * @default 10\n\t */\n\tdataSpaceConnectorRetainActivityLogsFor?: string;\n\n\t/**\n\t * The interval for cleaning up the activity logs.\n\t * @default 60\n\t */\n\tdataSpaceConnectorActivityLogsCleanUpInterval?: string;\n\n\t/**\n\t * Enable verifiable credential authentication for the API.\n\t */\n\tvcAuthenticationEnabled?: string;\n\n\t/**\n\t * Verifiable credential assertion for node to node communication.\n\t * Defaults to node-authentication-assertion.\n\t */\n\tvcAuthenticationVerificationMethodId?: string;\n\n\t/**\n\t * A comma separated list of additional node extensions to load, the initialiseExtension method will be called for each extension.\n\t */\n\textensions?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IEngineEnvironmentVariables.js","sourceRoot":"","sources":["../../../src/models/IEngineEnvironmentVariables.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The engine core environment variables.\n */\nexport interface IEngineEnvironmentVariables {\n\t/**\n\t * Start the engine in debug mode.\n\t */\n\tdebug?: string;\n\n\t/**\n\t * The root directory for storing items like state file.\n\t */\n\tstorageFileRoot?: string;\n\n\t/**\n\t * The name of the state file.\n\t */\n\tstateFilename?: string;\n\n\t/**\n\t * Is multi-tenant support enabled, defaults to false.\n\t */\n\ttenantEnabled?: string;\n\n\t/**\n\t * A tenant id to use as a default for the node.\n\t */\n\ttenantId?: string;\n\n\t/**\n\t * A tenant api key to use as a default for the node.\n\t */\n\ttenantApiKey?: string;\n\n\t/**\n\t * The type of the entity storage to create, comma separate for more than one connector.\n\t * values: file, memory, aws-dynamodb, azure-cosmosdb, gcp-firestoredb, scylladb, mysql, mongodb, postgresql\n\t */\n\tentityStorageConnectorType?: string;\n\n\t/**\n\t * The default entity storage connector to use, defaults to the first one in the list.\n\t */\n\tentityStorageConnectorDefault?: string;\n\n\t/**\n\t * A prefix for all the table in entity-storage, can be empty.\n\t */\n\tentityStorageTablePrefix?: string;\n\n\t/**\n\t * AWS DynamoDB auth mode, either credentials or pod.\n\t */\n\tawsDynamodbAuthMode?: string;\n\n\t/**\n\t * AWS Dynamo DB access key id.\n\t */\n\tawsDynamodbAccessKeyId?: string;\n\n\t/**\n\t * AWS Dynamo DB Endpoint if running local instance.\n\t */\n\tawsDynamodbEndpoint?: string;\n\n\t/**\n\t * AWS Dynamo DB region.\n\t */\n\tawsDynamodbRegion?: string;\n\n\t/**\n\t * AWS Dynamo DB secret access key.\n\t */\n\tawsDynamodbSecretAccessKey?: string;\n\n\t/**\n\t * AWS Dynamo DB connection timeout.\n\t */\n\tawsDynamodbConnectionTimeoutMs?: string;\n\n\t/**\n\t * Azure Cosmos DB key.\n\t */\n\tazureCosmosdbKey?: string;\n\n\t/**\n\t * Azure Cosmos DB container id.\n\t */\n\tazureCosmosdbContainerId?: string;\n\n\t/**\n\t * Azure Cosmos DB database id.\n\t */\n\tazureCosmosdbDatabaseId?: string;\n\n\t/**\n\t * Azure Cosmos DB endpoint.\n\t */\n\tazureCosmosdbEndpoint?: string;\n\n\t/**\n\t * GCP Firestore collection name.\n\t */\n\tgcpFirestoreCollectionName?: string;\n\n\t/**\n\t * GCP Firestore credentials.\n\t */\n\tgcpFirestoreCredentials?: string;\n\n\t/**\n\t * GCP Firestore database id.\n\t */\n\tgcpFirestoreDatabaseId?: string;\n\n\t/**\n\t * GCP Firestore endpoint.\n\t */\n\tgcpFirestoreApiEndpoint?: string;\n\n\t/**\n\t * GCP Firestore project id.\n\t */\n\tgcpFirestoreProjectId?: string;\n\n\t/**\n\t * ScyllaDB hosts as comma separated string.\n\t */\n\tscylladbHosts?: string;\n\n\t/**\n\t * ScyllaDB keyspace.\n\t */\n\tscylladbKeyspace?: string;\n\n\t/**\n\t * ScyllaDB local data center.\n\t */\n\tscylladbLocalDataCenter?: string;\n\n\t/**\n\t * ScyllaDB port.\n\t */\n\tscylladbPort?: string;\n\n\t/**\n\t * MySQL host.\n\t */\n\tmySqlHost?: string;\n\n\t/**\n\t * MySQL port.\n\t */\n\tmySqlPort?: number;\n\n\t/**\n\t * MySQL username.\n\t */\n\tmySqlUser?: string;\n\n\t/**\n\t * MySQL password.\n\t */\n\tmySqlPassword?: string;\n\n\t/**\n\t * MySQL Database.\n\t */\n\tmySqlDatabase?: string;\n\n\t/**\n\t * MongoDB host.\n\t */\n\tmongoDbHost?: string;\n\n\t/**\n\t * MongoDB port.\n\t */\n\tmongoDbPort?: number;\n\n\t/**\n\t * MongoDB username.\n\t */\n\tmongoDbUser?: string;\n\n\t/**\n\t * MongoDB password.\n\t */\n\tmongoDbPassword?: string;\n\n\t/**\n\t * MongoDB Database.\n\t */\n\tmongoDbDatabase?: string;\n\n\t/**\n\t * PostgreSQl host.\n\t */\n\tpostgreSqlHost?: string;\n\n\t/**\n\t * PostgreSQl port.\n\t */\n\tpostgreSqlPort?: number;\n\n\t/**\n\t * PostgreSQl username.\n\t */\n\tpostgreSqlUser?: string;\n\n\t/**\n\t * PostgreSQl password.\n\t */\n\tpostgreSqlPassword?: string;\n\n\t/**\n\t * PostgreSQl Database.\n\t */\n\tpostgreSqlDatabase?: string;\n\n\t/**\n\t * The security token for accessing IPFS API.\n\t */\n\tipfsBearerToken?: string;\n\n\t/**\n\t * The url for accessing IPFS API.\n\t */\n\tipfsApiUrl?: string;\n\n\t/**\n\t * The type of the entity storage to create, comma separate for more than one connector.\n\t * values: memory, file, ipfs, aws-s3, azure-storage, gcp-storage.\n\t */\n\tblobStorageConnectorType?: string;\n\n\t/**\n\t * The default blob storage connector to use, defaults to the first one in the list.\n\t */\n\tblobStorageConnectorDefault?: string;\n\n\t/**\n\t * Blog storage connector which has public access.\n\t */\n\tblobStorageConnectorPublic?: string;\n\n\t/**\n\t * Enable encryption for the blob storage.\n\t */\n\tblobStorageEnableEncryption?: string;\n\n\t/**\n\t * The id of the encryption key for the blob storage.\n\t */\n\tblobStorageEncryptionKeyId?: string;\n\n\t/**\n\t * A symmetric encryption key for the blob storage, should be ChaCha20Poly1305 in base64 format.\n\t * If encryption is enabled but a key is not provided one will be generated.\n\t */\n\tblobStorageSymmetricEncryptionKey?: string;\n\n\t/**\n\t * A prefix for all the blobs in blob-storage, can be empty.\n\t */\n\tblobStoragePrefix?: string;\n\n\t/**\n\t * AWS S3 region.\n\t */\n\tawsS3Region?: string;\n\n\t/**\n\t * AWS S3 bucket name.\n\t */\n\tawsS3BucketName?: string;\n\n\t/**\n\t * AWS S3 auth mode, either credentials or pod, defaults to credentials.\n\t */\n\tawsS3AuthMode?: string;\n\n\t/**\n\t * AWS S3 access key id.\n\t */\n\tawsS3AccessKeyId?: string;\n\n\t/**\n\t * AWS S3 secret access key.\n\t */\n\tawsS3SecretAccessKey?: string;\n\n\t/**\n\t * AWS S3 endpoint.\n\t */\n\tawsS3Endpoint?: string;\n\n\t/**\n\t * Azure Storage account key.\n\t */\n\tazureStorageAccountKey?: string;\n\n\t/**\n\t * Azure Storage account name.\n\t */\n\tazureStorageAccountName?: string;\n\n\t/**\n\t * Azure Storage container.\n\t */\n\tazureStorageContainerName?: string;\n\n\t/**\n\t * Azure Storage endpoint.\n\t */\n\tazureStorageEndpoint?: string;\n\n\t/**\n\t * GCP Storage bucket.\n\t */\n\tgcpStorageBucketName?: string;\n\n\t/**\n\t * GCP Storage credentials.\n\t */\n\tgcpStorageCredentials?: string;\n\n\t/**\n\t * GCP Storage endpoint.\n\t */\n\tgcpStorageEndpoint?: string;\n\n\t/**\n\t * GCP Storage project id.\n\t */\n\tgcpStorageProjectId?: string;\n\n\t/**\n\t * The type of the default vault connector: entity-storage, hashicorp.\n\t */\n\tvaultConnector?: string;\n\n\t/**\n\t * Hashicorp Vault token.\n\t */\n\thashicorpVaultToken?: string;\n\n\t/**\n\t * Hashicorp Vault endpoint.\n\t */\n\thashicorpVaultEndpoint?: string;\n\n\t/**\n\t * The type of logging task connector, can be a comma separated list: console, entity-storage.\n\t */\n\tloggingConnector?: string;\n\n\t/**\n\t * The type of background task connector: entity-storage.\n\t */\n\tbackgroundTaskConnector?: string;\n\n\t/**\n\t * The type of event bus connector: local.\n\t */\n\teventBusConnector?: string;\n\n\t/**\n\t * The type of event bus component: service.\n\t */\n\teventBusComponent?: string;\n\n\t/**\n\t * Are the messaging components enabled, defaults to false.\n\t */\n\tmessagingEnabled?: string;\n\n\t/**\n\t * AWS SES region.\n\t */\n\tawsSesRegion?: string;\n\n\t/**\n\t * AWS SES auth mode, either credentials or pod, defaults to credentials.\n\t */\n\tawsSesAuthMode?: string;\n\n\t/**\n\t * AWS SES secret access key.\n\t */\n\tawsSesSecretAccessKey?: string;\n\n\t/**\n\t * AWS SES access key id.\n\t */\n\tawsSesAccessKeyId?: string;\n\n\t/**\n\t * AWS SES endpoint.\n\t */\n\tawsSesEndpoint?: string;\n\n\t/**\n\t * The applications for the push notifications JSON stringified array of IAwsApplicationSettings.\n\t */\n\tawsMessagingPushNotificationApplications?: string;\n\n\t/**\n\t * The type of messaging email connector: entity-storage, aws.\n\t */\n\tmessagingEmailConnector?: string;\n\n\t/**\n\t * The type of messaging sms connector: entity-storage, aws.\n\t */\n\tmessagingSmsConnector?: string;\n\n\t/**\n\t * The type of messaging push notification connector: entity-storage, aws.\n\t */\n\tmessagingPushNotificationConnector?: string;\n\n\t/**\n\t * The type of telemetry connector: entity-storage.\n\t */\n\ttelemetryConnector?: string;\n\n\t/**\n\t * The type of faucet connector: entity-storage, iota.\n\t */\n\tfaucetConnector?: string;\n\n\t/**\n\t * The type of wallet connector: entity-storage, iota.\n\t */\n\twalletConnector?: string;\n\n\t/**\n\t * The type of NFT connector: entity-storage, iota.\n\t */\n\tnftConnector?: string;\n\n\t/**\n\t * The type of identity connector: entity-storage, iota.\n\t */\n\tidentityConnector?: string;\n\n\t/**\n\t * The type of identity resolver connector: entity-storage, iota.\n\t */\n\tidentityResolverConnector?: string;\n\n\t/**\n\t * The type of verifiable storage connector: entity-storage, iota.\n\t */\n\tverifiableStorageConnector?: string;\n\n\t/**\n\t * IOTA Faucet Endpoint.\n\t */\n\tiotaFaucetEndpoint?: string;\n\n\t/**\n\t * IOTA Node Endpoint.\n\t */\n\tiotaNodeEndpoint?: string;\n\n\t/**\n\t * IOTA network.\n\t */\n\tiotaNetwork?: string;\n\n\t/**\n\t * IOTA coin type.\n\t */\n\tiotaCoinType?: string;\n\n\t/**\n\t * IOTA Explorer Endpoint.\n\t */\n\tiotaExplorerEndpoint?: string;\n\n\t/**\n\t * IOTA Gas Station Endpoint.\n\t */\n\tiotaGasStationEndpoint?: string;\n\n\t/**\n\t * IOTA Gas Station Authentication Token.\n\t */\n\tiotaGasStationAuthToken?: string;\n\n\t/**\n\t * Universal Resolver Endpoint.\n\t */\n\tuniversalResolverEndpoint?: string;\n\n\t/**\n\t * The type of identity profile connector: entity-storage.\n\t */\n\tidentityProfileConnector?: string;\n\n\t/**\n\t * The identity verification method id to use with immutable proofs.\n\t */\n\timmutableProofVerificationMethodId?: string;\n\n\t/**\n\t * The type of attestation connector: entity-storage, iota.\n\t */\n\tattestationConnector?: string;\n\n\t/**\n\t * The identity verification method id to use with attestation.\n\t */\n\tattestationVerificationMethodId?: string;\n\n\t/**\n\t * Is the data processing enabled, defaults to false.\n\t */\n\tdataProcessingEnabled?: string;\n\n\t/**\n\t * The type of the default data converters, can be a comma separated list: json, xml.\n\t */\n\tdataConverterConnectors?: string;\n\n\t/**\n\t * The type of the default data extractor, can be a comma separated list: json-path.\n\t */\n\tdataExtractorConnectors?: string;\n\n\t/**\n\t * Is the auditable item graph enabled, defaults to false.\n\t */\n\tauditableItemGraphEnabled?: string;\n\n\t/**\n\t * Is the auditable item stream enabled, defaults to false.\n\t */\n\tauditableItemStreamEnabled?: string;\n\n\t/**\n\t * Is the document management enabled, defaults to false.\n\t */\n\tdocumentManagementEnabled?: string;\n\n\t/**\n\t * Is the synchronised storage enabled, defaults to false.\n\t */\n\tsynchronisedStorageEnabled?: string;\n\n\t/**\n\t * Url which points to the api for a trusted synchronised storage node, not required if this is a trusted node.\n\t */\n\tsynchronisedStorageTrustedUrl?: string;\n\n\t/**\n\t * The key for the smart contract which contains the verifiable storage pointer store for synchronised storage.\n\t * This only required if using a custom verifiable storage item, otherwise it will default to the network name.\n\t */\n\tsynchronisedStorageVerifiableStorageKeyId?: string;\n\n\t/**\n\t * The key from the vault which is used to encrypt the synchronised storage blobs.\n\t * Only required for trusted nodes, as regular nodes will request from the trusted nodes.\n\t * Defaults to synchronised-storage-blob-encryption\n\t */\n\tsynchronisedStorageBlobStorageEncryptionKeyId?: string;\n\n\t/**\n\t * The key used for blob encryption, should be ChaCha20Poly1305 encoded as base64.\n\t * Only required for trusted nodes, as regular nodes will not write encrypted data.\n\t */\n\tsynchronisedStorageBlobStorageKey?: string;\n\n\t/**\n\t * How often to check for entity updates in minutes.\n\t * @default 5\n\t */\n\tsynchronisedStorageEntityUpdateIntervalMinutes?: string;\n\n\t/**\n\t * Interval to perform consolidation of changesets, only used if this is a trusted node.\n\t * @default 60\n\t */\n\tsynchronisedStorageConsolidationIntervalMinutes?: string;\n\n\t/**\n\t * The number of entities to process in a single consolidation batch, only used if this is a trusted node.\n\t * @default 1000\n\t */\n\tsynchronisedStorageConsolidationBatchSize?: string;\n\n\t/**\n\t * The maximum number of consolidations to keep in storage, only used if this is a trusted node.\n\t * @default 5\n\t */\n\tsynchronisedStorageMaxConsolidations?: string;\n\n\t/**\n\t * Is the federated catalogue enabled, defaults to false.\n\t */\n\tfederatedCatalogueEnabled?: string;\n\n\t/**\n\t * Federated catalog TTL for the cache.\n\t */\n\tfederatedCatalogueCacheTtlMs?: number;\n\n\t/**\n\t * Federated catalog clearing house approver list, stringified array of DIDs.\n\t */\n\tfederatedCatalogueClearingHouseApproverList?: string;\n\n\t/**\n\t * Is the rights management enabled, defaults to false.\n\t */\n\trightsManagementEnabled?: string;\n\n\t/**\n\t * What is the base callback url for rights management negotiations e.g. https://my-node/rights-management.\n\t */\n\trightsManagementBaseCallbackUrl?: string;\n\n\t/**\n\t * The rights management configuration which includes the information sources modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementInformationSources?: string;\n\n\t/**\n\t * The rights management configuration which includes the negotiator modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementNegotiators?: string;\n\n\t/**\n\t * The rights management configuration which includes the requester modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementRequesters?: string;\n\n\t/**\n\t * The rights management configuration which includes the execution actions modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementExecutionActions?: string;\n\n\t/**\n\t * The rights management configuration which includes the enforcement processor modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementEnforcementProcessors?: string;\n\n\t/**\n\t * The rights management configuration which includes the arbiter modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementArbiters?: string;\n\n\t/**\n\t * The rights management configuration which includes the offer modules to load.\n\t * Use the @json: prefix to specify the path to the JSON configuration file.\n\t */\n\trightsManagementOffers?: string;\n\n\t/**\n\t * Is the task scheduler enabled, defaults to false.\n\t */\n\ttaskSchedulerEnabled?: string;\n\n\t/**\n\t * Is the data space connector enabled, defaults to false.\n\t */\n\tdataSpaceConnectorEnabled?: string;\n\n\t/**\n\t * The length of time to retain the activity logs for in minutes, set to -1 to keep forever.\n\t * @default 10\n\t */\n\tdataSpaceConnectorRetainActivityLogsFor?: string;\n\n\t/**\n\t * The interval for cleaning up the activity logs.\n\t * @default 60\n\t */\n\tdataSpaceConnectorActivityLogsCleanUpInterval?: string;\n\n\t/**\n\t * Enable verifiable credential authentication for the API.\n\t */\n\tvcAuthenticationEnabled?: string;\n\n\t/**\n\t * Verifiable credential assertion for node to node communication.\n\t * Defaults to node-authentication-assertion.\n\t */\n\tvcAuthenticationVerificationMethodId?: string;\n\n\t/**\n\t * A comma separated list of additional node extensions to load, the initialiseExtension method will be called for each extension.\n\t */\n\textensions?: string;\n}\n"]}
|
package/dist/es/node.js
CHANGED
|
@@ -23,7 +23,7 @@ export async function run(nodeOptions) {
|
|
|
23
23
|
nodeOptions ??= {};
|
|
24
24
|
const serverInfo = {
|
|
25
25
|
name: nodeOptions?.serverName ?? "TWIN Node Server",
|
|
26
|
-
version: nodeOptions?.serverVersion ?? "0.0.3-next.
|
|
26
|
+
version: nodeOptions?.serverVersion ?? "0.0.3-next.5" // x-release-please-version
|
|
27
27
|
};
|
|
28
28
|
CLIDisplay.header(serverInfo.name, serverInfo.version, "đŠī¸ ");
|
|
29
29
|
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,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAIrE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAK1E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACN,qBAAqB,EACrB,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,GAA8B,EAAE,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,WAA0B;IAQnD,IAAI,CAAC;QACJ,WAAW,KAAK,EAAE,CAAC;QAEnB,MAAM,UAAU,GAAgB;YAC/B,IAAI,EAAE,WAAW,EAAE,UAAU,IAAI,kBAAkB;YACnD,OAAO,EAAE,WAAW,EAAE,aAAa,IAAI,cAAc,CAAC,2BA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,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","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 { Coerce, EnvHelper, GeneralError, Is } 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 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 \"./server.js\";\nimport {\n\tcreateModuleImportUrl,\n\tfileExists,\n\tgetExecutionDirectory,\n\tgetExtensionsCacheDir,\n\thandleHttpsProtocol,\n\thandleNpmProtocol,\n\tinitialiseLocales,\n\tloadJsonFile,\n\tloadTextFile,\n\tparseModuleProtocol,\n\tresolvePackageEntryPoint\n} from \"./utils.js\";\n\nconst moduleCache: { [id: string]: unknown } = {};\n\n/**\n * Run the TWIN Node server.\n * @param nodeOptions Optional configuration options for running the server.\n * @returns A promise that resolves when the server is started containing a shutdown method.\n */\nexport async function run(nodeOptions?: INodeOptions): 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\ttry {\n\t\tnodeOptions ??= {};\n\n\t\tconst serverInfo: IServerInfo = {\n\t\t\tname: nodeOptions?.serverName ?? \"TWIN Node Server\",\n\t\t\tversion: nodeOptions?.serverVersion ?? \"0.0.3-next.0\" // 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\tnodeOptions.localesDirectory =\n\t\t\tnodeOptions?.localesDirectory ??\n\t\t\tpath.resolve(path.join(nodeOptions.executionDirectory, \"dist\", \"locales\"));\n\t\tCLIDisplay.value(\"Locales Directory\", nodeOptions.localesDirectory);\n\n\t\tawait initialiseLocales(nodeOptions.localesDirectory);\n\n\t\tif (Is.empty(nodeOptions?.openApiSpecFile)) {\n\t\t\tconst specFile = path.resolve(\n\t\t\t\tpath.join(nodeOptions.executionDirectory ?? \"\", \"docs\", \"open-api\", \"spec.json\")\n\t\t\t);\n\t\t\tCLIDisplay.value(\"Default OpenAPI Spec File\", specFile);\n\t\t\tif (await fileExists(specFile)) {\n\t\t\t\tnodeOptions ??= {};\n\t\t\t\tnodeOptions.openApiSpecFile = specFile;\n\t\t\t}\n\t\t} else {\n\t\t\tCLIDisplay.value(\"OpenAPI Spec File\", nodeOptions.openApiSpecFile);\n\t\t}\n\n\t\tif (Is.empty(nodeOptions?.favIconFile)) {\n\t\t\tconst favIconFile = path.resolve(\n\t\t\t\tpath.join(nodeOptions.executionDirectory ?? \"\", \"static\", \"favicon.png\")\n\t\t\t);\n\t\t\tCLIDisplay.value(\"Default Favicon File\", favIconFile);\n\t\t\tif (await fileExists(favIconFile)) {\n\t\t\t\tnodeOptions ??= {};\n\t\t\t\tnodeOptions.favIconFile = favIconFile;\n\t\t\t}\n\t\t} else {\n\t\t\tCLIDisplay.value(\"Favicon File\", nodeOptions.favIconFile);\n\t\t}\n\n\t\tnodeOptions.envPrefix ??= \"TWIN_\";\n\t\tCLIDisplay.value(\"Environment Variable Prefix\", nodeOptions.envPrefix);\n\n\t\toverrideModuleImport(nodeOptions.executionDirectory ?? \"\");\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\tconst {\n\t\t\tnodeEngineConfig,\n\t\t\tnodeEnvVars: envVars,\n\t\t\tavailableContextIdKeys\n\t\t} = await buildConfiguration(finalEnvVars, nodeOptions, serverInfo);\n\n\t\tCLIDisplay.break();\n\t\tconst startResult = await start(nodeOptions, nodeEngineConfig, envVars, availableContextIdKeys);\n\n\t\tif (!Is.empty(startResult)) {\n\t\t\tfor (const signal of [\"SIGHUP\", \"SIGINT\", \"SIGTERM\"]) {\n\t\t\t\tprocess.on(signal, async () => {\n\t\t\t\t\tCLIDisplay.value(\"Terminate Signal\", signal);\n\t\t\t\t\tawait startResult.shutdown();\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\t\tCLIDisplay.error(err);\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 server.\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; componentFeatures: string[] }[];\n}> {\n\tconst availableContextIdKeys: { key: string; componentFeatures: 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\tObject.assign(processEnv, output.parsed);\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 npmRoot = execSync(\"npm root\").toString().trim().replace(/\\\\/g, \"/\");\n\t\t\t\t\tconst packagePath = path.resolve(npmRoot, 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"]}
|
|
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,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAIrE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAK1E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACN,qBAAqB,EACrB,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,MAAM,YAAY,CAAC;AAEpB,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E,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,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","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 { Coerce, EnvHelper, GeneralError, Is } 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 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 \"./server.js\";\nimport {\n\tcreateModuleImportUrl,\n\tfileExists,\n\tgetExecutionDirectory,\n\tgetExtensionsCacheDir,\n\thandleHttpsProtocol,\n\thandleNpmProtocol,\n\tinitialiseLocales,\n\tloadJsonFile,\n\tloadTextFile,\n\tparseModuleProtocol,\n\tresolvePackageEntryPoint\n} from \"./utils.js\";\n\nconst moduleCache: { [id: string]: unknown } = {};\n\n/**\n * Run the TWIN Node server.\n * @param nodeOptions Optional configuration options for running the server.\n * @returns A promise that resolves when the server is started containing a shutdown method.\n */\nexport async function run(nodeOptions?: INodeOptions): 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\ttry {\n\t\tnodeOptions ??= {};\n\n\t\tconst serverInfo: IServerInfo = {\n\t\t\tname: nodeOptions?.serverName ?? \"TWIN Node Server\",\n\t\t\tversion: nodeOptions?.serverVersion ?? \"0.0.3-next.5\" // 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\tnodeOptions.localesDirectory =\n\t\t\tnodeOptions?.localesDirectory ??\n\t\t\tpath.resolve(path.join(nodeOptions.executionDirectory, \"dist\", \"locales\"));\n\t\tCLIDisplay.value(\"Locales Directory\", nodeOptions.localesDirectory);\n\n\t\tawait initialiseLocales(nodeOptions.localesDirectory);\n\n\t\tif (Is.empty(nodeOptions?.openApiSpecFile)) {\n\t\t\tconst specFile = path.resolve(\n\t\t\t\tpath.join(nodeOptions.executionDirectory ?? \"\", \"docs\", \"open-api\", \"spec.json\")\n\t\t\t);\n\t\t\tCLIDisplay.value(\"Default OpenAPI Spec File\", specFile);\n\t\t\tif (await fileExists(specFile)) {\n\t\t\t\tnodeOptions ??= {};\n\t\t\t\tnodeOptions.openApiSpecFile = specFile;\n\t\t\t}\n\t\t} else {\n\t\t\tCLIDisplay.value(\"OpenAPI Spec File\", nodeOptions.openApiSpecFile);\n\t\t}\n\n\t\tif (Is.empty(nodeOptions?.favIconFile)) {\n\t\t\tconst favIconFile = path.resolve(\n\t\t\t\tpath.join(nodeOptions.executionDirectory ?? \"\", \"static\", \"favicon.png\")\n\t\t\t);\n\t\t\tCLIDisplay.value(\"Default Favicon File\", favIconFile);\n\t\t\tif (await fileExists(favIconFile)) {\n\t\t\t\tnodeOptions ??= {};\n\t\t\t\tnodeOptions.favIconFile = favIconFile;\n\t\t\t}\n\t\t} else {\n\t\t\tCLIDisplay.value(\"Favicon File\", nodeOptions.favIconFile);\n\t\t}\n\n\t\tnodeOptions.envPrefix ??= \"TWIN_\";\n\t\tCLIDisplay.value(\"Environment Variable Prefix\", nodeOptions.envPrefix);\n\n\t\toverrideModuleImport(nodeOptions.executionDirectory ?? \"\");\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\tconst {\n\t\t\tnodeEngineConfig,\n\t\t\tnodeEnvVars: envVars,\n\t\t\tavailableContextIdKeys\n\t\t} = await buildConfiguration(finalEnvVars, nodeOptions, serverInfo);\n\n\t\tCLIDisplay.break();\n\t\tconst startResult = await start(nodeOptions, nodeEngineConfig, envVars, availableContextIdKeys);\n\n\t\tif (!Is.empty(startResult)) {\n\t\t\tfor (const signal of [\"SIGHUP\", \"SIGINT\", \"SIGTERM\"]) {\n\t\t\t\tprocess.on(signal, async () => {\n\t\t\t\t\tCLIDisplay.value(\"Terminate Signal\", signal);\n\t\t\t\t\tawait startResult.shutdown();\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\t\tCLIDisplay.error(err);\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 server.\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; componentFeatures: string[] }[];\n}> {\n\tconst availableContextIdKeys: { key: string; componentFeatures: 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\tObject.assign(processEnv, output.parsed);\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 npmRoot = execSync(\"npm root\").toString().trim().replace(/\\\\/g, \"/\");\n\t\t\t\t\tconst packagePath = path.resolve(npmRoot, 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"]}
|
|
@@ -59,6 +59,10 @@ export interface IEngineEnvironmentVariables {
|
|
|
59
59
|
* AWS Dynamo DB secret access key.
|
|
60
60
|
*/
|
|
61
61
|
awsDynamodbSecretAccessKey?: string;
|
|
62
|
+
/**
|
|
63
|
+
* AWS Dynamo DB connection timeout.
|
|
64
|
+
*/
|
|
65
|
+
awsDynamodbConnectionTimeoutMs?: string;
|
|
62
66
|
/**
|
|
63
67
|
* Azure Cosmos DB key.
|
|
64
68
|
*/
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @twin.org/node-core - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.5](https://github.com/twinfoundation/node/compare/node-core-v0.0.3-next.4...node-core-v0.0.3-next.5) (2025-11-26)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add support for dynamodb connection timeout ([63051b0](https://github.com/twinfoundation/node/commit/63051b0d22138079115dfac921e7f0c45eaad34e))
|
|
9
|
+
|
|
10
|
+
## [0.0.3-next.4](https://github.com/twinfoundation/node/compare/node-core-v0.0.3-next.3...node-core-v0.0.3-next.4) (2025-11-24)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* org identity verification methods ([18f158b](https://github.com/twinfoundation/node/commit/18f158b2f63930e20e94437c17ed43421771a458))
|
|
16
|
+
|
|
3
17
|
## [0.0.3-next.3](https://github.com/twinfoundation/node/compare/node-core-v0.0.3-next.2...node-core-v0.0.3-next.3) (2025-11-20)
|
|
4
18
|
|
|
5
19
|
|
|
@@ -121,6 +121,14 @@ AWS Dynamo DB secret access key.
|
|
|
121
121
|
|
|
122
122
|
***
|
|
123
123
|
|
|
124
|
+
### awsDynamodbConnectionTimeoutMs?
|
|
125
|
+
|
|
126
|
+
> `optional` **awsDynamodbConnectionTimeoutMs**: `string`
|
|
127
|
+
|
|
128
|
+
AWS Dynamo DB connection timeout.
|
|
129
|
+
|
|
130
|
+
***
|
|
131
|
+
|
|
124
132
|
### azureCosmosdbKey?
|
|
125
133
|
|
|
126
134
|
> `optional` **azureCosmosdbKey**: `string`
|
|
@@ -181,6 +181,18 @@ AWS Dynamo DB secret access key.
|
|
|
181
181
|
|
|
182
182
|
***
|
|
183
183
|
|
|
184
|
+
### awsDynamodbConnectionTimeoutMs?
|
|
185
|
+
|
|
186
|
+
> `optional` **awsDynamodbConnectionTimeoutMs**: `string`
|
|
187
|
+
|
|
188
|
+
AWS Dynamo DB connection timeout.
|
|
189
|
+
|
|
190
|
+
#### Inherited from
|
|
191
|
+
|
|
192
|
+
[`IEngineEnvironmentVariables`](IEngineEnvironmentVariables.md).[`awsDynamodbConnectionTimeoutMs`](IEngineEnvironmentVariables.md#awsdynamodbconnectiontimeoutms)
|
|
193
|
+
|
|
194
|
+
***
|
|
195
|
+
|
|
184
196
|
### azureCosmosdbKey?
|
|
185
197
|
|
|
186
198
|
> `optional` **azureCosmosdbKey**: `string`
|
|
@@ -177,6 +177,18 @@ AWS Dynamo DB secret access key.
|
|
|
177
177
|
|
|
178
178
|
***
|
|
179
179
|
|
|
180
|
+
### awsDynamodbConnectionTimeoutMs?
|
|
181
|
+
|
|
182
|
+
> `optional` **awsDynamodbConnectionTimeoutMs**: `string`
|
|
183
|
+
|
|
184
|
+
AWS Dynamo DB connection timeout.
|
|
185
|
+
|
|
186
|
+
#### Inherited from
|
|
187
|
+
|
|
188
|
+
[`IEngineServerEnvironmentVariables`](IEngineServerEnvironmentVariables.md).[`awsDynamodbConnectionTimeoutMs`](IEngineServerEnvironmentVariables.md#awsdynamodbconnectiontimeoutms)
|
|
189
|
+
|
|
190
|
+
***
|
|
191
|
+
|
|
180
192
|
### azureCosmosdbKey?
|
|
181
193
|
|
|
182
194
|
> `optional` **azureCosmosdbKey**: `string`
|
package/locales/en.json
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"node": {
|
|
13
|
-
"generatingMnemonic": "Generating mnemonic \"{mnemonic}\"",
|
|
14
13
|
"storingMnemonic": "Storing mnemonic",
|
|
15
14
|
"existingMnemonic": "Mnemonic already exists",
|
|
15
|
+
"finalMnemonic": "Mnemonic is stored in the vault under the key \"{vaultKey}\"",
|
|
16
16
|
"fundingWallet": "Funding wallet \"{address}\"",
|
|
17
17
|
"fundedWallet": "Wallet already funded",
|
|
18
18
|
"processingIdentity": "Processing identity of type \"{identityType}\"",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"existingUserProfile": "User profile already exists \"{identity}\"",
|
|
37
37
|
"nodeId": "Node identity \"{identity}\"",
|
|
38
38
|
"nodeAdminUserEmail": "Node Admin User Email \"{email}\"",
|
|
39
|
-
"nodeAdminUserPassword": "Node Admin User Password \"{
|
|
39
|
+
"nodeAdminUserPassword": "Node Admin User Password Generated and stored in the vault under the key \"{vaultKey}\"",
|
|
40
40
|
"extensionLoading": "Loading Extension",
|
|
41
41
|
"extensionInitialisingEngine": "Initialising engine for extension \"{extension}\"",
|
|
42
42
|
"extensionInitialisingEngineServer": "Initialising engine server for extension \"{extension}\"",
|