@twin.org/engine-server-types 0.0.2-next.2 → 0.0.2-next.20

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.
Files changed (29) hide show
  1. package/dist/cjs/index.cjs +109 -164
  2. package/dist/esm/index.mjs +110 -165
  3. package/dist/types/components/authentication.d.ts +7 -4
  4. package/dist/types/components/authenticationAdmin.d.ts +7 -4
  5. package/dist/types/components/information.d.ts +7 -4
  6. package/dist/types/components/mimeTypeProcessor.d.ts +8 -4
  7. package/dist/types/components/restRouteProcessor.d.ts +9 -5
  8. package/dist/types/components/socketRouteProcessor.d.ts +8 -4
  9. package/dist/types/models/config/restRouteProcessorConfig.d.ts +4 -0
  10. package/dist/types/models/config/socketRouteProcessorConfig.d.ts +4 -0
  11. package/dist/types/models/types/restRouteProcessorType.d.ts +4 -0
  12. package/dist/types/models/types/socketRouteProcessorType.d.ts +4 -0
  13. package/docs/changelog.md +270 -0
  14. package/docs/reference/functions/initialiseAuthenticationAdminComponent.md +3 -13
  15. package/docs/reference/functions/initialiseAuthenticationComponent.md +3 -13
  16. package/docs/reference/functions/initialiseInformationComponent.md +3 -13
  17. package/docs/reference/functions/initialiseMimeTypeProcessorComponent.md +3 -13
  18. package/docs/reference/functions/initialiseRestRouteProcessorComponent.md +3 -13
  19. package/docs/reference/functions/initialiseSocketRouteProcessorComponent.md +3 -13
  20. package/docs/reference/interfaces/IEngineServerConfig.md +1 -1
  21. package/docs/reference/type-aliases/RestRouteProcessorConfig.md +1 -1
  22. package/docs/reference/type-aliases/SocketRouteProcessorConfig.md +1 -1
  23. package/docs/reference/variables/AuthenticationAdminComponentType.md +1 -1
  24. package/docs/reference/variables/AuthenticationComponentType.md +1 -1
  25. package/docs/reference/variables/InformationComponentType.md +1 -1
  26. package/docs/reference/variables/MimeTypeProcessorType.md +1 -1
  27. package/docs/reference/variables/RestRouteProcessorType.md +7 -1
  28. package/docs/reference/variables/SocketRouteProcessorType.md +7 -1
  29. package/package.json +12 -3
@@ -8,6 +8,7 @@ var apiRestClient = require('@twin.org/api-rest-client');
8
8
  var apiService = require('@twin.org/api-service');
9
9
  var apiModels = require('@twin.org/api-models');
10
10
  var apiProcessors = require('@twin.org/api-processors');
11
+ var identityAuthentication = require('@twin.org/identity-authentication');
11
12
 
12
13
  // Copyright 2024 IOTA Stiftung.
13
14
  // SPDX-License-Identifier: Apache-2.0.
@@ -31,44 +32,30 @@ const AuthenticationComponentType = {
31
32
  * @param engineCore The engine core.
32
33
  * @param context The context for the engine.
33
34
  * @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.
35
+ * @returns The instance created and the factory for it.
37
36
  */
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;
37
+ async function initialiseAuthenticationComponent(engineCore, context, instanceConfig) {
43
38
  let component;
44
39
  let instanceType;
45
- if (type === AuthenticationComponentType.EntityStorage) {
40
+ if (instanceConfig.type === AuthenticationComponentType.EntityStorage) {
46
41
  apiAuthEntityStorageService.initSchema();
47
42
  engineTypes.initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.userEntityStorageType, "AuthenticationUser");
48
43
  component = new apiAuthEntityStorageService.EntityStorageAuthenticationService({
49
- vaultConnectorType: context.defaultTypes.vaultConnector,
50
- authenticationAdminServiceType: context.defaultTypes.authenticationAdminComponent,
44
+ vaultConnectorType: engineCore.getRegisteredInstanceType("vaultConnector"),
45
+ authenticationAdminServiceType: engineCore.getRegisteredInstanceType("authenticationAdminComponent"),
51
46
  ...instanceConfig.options
52
47
  });
53
- instanceType = core.StringHelper.kebabCase("EntityStorageAuthenticationService");
48
+ instanceType = "entity-storage-authentication-service";
54
49
  }
55
- else if (type === AuthenticationComponentType.RestClient) {
50
+ else if (instanceConfig.type === AuthenticationComponentType.RestClient) {
56
51
  component = new apiAuthEntityStorageRestClient.EntityStorageAuthenticationClient(instanceConfig.options);
57
- instanceType = core.StringHelper.kebabCase("EntityStorageAuthenticationClient");
52
+ instanceType = "entity-storage-authentication-client";
58
53
  }
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;
54
+ return {
55
+ component,
56
+ instanceType,
57
+ factory: core.ComponentFactory
58
+ };
72
59
  }
73
60
 
74
61
  // Copyright 2024 IOTA Stiftung.
@@ -89,38 +76,24 @@ const AuthenticationAdminComponentType = {
89
76
  * @param engineCore The engine core.
90
77
  * @param context The context for the engine.
91
78
  * @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.
79
+ * @returns The instance created and the factory for it.
95
80
  */
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;
81
+ async function initialiseAuthenticationAdminComponent(engineCore, context, instanceConfig) {
101
82
  let component;
102
83
  let instanceType;
103
- if (type === AuthenticationAdminComponentType.EntityStorage) {
84
+ if (instanceConfig.type === AuthenticationAdminComponentType.EntityStorage) {
104
85
  apiAuthEntityStorageService.initSchema();
105
86
  engineTypes.initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.userEntityStorageType, "AuthenticationUser");
106
87
  component = new apiAuthEntityStorageService.EntityStorageAuthenticationAdminService({
107
88
  ...instanceConfig.options
108
89
  });
109
- instanceType = core.StringHelper.kebabCase("EntityStorageAuthenticationAdminService");
110
- }
111
- else {
112
- throw new core.GeneralError("engineCore", "componentUnknownType", {
113
- type,
114
- componentType: "authenticationAdminComponent"
115
- });
90
+ instanceType = "entity-storage-authentication-admin-service";
116
91
  }
117
- const finalInstanceType = overrideInstanceType ?? instanceType;
118
- context.componentInstances.push({
119
- instanceType: finalInstanceType,
120
- component
121
- });
122
- core.ComponentFactory.register(finalInstanceType, () => component);
123
- return finalInstanceType;
92
+ return {
93
+ component,
94
+ instanceType,
95
+ factory: core.ComponentFactory
96
+ };
124
97
  }
125
98
 
126
99
  // Copyright 2024 IOTA Stiftung.
@@ -145,38 +118,24 @@ const InformationComponentType = {
145
118
  * @param engineCore The engine core.
146
119
  * @param context The context for the engine.
147
120
  * @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.
121
+ * @returns The instance created and the factory for it.
151
122
  */
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;
123
+ async function initialiseInformationComponent(engineCore, context, instanceConfig) {
157
124
  let component;
158
125
  let instanceType;
159
- if (type === InformationComponentType.Service) {
126
+ if (instanceConfig.type === InformationComponentType.Service) {
160
127
  component = new apiService.InformationService(instanceConfig.options);
161
- instanceType = core.StringHelper.kebabCase("InformationService");
128
+ instanceType = "information-service";
162
129
  }
163
- else if (type === InformationComponentType.RestClient) {
130
+ else if (instanceConfig.type === InformationComponentType.RestClient) {
164
131
  component = new apiRestClient.InformationClient(instanceConfig.options);
165
- instanceType = core.StringHelper.kebabCase("InformationClient");
132
+ instanceType = "information-client";
166
133
  }
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;
134
+ return {
135
+ component,
136
+ instanceType,
137
+ factory: core.ComponentFactory
138
+ };
180
139
  }
181
140
 
182
141
  // Copyright 2024 IOTA Stiftung.
@@ -199,34 +158,20 @@ const MimeTypeProcessorType = {
199
158
  * @param engineCore The engine core.
200
159
  * @param context The context for the engine.
201
160
  * @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.
161
+ * @returns The instance created and the factory for it.
205
162
  */
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;
163
+ async function initialiseMimeTypeProcessorComponent(engineCore, context, instanceConfig) {
211
164
  let component;
212
165
  let instanceType;
213
- if (type === MimeTypeProcessorType.Jwt) {
166
+ if (instanceConfig.type === MimeTypeProcessorType.Jwt) {
214
167
  component = new apiProcessors.JwtMimeTypeProcessor();
215
- instanceType = core.StringHelper.kebabCase("JwtMimeTypeProcessor");
168
+ instanceType = "jwt-mime-type-processor";
216
169
  }
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;
170
+ return {
171
+ component,
172
+ instanceType,
173
+ factory: apiModels.MimeTypeProcessorFactory
174
+ };
230
175
  }
231
176
 
232
177
  // Copyright 2024 IOTA Stiftung.
@@ -240,6 +185,10 @@ const RestRouteProcessorType = {
240
185
  * Auth header.
241
186
  */
242
187
  AuthHeader: "auth-header",
188
+ /**
189
+ * Auth verifiable credential.
190
+ */
191
+ AuthVerifiableCredential: "auth-verifiable-credential",
243
192
  /**
244
193
  * Logging.
245
194
  */
@@ -265,60 +214,56 @@ const RestRouteProcessorType = {
265
214
  * @param engineCore The engine core.
266
215
  * @param context The context for the engine.
267
216
  * @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.
217
+ * @returns The instance created and the factory for it.
271
218
  */
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;
219
+ async function initialiseRestRouteProcessorComponent(engineCore, context, instanceConfig) {
277
220
  let component;
278
221
  let instanceType;
279
- if (type === RestRouteProcessorType.AuthHeader) {
222
+ if (instanceConfig.type === RestRouteProcessorType.AuthHeader) {
280
223
  component = new apiAuthEntityStorageService.AuthHeaderProcessor({
281
- vaultConnectorType: context.defaultTypes.vaultConnector,
224
+ vaultConnectorType: engineCore.getRegisteredInstanceType("vaultConnector"),
225
+ config: {
226
+ ...instanceConfig.options?.config
227
+ }
228
+ });
229
+ instanceType = "auth-header-processor";
230
+ }
231
+ else if (instanceConfig.type === RestRouteProcessorType.AuthVerifiableCredential) {
232
+ component = new identityAuthentication.VerifiableCredentialAuthenticationProcessor({
233
+ identityConnectorType: engineCore.getRegisteredInstanceType("identityConnector"),
234
+ loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent"),
282
235
  config: {
283
236
  ...instanceConfig.options?.config
284
237
  }
285
238
  });
286
- instanceType = core.StringHelper.kebabCase("AuthHeaderProcessor");
239
+ instanceType = "verifiable-credential-authentication-processor";
287
240
  }
288
- else if (type === RestRouteProcessorType.Logging) {
241
+ else if (instanceConfig.type === RestRouteProcessorType.Logging) {
289
242
  component = new apiProcessors.LoggingProcessor({
290
- loggingConnectorType: context.defaultTypes.loggingConnector,
243
+ loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent"),
291
244
  config: {
292
245
  ...instanceConfig.options?.config
293
246
  }
294
247
  });
295
- instanceType = core.StringHelper.kebabCase("LoggingProcessor");
248
+ instanceType = "logging-processor";
296
249
  }
297
- else if (type === RestRouteProcessorType.NodeIdentity) {
250
+ else if (instanceConfig.type === RestRouteProcessorType.NodeIdentity) {
298
251
  component = new apiProcessors.NodeIdentityProcessor();
299
- instanceType = core.StringHelper.kebabCase("NodeIdentityProcessor");
252
+ instanceType = "node-identity-processor";
300
253
  }
301
- else if (type === RestRouteProcessorType.StaticUserIdentity) {
254
+ else if (instanceConfig.type === RestRouteProcessorType.StaticUserIdentity) {
302
255
  component = new apiProcessors.StaticUserIdentityProcessor(instanceConfig.options);
303
- instanceType = core.StringHelper.kebabCase("StaticUserIdentityProcessor");
256
+ instanceType = "static-user-identity-processor";
304
257
  }
305
- else if (type === RestRouteProcessorType.RestRoute) {
258
+ else if (instanceConfig.type === RestRouteProcessorType.RestRoute) {
306
259
  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
- });
260
+ instanceType = "rest-route-processor";
314
261
  }
315
- const finalInstanceType = overrideInstanceType ?? instanceType;
316
- context.componentInstances.push({
317
- instanceType: finalInstanceType,
318
- component
319
- });
320
- apiModels.RestRouteProcessorFactory.register(finalInstanceType, () => component);
321
- return finalInstanceType;
262
+ return {
263
+ component,
264
+ instanceType,
265
+ factory: apiModels.RestRouteProcessorFactory
266
+ };
322
267
  }
323
268
 
324
269
  // Copyright 2024 IOTA Stiftung.
@@ -332,6 +277,10 @@ const SocketRouteProcessorType = {
332
277
  * Auth header.
333
278
  */
334
279
  AuthHeader: "auth-header",
280
+ /**
281
+ * Auth verifiable credential.
282
+ */
283
+ AuthVerifiableCredential: "auth-verifiable-credential",
335
284
  /**
336
285
  * Logging.
337
286
  */
@@ -357,60 +306,56 @@ const SocketRouteProcessorType = {
357
306
  * @param engineCore The engine core.
358
307
  * @param context The context for the engine.
359
308
  * @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.
309
+ * @returns The instance created and the factory for it.
363
310
  */
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;
311
+ async function initialiseSocketRouteProcessorComponent(engineCore, context, instanceConfig) {
369
312
  let component;
370
313
  let instanceType;
371
- if (type === SocketRouteProcessorType.AuthHeader) {
314
+ if (instanceConfig.type === SocketRouteProcessorType.AuthHeader) {
372
315
  component = new apiAuthEntityStorageService.AuthHeaderProcessor({
373
- vaultConnectorType: context.defaultTypes.vaultConnector,
316
+ vaultConnectorType: engineCore.getRegisteredInstanceType("vaultConnector"),
374
317
  config: {
375
318
  ...instanceConfig.options?.config
376
319
  }
377
320
  });
378
- instanceType = core.StringHelper.kebabCase("AuthHeaderProcessor");
321
+ instanceType = "auth-header-processor";
379
322
  }
380
- else if (type === SocketRouteProcessorType.Logging) {
323
+ else if (instanceConfig.type === SocketRouteProcessorType.AuthVerifiableCredential) {
324
+ component = new identityAuthentication.VerifiableCredentialAuthenticationProcessor({
325
+ identityConnectorType: engineCore.getRegisteredInstanceType("identityConnector"),
326
+ loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent"),
327
+ config: {
328
+ ...instanceConfig.options?.config
329
+ }
330
+ });
331
+ instanceType = "verifiable-credential-authentication-processor";
332
+ }
333
+ else if (instanceConfig.type === SocketRouteProcessorType.Logging) {
381
334
  component = new apiProcessors.LoggingProcessor({
382
- loggingConnectorType: context.defaultTypes.loggingConnector,
335
+ loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent"),
383
336
  config: {
384
337
  ...instanceConfig.options?.config
385
338
  }
386
339
  });
387
- instanceType = core.StringHelper.kebabCase("LoggingProcessor");
340
+ instanceType = "logging-processor";
388
341
  }
389
- else if (type === SocketRouteProcessorType.NodeIdentity) {
342
+ else if (instanceConfig.type === SocketRouteProcessorType.NodeIdentity) {
390
343
  component = new apiProcessors.NodeIdentityProcessor();
391
- instanceType = core.StringHelper.kebabCase("NodeIdentityProcessor");
344
+ instanceType = "node-identity-processor";
392
345
  }
393
- else if (type === SocketRouteProcessorType.StaticUserIdentity) {
346
+ else if (instanceConfig.type === SocketRouteProcessorType.StaticUserIdentity) {
394
347
  component = new apiProcessors.StaticUserIdentityProcessor(instanceConfig.options);
395
- instanceType = core.StringHelper.kebabCase("StaticUserIdentityProcessor");
348
+ instanceType = "static-user-identity-processor";
396
349
  }
397
- else if (type === SocketRouteProcessorType.SocketRoute) {
350
+ else if (instanceConfig.type === SocketRouteProcessorType.SocketRoute) {
398
351
  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
- });
352
+ instanceType = "socket-route-processor";
406
353
  }
407
- const finalInstanceType = overrideInstanceType ?? instanceType;
408
- context.componentInstances.push({
409
- instanceType: finalInstanceType,
410
- component
411
- });
412
- apiModels.SocketRouteProcessorFactory.register(finalInstanceType, () => component);
413
- return finalInstanceType;
354
+ return {
355
+ component,
356
+ instanceType,
357
+ factory: apiModels.SocketRouteProcessorFactory
358
+ };
414
359
  }
415
360
 
416
361
  exports.AuthenticationAdminComponentType = AuthenticationAdminComponentType;