@twin.org/node-core 0.0.3-next.6 → 0.0.3-next.8

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.
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
3
  import path from "node:path";
4
4
  import { Coerce, Is } from "@twin.org/core";
5
- import { AttestationComponentType, AttestationConnectorType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, AuthenticationGeneratorComponentType, BackgroundTaskComponentType, BlobStorageComponentType, BlobStorageConnectorType, ContextIdHandlerComponentType, DataConverterConnectorType, DataExtractorConnectorType, DataProcessingComponentType, DataSpaceConnectorComponentType, DltConfigType, DocumentManagementComponentType, EngineTypeHelper, EntityStorageConnectorType, EventBusComponentType, EventBusConnectorType, FaucetConnectorType, FederatedCatalogueComponentType, FederatedCatalogueFilterComponentType, IdentityComponentType, IdentityConnectorType, IdentityProfileComponentType, IdentityProfileConnectorType, IdentityResolverComponentType, IdentityResolverConnectorType, ImmutableProofComponentType, LoggingComponentType, LoggingConnectorType, MessagingAdminComponentType, MessagingComponentType, MessagingEmailConnectorType, MessagingPushNotificationConnectorType, MessagingSmsConnectorType, NftComponentType, NftConnectorType, RightsManagementDapComponentType, RightsManagementDarpComponentType, RightsManagementPapComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPipComponentType, RightsManagementPmpComponentType, RightsManagementPnapComponentType, RightsManagementPnpComponentType, RightsManagementPxpComponentType, SynchronisedStorageComponentType, TaskSchedulerComponentType, TelemetryComponentType, TelemetryConnectorType, TenantAdminComponentType, VaultConnectorType, VerifiableStorageComponentType, VerifiableStorageConnectorType, WalletConnectorType } from "@twin.org/engine-types";
5
+ import { AttestationComponentType, AttestationConnectorType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, AuthenticationGeneratorComponentType, BackgroundTaskComponentType, BlobStorageComponentType, BlobStorageConnectorType, ContextIdHandlerComponentType, DataProcessingComponentType, DataSpaceConnectorComponentType, DltConfigType, DocumentManagementComponentType, EngineTypeHelper, EntityStorageConnectorType, EventBusComponentType, EventBusConnectorType, FaucetConnectorType, FederatedCatalogueComponentType, IdentityComponentType, IdentityConnectorType, IdentityProfileComponentType, IdentityProfileConnectorType, IdentityResolverComponentType, IdentityResolverConnectorType, ImmutableProofComponentType, LoggingComponentType, LoggingConnectorType, MessagingAdminComponentType, MessagingComponentType, MessagingEmailConnectorType, MessagingPushNotificationConnectorType, MessagingSmsConnectorType, NftComponentType, NftConnectorType, RightsManagementDapComponentType, RightsManagementDarpComponentType, RightsManagementPapComponentType, RightsManagementPdpComponentType, RightsManagementPepComponentType, RightsManagementPipComponentType, RightsManagementPmpComponentType, RightsManagementPnapComponentType, RightsManagementPnpComponentType, RightsManagementPxpComponentType, SynchronisedStorageComponentType, TaskSchedulerComponentType, TelemetryComponentType, TelemetryConnectorType, TenantAdminComponentType, TrustComponentType, VaultConnectorType, VerifiableStorageComponentType, VerifiableStorageConnectorType, WalletConnectorType } from "@twin.org/engine-types";
6
6
  import { DataAccessPointRestClient, PolicyNegotiationPointRestClient } from "@twin.org/rights-management-rest-client";
7
7
  import { ATTESTATION_VERIFICATION_METHOD_ID, BLOB_STORAGE_ENCRYPTION_KEY_ID, CONTEXT_ID_HANDLER_FEATURE_DID, CONTEXT_ID_HANDLER_FEATURE_TENANT, IMMUTABLE_PROOF_VERIFICATION_METHOD_ID, SYNCHRONISED_STORAGE_BLOB_STORAGE_ENCRYPTION_KEY_ID, VC_AUTHENTICATION_VERIFICATION_METHOD_ID } from "../defaults.js";
8
8
  /**
@@ -46,6 +46,7 @@ export async function buildEngineConfiguration(envVars, contextIdKeys) {
46
46
  await configureAuditableItemStream(coreConfig, envVars);
47
47
  await configureDocumentManagement(coreConfig, envVars);
48
48
  await configureVerifiableCredentialAuthentication(coreConfig, envVars);
49
+ await configureTrust(coreConfig, envVars);
49
50
  await configureRightsManagement(coreConfig, envVars);
50
51
  await configureSynchronisedStorage(coreConfig, envVars);
51
52
  await configureFederatedCatalogue(coreConfig, envVars);
@@ -60,7 +61,7 @@ export async function buildEngineConfiguration(envVars, contextIdKeys) {
60
61
  async function configureEntityStorage(coreConfig, envVars) {
61
62
  coreConfig.types ??= {};
62
63
  coreConfig.types.entityStorageConnector ??= [];
63
- const entityStorageConnectorTypes = envVars.entityStorageConnectorType?.split(",") ?? [];
64
+ const entityStorageConnectorTypes = commaSeparatedListToArray(envVars.entityStorageConnectorType);
64
65
  if (entityStorageConnectorTypes.includes(EntityStorageConnectorType.Memory)) {
65
66
  coreConfig.types.entityStorageConnector.push({
66
67
  type: EntityStorageConnectorType.Memory
@@ -125,7 +126,7 @@ async function configureEntityStorage(coreConfig, envVars) {
125
126
  type: EntityStorageConnectorType.ScyllaDb,
126
127
  options: {
127
128
  config: {
128
- hosts: envVars.scylladbHosts?.split(",") ?? [],
129
+ hosts: commaSeparatedListToArray(envVars.scylladbHosts),
129
130
  localDataCenter: envVars.scylladbLocalDataCenter ?? "",
130
131
  keyspace: envVars.scylladbKeyspace ?? "",
131
132
  port: Coerce.integer(envVars.scylladbPort)
@@ -205,7 +206,7 @@ async function configureEntityStorage(coreConfig, envVars) {
205
206
  */
206
207
  async function configureBlobStorage(coreConfig, envVars) {
207
208
  coreConfig.types.blobStorageConnector ??= [];
208
- const blobStorageConnectorTypes = envVars.blobStorageConnectorType?.split(",") ?? [];
209
+ const blobStorageConnectorTypes = commaSeparatedListToArray(envVars.blobStorageConnectorType);
209
210
  if (blobStorageConnectorTypes.includes(BlobStorageConnectorType.Memory)) {
210
211
  coreConfig.types.blobStorageConnector.push({
211
212
  type: BlobStorageConnectorType.Memory
@@ -316,7 +317,7 @@ async function configureBlobStorage(coreConfig, envVars) {
316
317
  */
317
318
  async function configureLogging(coreConfig, envVars) {
318
319
  coreConfig.types.loggingConnector ??= [];
319
- const loggingConnectorTypes = (envVars.loggingConnector ?? "").split(",");
320
+ const loggingConnectorTypes = commaSeparatedListToArray(envVars.loggingConnector);
320
321
  let additionalConnectorCount = 0;
321
322
  for (const loggingConnector of loggingConnectorTypes) {
322
323
  if (loggingConnector === LoggingConnectorType.Console) {
@@ -796,27 +797,18 @@ async function configureDataProcessing(coreConfig, envVars) {
796
797
  coreConfig.types.dataProcessingComponent ??= [];
797
798
  coreConfig.types.dataProcessingComponent.push({ type: DataProcessingComponentType.Service });
798
799
  coreConfig.types.dataConverterConnector ??= [];
799
- const converterConnectors = envVars.dataConverterConnectors?.split(",") ?? [];
800
+ const converterConnectors = commaSeparatedListToArray(envVars.dataConverterConnectors);
800
801
  for (const converterConnector of converterConnectors) {
801
- if (converterConnector === DataConverterConnectorType.Json) {
802
- coreConfig.types.dataConverterConnector.push({
803
- type: DataConverterConnectorType.Json
804
- });
805
- }
806
- else if (converterConnector === DataConverterConnectorType.Xml) {
807
- coreConfig.types.dataConverterConnector.push({
808
- type: DataConverterConnectorType.Xml
809
- });
810
- }
802
+ coreConfig.types.dataConverterConnector.push({
803
+ type: converterConnector
804
+ });
811
805
  }
812
806
  coreConfig.types.dataExtractorConnector ??= [];
813
- const extractorConnectors = envVars.dataExtractorConnectors?.split(",") ?? [];
807
+ const extractorConnectors = commaSeparatedListToArray(envVars.dataExtractorConnectors);
814
808
  for (const extractorConnector of extractorConnectors) {
815
- if (extractorConnector === DataExtractorConnectorType.JsonPath) {
816
- coreConfig.types.dataExtractorConnector.push({
817
- type: DataExtractorConnectorType.JsonPath
818
- });
819
- }
809
+ coreConfig.types.dataExtractorConnector.push({
810
+ type: extractorConnector
811
+ });
820
812
  }
821
813
  }
822
814
  }
@@ -853,6 +845,38 @@ async function configureVerifiableCredentialAuthentication(coreConfig, envVars)
853
845
  });
854
846
  }
855
847
  }
848
+ /**
849
+ * Configures the trust components.
850
+ * @param coreConfig The core config.
851
+ * @param envVars The environment variables.
852
+ */
853
+ async function configureTrust(coreConfig, envVars) {
854
+ if (Coerce.boolean(envVars.trustEnabled) ?? false) {
855
+ coreConfig.types.trustComponent ??= [];
856
+ coreConfig.types.trustComponent.push({
857
+ type: TrustComponentType.Service
858
+ });
859
+ coreConfig.types.trustGeneratorComponent ??= [];
860
+ const trustGeneratorTypes = commaSeparatedListToArray(envVars.trustGenerators);
861
+ for (const trustGeneratorType of trustGeneratorTypes) {
862
+ coreConfig.types.trustGeneratorComponent.push({
863
+ type: trustGeneratorType,
864
+ options: {
865
+ config: {
866
+ verificationMethodId: envVars.trustVerificationMethodId ?? VC_AUTHENTICATION_VERIFICATION_METHOD_ID
867
+ }
868
+ }
869
+ });
870
+ }
871
+ coreConfig.types.trustVerifierComponent ??= [];
872
+ const trustVerifierTypes = commaSeparatedListToArray(envVars.trustVerifiers);
873
+ for (const trustVerifierType of trustVerifierTypes) {
874
+ coreConfig.types.trustVerifierComponent.push({
875
+ type: trustVerifierType
876
+ });
877
+ }
878
+ }
879
+ }
856
880
  /**
857
881
  * Configures the rights management.
858
882
  * @param coreConfig The core config.
@@ -870,55 +894,26 @@ async function configureRightsManagement(coreConfig, envVars) {
870
894
  });
871
895
  coreConfig.types.rightsManagementPipComponent ??= [];
872
896
  coreConfig.types.rightsManagementPipComponent.push({
873
- type: RightsManagementPipComponentType.Service,
874
- options: {
875
- informationModulesConfig: Is.arrayValue(envVars.rightsManagementInformationSources)
876
- ? envVars.rightsManagementInformationSources
877
- : undefined
878
- }
897
+ type: RightsManagementPipComponentType.Service
879
898
  });
880
899
  coreConfig.types.rightsManagementPxpComponent ??= [];
881
900
  coreConfig.types.rightsManagementPxpComponent.push({
882
- type: RightsManagementPxpComponentType.Service,
883
- options: {
884
- actionModulesConfig: Is.arrayValue(envVars.rightsManagementExecutionActions)
885
- ? envVars.rightsManagementExecutionActions
886
- : undefined
887
- }
901
+ type: RightsManagementPxpComponentType.Service
888
902
  });
889
903
  coreConfig.types.rightsManagementPdpComponent ??= [];
890
904
  coreConfig.types.rightsManagementPdpComponent.push({
891
- type: RightsManagementPdpComponentType.Service,
892
- options: {
893
- arbiterModulesConfig: Is.arrayValue(envVars.rightsManagementArbiters)
894
- ? envVars.rightsManagementArbiters
895
- : undefined
896
- }
905
+ type: RightsManagementPdpComponentType.Service
897
906
  });
898
907
  coreConfig.types.rightsManagementPepComponent ??= [];
899
908
  coreConfig.types.rightsManagementPepComponent.push({
900
- type: RightsManagementPepComponentType.Service,
901
- options: {
902
- processorModulesConfig: Is.arrayValue(envVars.rightsManagementEnforcementProcessors)
903
- ? envVars.rightsManagementEnforcementProcessors
904
- : undefined
905
- }
909
+ type: RightsManagementPepComponentType.Service
906
910
  });
907
911
  coreConfig.types.rightsManagementPnpComponent ??= [];
908
912
  coreConfig.types.rightsManagementPnpComponent.push({
909
913
  type: RightsManagementPnpComponentType.Service,
910
914
  options: {
911
- negotiatorModulesConfig: Is.arrayValue(envVars.rightsManagementNegotiators)
912
- ? envVars.rightsManagementNegotiators
913
- : undefined,
914
- requesterModulesConfig: Is.arrayValue(envVars.rightsManagementRequesters)
915
- ? envVars.rightsManagementRequesters
916
- : undefined,
917
915
  config: {
918
916
  baseCallbackUrl: envVars.rightsManagementBaseCallbackUrl ?? "",
919
- offers: Is.arrayValue(envVars.rightsManagementOffers)
920
- ? envVars.rightsManagementOffers
921
- : [],
922
917
  negotiationComponentCreator: async (url) => new PolicyNegotiationPointRestClient({ endpoint: url })
923
918
  }
924
919
  }
@@ -940,6 +935,55 @@ async function configureRightsManagement(coreConfig, envVars) {
940
935
  }
941
936
  }
942
937
  });
938
+ coreConfig.types.rightsManagementDataAccessHandlerComponent ??= [];
939
+ const dataAccessHandlerTypes = commaSeparatedListToArray(envVars.rightsManagementDataAccessHandlers);
940
+ for (const dataAccessHandlerType of dataAccessHandlerTypes) {
941
+ coreConfig.types.rightsManagementDataAccessHandlerComponent.push({
942
+ type: dataAccessHandlerType
943
+ });
944
+ }
945
+ coreConfig.types.rightsManagementPolicyArbiterComponent ??= [];
946
+ const policyArbiterTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyArbiters);
947
+ for (const policyArbiterType of policyArbiterTypes) {
948
+ coreConfig.types.rightsManagementPolicyArbiterComponent.push({
949
+ type: policyArbiterType
950
+ });
951
+ }
952
+ coreConfig.types.rightsManagementPolicyEnforcementProcessorComponent ??= [];
953
+ const policyEnforcementProcessTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyEnforcementProcessors);
954
+ for (const policyEnforcementProcessorType of policyEnforcementProcessTypes) {
955
+ coreConfig.types.rightsManagementPolicyEnforcementProcessorComponent.push({
956
+ type: policyEnforcementProcessorType
957
+ });
958
+ }
959
+ coreConfig.types.rightsManagementPolicyExecutionActionComponent ??= [];
960
+ const policyExecutionActionTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyExecutionActions);
961
+ for (const policyExecutionActionType of policyExecutionActionTypes) {
962
+ coreConfig.types.rightsManagementPolicyExecutionActionComponent.push({
963
+ type: policyExecutionActionType
964
+ });
965
+ }
966
+ coreConfig.types.rightsManagementPolicyInformationSourceComponent ??= [];
967
+ const policyInformationSourceTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyInformationSources);
968
+ for (const policyInformationSourceType of policyInformationSourceTypes) {
969
+ coreConfig.types.rightsManagementPolicyInformationSourceComponent.push({
970
+ type: policyInformationSourceType
971
+ });
972
+ }
973
+ coreConfig.types.rightsManagementPolicyRequesterComponent ??= [];
974
+ const policyRequesterTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyRequesters);
975
+ for (const policyRequesterType of policyRequesterTypes) {
976
+ coreConfig.types.rightsManagementPolicyRequesterComponent.push({
977
+ type: policyRequesterType
978
+ });
979
+ }
980
+ coreConfig.types.rightsManagementPolicyNegotiatorComponent ??= [];
981
+ const policyNegotiatorTypes = commaSeparatedListToArray(envVars.rightsManagementPolicyNegotiators);
982
+ for (const policyNegotiatorType of policyNegotiatorTypes) {
983
+ coreConfig.types.rightsManagementPolicyNegotiatorComponent.push({
984
+ type: policyNegotiatorType
985
+ });
986
+ }
943
987
  }
944
988
  }
945
989
  /**
@@ -1011,18 +1055,12 @@ async function configureFederatedCatalogue(coreConfig, envVars) {
1011
1055
  options: {}
1012
1056
  });
1013
1057
  coreConfig.types.federatedCatalogueFilterComponent ??= [];
1014
- const filters = (envVars.federatedCatalogueFilters ?? "")
1015
- .split(",")
1016
- .map(filter => filter.trim())
1017
- .filter(filter => filter.length > 0);
1058
+ const filters = commaSeparatedListToArray(envVars.federatedCatalogueFilters);
1018
1059
  for (const filter of filters) {
1019
- const type = FederatedCatalogueFilterComponentType[filter];
1020
- if (type) {
1021
- coreConfig.types.federatedCatalogueFilterComponent.push({
1022
- type,
1023
- options: {}
1024
- });
1025
- }
1060
+ coreConfig.types.federatedCatalogueFilterComponent.push({
1061
+ type: filter,
1062
+ options: {}
1063
+ });
1026
1064
  }
1027
1065
  }
1028
1066
  }
@@ -1077,4 +1115,15 @@ async function configureDlt(coreConfig, envVars) {
1077
1115
  });
1078
1116
  }
1079
1117
  }
1118
+ /**
1119
+ * Converts a comma separated list to an array.
1120
+ * @param value The comma separated list.
1121
+ * @returns The array.
1122
+ */
1123
+ function commaSeparatedListToArray(value) {
1124
+ return (value ?? "")
1125
+ .split(",")
1126
+ .map(item => item.trim())
1127
+ .filter(item => item.length > 0);
1128
+ }
1080
1129
  //# sourceMappingURL=engineEnvBuilder.js.map