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