@twin.org/node-core 0.0.2-next.13 → 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.
- package/dist/cjs/index.cjs +67 -76
- package/dist/esm/index.mjs +69 -78
- package/dist/types/models/IEngineEnvironmentVariables.d.ts +21 -1
- package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +14 -5
- package/dist/types/models/INodeEnvironmentVariables.d.ts +1 -2
- package/docs/changelog.md +14 -0
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +42 -2
- package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +1544 -8
- package/docs/reference/interfaces/INodeEnvironmentVariables.md +212 -128
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -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
|
-
|
|
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
|
|
380
|
-
const identityProfileConnector = identityModels.IdentityProfileConnectorFactory.get(
|
|
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
|
-
|
|
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
|
|
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:
|
|
1077
|
-
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
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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
|
|
1340
|
+
* Configures the verifiable credential authentication.
|
|
1359
1341
|
* @param coreConfig The core config.
|
|
1360
1342
|
* @param envVars The environment variables.
|
|
1361
1343
|
*/
|
|
1362
|
-
function
|
|
1363
|
-
if (core.
|
|
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({
|
|
@@ -1655,11 +1637,18 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
|
|
|
1655
1637
|
});
|
|
1656
1638
|
}
|
|
1657
1639
|
if (!coreEngineConfig.silent) {
|
|
1640
|
+
const includeBody = core.Coerce.boolean(envVars.routeLoggingIncludeBody) ?? coreEngineConfig.debug;
|
|
1641
|
+
const fullBase64 = core.Coerce.boolean(envVars.routeLoggingFullBase64) ?? false;
|
|
1642
|
+
const obfuscateProperties = core.Is.stringValue(envVars.routeLoggingObfuscateProperties)
|
|
1643
|
+
? envVars.routeLoggingObfuscateProperties.split(",")
|
|
1644
|
+
: undefined;
|
|
1658
1645
|
serverConfig.types.restRouteProcessor.push({
|
|
1659
1646
|
type: engineServerTypes.RestRouteProcessorType.Logging,
|
|
1660
1647
|
options: {
|
|
1661
1648
|
config: {
|
|
1662
|
-
includeBody
|
|
1649
|
+
includeBody,
|
|
1650
|
+
fullBase64,
|
|
1651
|
+
obfuscateProperties
|
|
1663
1652
|
}
|
|
1664
1653
|
}
|
|
1665
1654
|
});
|
|
@@ -1667,7 +1656,9 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
|
|
|
1667
1656
|
type: engineServerTypes.SocketRouteProcessorType.Logging,
|
|
1668
1657
|
options: {
|
|
1669
1658
|
config: {
|
|
1670
|
-
includeBody
|
|
1659
|
+
includeBody,
|
|
1660
|
+
fullBase64,
|
|
1661
|
+
obfuscateProperties
|
|
1671
1662
|
}
|
|
1672
1663
|
}
|
|
1673
1664
|
});
|
|
@@ -1726,7 +1717,7 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
|
|
|
1726
1717
|
}
|
|
1727
1718
|
});
|
|
1728
1719
|
}
|
|
1729
|
-
if (core.Coerce.boolean(envVars.
|
|
1720
|
+
if (core.Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
|
|
1730
1721
|
serverConfig.types.restRouteProcessor.push({
|
|
1731
1722
|
type: engineServerTypes.RestRouteProcessorType.AuthVerifiableCredential
|
|
1732
1723
|
});
|
|
@@ -1768,13 +1759,13 @@ async function start(nodeOptions, engineServerConfig, envVars) {
|
|
|
1768
1759
|
stateStorage: nodeOptions?.stateStorage ?? new engineCore.FileStateStorage(envVars.stateFilename ?? ""),
|
|
1769
1760
|
customBootstrap: async (core, engineContext) => bootstrap(core, engineContext, envVars)
|
|
1770
1761
|
});
|
|
1762
|
+
// Construct the server with the engine.
|
|
1763
|
+
const server = new engineServer.EngineServer({ engineCore: engine$1 });
|
|
1771
1764
|
// Extend the engine.
|
|
1772
1765
|
if (core.Is.function(nodeOptions?.extendEngine)) {
|
|
1773
1766
|
console.info("Extending Engine");
|
|
1774
1767
|
await nodeOptions.extendEngine(engine$1);
|
|
1775
1768
|
}
|
|
1776
|
-
// Construct the server with the engine.
|
|
1777
|
-
const server = new engineServer.EngineServer({ engineCore: engine$1 });
|
|
1778
1769
|
// Extend the engine server.
|
|
1779
1770
|
if (core.Is.function(nodeOptions?.extendEngineServer)) {
|
|
1780
1771
|
console.info("Extending Engine Server");
|
|
@@ -1806,7 +1797,7 @@ async function run(nodeOptions) {
|
|
|
1806
1797
|
nodeOptions ??= {};
|
|
1807
1798
|
const serverInfo = {
|
|
1808
1799
|
name: nodeOptions?.serverName ?? "TWIN Node Server",
|
|
1809
|
-
version: nodeOptions?.serverVersion ?? "0.0.2-next.
|
|
1800
|
+
version: nodeOptions?.serverVersion ?? "0.0.2-next.15" // x-release-please-version
|
|
1810
1801
|
};
|
|
1811
1802
|
console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
|
|
1812
1803
|
if (!core.Is.stringValue(nodeOptions?.executionDirectory)) {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PasswordHelper } from '@twin.org/api-auth-entity-storage-service';
|
|
2
|
-
import { I18n, Is, Converter, RandomHelper, StringHelper,
|
|
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,
|
|
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
|
-
|
|
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
|
|
359
|
-
const identityProfileConnector = IdentityProfileConnectorFactory.get(
|
|
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
|
-
|
|
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
|
|
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:
|
|
1056
|
-
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
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
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 (
|
|
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
|
|
1319
|
+
* Configures the verifiable credential authentication.
|
|
1338
1320
|
* @param coreConfig The core config.
|
|
1339
1321
|
* @param envVars The environment variables.
|
|
1340
1322
|
*/
|
|
1341
|
-
function
|
|
1342
|
-
if (
|
|
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({
|
|
@@ -1634,11 +1616,18 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
|
|
|
1634
1616
|
});
|
|
1635
1617
|
}
|
|
1636
1618
|
if (!coreEngineConfig.silent) {
|
|
1619
|
+
const includeBody = Coerce.boolean(envVars.routeLoggingIncludeBody) ?? coreEngineConfig.debug;
|
|
1620
|
+
const fullBase64 = Coerce.boolean(envVars.routeLoggingFullBase64) ?? false;
|
|
1621
|
+
const obfuscateProperties = Is.stringValue(envVars.routeLoggingObfuscateProperties)
|
|
1622
|
+
? envVars.routeLoggingObfuscateProperties.split(",")
|
|
1623
|
+
: undefined;
|
|
1637
1624
|
serverConfig.types.restRouteProcessor.push({
|
|
1638
1625
|
type: RestRouteProcessorType.Logging,
|
|
1639
1626
|
options: {
|
|
1640
1627
|
config: {
|
|
1641
|
-
includeBody
|
|
1628
|
+
includeBody,
|
|
1629
|
+
fullBase64,
|
|
1630
|
+
obfuscateProperties
|
|
1642
1631
|
}
|
|
1643
1632
|
}
|
|
1644
1633
|
});
|
|
@@ -1646,7 +1635,9 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
|
|
|
1646
1635
|
type: SocketRouteProcessorType.Logging,
|
|
1647
1636
|
options: {
|
|
1648
1637
|
config: {
|
|
1649
|
-
includeBody
|
|
1638
|
+
includeBody,
|
|
1639
|
+
fullBase64,
|
|
1640
|
+
obfuscateProperties
|
|
1650
1641
|
}
|
|
1651
1642
|
}
|
|
1652
1643
|
});
|
|
@@ -1705,7 +1696,7 @@ function buildEngineServerConfiguration(envVars, coreEngineConfig, serverInfo, o
|
|
|
1705
1696
|
}
|
|
1706
1697
|
});
|
|
1707
1698
|
}
|
|
1708
|
-
if (Coerce.boolean(envVars.
|
|
1699
|
+
if (Coerce.boolean(envVars.vcAuthenticationEnabled) ?? false) {
|
|
1709
1700
|
serverConfig.types.restRouteProcessor.push({
|
|
1710
1701
|
type: RestRouteProcessorType.AuthVerifiableCredential
|
|
1711
1702
|
});
|
|
@@ -1747,13 +1738,13 @@ async function start(nodeOptions, engineServerConfig, envVars) {
|
|
|
1747
1738
|
stateStorage: nodeOptions?.stateStorage ?? new FileStateStorage(envVars.stateFilename ?? ""),
|
|
1748
1739
|
customBootstrap: async (core, engineContext) => bootstrap(core, engineContext, envVars)
|
|
1749
1740
|
});
|
|
1741
|
+
// Construct the server with the engine.
|
|
1742
|
+
const server = new EngineServer({ engineCore: engine });
|
|
1750
1743
|
// Extend the engine.
|
|
1751
1744
|
if (Is.function(nodeOptions?.extendEngine)) {
|
|
1752
1745
|
console.info("Extending Engine");
|
|
1753
1746
|
await nodeOptions.extendEngine(engine);
|
|
1754
1747
|
}
|
|
1755
|
-
// Construct the server with the engine.
|
|
1756
|
-
const server = new EngineServer({ engineCore: engine });
|
|
1757
1748
|
// Extend the engine server.
|
|
1758
1749
|
if (Is.function(nodeOptions?.extendEngineServer)) {
|
|
1759
1750
|
console.info("Extending Engine Server");
|
|
@@ -1785,7 +1776,7 @@ async function run(nodeOptions) {
|
|
|
1785
1776
|
nodeOptions ??= {};
|
|
1786
1777
|
const serverInfo = {
|
|
1787
1778
|
name: nodeOptions?.serverName ?? "TWIN Node Server",
|
|
1788
|
-
version: nodeOptions?.serverVersion ?? "0.0.2-next.
|
|
1779
|
+
version: nodeOptions?.serverVersion ?? "0.0.2-next.15" // x-release-please-version
|
|
1789
1780
|
};
|
|
1790
1781
|
console.log(`\u001B[4m🌩️ ${serverInfo.name} v${serverInfo.version}\u001B[24m\n`);
|
|
1791
1782
|
if (!Is.stringValue(nodeOptions?.executionDirectory)) {
|