@twin.org/engine-server-types 0.0.2-next.9 → 0.0.3-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/components/authentication.js +40 -0
- package/dist/es/components/authentication.js.map +1 -0
- package/dist/es/components/authenticationAdmin.js +33 -0
- package/dist/es/components/authenticationAdmin.js.map +1 -0
- package/dist/es/components/information.js +29 -0
- package/dist/es/components/information.js.map +1 -0
- package/dist/es/components/mimeTypeProcessor.js +26 -0
- package/dist/es/components/mimeTypeProcessor.js.map +1 -0
- package/dist/es/components/restRouteProcessor.js +76 -0
- package/dist/es/components/restRouteProcessor.js.map +1 -0
- package/dist/es/components/socketRouteProcessor.js +73 -0
- package/dist/es/components/socketRouteProcessor.js.map +1 -0
- package/dist/es/index.js +22 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IEngineServerConfig.js +2 -0
- package/dist/es/models/IEngineServerConfig.js.map +1 -0
- package/dist/es/models/config/authenticationAdminComponentConfig.js +2 -0
- package/dist/es/models/config/authenticationAdminComponentConfig.js.map +1 -0
- package/dist/es/models/config/authenticationComponentConfig.js +2 -0
- package/dist/es/models/config/authenticationComponentConfig.js.map +1 -0
- package/dist/es/models/config/informationComponentConfig.js +2 -0
- package/dist/es/models/config/informationComponentConfig.js.map +1 -0
- package/dist/es/models/config/mimeTypeProcessorConfig.js +2 -0
- package/dist/es/models/config/mimeTypeProcessorConfig.js.map +1 -0
- package/dist/es/models/config/restRouteProcessorConfig.js +2 -0
- package/dist/es/models/config/restRouteProcessorConfig.js.map +1 -0
- package/dist/es/models/config/socketRouteProcessorConfig.js +2 -0
- package/dist/es/models/config/socketRouteProcessorConfig.js.map +1 -0
- package/dist/es/models/types/authenticationAdminComponentType.js +13 -0
- package/dist/es/models/types/authenticationAdminComponentType.js.map +1 -0
- package/dist/es/models/types/authenticationComponentType.js +17 -0
- package/dist/es/models/types/authenticationComponentType.js.map +1 -0
- package/dist/es/models/types/informationComponentType.js +17 -0
- package/dist/es/models/types/informationComponentType.js.map +1 -0
- package/dist/es/models/types/mimeTypeProcessorType.js +13 -0
- package/dist/es/models/types/mimeTypeProcessorType.js.map +1 -0
- package/dist/es/models/types/restRouteProcessorType.js +37 -0
- package/dist/es/models/types/restRouteProcessorType.js.map +1 -0
- package/dist/es/models/types/socketRouteProcessorType.js +37 -0
- package/dist/es/models/types/socketRouteProcessorType.js.map +1 -0
- package/dist/types/components/authentication.d.ts +9 -6
- package/dist/types/components/authenticationAdmin.d.ts +9 -6
- package/dist/types/components/information.d.ts +9 -6
- package/dist/types/components/mimeTypeProcessor.d.ts +10 -6
- package/dist/types/components/restRouteProcessor.d.ts +11 -7
- package/dist/types/components/socketRouteProcessor.d.ts +10 -6
- package/dist/types/index.d.ts +19 -19
- package/dist/types/models/IEngineServerConfig.d.ts +6 -6
- package/dist/types/models/config/authenticationAdminComponentConfig.d.ts +1 -1
- package/dist/types/models/config/authenticationComponentConfig.d.ts +1 -1
- package/dist/types/models/config/informationComponentConfig.d.ts +1 -1
- package/dist/types/models/config/mimeTypeProcessorConfig.d.ts +1 -1
- package/dist/types/models/config/restRouteProcessorConfig.d.ts +14 -6
- package/dist/types/models/config/socketRouteProcessorConfig.d.ts +14 -6
- package/dist/types/models/types/restRouteProcessorType.d.ts +12 -4
- package/dist/types/models/types/socketRouteProcessorType.d.ts +12 -4
- package/docs/changelog.md +307 -0
- package/docs/reference/functions/initialiseAuthenticationAdminComponent.md +3 -13
- package/docs/reference/functions/initialiseAuthenticationComponent.md +3 -13
- package/docs/reference/functions/initialiseInformationComponent.md +3 -13
- package/docs/reference/functions/initialiseMimeTypeProcessorComponent.md +3 -13
- package/docs/reference/functions/initialiseRestRouteProcessorComponent.md +3 -13
- package/docs/reference/functions/initialiseSocketRouteProcessorComponent.md +3 -13
- package/docs/reference/interfaces/IEngineServerConfig.md +1 -1
- package/docs/reference/type-aliases/RestRouteProcessorConfig.md +1 -1
- package/docs/reference/type-aliases/SocketRouteProcessorConfig.md +1 -1
- package/docs/reference/variables/AuthenticationAdminComponentType.md +1 -1
- package/docs/reference/variables/AuthenticationComponentType.md +1 -1
- package/docs/reference/variables/InformationComponentType.md +1 -1
- package/docs/reference/variables/MimeTypeProcessorType.md +1 -1
- package/docs/reference/variables/RestRouteProcessorType.md +19 -7
- package/docs/reference/variables/SocketRouteProcessorType.md +19 -7
- package/package.json +23 -10
- package/dist/cjs/index.cjs +0 -427
- package/dist/esm/index.mjs +0 -414
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/engine-server-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-next.2",
|
|
4
4
|
"description": "Server types to use in an engine server.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,28 +22,41 @@
|
|
|
22
22
|
"@twin.org/api-rest-client": "next",
|
|
23
23
|
"@twin.org/api-server-fastify": "next",
|
|
24
24
|
"@twin.org/api-service": "next",
|
|
25
|
+
"@twin.org/api-tenant-processor": "next",
|
|
26
|
+
"@twin.org/context": "next",
|
|
25
27
|
"@twin.org/core": "next",
|
|
26
|
-
"@twin.org/engine-models": "0.0.
|
|
27
|
-
"@twin.org/engine-types": "0.0.
|
|
28
|
+
"@twin.org/engine-models": "0.0.3-next.2",
|
|
29
|
+
"@twin.org/engine-types": "0.0.3-next.2",
|
|
28
30
|
"@twin.org/entity": "next",
|
|
31
|
+
"@twin.org/identity-authentication": "next",
|
|
29
32
|
"@twin.org/nameof": "next"
|
|
30
33
|
},
|
|
31
|
-
"main": "./dist/
|
|
32
|
-
"module": "./dist/esm/index.mjs",
|
|
34
|
+
"main": "./dist/es/index.js",
|
|
33
35
|
"types": "./dist/types/index.d.ts",
|
|
34
36
|
"exports": {
|
|
35
37
|
".": {
|
|
36
38
|
"types": "./dist/types/index.d.ts",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
+
"import": "./dist/es/index.js",
|
|
40
|
+
"default": "./dist/es/index.js"
|
|
39
41
|
},
|
|
40
42
|
"./locales/*.json": "./locales/*.json"
|
|
41
43
|
},
|
|
42
44
|
"files": [
|
|
43
|
-
"dist/
|
|
44
|
-
"dist/esm",
|
|
45
|
+
"dist/es",
|
|
45
46
|
"dist/types",
|
|
46
47
|
"locales",
|
|
47
48
|
"docs"
|
|
48
|
-
]
|
|
49
|
+
],
|
|
50
|
+
"keywords": [
|
|
51
|
+
"twin",
|
|
52
|
+
"trade",
|
|
53
|
+
"iota",
|
|
54
|
+
"framework",
|
|
55
|
+
"blockchain",
|
|
56
|
+
"engine"
|
|
57
|
+
],
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "git+https://github.com/twinfoundation/engine/issues"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://twindev.org"
|
|
49
62
|
}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,427 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var apiAuthEntityStorageRestClient = require('@twin.org/api-auth-entity-storage-rest-client');
|
|
4
|
-
var apiAuthEntityStorageService = require('@twin.org/api-auth-entity-storage-service');
|
|
5
|
-
var core = require('@twin.org/core');
|
|
6
|
-
var engineTypes = require('@twin.org/engine-types');
|
|
7
|
-
var apiRestClient = require('@twin.org/api-rest-client');
|
|
8
|
-
var apiService = require('@twin.org/api-service');
|
|
9
|
-
var apiModels = require('@twin.org/api-models');
|
|
10
|
-
var apiProcessors = require('@twin.org/api-processors');
|
|
11
|
-
|
|
12
|
-
// Copyright 2024 IOTA Stiftung.
|
|
13
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
14
|
-
/**
|
|
15
|
-
* Authentication component types.
|
|
16
|
-
*/
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
18
|
-
const AuthenticationComponentType = {
|
|
19
|
-
/**
|
|
20
|
-
* Entity storage.
|
|
21
|
-
*/
|
|
22
|
-
EntityStorage: "entity-storage",
|
|
23
|
-
/**
|
|
24
|
-
* REST client.
|
|
25
|
-
*/
|
|
26
|
-
RestClient: "rest-client"
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Initialise the authentication.
|
|
31
|
-
* @param engineCore The engine core.
|
|
32
|
-
* @param context The context for the engine.
|
|
33
|
-
* @param instanceConfig The instance config.
|
|
34
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
35
|
-
* @returns The name of the instance created.
|
|
36
|
-
* @throws GeneralError if the component type is unknown.
|
|
37
|
-
*/
|
|
38
|
-
function initialiseAuthenticationComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
39
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
40
|
-
element: `Authentication Component: ${instanceConfig.type}`
|
|
41
|
-
}));
|
|
42
|
-
const type = instanceConfig.type;
|
|
43
|
-
let component;
|
|
44
|
-
let instanceType;
|
|
45
|
-
if (type === AuthenticationComponentType.EntityStorage) {
|
|
46
|
-
apiAuthEntityStorageService.initSchema();
|
|
47
|
-
engineTypes.initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.userEntityStorageType, "AuthenticationUser");
|
|
48
|
-
component = new apiAuthEntityStorageService.EntityStorageAuthenticationService({
|
|
49
|
-
vaultConnectorType: engineCore.getRegisteredInstanceType("vaultConnector"),
|
|
50
|
-
authenticationAdminServiceType: engineCore.getRegisteredInstanceType("authenticationAdminComponent"),
|
|
51
|
-
...instanceConfig.options
|
|
52
|
-
});
|
|
53
|
-
instanceType = core.StringHelper.kebabCase("EntityStorageAuthenticationService");
|
|
54
|
-
}
|
|
55
|
-
else if (type === AuthenticationComponentType.RestClient) {
|
|
56
|
-
component = new apiAuthEntityStorageRestClient.EntityStorageAuthenticationClient(instanceConfig.options);
|
|
57
|
-
instanceType = core.StringHelper.kebabCase("EntityStorageAuthenticationClient");
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
61
|
-
type,
|
|
62
|
-
componentType: "authenticationComponent"
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
66
|
-
context.componentInstances.push({
|
|
67
|
-
instanceType: finalInstanceType,
|
|
68
|
-
component
|
|
69
|
-
});
|
|
70
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
71
|
-
return finalInstanceType;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Copyright 2024 IOTA Stiftung.
|
|
75
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
76
|
-
/**
|
|
77
|
-
* Authentication admin component types.
|
|
78
|
-
*/
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
80
|
-
const AuthenticationAdminComponentType = {
|
|
81
|
-
/**
|
|
82
|
-
* Entity storage.
|
|
83
|
-
*/
|
|
84
|
-
EntityStorage: "entity-storage"
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Initialise the authentication admin.
|
|
89
|
-
* @param engineCore The engine core.
|
|
90
|
-
* @param context The context for the engine.
|
|
91
|
-
* @param instanceConfig The instance config.
|
|
92
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
93
|
-
* @returns The name of the instance created.
|
|
94
|
-
* @throws GeneralError if the component type is unknown.
|
|
95
|
-
*/
|
|
96
|
-
function initialiseAuthenticationAdminComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
97
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
98
|
-
element: `Authentication Admin Component: ${instanceConfig.type}`
|
|
99
|
-
}));
|
|
100
|
-
const type = instanceConfig.type;
|
|
101
|
-
let component;
|
|
102
|
-
let instanceType;
|
|
103
|
-
if (type === AuthenticationAdminComponentType.EntityStorage) {
|
|
104
|
-
apiAuthEntityStorageService.initSchema();
|
|
105
|
-
engineTypes.initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.userEntityStorageType, "AuthenticationUser");
|
|
106
|
-
component = new apiAuthEntityStorageService.EntityStorageAuthenticationAdminService({
|
|
107
|
-
...instanceConfig.options
|
|
108
|
-
});
|
|
109
|
-
instanceType = core.StringHelper.kebabCase("EntityStorageAuthenticationAdminService");
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
113
|
-
type,
|
|
114
|
-
componentType: "authenticationAdminComponent"
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
118
|
-
context.componentInstances.push({
|
|
119
|
-
instanceType: finalInstanceType,
|
|
120
|
-
component
|
|
121
|
-
});
|
|
122
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
123
|
-
return finalInstanceType;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Copyright 2024 IOTA Stiftung.
|
|
127
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
128
|
-
/**
|
|
129
|
-
* Information component types.
|
|
130
|
-
*/
|
|
131
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
132
|
-
const InformationComponentType = {
|
|
133
|
-
/**
|
|
134
|
-
* Service.
|
|
135
|
-
*/
|
|
136
|
-
Service: "service",
|
|
137
|
-
/**
|
|
138
|
-
* REST client.
|
|
139
|
-
*/
|
|
140
|
-
RestClient: "rest-client"
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Initialise the information component.
|
|
145
|
-
* @param engineCore The engine core.
|
|
146
|
-
* @param context The context for the engine.
|
|
147
|
-
* @param instanceConfig The instance config.
|
|
148
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
149
|
-
* @returns The name of the instance created.
|
|
150
|
-
* @throws GeneralError if the component type is unknown.
|
|
151
|
-
*/
|
|
152
|
-
function initialiseInformationComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
153
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
154
|
-
element: `Information Component: ${instanceConfig.type}`
|
|
155
|
-
}));
|
|
156
|
-
const type = instanceConfig.type;
|
|
157
|
-
let component;
|
|
158
|
-
let instanceType;
|
|
159
|
-
if (type === InformationComponentType.Service) {
|
|
160
|
-
component = new apiService.InformationService(instanceConfig.options);
|
|
161
|
-
instanceType = core.StringHelper.kebabCase("InformationService");
|
|
162
|
-
}
|
|
163
|
-
else if (type === InformationComponentType.RestClient) {
|
|
164
|
-
component = new apiRestClient.InformationClient(instanceConfig.options);
|
|
165
|
-
instanceType = core.StringHelper.kebabCase("InformationClient");
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
169
|
-
type,
|
|
170
|
-
componentType: "informationComponent"
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
174
|
-
context.componentInstances.push({
|
|
175
|
-
instanceType: finalInstanceType,
|
|
176
|
-
component
|
|
177
|
-
});
|
|
178
|
-
core.ComponentFactory.register(finalInstanceType, () => component);
|
|
179
|
-
return finalInstanceType;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Copyright 2024 IOTA Stiftung.
|
|
183
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
184
|
-
/**
|
|
185
|
-
* Mime type route processor types.
|
|
186
|
-
*/
|
|
187
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
188
|
-
const MimeTypeProcessorType = {
|
|
189
|
-
/**
|
|
190
|
-
* Jwt.
|
|
191
|
-
*/
|
|
192
|
-
Jwt: "jwt"
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
// Copyright 2024 IOTA Stiftung.
|
|
196
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
197
|
-
/**
|
|
198
|
-
* Initialise the mime type processor.
|
|
199
|
-
* @param engineCore The engine core.
|
|
200
|
-
* @param context The context for the engine.
|
|
201
|
-
* @param instanceConfig The instance config.
|
|
202
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
203
|
-
* @returns The name of the instance created.
|
|
204
|
-
* @throws GeneralError if the component type is unknown.
|
|
205
|
-
*/
|
|
206
|
-
function initialiseMimeTypeProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
207
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
208
|
-
element: `Mime Type Processor: ${instanceConfig.type}`
|
|
209
|
-
}));
|
|
210
|
-
const type = instanceConfig.type;
|
|
211
|
-
let component;
|
|
212
|
-
let instanceType;
|
|
213
|
-
if (type === MimeTypeProcessorType.Jwt) {
|
|
214
|
-
component = new apiProcessors.JwtMimeTypeProcessor();
|
|
215
|
-
instanceType = core.StringHelper.kebabCase("JwtMimeTypeProcessor");
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
219
|
-
type,
|
|
220
|
-
componentType: "mimeTypeProcessorComponent"
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
224
|
-
context.componentInstances.push({
|
|
225
|
-
instanceType: finalInstanceType,
|
|
226
|
-
component
|
|
227
|
-
});
|
|
228
|
-
apiModels.MimeTypeProcessorFactory.register(finalInstanceType, () => component);
|
|
229
|
-
return finalInstanceType;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Copyright 2024 IOTA Stiftung.
|
|
233
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
234
|
-
/**
|
|
235
|
-
* REST route processor types.
|
|
236
|
-
*/
|
|
237
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
238
|
-
const RestRouteProcessorType = {
|
|
239
|
-
/**
|
|
240
|
-
* Auth header.
|
|
241
|
-
*/
|
|
242
|
-
AuthHeader: "auth-header",
|
|
243
|
-
/**
|
|
244
|
-
* Logging.
|
|
245
|
-
*/
|
|
246
|
-
Logging: "logging",
|
|
247
|
-
/**
|
|
248
|
-
* Node Identity.
|
|
249
|
-
*/
|
|
250
|
-
NodeIdentity: "node-identity",
|
|
251
|
-
/**
|
|
252
|
-
* Static User Identity.
|
|
253
|
-
*/
|
|
254
|
-
StaticUserIdentity: "static-user-identity",
|
|
255
|
-
/**
|
|
256
|
-
* REST Route.
|
|
257
|
-
*/
|
|
258
|
-
RestRoute: "rest-route"
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
// Copyright 2024 IOTA Stiftung.
|
|
262
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
263
|
-
/**
|
|
264
|
-
* Initialise the rest route processor.
|
|
265
|
-
* @param engineCore The engine core.
|
|
266
|
-
* @param context The context for the engine.
|
|
267
|
-
* @param instanceConfig The instance config.
|
|
268
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
269
|
-
* @returns The name of the instance created.
|
|
270
|
-
* @throws GeneralError if the component type is unknown.
|
|
271
|
-
*/
|
|
272
|
-
function initialiseRestRouteProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
273
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
274
|
-
element: `REST Route Processor: ${instanceConfig.type}`
|
|
275
|
-
}));
|
|
276
|
-
const type = instanceConfig.type;
|
|
277
|
-
let component;
|
|
278
|
-
let instanceType;
|
|
279
|
-
if (type === RestRouteProcessorType.AuthHeader) {
|
|
280
|
-
component = new apiAuthEntityStorageService.AuthHeaderProcessor({
|
|
281
|
-
vaultConnectorType: engineCore.getRegisteredInstanceType("vaultConnector"),
|
|
282
|
-
config: {
|
|
283
|
-
...instanceConfig.options?.config
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
instanceType = core.StringHelper.kebabCase("AuthHeaderProcessor");
|
|
287
|
-
}
|
|
288
|
-
else if (type === RestRouteProcessorType.Logging) {
|
|
289
|
-
component = new apiProcessors.LoggingProcessor({
|
|
290
|
-
loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent"),
|
|
291
|
-
config: {
|
|
292
|
-
...instanceConfig.options?.config
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
instanceType = core.StringHelper.kebabCase("LoggingProcessor");
|
|
296
|
-
}
|
|
297
|
-
else if (type === RestRouteProcessorType.NodeIdentity) {
|
|
298
|
-
component = new apiProcessors.NodeIdentityProcessor();
|
|
299
|
-
instanceType = core.StringHelper.kebabCase("NodeIdentityProcessor");
|
|
300
|
-
}
|
|
301
|
-
else if (type === RestRouteProcessorType.StaticUserIdentity) {
|
|
302
|
-
component = new apiProcessors.StaticUserIdentityProcessor(instanceConfig.options);
|
|
303
|
-
instanceType = core.StringHelper.kebabCase("StaticUserIdentityProcessor");
|
|
304
|
-
}
|
|
305
|
-
else if (type === RestRouteProcessorType.RestRoute) {
|
|
306
|
-
component = new apiProcessors.RestRouteProcessor(instanceConfig.options);
|
|
307
|
-
instanceType = core.StringHelper.kebabCase("RestRouteProcessor");
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
311
|
-
type,
|
|
312
|
-
componentType: "restRouteProcessorComponent"
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
316
|
-
context.componentInstances.push({
|
|
317
|
-
instanceType: finalInstanceType,
|
|
318
|
-
component
|
|
319
|
-
});
|
|
320
|
-
apiModels.RestRouteProcessorFactory.register(finalInstanceType, () => component);
|
|
321
|
-
return finalInstanceType;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// Copyright 2024 IOTA Stiftung.
|
|
325
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
326
|
-
/**
|
|
327
|
-
* Socket route processor types.
|
|
328
|
-
*/
|
|
329
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
330
|
-
const SocketRouteProcessorType = {
|
|
331
|
-
/**
|
|
332
|
-
* Auth header.
|
|
333
|
-
*/
|
|
334
|
-
AuthHeader: "auth-header",
|
|
335
|
-
/**
|
|
336
|
-
* Logging.
|
|
337
|
-
*/
|
|
338
|
-
Logging: "logging",
|
|
339
|
-
/**
|
|
340
|
-
* Node Identity.
|
|
341
|
-
*/
|
|
342
|
-
NodeIdentity: "node-identity",
|
|
343
|
-
/**
|
|
344
|
-
* Static User Identity.
|
|
345
|
-
*/
|
|
346
|
-
StaticUserIdentity: "static-user-identity",
|
|
347
|
-
/**
|
|
348
|
-
* Socket Route.
|
|
349
|
-
*/
|
|
350
|
-
SocketRoute: "socket-route"
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
// Copyright 2024 IOTA Stiftung.
|
|
354
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
355
|
-
/**
|
|
356
|
-
* Initialise the socket route processor.
|
|
357
|
-
* @param engineCore The engine core.
|
|
358
|
-
* @param context The context for the engine.
|
|
359
|
-
* @param instanceConfig The instance config.
|
|
360
|
-
* @param overrideInstanceType The instance type to override the default.
|
|
361
|
-
* @returns The name of the instance created.
|
|
362
|
-
* @throws GeneralError if the component type is unknown.
|
|
363
|
-
*/
|
|
364
|
-
function initialiseSocketRouteProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
365
|
-
engineCore.logInfo(core.I18n.formatMessage("engineCore.configuring", {
|
|
366
|
-
element: `Socket Route Processor: ${instanceConfig.type}`
|
|
367
|
-
}));
|
|
368
|
-
const type = instanceConfig.type;
|
|
369
|
-
let component;
|
|
370
|
-
let instanceType;
|
|
371
|
-
if (type === SocketRouteProcessorType.AuthHeader) {
|
|
372
|
-
component = new apiAuthEntityStorageService.AuthHeaderProcessor({
|
|
373
|
-
vaultConnectorType: engineCore.getRegisteredInstanceType("vaultConnector"),
|
|
374
|
-
config: {
|
|
375
|
-
...instanceConfig.options?.config
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
instanceType = core.StringHelper.kebabCase("AuthHeaderProcessor");
|
|
379
|
-
}
|
|
380
|
-
else if (type === SocketRouteProcessorType.Logging) {
|
|
381
|
-
component = new apiProcessors.LoggingProcessor({
|
|
382
|
-
loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent"),
|
|
383
|
-
config: {
|
|
384
|
-
...instanceConfig.options?.config
|
|
385
|
-
}
|
|
386
|
-
});
|
|
387
|
-
instanceType = core.StringHelper.kebabCase("LoggingProcessor");
|
|
388
|
-
}
|
|
389
|
-
else if (type === SocketRouteProcessorType.NodeIdentity) {
|
|
390
|
-
component = new apiProcessors.NodeIdentityProcessor();
|
|
391
|
-
instanceType = core.StringHelper.kebabCase("NodeIdentityProcessor");
|
|
392
|
-
}
|
|
393
|
-
else if (type === SocketRouteProcessorType.StaticUserIdentity) {
|
|
394
|
-
component = new apiProcessors.StaticUserIdentityProcessor(instanceConfig.options);
|
|
395
|
-
instanceType = core.StringHelper.kebabCase("StaticUserIdentityProcessor");
|
|
396
|
-
}
|
|
397
|
-
else if (type === SocketRouteProcessorType.SocketRoute) {
|
|
398
|
-
component = new apiProcessors.SocketRouteProcessor(instanceConfig.options);
|
|
399
|
-
instanceType = core.StringHelper.kebabCase("SocketRouteProcessor");
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
402
|
-
throw new core.GeneralError("engineCore", "componentUnknownType", {
|
|
403
|
-
type,
|
|
404
|
-
componentType: "socketRouteProcessorComponent"
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
408
|
-
context.componentInstances.push({
|
|
409
|
-
instanceType: finalInstanceType,
|
|
410
|
-
component
|
|
411
|
-
});
|
|
412
|
-
apiModels.SocketRouteProcessorFactory.register(finalInstanceType, () => component);
|
|
413
|
-
return finalInstanceType;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
exports.AuthenticationAdminComponentType = AuthenticationAdminComponentType;
|
|
417
|
-
exports.AuthenticationComponentType = AuthenticationComponentType;
|
|
418
|
-
exports.InformationComponentType = InformationComponentType;
|
|
419
|
-
exports.MimeTypeProcessorType = MimeTypeProcessorType;
|
|
420
|
-
exports.RestRouteProcessorType = RestRouteProcessorType;
|
|
421
|
-
exports.SocketRouteProcessorType = SocketRouteProcessorType;
|
|
422
|
-
exports.initialiseAuthenticationAdminComponent = initialiseAuthenticationAdminComponent;
|
|
423
|
-
exports.initialiseAuthenticationComponent = initialiseAuthenticationComponent;
|
|
424
|
-
exports.initialiseInformationComponent = initialiseInformationComponent;
|
|
425
|
-
exports.initialiseMimeTypeProcessorComponent = initialiseMimeTypeProcessorComponent;
|
|
426
|
-
exports.initialiseRestRouteProcessorComponent = initialiseRestRouteProcessorComponent;
|
|
427
|
-
exports.initialiseSocketRouteProcessorComponent = initialiseSocketRouteProcessorComponent;
|