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

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.
@@ -98,6 +98,64 @@ async function fileExists(filename) {
98
98
  return false;
99
99
  }
100
100
  }
101
+ /**
102
+ * Does the specified directory exist.
103
+ * @param directory The directory to check for existence.
104
+ * @returns True if the directory exists.
105
+ */
106
+ async function directoryExists(directory) {
107
+ try {
108
+ const stats = await promises.stat(directory);
109
+ return stats.isDirectory();
110
+ }
111
+ catch {
112
+ return false;
113
+ }
114
+ }
115
+ /**
116
+ * Get the sub folders for the folder.
117
+ * @param directory The directory to get the sub folders.
118
+ * @returns The list of sub folders.
119
+ */
120
+ async function getSubFolders(directory) {
121
+ try {
122
+ const dir = await promises.readdir(directory);
123
+ const folders = [];
124
+ for (const dirEntry of dir) {
125
+ const fullPath = path.join(directory, dirEntry);
126
+ const stats = await promises.stat(fullPath);
127
+ if (stats.isDirectory()) {
128
+ folders.push(fullPath);
129
+ }
130
+ }
131
+ return folders;
132
+ }
133
+ catch {
134
+ return [];
135
+ }
136
+ }
137
+ /**
138
+ * Get the files in the directory.
139
+ * @param directory The directory to get the files from.
140
+ * @returns The list of files in the directory.
141
+ */
142
+ async function getFiles(directory) {
143
+ try {
144
+ const dir = await promises.readdir(directory);
145
+ const files = [];
146
+ for (const dirEntry of dir) {
147
+ const fullPath = path.join(directory, dirEntry);
148
+ const stats = await promises.stat(fullPath);
149
+ if (stats.isFile()) {
150
+ files.push(fullPath);
151
+ }
152
+ }
153
+ return files;
154
+ }
155
+ catch {
156
+ return [];
157
+ }
158
+ }
101
159
  /**
102
160
  * Load the text file.
103
161
  * @param filename The filename of the text file to load.
@@ -153,7 +211,9 @@ async function bootstrap(engineCore, context, envVars) {
153
211
  await bootstrapBlobEncryption(engineCore, context, envVars);
154
212
  await addVerificationMethod(engineCore, context, "attestation", envVars.attestationVerificationMethodId);
155
213
  await addVerificationMethod(engineCore, context, "immutable proof", envVars.immutableProofVerificationMethodId);
156
- await addVerificationMethod(engineCore, context, "node to node authentication", envVars.vcAuthenticationVerificationMethodId);
214
+ if (core.Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
215
+ await addVerificationMethod(engineCore, context, "verifiable credential authentication", envVars.vcAuthenticationVerificationMethodId);
216
+ }
157
217
  await bootstrapSynchronisedStorage(engineCore, context, envVars);
158
218
  }
159
219
  /**
@@ -265,7 +325,7 @@ async function finaliseWallet(engineCore, envVars, features, finalIdentity, addr
265
325
  // If we are using entity storage for wallet the identity associated with the
266
326
  // address will be wrong, so fix it
267
327
  if (defaultWalletConnectorType.startsWith(engineTypes.WalletConnectorType.EntityStorage)) {
268
- const walletAddress = entityStorageModels.EntityStorageConnectorFactory.get(core.StringHelper.kebabCase("WalletAddress"));
328
+ const walletAddress = entityStorageModels.EntityStorageConnectorFactory.get("wallet-address");
269
329
  const addr = await walletAddress.get(addresses[0]);
270
330
  if (!core.Is.empty(addr)) {
271
331
  addr.identity = finalIdentity;
@@ -335,7 +395,7 @@ async function bootstrapNodeUser(engineCore, context, envVars, features) {
335
395
  const defaultAuthenticationComponentType = engineCore.getRegisteredInstanceType("authenticationComponent");
336
396
  if (defaultAuthenticationComponentType.startsWith(engineServerTypes.AuthenticationComponentType.EntityStorage) &&
337
397
  core.Is.stringValue(context.state.nodeIdentity)) {
338
- const authUserEntityStorage = entityStorageModels.EntityStorageConnectorFactory.get(core.StringHelper.kebabCase("AuthenticationUser"));
398
+ const authUserEntityStorage = entityStorageModels.EntityStorageConnectorFactory.get("authentication-user");
339
399
  const email = envVars.username ?? DEFAULT_NODE_USERNAME;
340
400
  let nodeAdminUser = await authUserEntityStorage.get(email);
341
401
  if (core.Is.empty(nodeAdminUser)) {
@@ -376,8 +436,8 @@ async function bootstrapNodeUser(engineCore, context, envVars, features) {
376
436
  }
377
437
  }
378
438
  // 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);
439
+ const defaultIdentityProfileConnectorType = engineCore.getRegisteredInstanceType("identityProfileConnector");
440
+ const identityProfileConnector = identityModels.IdentityProfileConnectorFactory.get(defaultIdentityProfileConnectorType);
381
441
  if (identityProfileConnector) {
382
442
  let userProfile;
383
443
  try {
@@ -559,7 +619,7 @@ async function addVerificationMethod(engineCore, context, verificationMethodTitl
559
619
  * @param envVars The environment variables.
560
620
  * @returns The config for the core.
561
621
  */
562
- function buildEngineConfiguration(envVars) {
622
+ async function buildEngineConfiguration(envVars) {
563
623
  if (core.Is.stringValue(envVars.storageFileRoot)) {
564
624
  envVars.stateFilename ??= "engine-state.json";
565
625
  envVars.storageFileRoot = path.resolve(envVars.storageFileRoot);
@@ -575,50 +635,41 @@ function buildEngineConfiguration(envVars) {
575
635
  debug: core.Coerce.boolean(envVars.debug) ?? false,
576
636
  types: {}
577
637
  };
578
- configureEntityStorage(coreConfig, envVars);
579
- configureBlobStorage(coreConfig, envVars);
580
- configureVault(coreConfig, envVars);
581
- configureDlt(coreConfig, envVars);
582
- configureLogging(coreConfig, envVars);
583
- configureBackgroundTask(coreConfig, envVars);
584
- configureTaskScheduler(coreConfig, envVars);
585
- configureEventBus(coreConfig, envVars);
586
- configureTelemetry(coreConfig, envVars);
587
- configureMessaging(coreConfig, envVars);
588
- configureFaucet(coreConfig, envVars);
589
- configureWallet(coreConfig, envVars);
590
- configureNft(coreConfig, envVars);
591
- configureVerifiableStorage(coreConfig, envVars);
592
- configureIdentity(coreConfig, envVars);
593
- configureIdentityResolver(coreConfig, envVars);
594
- configureIdentityProfile(coreConfig, envVars);
595
- configureAttestation(coreConfig, envVars);
596
- configureDataProcessing(coreConfig, envVars);
597
- configureAuditableItemGraph(coreConfig);
598
- configureAuditableItemStream(coreConfig);
599
- configureDocumentManagement(coreConfig);
600
- configureNodeToNode(coreConfig, envVars);
601
- configureRightsManagement(coreConfig, envVars);
602
- configureSynchronisedStorage(coreConfig, envVars);
603
- configureFederatedCatalogue(coreConfig, envVars);
604
- configureDataSpaceConnector(coreConfig, envVars);
638
+ await configureEntityStorage(coreConfig, envVars);
639
+ await configureBlobStorage(coreConfig, envVars);
640
+ await configureVault(coreConfig, envVars);
641
+ await configureDlt(coreConfig, envVars);
642
+ await configureLogging(coreConfig, envVars);
643
+ await configureBackgroundTask(coreConfig, envVars);
644
+ await configureTaskScheduler(coreConfig, envVars);
645
+ await configureEventBus(coreConfig, envVars);
646
+ await configureTelemetry(coreConfig, envVars);
647
+ await configureMessaging(coreConfig, envVars);
648
+ await configureFaucet(coreConfig, envVars);
649
+ await configureWallet(coreConfig, envVars);
650
+ await configureNft(coreConfig, envVars);
651
+ await configureVerifiableStorage(coreConfig, envVars);
652
+ await configureIdentity(coreConfig, envVars);
653
+ await configureIdentityResolver(coreConfig, envVars);
654
+ await configureIdentityProfile(coreConfig, envVars);
655
+ await configureAttestation(coreConfig, envVars);
656
+ await configureDataProcessing(coreConfig, envVars);
657
+ await configureAuditableItemGraph(coreConfig, envVars);
658
+ await configureAuditableItemStream(coreConfig, envVars);
659
+ await configureDocumentManagement(coreConfig, envVars);
660
+ await configureVerifiableCredentialAuthentication(coreConfig, envVars);
661
+ await configureRightsManagement(coreConfig, envVars);
662
+ await configureSynchronisedStorage(coreConfig, envVars);
663
+ await configureFederatedCatalogue(coreConfig, envVars);
664
+ await configureDataSpaceConnector(coreConfig, envVars);
605
665
  return coreConfig;
606
666
  }
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
667
  /**
617
668
  * Configures the entity storage.
618
669
  * @param coreConfig The core config.
619
670
  * @param envVars The environment variables.
620
671
  */
621
- function configureEntityStorage(coreConfig, envVars) {
672
+ async function configureEntityStorage(coreConfig, envVars) {
622
673
  coreConfig.types ??= {};
623
674
  coreConfig.types.entityStorageConnector ??= [];
624
675
  const entityStorageConnectorTypes = envVars.entityStorageConnectorType?.split(",") ?? [];
@@ -762,7 +813,7 @@ function configureEntityStorage(coreConfig, envVars) {
762
813
  * @param coreConfig The core config.
763
814
  * @param envVars The environment variables.
764
815
  */
765
- function configureBlobStorage(coreConfig, envVars) {
816
+ async function configureBlobStorage(coreConfig, envVars) {
766
817
  coreConfig.types.blobStorageConnector ??= [];
767
818
  const blobStorageConnectorTypes = envVars.blobStorageConnectorType?.split(",") ?? [];
768
819
  if (blobStorageConnectorTypes.includes(engineTypes.BlobStorageConnectorType.Memory)) {
@@ -872,7 +923,7 @@ function configureBlobStorage(coreConfig, envVars) {
872
923
  * @param coreConfig The core config.
873
924
  * @param envVars The environment variables.
874
925
  */
875
- function configureLogging(coreConfig, envVars) {
926
+ async function configureLogging(coreConfig, envVars) {
876
927
  coreConfig.types.loggingConnector ??= [];
877
928
  const loggingConnectors = (envVars.loggingConnector ?? "").split(",");
878
929
  for (const loggingConnector of loggingConnectors) {
@@ -914,7 +965,7 @@ function configureLogging(coreConfig, envVars) {
914
965
  * @param coreConfig The core config.
915
966
  * @param envVars The environment variables.
916
967
  */
917
- function configureVault(coreConfig, envVars) {
968
+ async function configureVault(coreConfig, envVars) {
918
969
  coreConfig.types.vaultConnector ??= [];
919
970
  if (envVars.vaultConnector === engineTypes.VaultConnectorType.EntityStorage) {
920
971
  coreConfig.types.vaultConnector.push({
@@ -938,7 +989,7 @@ function configureVault(coreConfig, envVars) {
938
989
  * @param coreConfig The core config.
939
990
  * @param envVars The environment variables.
940
991
  */
941
- function configureBackgroundTask(coreConfig, envVars) {
992
+ async function configureBackgroundTask(coreConfig, envVars) {
942
993
  coreConfig.types.backgroundTaskConnector ??= [];
943
994
  if (envVars.backgroundTaskConnector === engineTypes.BackgroundTaskConnectorType.EntityStorage) {
944
995
  coreConfig.types.backgroundTaskConnector.push({
@@ -951,7 +1002,7 @@ function configureBackgroundTask(coreConfig, envVars) {
951
1002
  * @param coreConfig The core config.
952
1003
  * @param envVars The environment variables.
953
1004
  */
954
- function configureEventBus(coreConfig, envVars) {
1005
+ async function configureEventBus(coreConfig, envVars) {
955
1006
  coreConfig.types.eventBusConnector ??= [];
956
1007
  if (envVars.eventBusConnector === engineTypes.EventBusConnectorType.Local) {
957
1008
  coreConfig.types.eventBusConnector.push({
@@ -968,7 +1019,7 @@ function configureEventBus(coreConfig, envVars) {
968
1019
  * @param coreConfig The core config.
969
1020
  * @param envVars The environment variables.
970
1021
  */
971
- function configureTelemetry(coreConfig, envVars) {
1022
+ async function configureTelemetry(coreConfig, envVars) {
972
1023
  coreConfig.types.telemetryConnector ??= [];
973
1024
  if (envVars.telemetryConnector === engineTypes.TelemetryConnectorType.EntityStorage) {
974
1025
  coreConfig.types.telemetryConnector.push({
@@ -985,71 +1036,81 @@ function configureTelemetry(coreConfig, envVars) {
985
1036
  * @param coreConfig The core config.
986
1037
  * @param envVars The environment variables.
987
1038
  */
988
- function configureMessaging(coreConfig, envVars) {
989
- coreConfig.types.messagingEmailConnector ??= [];
990
- coreConfig.types.messagingSmsConnector ??= [];
991
- coreConfig.types.messagingPushNotificationConnector ??= [];
992
- if (envVars.messagingEmailConnector === engineTypes.MessagingEmailConnectorType.EntityStorage) {
993
- coreConfig.types.messagingEmailConnector.push({
994
- type: engineTypes.MessagingEmailConnectorType.EntityStorage
995
- });
996
- }
997
- else if (envVars.messagingEmailConnector === engineTypes.MessagingEmailConnectorType.Aws) {
998
- coreConfig.types.messagingEmailConnector.push({
999
- type: engineTypes.MessagingEmailConnectorType.Aws,
1000
- options: {
1001
- config: {
1002
- region: envVars.awsS3Region ?? "",
1003
- accessKeyId: envVars.awsS3AccessKeyId ?? "",
1004
- secretAccessKey: envVars.awsS3SecretAccessKey ?? "",
1005
- endpoint: envVars.awsS3Endpoint ?? ""
1039
+ async function configureMessaging(coreConfig, envVars) {
1040
+ if (core.Coerce.boolean(envVars.messagingEnabled) ?? false) {
1041
+ coreConfig.types.messagingEmailConnector ??= [];
1042
+ coreConfig.types.messagingSmsConnector ??= [];
1043
+ coreConfig.types.messagingPushNotificationConnector ??= [];
1044
+ if (envVars.messagingEmailConnector === engineTypes.MessagingEmailConnectorType.EntityStorage) {
1045
+ coreConfig.types.messagingEmailConnector.push({
1046
+ type: engineTypes.MessagingEmailConnectorType.EntityStorage
1047
+ });
1048
+ }
1049
+ else if (envVars.messagingEmailConnector === engineTypes.MessagingEmailConnectorType.Aws) {
1050
+ coreConfig.types.messagingEmailConnector.push({
1051
+ type: engineTypes.MessagingEmailConnectorType.Aws,
1052
+ options: {
1053
+ config: {
1054
+ region: envVars.awsS3Region ?? "",
1055
+ accessKeyId: envVars.awsS3AccessKeyId ?? "",
1056
+ secretAccessKey: envVars.awsS3SecretAccessKey ?? "",
1057
+ endpoint: envVars.awsS3Endpoint ?? ""
1058
+ }
1006
1059
  }
1007
- }
1008
- });
1009
- }
1010
- if (envVars.messagingSmsConnector === engineTypes.MessagingSmsConnectorType.EntityStorage) {
1011
- coreConfig.types.messagingSmsConnector.push({
1012
- type: engineTypes.MessagingSmsConnectorType.EntityStorage
1013
- });
1014
- }
1015
- else if (envVars.messagingSmsConnector === engineTypes.MessagingSmsConnectorType.Aws) {
1016
- coreConfig.types.messagingSmsConnector.push({
1017
- type: engineTypes.MessagingSmsConnectorType.Aws,
1018
- options: {
1019
- config: {
1020
- region: envVars.awsS3Region ?? "",
1021
- accessKeyId: envVars.awsS3AccessKeyId ?? "",
1022
- secretAccessKey: envVars.awsS3SecretAccessKey ?? "",
1023
- endpoint: envVars.awsS3Endpoint ?? ""
1060
+ });
1061
+ }
1062
+ if (envVars.messagingSmsConnector === engineTypes.MessagingSmsConnectorType.EntityStorage) {
1063
+ coreConfig.types.messagingSmsConnector.push({
1064
+ type: engineTypes.MessagingSmsConnectorType.EntityStorage
1065
+ });
1066
+ }
1067
+ else if (envVars.messagingSmsConnector === engineTypes.MessagingSmsConnectorType.Aws) {
1068
+ coreConfig.types.messagingSmsConnector.push({
1069
+ type: engineTypes.MessagingSmsConnectorType.Aws,
1070
+ options: {
1071
+ config: {
1072
+ region: envVars.awsS3Region ?? "",
1073
+ accessKeyId: envVars.awsS3AccessKeyId ?? "",
1074
+ secretAccessKey: envVars.awsS3SecretAccessKey ?? "",
1075
+ endpoint: envVars.awsS3Endpoint ?? ""
1076
+ }
1024
1077
  }
1025
- }
1026
- });
1027
- }
1028
- if (envVars.messagingPushNotificationConnector ===
1029
- engineTypes.MessagingPushNotificationConnectorType.EntityStorage) {
1030
- coreConfig.types.messagingPushNotificationConnector.push({
1031
- type: engineTypes.MessagingPushNotificationConnectorType.EntityStorage
1032
- });
1033
- }
1034
- else if (envVars.messagingPushNotificationConnector === engineTypes.MessagingPushNotificationConnectorType.Aws) {
1035
- coreConfig.types.messagingPushNotificationConnector.push({
1036
- type: engineTypes.MessagingPushNotificationConnectorType.Aws,
1078
+ });
1079
+ }
1080
+ if (envVars.messagingPushNotificationConnector ===
1081
+ engineTypes.MessagingPushNotificationConnectorType.EntityStorage) {
1082
+ coreConfig.types.messagingPushNotificationConnector.push({
1083
+ type: engineTypes.MessagingPushNotificationConnectorType.EntityStorage
1084
+ });
1085
+ }
1086
+ else if (envVars.messagingPushNotificationConnector === engineTypes.MessagingPushNotificationConnectorType.Aws) {
1087
+ coreConfig.types.messagingPushNotificationConnector.push({
1088
+ type: engineTypes.MessagingPushNotificationConnectorType.Aws,
1089
+ options: {
1090
+ config: {
1091
+ region: envVars.awsSesRegion ?? "",
1092
+ accessKeyId: envVars.awsSesAccessKeyId ?? "",
1093
+ secretAccessKey: envVars.awsSesSecretAccessKey ?? "",
1094
+ endpoint: envVars.awsSesEndpoint,
1095
+ applicationsSettings: core.Is.json(envVars.awsMessagingPushNotificationApplications)
1096
+ ? JSON.parse(envVars.awsMessagingPushNotificationApplications)
1097
+ : []
1098
+ }
1099
+ }
1100
+ });
1101
+ }
1102
+ const templates = core.Is.arrayValue(envVars.messagingTemplates)
1103
+ ? envVars.messagingTemplates
1104
+ : undefined;
1105
+ coreConfig.types.messagingAdminComponent ??= [];
1106
+ coreConfig.types.messagingAdminComponent.push({
1107
+ type: engineTypes.MessagingAdminComponentType.Service,
1037
1108
  options: {
1038
1109
  config: {
1039
- region: envVars.awsS3Region ?? "",
1040
- accessKeyId: envVars.awsS3AccessKeyId ?? "",
1041
- secretAccessKey: envVars.awsS3SecretAccessKey ?? "",
1042
- endpoint: envVars.awsS3Endpoint ?? "",
1043
- applicationsSettings: core.Is.json(envVars.awsMessagingPushNotificationApplications)
1044
- ? JSON.parse(envVars.awsMessagingPushNotificationApplications)
1045
- : []
1110
+ templates
1046
1111
  }
1047
1112
  }
1048
1113
  });
1049
- }
1050
- if (coreConfig.types.messagingEmailConnector.length > 0 ||
1051
- coreConfig.types.messagingSmsConnector.length > 0 ||
1052
- coreConfig.types.messagingPushNotificationConnector.length > 0) {
1053
1114
  coreConfig.types.messagingComponent ??= [];
1054
1115
  coreConfig.types.messagingComponent.push({ type: engineTypes.MessagingComponentType.Service });
1055
1116
  }
@@ -1059,7 +1120,7 @@ function configureMessaging(coreConfig, envVars) {
1059
1120
  * @param coreConfig The core config.
1060
1121
  * @param envVars The environment variables.
1061
1122
  */
1062
- function configureFaucet(coreConfig, envVars) {
1123
+ async function configureFaucet(coreConfig, envVars) {
1063
1124
  coreConfig.types.faucetConnector ??= [];
1064
1125
  if (envVars.faucetConnector === engineTypes.FaucetConnectorType.EntityStorage) {
1065
1126
  coreConfig.types.faucetConnector.push({
@@ -1067,14 +1128,14 @@ function configureFaucet(coreConfig, envVars) {
1067
1128
  });
1068
1129
  }
1069
1130
  else if (envVars.faucetConnector === engineTypes.FaucetConnectorType.Iota) {
1070
- const iotaConfig = getIotaConfig(coreConfig);
1131
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1071
1132
  coreConfig.types.faucetConnector.push({
1072
1133
  type: engineTypes.FaucetConnectorType.Iota,
1073
1134
  options: {
1074
1135
  config: {
1075
1136
  endpoint: envVars.iotaFaucetEndpoint ?? "",
1076
- clientOptions: iotaConfig?.clientOptions ?? { url: "" },
1077
- network: iotaConfig?.network ?? ""
1137
+ clientOptions: dltConfig?.options?.config?.clientOptions ?? { url: "" },
1138
+ network: dltConfig?.options?.config?.network ?? ""
1078
1139
  }
1079
1140
  }
1080
1141
  });
@@ -1085,7 +1146,7 @@ function configureFaucet(coreConfig, envVars) {
1085
1146
  * @param coreConfig The core config.
1086
1147
  * @param envVars The environment variables.
1087
1148
  */
1088
- function configureWallet(coreConfig, envVars) {
1149
+ async function configureWallet(coreConfig, envVars) {
1089
1150
  coreConfig.types.walletConnector ??= [];
1090
1151
  if (envVars.walletConnector === engineTypes.WalletConnectorType.EntityStorage) {
1091
1152
  coreConfig.types.walletConnector.push({
@@ -1093,11 +1154,11 @@ function configureWallet(coreConfig, envVars) {
1093
1154
  });
1094
1155
  }
1095
1156
  else if (envVars.walletConnector === engineTypes.WalletConnectorType.Iota) {
1096
- const iotaConfig = getIotaConfig(coreConfig);
1157
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1097
1158
  coreConfig.types.walletConnector.push({
1098
1159
  type: engineTypes.WalletConnectorType.Iota,
1099
1160
  options: {
1100
- config: iotaConfig ?? {}
1161
+ config: dltConfig?.options?.config ?? {}
1101
1162
  }
1102
1163
  });
1103
1164
  }
@@ -1107,7 +1168,7 @@ function configureWallet(coreConfig, envVars) {
1107
1168
  * @param coreConfig The core config.
1108
1169
  * @param envVars The environment variables.
1109
1170
  */
1110
- function configureNft(coreConfig, envVars) {
1171
+ async function configureNft(coreConfig, envVars) {
1111
1172
  coreConfig.types.nftConnector ??= [];
1112
1173
  if (envVars.nftConnector === engineTypes.NftConnectorType.EntityStorage) {
1113
1174
  coreConfig.types.nftConnector.push({
@@ -1115,11 +1176,11 @@ function configureNft(coreConfig, envVars) {
1115
1176
  });
1116
1177
  }
1117
1178
  else if (envVars.nftConnector === engineTypes.NftConnectorType.Iota) {
1118
- const iotaConfig = getIotaConfig(coreConfig);
1179
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1119
1180
  coreConfig.types.nftConnector.push({
1120
1181
  type: engineTypes.NftConnectorType.Iota,
1121
1182
  options: {
1122
- config: iotaConfig ?? {}
1183
+ config: dltConfig?.options?.config ?? {}
1123
1184
  }
1124
1185
  });
1125
1186
  }
@@ -1133,7 +1194,7 @@ function configureNft(coreConfig, envVars) {
1133
1194
  * @param coreConfig The core config.
1134
1195
  * @param envVars The environment variables.
1135
1196
  */
1136
- function configureVerifiableStorage(coreConfig, envVars) {
1197
+ async function configureVerifiableStorage(coreConfig, envVars) {
1137
1198
  coreConfig.types.verifiableStorageConnector ??= [];
1138
1199
  if (envVars.verifiableStorageConnector === engineTypes.VerifiableStorageConnectorType.EntityStorage) {
1139
1200
  coreConfig.types.verifiableStorageConnector.push({
@@ -1141,11 +1202,11 @@ function configureVerifiableStorage(coreConfig, envVars) {
1141
1202
  });
1142
1203
  }
1143
1204
  else if (envVars.verifiableStorageConnector === engineTypes.VerifiableStorageConnectorType.Iota) {
1144
- const iotaConfig = getIotaConfig(coreConfig);
1205
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1145
1206
  coreConfig.types.verifiableStorageConnector.push({
1146
1207
  type: engineTypes.VerifiableStorageConnectorType.Iota,
1147
1208
  options: {
1148
- config: iotaConfig ?? {}
1209
+ config: dltConfig?.options?.config ?? {}
1149
1210
  }
1150
1211
  });
1151
1212
  }
@@ -1163,14 +1224,6 @@ function configureVerifiableStorage(coreConfig, envVars) {
1163
1224
  }
1164
1225
  }
1165
1226
  });
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
1227
  }
1175
1228
  }
1176
1229
  /**
@@ -1178,7 +1231,7 @@ function configureVerifiableStorage(coreConfig, envVars) {
1178
1231
  * @param coreConfig The core config.
1179
1232
  * @param envVars The environment variables.
1180
1233
  */
1181
- function configureIdentity(coreConfig, envVars) {
1234
+ async function configureIdentity(coreConfig, envVars) {
1182
1235
  coreConfig.types.identityConnector ??= [];
1183
1236
  if (envVars.identityConnector === engineTypes.IdentityConnectorType.EntityStorage) {
1184
1237
  coreConfig.types.identityConnector.push({
@@ -1186,11 +1239,11 @@ function configureIdentity(coreConfig, envVars) {
1186
1239
  });
1187
1240
  }
1188
1241
  else if (envVars.identityConnector === engineTypes.IdentityConnectorType.Iota) {
1189
- const iotaConfig = getIotaConfig(coreConfig);
1242
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1190
1243
  coreConfig.types.identityConnector.push({
1191
1244
  type: engineTypes.IdentityConnectorType.Iota,
1192
1245
  options: {
1193
- config: iotaConfig ?? {}
1246
+ config: dltConfig?.options?.config ?? {}
1194
1247
  }
1195
1248
  });
1196
1249
  }
@@ -1204,7 +1257,7 @@ function configureIdentity(coreConfig, envVars) {
1204
1257
  * @param coreConfig The core config.
1205
1258
  * @param envVars The environment variables.
1206
1259
  */
1207
- function configureIdentityResolver(coreConfig, envVars) {
1260
+ async function configureIdentityResolver(coreConfig, envVars) {
1208
1261
  coreConfig.types.identityResolverConnector ??= [];
1209
1262
  if (envVars.identityResolverConnector === engineTypes.IdentityResolverConnectorType.EntityStorage) {
1210
1263
  coreConfig.types.identityResolverConnector.push({
@@ -1212,11 +1265,11 @@ function configureIdentityResolver(coreConfig, envVars) {
1212
1265
  });
1213
1266
  }
1214
1267
  else if (envVars.identityResolverConnector === engineTypes.IdentityResolverConnectorType.Iota) {
1215
- const iotaConfig = getIotaConfig(coreConfig);
1268
+ const dltConfig = engineTypes.EngineTypeHelper.getConfigOfType(coreConfig, "dltConfig", engineTypes.DltConfigType.Iota);
1216
1269
  coreConfig.types.identityResolverConnector.push({
1217
1270
  type: engineTypes.IdentityResolverConnectorType.Iota,
1218
1271
  options: {
1219
- config: iotaConfig ?? {}
1272
+ config: dltConfig?.options?.config ?? {}
1220
1273
  }
1221
1274
  });
1222
1275
  }
@@ -1242,7 +1295,7 @@ function configureIdentityResolver(coreConfig, envVars) {
1242
1295
  * @param coreConfig The core config.
1243
1296
  * @param envVars The environment variables.
1244
1297
  */
1245
- function configureIdentityProfile(coreConfig, envVars) {
1298
+ async function configureIdentityProfile(coreConfig, envVars) {
1246
1299
  coreConfig.types.identityProfileConnector ??= [];
1247
1300
  if (envVars.identityProfileConnector === engineTypes.IdentityConnectorType.EntityStorage) {
1248
1301
  coreConfig.types.identityProfileConnector.push({
@@ -1259,7 +1312,7 @@ function configureIdentityProfile(coreConfig, envVars) {
1259
1312
  * @param coreConfig The core config.
1260
1313
  * @param envVars The environment variables.
1261
1314
  */
1262
- function configureAttestation(coreConfig, envVars) {
1315
+ async function configureAttestation(coreConfig, envVars) {
1263
1316
  coreConfig.types.attestationConnector ??= [];
1264
1317
  if (envVars.attestationConnector === engineTypes.AttestationConnectorType.Nft) {
1265
1318
  coreConfig.types.attestationConnector.push({
@@ -1283,8 +1336,8 @@ function configureAttestation(coreConfig, envVars) {
1283
1336
  * @param coreConfig The core config.
1284
1337
  * @param envVars The environment variables.
1285
1338
  */
1286
- function configureAuditableItemGraph(coreConfig, envVars) {
1287
- if (core.Is.arrayValue(coreConfig.types.verifiableStorageConnector)) {
1339
+ async function configureAuditableItemGraph(coreConfig, envVars) {
1340
+ if (core.Coerce.boolean(envVars.auditableItemGraphEnabled) ?? false) {
1288
1341
  coreConfig.types.auditableItemGraphComponent ??= [];
1289
1342
  coreConfig.types.auditableItemGraphComponent.push({
1290
1343
  type: engineTypes.AuditableItemGraphComponentType.Service
@@ -1296,8 +1349,8 @@ function configureAuditableItemGraph(coreConfig, envVars) {
1296
1349
  * @param coreConfig The core config.
1297
1350
  * @param envVars The environment variables.
1298
1351
  */
1299
- function configureAuditableItemStream(coreConfig, envVars) {
1300
- if (core.Is.arrayValue(coreConfig.types.verifiableStorageConnector)) {
1352
+ async function configureAuditableItemStream(coreConfig, envVars) {
1353
+ if (core.Coerce.boolean(envVars.auditableItemStreamEnabled) ?? false) {
1301
1354
  coreConfig.types.auditableItemStreamComponent ??= [];
1302
1355
  coreConfig.types.auditableItemStreamComponent.push({
1303
1356
  type: engineTypes.AuditableItemStreamComponentType.Service
@@ -1309,34 +1362,33 @@ function configureAuditableItemStream(coreConfig, envVars) {
1309
1362
  * @param coreConfig The core config.
1310
1363
  * @param envVars The environment variables.
1311
1364
  */
1312
- 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) {
1365
+ async function configureDataProcessing(coreConfig, envVars) {
1366
+ if (core.Coerce.boolean(envVars.dataProcessingEnabled) ?? false) {
1338
1367
  coreConfig.types.dataProcessingComponent ??= [];
1339
1368
  coreConfig.types.dataProcessingComponent.push({ type: engineTypes.DataProcessingComponentType.Service });
1369
+ coreConfig.types.dataConverterConnector ??= [];
1370
+ const converterConnectors = envVars.dataConverterConnectors?.split(",") ?? [];
1371
+ for (const converterConnector of converterConnectors) {
1372
+ if (converterConnector === engineTypes.DataConverterConnectorType.Json) {
1373
+ coreConfig.types.dataConverterConnector.push({
1374
+ type: engineTypes.DataConverterConnectorType.Json
1375
+ });
1376
+ }
1377
+ else if (converterConnector === engineTypes.DataConverterConnectorType.Xml) {
1378
+ coreConfig.types.dataConverterConnector.push({
1379
+ type: engineTypes.DataConverterConnectorType.Xml
1380
+ });
1381
+ }
1382
+ }
1383
+ coreConfig.types.dataExtractorConnector ??= [];
1384
+ const extractorConnectors = envVars.dataExtractorConnectors?.split(",") ?? [];
1385
+ for (const extractorConnector of extractorConnectors) {
1386
+ if (extractorConnector === engineTypes.DataExtractorConnectorType.JsonPath) {
1387
+ coreConfig.types.dataExtractorConnector.push({
1388
+ type: engineTypes.DataExtractorConnectorType.JsonPath
1389
+ });
1390
+ }
1391
+ }
1340
1392
  }
1341
1393
  }
1342
1394
  /**
@@ -1344,10 +1396,8 @@ function configureDataProcessing(coreConfig, envVars) {
1344
1396
  * @param coreConfig The core config.
1345
1397
  * @param envVars The environment variables.
1346
1398
  */
1347
- 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)) {
1399
+ async function configureDocumentManagement(coreConfig, envVars) {
1400
+ if (core.Coerce.boolean(envVars.documentManagementEnabled) ?? false) {
1351
1401
  coreConfig.types.documentManagementComponent ??= [];
1352
1402
  coreConfig.types.documentManagementComponent.push({
1353
1403
  type: engineTypes.DocumentManagementComponentType.Service
@@ -1355,12 +1405,12 @@ function configureDocumentManagement(coreConfig, envVars) {
1355
1405
  }
1356
1406
  }
1357
1407
  /**
1358
- * Configures the node to node.
1408
+ * Configures the verifiable credential authentication.
1359
1409
  * @param coreConfig The core config.
1360
1410
  * @param envVars The environment variables.
1361
1411
  */
1362
- function configureNodeToNode(coreConfig, envVars) {
1363
- if (core.Is.arrayValue(coreConfig.types.identityComponent)) {
1412
+ async function configureVerifiableCredentialAuthentication(coreConfig, envVars) {
1413
+ if (core.Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
1364
1414
  // Can only perform VC authentication if identity component is available
1365
1415
  coreConfig.types.authenticationGeneratorComponent ??= [];
1366
1416
  coreConfig.types.authenticationGeneratorComponent.push({
@@ -1377,7 +1427,7 @@ function configureNodeToNode(coreConfig, envVars) {
1377
1427
  * @param coreConfig The core config.
1378
1428
  * @param envVars The environment variables.
1379
1429
  */
1380
- function configureRightsManagement(coreConfig, envVars) {
1430
+ async function configureRightsManagement(coreConfig, envVars) {
1381
1431
  if (core.Coerce.boolean(envVars.rightsManagementEnabled) ?? false) {
1382
1432
  coreConfig.types.rightsManagementPapComponent ??= [];
1383
1433
  coreConfig.types.rightsManagementPapComponent.push({
@@ -1466,7 +1516,7 @@ function configureRightsManagement(coreConfig, envVars) {
1466
1516
  * @param coreConfig The core config.
1467
1517
  * @param envVars The environment variables.
1468
1518
  */
1469
- function configureTaskScheduler(coreConfig, envVars) {
1519
+ async function configureTaskScheduler(coreConfig, envVars) {
1470
1520
  if (core.Coerce.boolean(envVars.taskSchedulerEnabled) ?? false) {
1471
1521
  coreConfig.types.taskSchedulerComponent ??= [];
1472
1522
  coreConfig.types.taskSchedulerComponent.push({
@@ -1479,7 +1529,7 @@ function configureTaskScheduler(coreConfig, envVars) {
1479
1529
  * @param coreConfig The core config.
1480
1530
  * @param envVars The environment variables.
1481
1531
  */
1482
- function configureSynchronisedStorage(coreConfig, envVars) {
1532
+ async function configureSynchronisedStorage(coreConfig, envVars) {
1483
1533
  if (core.Is.arrayValue(coreConfig.types.identityResolverComponent) &&
1484
1534
  (core.Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false)) {
1485
1535
  // Check if the config provides a custom verifiable storage key id
@@ -1521,7 +1571,7 @@ function configureSynchronisedStorage(coreConfig, envVars) {
1521
1571
  * @param coreConfig The core config.
1522
1572
  * @param envVars The environment variables.
1523
1573
  */
1524
- function configureFederatedCatalogue(coreConfig, envVars) {
1574
+ async function configureFederatedCatalogue(coreConfig, envVars) {
1525
1575
  if (core.Coerce.boolean(envVars.federatedCatalogueEnabled) ?? false) {
1526
1576
  coreConfig.types.federatedCatalogueComponent ??= [];
1527
1577
  coreConfig.types.federatedCatalogueComponent.push({
@@ -1540,7 +1590,7 @@ function configureFederatedCatalogue(coreConfig, envVars) {
1540
1590
  * @param coreConfig The core config.
1541
1591
  * @param envVars The environment variables.
1542
1592
  */
1543
- function configureDataSpaceConnector(coreConfig, envVars) {
1593
+ async function configureDataSpaceConnector(coreConfig, envVars) {
1544
1594
  if (core.Coerce.boolean(envVars.dataSpaceConnectorEnabled) ?? false) {
1545
1595
  coreConfig.types.dataSpaceConnectorComponent ??= [];
1546
1596
  coreConfig.types.dataSpaceConnectorComponent.push({
@@ -1560,7 +1610,7 @@ function configureDataSpaceConnector(coreConfig, envVars) {
1560
1610
  * @param coreConfig The core config.
1561
1611
  * @param envVars The environment variables.
1562
1612
  */
1563
- function configureDlt(coreConfig, envVars) {
1613
+ async function configureDlt(coreConfig, envVars) {
1564
1614
  // Create centralized DLT configuration for IOTA if essential IOTA variables are set
1565
1615
  if (core.Is.stringValue(envVars.iotaNodeEndpoint) && core.Is.stringValue(envVars.iotaNetwork)) {
1566
1616
  coreConfig.types.dltConfig ??= [];
@@ -1597,7 +1647,7 @@ function configureDlt(coreConfig, envVars) {
1597
1647
  * @param favIconPath The path to the favicon.
1598
1648
  * @returns The the config for the core and the server.
1599
1649
  */
1600
- function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, openApiSpecPath, favIconPath) {
1650
+ async function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, openApiSpecPath, favIconPath) {
1601
1651
  envVars.authSigningKeyId ??= "auth-signing";
1602
1652
  const webServerOptions = {
1603
1653
  port: core.Coerce.number(envVars.port),
@@ -1735,7 +1785,7 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
1735
1785
  }
1736
1786
  });
1737
1787
  }
1738
- if (core.Coerce.boolean(envVars.enableVerifiableCredentialRouteProcessors) ?? false) {
1788
+ if (core.Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
1739
1789
  serverConfig.types.restRouteProcessor.push({
1740
1790
  type: engineServerTypes.RestRouteProcessorType.AuthVerifiableCredential
1741
1791
  });
@@ -1777,13 +1827,13 @@ async function start(nodeOptions, engineServerConfig, envVars) {
1777
1827
  stateStorage: nodeOptions?.stateStorage ?? new engineCore.FileStateStorage(envVars.stateFilename ?? ""),
1778
1828
  customBootstrap: async (core, engineContext) => bootstrap(core, engineContext, envVars)
1779
1829
  });
1830
+ // Construct the server with the engine.
1831
+ const server = new engineServer.EngineServer({ engineCore: engine$1 });
1780
1832
  // Extend the engine.
1781
1833
  if (core.Is.function(nodeOptions?.extendEngine)) {
1782
1834
  console.info("Extending Engine");
1783
1835
  await nodeOptions.extendEngine(engine$1);
1784
1836
  }
1785
- // Construct the server with the engine.
1786
- const server = new engineServer.EngineServer({ engineCore: engine$1 });
1787
1837
  // Extend the engine server.
1788
1838
  if (core.Is.function(nodeOptions?.extendEngineServer)) {
1789
1839
  console.info("Extending Engine Server");
@@ -1815,7 +1865,7 @@ async function run(nodeOptions) {
1815
1865
  nodeOptions ??= {};
1816
1866
  const serverInfo = {
1817
1867
  name: nodeOptions?.serverName ?? "TWIN Node Server",
1818
- version: nodeOptions?.serverVersion ?? "0.0.2-next.14" // x-release-please-version
1868
+ version: nodeOptions?.serverVersion ?? "0.0.2-next.16" // x-release-please-version
1819
1869
  };
1820
1870
  console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
1821
1871
  if (!core.Is.stringValue(nodeOptions?.executionDirectory)) {
@@ -1918,8 +1968,8 @@ async function buildConfiguration(processEnv, options, serverInfo) {
1918
1968
  await options.extendEnvVars(envVars);
1919
1969
  }
1920
1970
  // Build the engine configuration from the environment variables.
1921
- const coreConfig = buildEngineConfiguration(envVars);
1922
- const engineServerConfig = buildEngineServerConfiguration(envVars, coreConfig, serverInfo, options?.openApiSpecFile, options?.favIconFile);
1971
+ const coreConfig = await buildEngineConfiguration(envVars);
1972
+ const engineServerConfig = await buildEngineServerConfiguration(envVars, coreConfig, serverInfo, options?.openApiSpecFile, options?.favIconFile);
1923
1973
  // Merge any custom configuration provided in the options.
1924
1974
  if (core.Is.arrayValue(options?.configFilenames)) {
1925
1975
  for (const configFile of options.configFilenames) {
@@ -1986,9 +2036,12 @@ exports.bootstrapSynchronisedStorage = bootstrapSynchronisedStorage;
1986
2036
  exports.buildConfiguration = buildConfiguration;
1987
2037
  exports.buildEngineConfiguration = buildEngineConfiguration;
1988
2038
  exports.buildEngineServerConfiguration = buildEngineServerConfiguration;
2039
+ exports.directoryExists = directoryExists;
1989
2040
  exports.fileExists = fileExists;
1990
2041
  exports.getExecutionDirectory = getExecutionDirectory;
1991
2042
  exports.getFeatures = getFeatures;
2043
+ exports.getFiles = getFiles;
2044
+ exports.getSubFolders = getSubFolders;
1992
2045
  exports.initialiseLocales = initialiseLocales;
1993
2046
  exports.loadJsonFile = loadJsonFile;
1994
2047
  exports.loadTextFile = loadTextFile;