@twin.org/node-core 0.0.2-next.14 → 0.0.2-next.15

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.
@@ -153,7 +153,9 @@ async function bootstrap(engineCore, context, envVars) {
153
153
  await bootstrapBlobEncryption(engineCore, context, envVars);
154
154
  await addVerificationMethod(engineCore, context, "attestation", envVars.attestationVerificationMethodId);
155
155
  await addVerificationMethod(engineCore, context, "immutable proof", envVars.immutableProofVerificationMethodId);
156
- await addVerificationMethod(engineCore, context, "node to node authentication", envVars.vcAuthenticationVerificationMethodId);
156
+ if (core.Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
157
+ await addVerificationMethod(engineCore, context, "verifiable credential authentication", envVars.vcAuthenticationVerificationMethodId);
158
+ }
157
159
  await bootstrapSynchronisedStorage(engineCore, context, envVars);
158
160
  }
159
161
  /**
@@ -376,8 +378,8 @@ async function bootstrapNodeUser(engineCore, context, envVars, features) {
376
378
  }
377
379
  }
378
380
  // We have create a node user, now we need to create a profile for the user
379
- const defaultIdentityConnectorType = engineCore.getRegisteredInstanceType("identityConnector");
380
- const identityProfileConnector = identityModels.IdentityProfileConnectorFactory.get(defaultIdentityConnectorType);
381
+ const defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType("identityProfileConnector");
382
+ const identityProfileConnector = identityModels.IdentityProfileConnectorFactory.get(defaultIdentityProfileConnectorType);
381
383
  if (identityProfileConnector) {
382
384
  let userProfile;
383
385
  try {
@@ -594,25 +596,16 @@ function buildEngineConfiguration(envVars) {
594
596
  configureIdentityProfile(coreConfig, envVars);
595
597
  configureAttestation(coreConfig, envVars);
596
598
  configureDataProcessing(coreConfig, envVars);
597
- configureAuditableItemGraph(coreConfig);
598
- configureAuditableItemStream(coreConfig);
599
- configureDocumentManagement(coreConfig);
600
- configureNodeToNode(coreConfig, envVars);
599
+ configureAuditableItemGraph(coreConfig, envVars);
600
+ configureAuditableItemStream(coreConfig, envVars);
601
+ configureDocumentManagement(coreConfig, envVars);
602
+ configureVerifiableCredentialAuthentication(coreConfig, envVars);
601
603
  configureRightsManagement(coreConfig, envVars);
602
604
  configureSynchronisedStorage(coreConfig, envVars);
603
605
  configureFederatedCatalogue(coreConfig, envVars);
604
606
  configureDataSpaceConnector(coreConfig, envVars);
605
607
  return coreConfig;
606
608
  }
607
- /**
608
- * Helper function to get IOTA configuration from centralized dltConfig.
609
- * @param coreConfig The core config.
610
- * @returns The IOTA configuration if found, undefined otherwise.
611
- */
612
- function getIotaConfig(coreConfig) {
613
- const dltConfig = coreConfig.types.dltConfig?.find(config => config.type === engineTypes.DltConfigType.Iota && config.isDefault);
614
- return dltConfig?.options?.config;
615
- }
616
609
  /**
617
610
  * Configures the entity storage.
618
611
  * @param coreConfig The core config.
@@ -1067,14 +1060,14 @@ function configureFaucet(coreConfig, envVars) {
1067
1060
  });
1068
1061
  }
1069
1062
  else if (envVars.faucetConnector === engineTypes.FaucetConnectorType.Iota) {
1070
- const iotaConfig = getIotaConfig(coreConfig);
1063
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1071
1064
  coreConfig.types.faucetConnector.push({
1072
1065
  type: engineTypes.FaucetConnectorType.Iota,
1073
1066
  options: {
1074
1067
  config: {
1075
1068
  endpoint: envVars.iotaFaucetEndpoint ?? "",
1076
- clientOptions: iotaConfig?.clientOptions ?? { url: "" },
1077
- network: iotaConfig?.network ?? ""
1069
+ clientOptions: dltConfig?.options?.config?.clientOptions ?? { url: "" },
1070
+ network: dltConfig?.options?.config?.network ?? ""
1078
1071
  }
1079
1072
  }
1080
1073
  });
@@ -1093,11 +1086,11 @@ function configureWallet(coreConfig, envVars) {
1093
1086
  });
1094
1087
  }
1095
1088
  else if (envVars.walletConnector === engineTypes.WalletConnectorType.Iota) {
1096
- const iotaConfig = getIotaConfig(coreConfig);
1089
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1097
1090
  coreConfig.types.walletConnector.push({
1098
1091
  type: engineTypes.WalletConnectorType.Iota,
1099
1092
  options: {
1100
- config: iotaConfig ?? {}
1093
+ config: dltConfig?.options?.config ?? {}
1101
1094
  }
1102
1095
  });
1103
1096
  }
@@ -1115,11 +1108,11 @@ function configureNft(coreConfig, envVars) {
1115
1108
  });
1116
1109
  }
1117
1110
  else if (envVars.nftConnector === engineTypes.NftConnectorType.Iota) {
1118
- const iotaConfig = getIotaConfig(coreConfig);
1111
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1119
1112
  coreConfig.types.nftConnector.push({
1120
1113
  type: engineTypes.NftConnectorType.Iota,
1121
1114
  options: {
1122
- config: iotaConfig ?? {}
1115
+ config: dltConfig?.options?.config ?? {}
1123
1116
  }
1124
1117
  });
1125
1118
  }
@@ -1141,11 +1134,11 @@ function configureVerifiableStorage(coreConfig, envVars) {
1141
1134
  });
1142
1135
  }
1143
1136
  else if (envVars.verifiableStorageConnector === engineTypes.VerifiableStorageConnectorType.Iota) {
1144
- const iotaConfig = getIotaConfig(coreConfig);
1137
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1145
1138
  coreConfig.types.verifiableStorageConnector.push({
1146
1139
  type: engineTypes.VerifiableStorageConnectorType.Iota,
1147
1140
  options: {
1148
- config: iotaConfig ?? {}
1141
+ config: dltConfig?.options?.config ?? {}
1149
1142
  }
1150
1143
  });
1151
1144
  }
@@ -1163,14 +1156,6 @@ function configureVerifiableStorage(coreConfig, envVars) {
1163
1156
  }
1164
1157
  }
1165
1158
  });
1166
- coreConfig.types.auditableItemGraphComponent ??= [];
1167
- coreConfig.types.auditableItemGraphComponent.push({
1168
- type: engineTypes.AuditableItemGraphComponentType.Service
1169
- });
1170
- coreConfig.types.auditableItemStreamComponent ??= [];
1171
- coreConfig.types.auditableItemStreamComponent.push({
1172
- type: engineTypes.AuditableItemStreamComponentType.Service
1173
- });
1174
1159
  }
1175
1160
  }
1176
1161
  /**
@@ -1186,11 +1171,11 @@ function configureIdentity(coreConfig, envVars) {
1186
1171
  });
1187
1172
  }
1188
1173
  else if (envVars.identityConnector === engineTypes.IdentityConnectorType.Iota) {
1189
- const iotaConfig = getIotaConfig(coreConfig);
1174
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1190
1175
  coreConfig.types.identityConnector.push({
1191
1176
  type: engineTypes.IdentityConnectorType.Iota,
1192
1177
  options: {
1193
- config: iotaConfig ?? {}
1178
+ config: dltConfig?.options?.config ?? {}
1194
1179
  }
1195
1180
  });
1196
1181
  }
@@ -1212,11 +1197,11 @@ function configureIdentityResolver(coreConfig, envVars) {
1212
1197
  });
1213
1198
  }
1214
1199
  else if (envVars.identityResolverConnector === engineTypes.IdentityResolverConnectorType.Iota) {
1215
- const iotaConfig = getIotaConfig(coreConfig);
1200
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1216
1201
  coreConfig.types.identityResolverConnector.push({
1217
1202
  type: engineTypes.IdentityResolverConnectorType.Iota,
1218
1203
  options: {
1219
- config: iotaConfig ?? {}
1204
+ config: dltConfig?.options?.config ?? {}
1220
1205
  }
1221
1206
  });
1222
1207
  }
@@ -1284,7 +1269,7 @@ function configureAttestation(coreConfig, envVars) {
1284
1269
  * @param envVars The environment variables.
1285
1270
  */
1286
1271
  function configureAuditableItemGraph(coreConfig, envVars) {
1287
- if (core.Is.arrayValue(coreConfig.types.verifiableStorageConnector)) {
1272
+ if (core.Coerce.boolean(envVars.auditableItemGraphEnabled) ?? false) {
1288
1273
  coreConfig.types.auditableItemGraphComponent ??= [];
1289
1274
  coreConfig.types.auditableItemGraphComponent.push({
1290
1275
  type: engineTypes.AuditableItemGraphComponentType.Service
@@ -1297,7 +1282,7 @@ function configureAuditableItemGraph(coreConfig, envVars) {
1297
1282
  * @param envVars The environment variables.
1298
1283
  */
1299
1284
  function configureAuditableItemStream(coreConfig, envVars) {
1300
- if (core.Is.arrayValue(coreConfig.types.verifiableStorageConnector)) {
1285
+ if (core.Coerce.boolean(envVars.auditableItemStreamEnabled) ?? false) {
1301
1286
  coreConfig.types.auditableItemStreamComponent ??= [];
1302
1287
  coreConfig.types.auditableItemStreamComponent.push({
1303
1288
  type: engineTypes.AuditableItemStreamComponentType.Service
@@ -1310,33 +1295,32 @@ function configureAuditableItemStream(coreConfig, envVars) {
1310
1295
  * @param envVars The environment variables.
1311
1296
  */
1312
1297
  function configureDataProcessing(coreConfig, envVars) {
1313
- coreConfig.types.dataConverterConnector ??= [];
1314
- coreConfig.types.dataExtractorConnector ??= [];
1315
- const converterConnectors = envVars.dataConverterConnectors?.split(",") ?? [];
1316
- for (const converterConnector of converterConnectors) {
1317
- if (converterConnector === engineTypes.DataConverterConnectorType.Json) {
1318
- coreConfig.types.dataConverterConnector.push({
1319
- type: engineTypes.DataConverterConnectorType.Json
1320
- });
1321
- }
1322
- else if (converterConnector === engineTypes.DataConverterConnectorType.Xml) {
1323
- coreConfig.types.dataConverterConnector.push({
1324
- type: engineTypes.DataConverterConnectorType.Xml
1325
- });
1326
- }
1327
- }
1328
- const extractorConnectors = envVars.dataExtractorConnectors?.split(",") ?? [];
1329
- for (const extractorConnector of extractorConnectors) {
1330
- if (extractorConnector === engineTypes.DataExtractorConnectorType.JsonPath) {
1331
- coreConfig.types.dataExtractorConnector.push({
1332
- type: engineTypes.DataExtractorConnectorType.JsonPath
1333
- });
1334
- }
1335
- }
1336
- if (coreConfig.types.dataConverterConnector.length > 0 ||
1337
- coreConfig.types.dataExtractorConnector.length > 0) {
1298
+ if (core.Coerce.boolean(envVars.dataProcessingEnabled) ?? false) {
1338
1299
  coreConfig.types.dataProcessingComponent ??= [];
1339
1300
  coreConfig.types.dataProcessingComponent.push({ type: engineTypes.DataProcessingComponentType.Service });
1301
+ coreConfig.types.dataConverterConnector ??= [];
1302
+ const converterConnectors = envVars.dataConverterConnectors?.split(",") ?? [];
1303
+ for (const converterConnector of converterConnectors) {
1304
+ if (converterConnector === engineTypes.DataConverterConnectorType.Json) {
1305
+ coreConfig.types.dataConverterConnector.push({
1306
+ type: engineTypes.DataConverterConnectorType.Json
1307
+ });
1308
+ }
1309
+ else if (converterConnector === engineTypes.DataConverterConnectorType.Xml) {
1310
+ coreConfig.types.dataConverterConnector.push({
1311
+ type: engineTypes.DataConverterConnectorType.Xml
1312
+ });
1313
+ }
1314
+ }
1315
+ coreConfig.types.dataExtractorConnector ??= [];
1316
+ const extractorConnectors = envVars.dataExtractorConnectors?.split(",") ?? [];
1317
+ for (const extractorConnector of extractorConnectors) {
1318
+ if (extractorConnector === engineTypes.DataExtractorConnectorType.JsonPath) {
1319
+ coreConfig.types.dataExtractorConnector.push({
1320
+ type: engineTypes.DataExtractorConnectorType.JsonPath
1321
+ });
1322
+ }
1323
+ }
1340
1324
  }
1341
1325
  }
1342
1326
  /**
@@ -1345,9 +1329,7 @@ function configureDataProcessing(coreConfig, envVars) {
1345
1329
  * @param envVars The environment variables.
1346
1330
  */
1347
1331
  function configureDocumentManagement(coreConfig, envVars) {
1348
- if (core.Is.arrayValue(coreConfig.types.auditableItemGraphComponent) &&
1349
- core.Is.arrayValue(coreConfig.types.blobStorageComponent) &&
1350
- core.Is.arrayValue(coreConfig.types.attestationComponent)) {
1332
+ if (core.Coerce.boolean(envVars.documentManagementEnabled) ?? false) {
1351
1333
  coreConfig.types.documentManagementComponent ??= [];
1352
1334
  coreConfig.types.documentManagementComponent.push({
1353
1335
  type: engineTypes.DocumentManagementComponentType.Service
@@ -1355,12 +1337,12 @@ function configureDocumentManagement(coreConfig, envVars) {
1355
1337
  }
1356
1338
  }
1357
1339
  /**
1358
- * Configures the node to node.
1340
+ * Configures the verifiable credential authentication.
1359
1341
  * @param coreConfig The core config.
1360
1342
  * @param envVars The environment variables.
1361
1343
  */
1362
- function configureNodeToNode(coreConfig, envVars) {
1363
- if (core.Is.arrayValue(coreConfig.types.identityComponent)) {
1344
+ function configureVerifiableCredentialAuthentication(coreConfig, envVars) {
1345
+ if (core.Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
1364
1346
  // Can only perform VC authentication if identity component is available
1365
1347
  coreConfig.types.authenticationGeneratorComponent ??= [];
1366
1348
  coreConfig.types.authenticationGeneratorComponent.push({
@@ -1735,7 +1717,7 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
1735
1717
  }
1736
1718
  });
1737
1719
  }
1738
- if (core.Coerce.boolean(envVars.enableVerifiableCredentialRouteProcessors) ?? false) {
1720
+ if (core.Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
1739
1721
  serverConfig.types.restRouteProcessor.push({
1740
1722
  type: engineServerTypes.RestRouteProcessorType.AuthVerifiableCredential
1741
1723
  });
@@ -1777,13 +1759,13 @@ async function start(nodeOptions, engineServerConfig, envVars) {
1777
1759
  stateStorage: nodeOptions?.stateStorage ?? new engineCore.FileStateStorage(envVars.stateFilename ?? ""),
1778
1760
  customBootstrap: async (core, engineContext) => bootstrap(core, engineContext, envVars)
1779
1761
  });
1762
+ // Construct the server with the engine.
1763
+ const server = new engineServer.EngineServer({ engineCore: engine$1 });
1780
1764
  // Extend the engine.
1781
1765
  if (core.Is.function(nodeOptions?.extendEngine)) {
1782
1766
  console.info("Extending Engine");
1783
1767
  await nodeOptions.extendEngine(engine$1);
1784
1768
  }
1785
- // Construct the server with the engine.
1786
- const server = new engineServer.EngineServer({ engineCore: engine$1 });
1787
1769
  // Extend the engine server.
1788
1770
  if (core.Is.function(nodeOptions?.extendEngineServer)) {
1789
1771
  console.info("Extending Engine Server");
@@ -1815,7 +1797,7 @@ async function run(nodeOptions) {
1815
1797
  nodeOptions ??= {};
1816
1798
  const serverInfo = {
1817
1799
  name: nodeOptions?.serverName ?? "TWIN Node Server",
1818
- version: nodeOptions?.serverVersion ?? "0.0.2-next.14" // x-release-please-version
1800
+ version: nodeOptions?.serverVersion ?? "0.0.2-next.15" // x-release-please-version
1819
1801
  };
1820
1802
  console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
1821
1803
  if (!core.Is.stringValue(nodeOptions?.executionDirectory)) {
@@ -1,8 +1,8 @@
1
1
  import { PasswordHelper } from '@twin.org/api-auth-entity-storage-service';
2
- import { I18n, Is, Converter, RandomHelper, StringHelper, Coerce, Urn, GeneralError, ErrorHelper, EnvHelper } from '@twin.org/core';
2
+ import { I18n, Is, Coerce, Converter, RandomHelper, StringHelper, Urn, GeneralError, ErrorHelper, EnvHelper } from '@twin.org/core';
3
3
  import { PasswordGenerator, Bip39 } from '@twin.org/crypto';
4
4
  import { AuthenticationComponentType, InformationComponentType, RestRouteProcessorType, SocketRouteProcessorType, AuthenticationAdminComponentType } from '@twin.org/engine-server-types';
5
- import { WalletConnectorType, IdentityConnectorType, EntityStorageConnectorType, BlobStorageConnectorType, BlobStorageComponentType, VaultConnectorType, DltConfigType, LoggingConnectorType, LoggingComponentType, BackgroundTaskConnectorType, TaskSchedulerComponentType, EventBusConnectorType, EventBusComponentType, TelemetryConnectorType, TelemetryComponentType, MessagingEmailConnectorType, MessagingSmsConnectorType, MessagingPushNotificationConnectorType, MessagingComponentType, FaucetConnectorType, NftConnectorType, NftComponentType, VerifiableStorageConnectorType, VerifiableStorageComponentType, ImmutableProofComponentType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, IdentityComponentType, IdentityResolverConnectorType, IdentityResolverComponentType, IdentityProfileConnectorType, IdentityProfileComponentType, AttestationConnectorType, AttestationComponentType, DataConverterConnectorType, DataExtractorConnectorType, DataProcessingComponentType, DocumentManagementComponentType, AuthenticationGeneratorComponentType, RightsManagementPapComponentType, RightsManagementPmpComponentType, RightsManagementPipComponentType, RightsManagementPxpComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPnpComponentType, RightsManagementPnapComponentType, RightsManagementDapComponentType, RightsManagementDarpComponentType, SynchronisedStorageComponentType, FederatedCatalogueComponentType, DataSpaceConnectorComponentType } from '@twin.org/engine-types';
5
+ import { WalletConnectorType, IdentityConnectorType, EntityStorageConnectorType, BlobStorageConnectorType, BlobStorageComponentType, VaultConnectorType, DltConfigType, LoggingConnectorType, LoggingComponentType, BackgroundTaskConnectorType, TaskSchedulerComponentType, EventBusConnectorType, EventBusComponentType, TelemetryConnectorType, TelemetryComponentType, MessagingEmailConnectorType, MessagingSmsConnectorType, MessagingPushNotificationConnectorType, MessagingComponentType, FaucetConnectorType, EngineTypeHelper, NftConnectorType, NftComponentType, VerifiableStorageConnectorType, VerifiableStorageComponentType, ImmutableProofComponentType, IdentityComponentType, IdentityResolverConnectorType, IdentityResolverComponentType, IdentityProfileConnectorType, IdentityProfileComponentType, AttestationConnectorType, AttestationComponentType, DataProcessingComponentType, DataConverterConnectorType, DataExtractorConnectorType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, DocumentManagementComponentType, AuthenticationGeneratorComponentType, RightsManagementPapComponentType, RightsManagementPmpComponentType, RightsManagementPipComponentType, RightsManagementPxpComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPnpComponentType, RightsManagementPnapComponentType, RightsManagementDapComponentType, RightsManagementDarpComponentType, SynchronisedStorageComponentType, FederatedCatalogueComponentType, DataSpaceConnectorComponentType } from '@twin.org/engine-types';
6
6
  import { EntityStorageConnectorFactory } from '@twin.org/entity-storage-models';
7
7
  import { IdentityProfileConnectorFactory, IdentityConnectorFactory, IdentityResolverConnectorFactory, DocumentHelper } from '@twin.org/identity-models';
8
8
  import { VaultConnectorFactory, VaultKeyType } from '@twin.org/vault-models';
@@ -132,7 +132,9 @@ async function bootstrap(engineCore, context, envVars) {
132
132
  await bootstrapBlobEncryption(engineCore, context, envVars);
133
133
  await addVerificationMethod(engineCore, context, "attestation", envVars.attestationVerificationMethodId);
134
134
  await addVerificationMethod(engineCore, context, "immutable proof", envVars.immutableProofVerificationMethodId);
135
- await addVerificationMethod(engineCore, context, "node to node authentication", envVars.vcAuthenticationVerificationMethodId);
135
+ if (Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
136
+ await addVerificationMethod(engineCore, context, "verifiable credential authentication", envVars.vcAuthenticationVerificationMethodId);
137
+ }
136
138
  await bootstrapSynchronisedStorage(engineCore, context, envVars);
137
139
  }
138
140
  /**
@@ -355,8 +357,8 @@ async function bootstrapNodeUser(engineCore, context, envVars, features) {
355
357
  }
356
358
  }
357
359
  // We have create a node user, now we need to create a profile for the user
358
- const defaultIdentityConnectorType = engineCore.getRegisteredInstanceType("identityConnector");
359
- const identityProfileConnector = IdentityProfileConnectorFactory.get(defaultIdentityConnectorType);
360
+ const defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType("identityProfileConnector");
361
+ const identityProfileConnector = IdentityProfileConnectorFactory.get(defaultIdentityProfileConnectorType);
360
362
  if (identityProfileConnector) {
361
363
  let userProfile;
362
364
  try {
@@ -573,25 +575,16 @@ function buildEngineConfiguration(envVars) {
573
575
  configureIdentityProfile(coreConfig, envVars);
574
576
  configureAttestation(coreConfig, envVars);
575
577
  configureDataProcessing(coreConfig, envVars);
576
- configureAuditableItemGraph(coreConfig);
577
- configureAuditableItemStream(coreConfig);
578
- configureDocumentManagement(coreConfig);
579
- configureNodeToNode(coreConfig, envVars);
578
+ configureAuditableItemGraph(coreConfig, envVars);
579
+ configureAuditableItemStream(coreConfig, envVars);
580
+ configureDocumentManagement(coreConfig, envVars);
581
+ configureVerifiableCredentialAuthentication(coreConfig, envVars);
580
582
  configureRightsManagement(coreConfig, envVars);
581
583
  configureSynchronisedStorage(coreConfig, envVars);
582
584
  configureFederatedCatalogue(coreConfig, envVars);
583
585
  configureDataSpaceConnector(coreConfig, envVars);
584
586
  return coreConfig;
585
587
  }
586
- /**
587
- * Helper function to get IOTA configuration from centralized dltConfig.
588
- * @param coreConfig The core config.
589
- * @returns The IOTA configuration if found, undefined otherwise.
590
- */
591
- function getIotaConfig(coreConfig) {
592
- const dltConfig = coreConfig.types.dltConfig?.find(config => config.type === DltConfigType.Iota && config.isDefault);
593
- return dltConfig?.options?.config;
594
- }
595
588
  /**
596
589
  * Configures the entity storage.
597
590
  * @param coreConfig The core config.
@@ -1046,14 +1039,14 @@ function configureFaucet(coreConfig, envVars) {
1046
1039
  });
1047
1040
  }
1048
1041
  else if (envVars.faucetConnector === FaucetConnectorType.Iota) {
1049
- const iotaConfig = getIotaConfig(coreConfig);
1042
+ const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
1050
1043
  coreConfig.types.faucetConnector.push({
1051
1044
  type: FaucetConnectorType.Iota,
1052
1045
  options: {
1053
1046
  config: {
1054
1047
  endpoint: envVars.iotaFaucetEndpoint ?? "",
1055
- clientOptions: iotaConfig?.clientOptions ?? { url: "" },
1056
- network: iotaConfig?.network ?? ""
1048
+ clientOptions: dltConfig?.options?.config?.clientOptions ?? { url: "" },
1049
+ network: dltConfig?.options?.config?.network ?? ""
1057
1050
  }
1058
1051
  }
1059
1052
  });
@@ -1072,11 +1065,11 @@ function configureWallet(coreConfig, envVars) {
1072
1065
  });
1073
1066
  }
1074
1067
  else if (envVars.walletConnector === WalletConnectorType.Iota) {
1075
- const iotaConfig = getIotaConfig(coreConfig);
1068
+ const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
1076
1069
  coreConfig.types.walletConnector.push({
1077
1070
  type: WalletConnectorType.Iota,
1078
1071
  options: {
1079
- config: iotaConfig ?? {}
1072
+ config: dltConfig?.options?.config ?? {}
1080
1073
  }
1081
1074
  });
1082
1075
  }
@@ -1094,11 +1087,11 @@ function configureNft(coreConfig, envVars) {
1094
1087
  });
1095
1088
  }
1096
1089
  else if (envVars.nftConnector === NftConnectorType.Iota) {
1097
- const iotaConfig = getIotaConfig(coreConfig);
1090
+ const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
1098
1091
  coreConfig.types.nftConnector.push({
1099
1092
  type: NftConnectorType.Iota,
1100
1093
  options: {
1101
- config: iotaConfig ?? {}
1094
+ config: dltConfig?.options?.config ?? {}
1102
1095
  }
1103
1096
  });
1104
1097
  }
@@ -1120,11 +1113,11 @@ function configureVerifiableStorage(coreConfig, envVars) {
1120
1113
  });
1121
1114
  }
1122
1115
  else if (envVars.verifiableStorageConnector === VerifiableStorageConnectorType.Iota) {
1123
- const iotaConfig = getIotaConfig(coreConfig);
1116
+ const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
1124
1117
  coreConfig.types.verifiableStorageConnector.push({
1125
1118
  type: VerifiableStorageConnectorType.Iota,
1126
1119
  options: {
1127
- config: iotaConfig ?? {}
1120
+ config: dltConfig?.options?.config ?? {}
1128
1121
  }
1129
1122
  });
1130
1123
  }
@@ -1142,14 +1135,6 @@ function configureVerifiableStorage(coreConfig, envVars) {
1142
1135
  }
1143
1136
  }
1144
1137
  });
1145
- coreConfig.types.auditableItemGraphComponent ??= [];
1146
- coreConfig.types.auditableItemGraphComponent.push({
1147
- type: AuditableItemGraphComponentType.Service
1148
- });
1149
- coreConfig.types.auditableItemStreamComponent ??= [];
1150
- coreConfig.types.auditableItemStreamComponent.push({
1151
- type: AuditableItemStreamComponentType.Service
1152
- });
1153
1138
  }
1154
1139
  }
1155
1140
  /**
@@ -1165,11 +1150,11 @@ function configureIdentity(coreConfig, envVars) {
1165
1150
  });
1166
1151
  }
1167
1152
  else if (envVars.identityConnector === IdentityConnectorType.Iota) {
1168
- const iotaConfig = getIotaConfig(coreConfig);
1153
+ const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
1169
1154
  coreConfig.types.identityConnector.push({
1170
1155
  type: IdentityConnectorType.Iota,
1171
1156
  options: {
1172
- config: iotaConfig ?? {}
1157
+ config: dltConfig?.options?.config ?? {}
1173
1158
  }
1174
1159
  });
1175
1160
  }
@@ -1191,11 +1176,11 @@ function configureIdentityResolver(coreConfig, envVars) {
1191
1176
  });
1192
1177
  }
1193
1178
  else if (envVars.identityResolverConnector === IdentityResolverConnectorType.Iota) {
1194
- const iotaConfig = getIotaConfig(coreConfig);
1179
+ const dltConfig = EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", DltConfigType.Iota);
1195
1180
  coreConfig.types.identityResolverConnector.push({
1196
1181
  type: IdentityResolverConnectorType.Iota,
1197
1182
  options: {
1198
- config: iotaConfig ?? {}
1183
+ config: dltConfig?.options?.config ?? {}
1199
1184
  }
1200
1185
  });
1201
1186
  }
@@ -1263,7 +1248,7 @@ function configureAttestation(coreConfig, envVars) {
1263
1248
  * @param envVars The environment variables.
1264
1249
  */
1265
1250
  function configureAuditableItemGraph(coreConfig, envVars) {
1266
- if (Is.arrayValue(coreConfig.types.verifiableStorageConnector)) {
1251
+ if (Coerce.boolean(envVars.auditableItemGraphEnabled) ?? false) {
1267
1252
  coreConfig.types.auditableItemGraphComponent ??= [];
1268
1253
  coreConfig.types.auditableItemGraphComponent.push({
1269
1254
  type: AuditableItemGraphComponentType.Service
@@ -1276,7 +1261,7 @@ function configureAuditableItemGraph(coreConfig, envVars) {
1276
1261
  * @param envVars The environment variables.
1277
1262
  */
1278
1263
  function configureAuditableItemStream(coreConfig, envVars) {
1279
- if (Is.arrayValue(coreConfig.types.verifiableStorageConnector)) {
1264
+ if (Coerce.boolean(envVars.auditableItemStreamEnabled) ?? false) {
1280
1265
  coreConfig.types.auditableItemStreamComponent ??= [];
1281
1266
  coreConfig.types.auditableItemStreamComponent.push({
1282
1267
  type: AuditableItemStreamComponentType.Service
@@ -1289,33 +1274,32 @@ function configureAuditableItemStream(coreConfig, envVars) {
1289
1274
  * @param envVars The environment variables.
1290
1275
  */
1291
1276
  function configureDataProcessing(coreConfig, envVars) {
1292
- coreConfig.types.dataConverterConnector ??= [];
1293
- coreConfig.types.dataExtractorConnector ??= [];
1294
- const converterConnectors = envVars.dataConverterConnectors?.split(",") ?? [];
1295
- for (const converterConnector of converterConnectors) {
1296
- if (converterConnector === DataConverterConnectorType.Json) {
1297
- coreConfig.types.dataConverterConnector.push({
1298
- type: DataConverterConnectorType.Json
1299
- });
1300
- }
1301
- else if (converterConnector === DataConverterConnectorType.Xml) {
1302
- coreConfig.types.dataConverterConnector.push({
1303
- type: DataConverterConnectorType.Xml
1304
- });
1305
- }
1306
- }
1307
- const extractorConnectors = envVars.dataExtractorConnectors?.split(",") ?? [];
1308
- for (const extractorConnector of extractorConnectors) {
1309
- if (extractorConnector === DataExtractorConnectorType.JsonPath) {
1310
- coreConfig.types.dataExtractorConnector.push({
1311
- type: DataExtractorConnectorType.JsonPath
1312
- });
1313
- }
1314
- }
1315
- if (coreConfig.types.dataConverterConnector.length > 0 ||
1316
- coreConfig.types.dataExtractorConnector.length > 0) {
1277
+ if (Coerce.boolean(envVars.dataProcessingEnabled) ?? false) {
1317
1278
  coreConfig.types.dataProcessingComponent ??= [];
1318
1279
  coreConfig.types.dataProcessingComponent.push({ type: DataProcessingComponentType.Service });
1280
+ coreConfig.types.dataConverterConnector ??= [];
1281
+ const converterConnectors = envVars.dataConverterConnectors?.split(",") ?? [];
1282
+ for (const converterConnector of converterConnectors) {
1283
+ if (converterConnector === DataConverterConnectorType.Json) {
1284
+ coreConfig.types.dataConverterConnector.push({
1285
+ type: DataConverterConnectorType.Json
1286
+ });
1287
+ }
1288
+ else if (converterConnector === DataConverterConnectorType.Xml) {
1289
+ coreConfig.types.dataConverterConnector.push({
1290
+ type: DataConverterConnectorType.Xml
1291
+ });
1292
+ }
1293
+ }
1294
+ coreConfig.types.dataExtractorConnector ??= [];
1295
+ const extractorConnectors = envVars.dataExtractorConnectors?.split(",") ?? [];
1296
+ for (const extractorConnector of extractorConnectors) {
1297
+ if (extractorConnector === DataExtractorConnectorType.JsonPath) {
1298
+ coreConfig.types.dataExtractorConnector.push({
1299
+ type: DataExtractorConnectorType.JsonPath
1300
+ });
1301
+ }
1302
+ }
1319
1303
  }
1320
1304
  }
1321
1305
  /**
@@ -1324,9 +1308,7 @@ function configureDataProcessing(coreConfig, envVars) {
1324
1308
  * @param envVars The environment variables.
1325
1309
  */
1326
1310
  function configureDocumentManagement(coreConfig, envVars) {
1327
- if (Is.arrayValue(coreConfig.types.auditableItemGraphComponent) &&
1328
- Is.arrayValue(coreConfig.types.blobStorageComponent) &&
1329
- Is.arrayValue(coreConfig.types.attestationComponent)) {
1311
+ if (Coerce.boolean(envVars.documentManagementEnabled) ?? false) {
1330
1312
  coreConfig.types.documentManagementComponent ??= [];
1331
1313
  coreConfig.types.documentManagementComponent.push({
1332
1314
  type: DocumentManagementComponentType.Service
@@ -1334,12 +1316,12 @@ function configureDocumentManagement(coreConfig, envVars) {
1334
1316
  }
1335
1317
  }
1336
1318
  /**
1337
- * Configures the node to node.
1319
+ * Configures the verifiable credential authentication.
1338
1320
  * @param coreConfig The core config.
1339
1321
  * @param envVars The environment variables.
1340
1322
  */
1341
- function configureNodeToNode(coreConfig, envVars) {
1342
- if (Is.arrayValue(coreConfig.types.identityComponent)) {
1323
+ function configureVerifiableCredentialAuthentication(coreConfig, envVars) {
1324
+ if (Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
1343
1325
  // Can only perform VC authentication if identity component is available
1344
1326
  coreConfig.types.authenticationGeneratorComponent ??= [];
1345
1327
  coreConfig.types.authenticationGeneratorComponent.push({
@@ -1714,7 +1696,7 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
1714
1696
  }
1715
1697
  });
1716
1698
  }
1717
- if (Coerce.boolean(envVars.enableVerifiableCredentialRouteProcessors) ?? false) {
1699
+ if (Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
1718
1700
  serverConfig.types.restRouteProcessor.push({
1719
1701
  type: RestRouteProcessorType.AuthVerifiableCredential
1720
1702
  });
@@ -1756,13 +1738,13 @@ async function start(nodeOptions, engineServerConfig, envVars) {
1756
1738
  stateStorage: nodeOptions?.stateStorage ?? new FileStateStorage(envVars.stateFilename ?? ""),
1757
1739
  customBootstrap: async (core, engineContext) => bootstrap(core, engineContext, envVars)
1758
1740
  });
1741
+ // Construct the server with the engine.
1742
+ const server = new EngineServer({ engineCore: engine });
1759
1743
  // Extend the engine.
1760
1744
  if (Is.function(nodeOptions?.extendEngine)) {
1761
1745
  console.info("Extending Engine");
1762
1746
  await nodeOptions.extendEngine(engine);
1763
1747
  }
1764
- // Construct the server with the engine.
1765
- const server = new EngineServer({ engineCore: engine });
1766
1748
  // Extend the engine server.
1767
1749
  if (Is.function(nodeOptions?.extendEngineServer)) {
1768
1750
  console.info("Extending Engine Server");
@@ -1794,7 +1776,7 @@ async function run(nodeOptions) {
1794
1776
  nodeOptions ??= {};
1795
1777
  const serverInfo = {
1796
1778
  name: nodeOptions?.serverName ?? "TWIN Node Server",
1797
- version: nodeOptions?.serverVersion ?? "0.0.2-next.14" // x-release-please-version
1779
+ version: nodeOptions?.serverVersion ?? "0.0.2-next.15" // x-release-please-version
1798
1780
  };
1799
1781
  console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
1800
1782
  if (!Is.stringValue(nodeOptions?.executionDirectory)) {
@@ -369,6 +369,10 @@ export interface IEngineEnvironmentVariables {
369
369
  * The identity verification method id to use with attestation.
370
370
  */
371
371
  attestationVerificationMethodId?: string;
372
+ /**
373
+ * Is the data processing enabled, defaults to false.
374
+ */
375
+ dataProcessingEnabled?: string;
372
376
  /**
373
377
  * The type of the default data converters, can be a comma separated list: json, xml.
374
378
  */
@@ -377,6 +381,18 @@ export interface IEngineEnvironmentVariables {
377
381
  * The type of the default data extractor, can be a comma separated list: json-path.
378
382
  */
379
383
  dataExtractorConnectors?: string;
384
+ /**
385
+ * Is the auditable item graph enabled, defaults to false.
386
+ */
387
+ auditableItemGraphEnabled?: string;
388
+ /**
389
+ * Is the auditable item stream enabled, defaults to false.
390
+ */
391
+ auditableItemStreamEnabled?: string;
392
+ /**
393
+ * Is the document management enabled, defaults to false.
394
+ */
395
+ documentManagementEnabled?: string;
380
396
  /**
381
397
  * Is the synchronised storage enabled, defaults to false.
382
398
  */
@@ -489,6 +505,10 @@ export interface IEngineEnvironmentVariables {
489
505
  * Use the @json: prefix to specify the path to the JSON configuration file.
490
506
  */
491
507
  dataSpaceConnectorApps?: string;
508
+ /**
509
+ * Enable verifiable credential authentication for the API.
510
+ */
511
+ vcAuthenticationEnabled?: string;
492
512
  /**
493
513
  * Verifiable credential assertion for node to node communication.
494
514
  * Defaults to node-authentication-assertion.
@@ -1,7 +1,8 @@
1
+ import type { IEngineEnvironmentVariables } from "./IEngineEnvironmentVariables";
1
2
  /**
2
3
  * The engine server environment variables.
3
4
  */
4
- export interface IEngineServerEnvironmentVariables {
5
+ export interface IEngineServerEnvironmentVariables extends IEngineEnvironmentVariables {
5
6
  /**
6
7
  * The port to serve the API from.
7
8
  */
@@ -42,10 +43,6 @@ export interface IEngineServerEnvironmentVariables {
42
43
  * Additional MIME type processors to include, comma separated.
43
44
  */
44
45
  mimeTypeProcessors?: string;
45
- /**
46
- * Enable to the route processor for verifiable credentials.
47
- */
48
- enableVerifiableCredentialRouteProcessors?: string;
49
46
  /**
50
47
  * Disable Node Identity route processors.
51
48
  */
@@ -1,9 +1,8 @@
1
- import type { IEngineEnvironmentVariables } from "./IEngineEnvironmentVariables";
2
1
  import type { IEngineServerEnvironmentVariables } from "./IEngineServerEnvironmentVariables";
3
2
  /**
4
3
  * The environment variables for the node.
5
4
  */
6
- export interface INodeEnvironmentVariables extends IEngineEnvironmentVariables, IEngineServerEnvironmentVariables {
5
+ export interface INodeEnvironmentVariables extends IEngineServerEnvironmentVariables {
7
6
  /**
8
7
  * The features that are enabled on the node.
9
8
  * @default [NodeFeatures.NodeIdentity]