@wabot-dev/framework 0.2.0-beta.8 → 0.2.0-beta.9

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.
@@ -0,0 +1,16 @@
1
+ import { handshakeMiddlewares } from '../../../feature/socket-controller/metadata/@handshakeMiddlewares.js';
2
+ import '../../../feature/socket-controller/metadata/SocketControllerMetadataStore.js';
3
+ import '../../../core/injection/index.js';
4
+ import 'debug';
5
+ import '../../../core/validation/metadata/ValidationMetadataStore.js';
6
+ import 'socket.io';
7
+ import '../../../feature/socket/SocketServerProvider.js';
8
+ import { ApiKeyHandshakeGuardMiddleware } from './ApiKeyHandshakeGuardMiddleware.js';
9
+
10
+ function apiKeyHandshakeGuard() {
11
+ return function (target) {
12
+ handshakeMiddlewares([ApiKeyHandshakeGuardMiddleware])(target);
13
+ };
14
+ }
15
+
16
+ export { apiKeyHandshakeGuard };
@@ -4,7 +4,7 @@ import { CustomError } from '../../../core/error/CustomError.js';
4
4
  import { injectable } from '../../../core/injection/index.js';
5
5
  import { ApiKeyRepository } from './ApiKeyRepository.js';
6
6
 
7
- let ApiKeyConnectionGuardMiddleware = class ApiKeyConnectionGuardMiddleware {
7
+ let ApiKeyHandshakeGuardMiddleware = class ApiKeyHandshakeGuardMiddleware {
8
8
  apiKeyRepository;
9
9
  auth;
10
10
  constructor(apiKeyRepository, auth) {
@@ -45,10 +45,10 @@ let ApiKeyConnectionGuardMiddleware = class ApiKeyConnectionGuardMiddleware {
45
45
  }
46
46
  }
47
47
  };
48
- ApiKeyConnectionGuardMiddleware = __decorate([
48
+ ApiKeyHandshakeGuardMiddleware = __decorate([
49
49
  injectable(),
50
50
  __metadata("design:paramtypes", [ApiKeyRepository,
51
51
  Auth])
52
- ], ApiKeyConnectionGuardMiddleware);
52
+ ], ApiKeyHandshakeGuardMiddleware);
53
53
 
54
- export { ApiKeyConnectionGuardMiddleware };
54
+ export { ApiKeyHandshakeGuardMiddleware };
@@ -0,0 +1,16 @@
1
+ import { handshakeMiddlewares } from '../../../feature/socket-controller/metadata/@handshakeMiddlewares.js';
2
+ import '../../../feature/socket-controller/metadata/SocketControllerMetadataStore.js';
3
+ import '../../../core/injection/index.js';
4
+ import 'debug';
5
+ import '../../../core/validation/metadata/ValidationMetadataStore.js';
6
+ import 'socket.io';
7
+ import '../../../feature/socket/SocketServerProvider.js';
8
+ import { JwtHandshakeGuardMiddleware } from './JwtHandshakeGuardMiddleware.js';
9
+
10
+ function jwtHandshakeGuard() {
11
+ return function (target) {
12
+ handshakeMiddlewares([JwtHandshakeGuardMiddleware])(target);
13
+ };
14
+ }
15
+
16
+ export { jwtHandshakeGuard };
@@ -5,7 +5,7 @@ import { Auth } from '../../../core/auth/Auth.js';
5
5
  import { CustomError } from '../../../core/error/CustomError.js';
6
6
  import { JwtConfig } from './JwtConfig.js';
7
7
 
8
- let JwtConnectionGuardMiddleware = class JwtConnectionGuardMiddleware {
8
+ let JwtHandshakeGuardMiddleware = class JwtHandshakeGuardMiddleware {
9
9
  config;
10
10
  auth;
11
11
  constructor(config, auth) {
@@ -48,10 +48,10 @@ let JwtConnectionGuardMiddleware = class JwtConnectionGuardMiddleware {
48
48
  }
49
49
  }
50
50
  };
51
- JwtConnectionGuardMiddleware = __decorate([
51
+ JwtHandshakeGuardMiddleware = __decorate([
52
52
  injectable(),
53
53
  __metadata("design:paramtypes", [JwtConfig,
54
54
  Auth])
55
- ], JwtConnectionGuardMiddleware);
55
+ ], JwtHandshakeGuardMiddleware);
56
56
 
57
- export { JwtConnectionGuardMiddleware };
57
+ export { JwtHandshakeGuardMiddleware };
@@ -18,7 +18,7 @@ function socket(config) {
18
18
  channelConstructor: SocketChannel,
19
19
  functionName: propertyKey.toString(),
20
20
  controllerConstructor: target.constructor,
21
- channelConfig: new SocketChannelConfig(config.channel),
21
+ channelConfig: new SocketChannelConfig(config.namespace, config.handshakeMidlewares),
22
22
  });
23
23
  };
24
24
  }
@@ -1,65 +1,77 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
2
  import { injectable } from '../../../core/injection/index.js';
3
- import { SocketServerProvider } from '../../../feature/socket/SocketServerProvider.js';
3
+ import { handshakeMiddlewares } from '../../../feature/socket-controller/metadata/@handshakeMiddlewares.js';
4
+ import { socketController } from '../../../feature/socket-controller/metadata/@socketController.js';
5
+ import { onSocketEvent } from '../../../feature/socket-controller/metadata/@onSocketEvent.js';
6
+ import '../../../feature/socket-controller/metadata/SocketControllerMetadataStore.js';
7
+ import { runSocketControllers } from '../../../feature/socket-controller/runSocketControllers.js';
8
+ import { Socket } from 'socket.io';
4
9
  import { SocketChannelConfig } from './SocketChannelConfig.js';
5
10
 
6
11
  var SocketChannel_1;
7
12
  let SocketChannel = SocketChannel_1 = class SocketChannel {
8
13
  config;
9
- socketServerProvider;
10
14
  callBack = null;
11
- server;
12
- constructor(config, socketServerProvider) {
15
+ controller = null;
16
+ constructor(config) {
13
17
  this.config = config;
14
- this.socketServerProvider = socketServerProvider;
15
- this.server = this.socketServerProvider.getSocketServer();
18
+ this.configController();
16
19
  }
17
- listen(callback) {
18
- this.callBack = callback;
19
- }
20
- connect() {
21
- this.server.on('connection', (socket) => {
22
- socket.on(this.config.channel, async (message) => {
20
+ configController() {
21
+ const channel = this;
22
+ let SocketChannelController = class SocketChannelController {
23
+ onMessage(message, socket) {
24
+ if (!channel.callBack)
25
+ return;
23
26
  const trimmedInput = message.text.trim();
24
27
  if (!trimmedInput) {
25
28
  return;
26
29
  }
27
- if (!message.chatId || !message.userId || !message.senderName) {
28
- socket.emit(this.config.channel, {
29
- error: 'Invalid message format. chatId, userId, and senderName are required.',
30
- });
31
- return;
32
- }
33
30
  const chatConnection = {
34
31
  id: message.chatId,
35
32
  chatType: 'PRIVATE',
36
33
  channelName: SocketChannel_1.name,
37
34
  };
38
- if (!this.callBack)
39
- return;
40
- this.callBack({
35
+ channel.callBack({
41
36
  chatConnection,
42
37
  message: {
43
- text: trimmedInput,
38
+ text: message.text,
44
39
  senderName: message.senderName,
45
40
  },
46
41
  reply: (message) => {
47
- socket.emit(this.config.channel, message);
42
+ socket.emit('message', message);
48
43
  },
49
44
  authInfo: socket.data.authInfo,
50
45
  setAuthInfo: (authInfo) => {
51
46
  socket.data.authInfo = authInfo;
52
47
  },
53
48
  });
54
- });
55
- });
56
- this.socketServerProvider.listen();
49
+ }
50
+ };
51
+ __decorate([
52
+ onSocketEvent('message'),
53
+ __metadata("design:type", Function),
54
+ __metadata("design:paramtypes", [Object, Socket]),
55
+ __metadata("design:returntype", void 0)
56
+ ], SocketChannelController.prototype, "onMessage", null);
57
+ SocketChannelController = __decorate([
58
+ socketController(channel.config.namespace),
59
+ handshakeMiddlewares(channel.config.handshakeMidlewares ?? [])
60
+ ], SocketChannelController);
61
+ this.controller = SocketChannelController;
62
+ }
63
+ listen(callback) {
64
+ this.callBack = callback;
65
+ }
66
+ connect() {
67
+ if (!this.controller)
68
+ return;
69
+ runSocketControllers([this.controller]);
57
70
  }
58
71
  };
59
72
  SocketChannel = SocketChannel_1 = __decorate([
60
73
  injectable(),
61
- __metadata("design:paramtypes", [SocketChannelConfig,
62
- SocketServerProvider])
74
+ __metadata("design:paramtypes", [SocketChannelConfig])
63
75
  ], SocketChannel);
64
76
 
65
77
  export { SocketChannel };
@@ -2,14 +2,16 @@ import { __decorate, __metadata } from 'tslib';
2
2
  import { injectable } from '../../../core/injection/index.js';
3
3
 
4
4
  let SocketChannelConfig = class SocketChannelConfig {
5
- channel;
6
- constructor(channel) {
7
- this.channel = channel;
5
+ namespace;
6
+ handshakeMidlewares;
7
+ constructor(namespace, handshakeMidlewares) {
8
+ this.namespace = namespace;
9
+ this.handshakeMidlewares = handshakeMidlewares;
8
10
  }
9
11
  };
10
12
  SocketChannelConfig = __decorate([
11
13
  injectable(),
12
- __metadata("design:paramtypes", [String])
14
+ __metadata("design:paramtypes", [String, Array])
13
15
  ], SocketChannelConfig);
14
16
 
15
17
  export { SocketChannelConfig };
@@ -4,6 +4,7 @@ import { scoped, Lifecycle } from '../injection/index.js';
4
4
 
5
5
  let Auth = class Auth {
6
6
  authInfo = null;
7
+ overrided = false;
7
8
  require() {
8
9
  if (!this.authInfo) {
9
10
  throw new CustomError({ message: 'Unauthorized', httpCode: 401 });
@@ -18,13 +19,18 @@ let Auth = class Auth {
18
19
  }
19
20
  override(authInfo) {
20
21
  this.authInfo = authInfo;
22
+ this.overrided = true;
21
23
  }
22
24
  clear() {
23
25
  this.authInfo = null;
26
+ this.overrided = true;
24
27
  }
25
28
  isAssigned() {
26
29
  return this.authInfo !== null;
27
30
  }
31
+ wasOverrided() {
32
+ return this.overrided;
33
+ }
28
34
  };
29
35
  Auth = __decorate([
30
36
  scoped(Lifecycle.ContainerScoped)
@@ -69,7 +69,9 @@ function runChatControllers(controllers) {
69
69
  channelMessage.reply(message);
70
70
  if (channelMessage.setAuthInfo) {
71
71
  const auth = chatContainer.resolve(Auth);
72
- channelMessage.setAuthInfo(auth['authInfo'] || undefined);
72
+ if (auth.wasOverrided()) {
73
+ channelMessage.setAuthInfo(auth['authInfo'] || undefined);
74
+ }
73
75
  }
74
76
  },
75
77
  };
@@ -0,0 +1,16 @@
1
+ import { SocketControllerMetadataStore } from './SocketControllerMetadataStore.js';
2
+ import { container } from '../../../core/injection/index.js';
3
+
4
+ function handshakeMiddlewares(middlewares) {
5
+ return function (target) {
6
+ const store = container.resolve(SocketControllerMetadataStore);
7
+ for (const mw of middlewares) {
8
+ store.saveHandshakeMiddlewareMetadata({
9
+ controllerConstructor: target.constructor,
10
+ middlewareConstructor: mw,
11
+ });
12
+ }
13
+ };
14
+ }
15
+
16
+ export { handshakeMiddlewares };
@@ -1,7 +1,7 @@
1
1
  import { container } from '../../../core/injection/index.js';
2
2
  import { SocketControllerMetadataStore } from './SocketControllerMetadataStore.js';
3
3
 
4
- function socketEvent(config) {
4
+ function onSocketEvent(config) {
5
5
  return function (target, propertyKey) {
6
6
  const functionName = propertyKey.toString();
7
7
  const paramsTypes = Reflect.getMetadata('design:paramtypes', target, functionName);
@@ -15,4 +15,4 @@ function socketEvent(config) {
15
15
  };
16
16
  }
17
17
 
18
- export { socketEvent };
18
+ export { onSocketEvent };
@@ -3,19 +3,11 @@ import { singleton } from '../../../core/injection/index.js';
3
3
 
4
4
  let SocketControllerMetadataStore = class SocketControllerMetadataStore {
5
5
  socketControllers = new Map();
6
- socketConnections = new Map();
7
6
  socketEvents = new Map();
8
- connectionMiddlewares = new Map();
7
+ handshakeMiddlewares = new Map();
9
8
  saveControllerMetadata(controllerMetadata) {
10
9
  this.socketControllers.set(controllerMetadata.controllerConstructor, controllerMetadata);
11
10
  }
12
- saveSocketConnectionMetadata(socketConnectionMetadata) {
13
- let controllerConnections = this.socketConnections.get(socketConnectionMetadata.controllerConstructor);
14
- if (!controllerConnections) {
15
- this.socketConnections.set(socketConnectionMetadata.controllerConstructor, (controllerConnections = new Map()));
16
- }
17
- controllerConnections.set(socketConnectionMetadata.functionName, socketConnectionMetadata);
18
- }
19
11
  saveSocketEventMetadata(socketEventMetadata) {
20
12
  let controllerEvents = this.socketEvents.get(socketEventMetadata.controllerConstructor);
21
13
  if (!controllerEvents) {
@@ -23,39 +15,25 @@ let SocketControllerMetadataStore = class SocketControllerMetadataStore {
23
15
  }
24
16
  controllerEvents.set(socketEventMetadata.functionName, socketEventMetadata);
25
17
  }
26
- saveConnectionMiddlewareMetadata(middlewareMetadata) {
27
- let controllerMiddlewares = this.connectionMiddlewares.get(middlewareMetadata.controllerConstructor);
18
+ saveHandshakeMiddlewareMetadata(handshakeMetadata) {
19
+ let controllerMiddlewares = this.handshakeMiddlewares.get(handshakeMetadata.controllerConstructor);
28
20
  if (!controllerMiddlewares) {
29
- this.connectionMiddlewares.set(middlewareMetadata.controllerConstructor, (controllerMiddlewares = new Map()));
21
+ this.handshakeMiddlewares.set(handshakeMetadata.controllerConstructor, (controllerMiddlewares = []));
30
22
  }
31
- let methodMiddlewares = controllerMiddlewares.get(middlewareMetadata.functionName);
32
- if (!methodMiddlewares) {
33
- controllerMiddlewares.set(middlewareMetadata.functionName, (methodMiddlewares = []));
34
- }
35
- methodMiddlewares.unshift(middlewareMetadata);
23
+ controllerMiddlewares.unshift(handshakeMetadata);
36
24
  }
37
- getControllerSockerConnectionsInfo(controllerConstructor) {
25
+ getSocketControllerInfo(controllerConstructor) {
38
26
  const controller = this.socketControllers.get(controllerConstructor);
39
27
  if (!controller) {
40
28
  throw new Error(`${controllerConstructor.name} should be decorated with @socketController`);
41
29
  }
42
- const connections = this.socketConnections.get(controllerConstructor);
30
+ const handShakeMiddlewares = this.handshakeMiddlewares.get(controllerConstructor);
43
31
  const events = this.socketEvents.get(controllerConstructor) ?? new Map();
44
- if (!connections?.size) {
45
- // TODO: Warning
46
- return [];
47
- }
48
- return [...connections.values()].map((connection) => ({
49
- ...connection,
50
- events: (() => {
51
- const connectionNamespace = connection.config?.namespace;
52
- return [...events.values()].filter((x) => x.config?.namespace === connectionNamespace);
53
- })(),
54
- connectionMiddlewares: this.connectionMiddlewares
55
- .get(connection.controllerConstructor)
56
- ?.get(connection.functionName) ?? [],
57
- controller: this.socketControllers.get(connection.controllerConstructor),
58
- }));
32
+ return {
33
+ controller,
34
+ events,
35
+ handShakeMiddlewares,
36
+ };
59
37
  }
60
38
  };
61
39
  SocketControllerMetadataStore = __decorate([
@@ -1,11 +1,11 @@
1
- import { SocketControllerMetadataStore } from './metadata/SocketControllerMetadataStore.js';
1
+ import { CustomError } from '../../core/error/CustomError.js';
2
2
  import { container } from '../../core/injection/index.js';
3
- import path__default from 'path';
4
3
  import { Logger } from '../../core/logger/Logger.js';
5
- import { SocketServerProvider } from '../socket/SocketServerProvider.js';
6
- import { CustomError } from '../../core/error/CustomError.js';
7
4
  import '../../core/validation/metadata/ValidationMetadataStore.js';
8
5
  import { validateAndTransform } from '../../core/validation/validateAndTransform.js';
6
+ import { Socket } from 'socket.io';
7
+ import { SocketServerProvider } from '../socket/SocketServerProvider.js';
8
+ import { SocketControllerMetadataStore } from './metadata/SocketControllerMetadataStore.js';
9
9
 
10
10
  function runSocketControllers(controllers) {
11
11
  const logger = new Logger('wabot:socket');
@@ -13,84 +13,102 @@ function runSocketControllers(controllers) {
13
13
  const socketServerProvider = container.resolve(SocketServerProvider);
14
14
  const socketServer = socketServerProvider.getSocketServer();
15
15
  controllers.forEach((controller) => {
16
- const connections = metadataStore.getControllerSockerConnectionsInfo(controller);
17
- connections.forEach((connection) => {
18
- const namespace = path__default
19
- .join(connection.controller.config?.namespace ?? '/', connection.config?.namespace ?? '')
20
- .replaceAll('\\', '/');
21
- logger.info(`config connection to ${namespace}`);
22
- const namespaceServer = socketServer.of(namespace);
23
- namespaceServer.use(async (socket, next) => {
24
- const connectionContainer = container.createChildContainer();
25
- try {
26
- const middlewares = connection.connectionMiddlewares.map((x) => connectionContainer.resolve(x.middlewareConstructor));
27
- for (const middleware of middlewares) {
28
- await middleware.handle(socket, connectionContainer);
29
- }
30
- socket.data.connectionContainer = connectionContainer;
31
- next();
16
+ const controllerInfo = metadataStore.getSocketControllerInfo(controller);
17
+ const namespace = `/${controllerInfo.controller.config?.namespace ?? ''}`;
18
+ logger.info(`config connection to ${namespace}`);
19
+ const namespaceServer = socketServer.of(namespace);
20
+ namespaceServer.use(async (socket, next) => {
21
+ const connectionContainer = container.createChildContainer();
22
+ try {
23
+ const middlewares = controllerInfo.handShakeMiddlewares?.map((x) => connectionContainer.resolve(x.middlewareConstructor)) ?? [];
24
+ for (const middleware of middlewares) {
25
+ await middleware.handle(socket, connectionContainer);
32
26
  }
33
- catch (err) {
34
- next(err);
35
- connectionContainer.dispose();
27
+ socket.data.connectionContainer = connectionContainer;
28
+ next();
29
+ }
30
+ catch (err) {
31
+ next(err);
32
+ connectionContainer.dispose();
33
+ }
34
+ });
35
+ const eventListener = async (controllerInstance, socket, event, req, callback) => {
36
+ logger.trace(`received '${event.config.event}' event on '${namespace}'`);
37
+ const paramsValues = [];
38
+ try {
39
+ if (event.paramsTypes.length > 2) {
40
+ throw new CustomError({
41
+ httpCode: 400,
42
+ message: 'the socket event handler should have max 2 parameters: (req, socket)',
43
+ });
36
44
  }
37
- });
38
- namespaceServer.on('connection', async (socket) => {
39
- logger.trace(`connection on '${namespace}'`);
40
- const connectionContainer = socket.data.connectionContainer;
41
- try {
42
- const controllerInstance = connectionContainer.resolve(connection.controllerConstructor);
43
- connection.events.forEach((event) => {
44
- logger.trace(`config listener to '${event.config.event}' event on '${namespace}'`);
45
- socket.on(event.config.event, async (req, callback) => {
46
- logger.trace(`received '${event.config.event}' event on '${namespace}'`);
47
- try {
48
- const reqType = event.paramsTypes[0];
49
- if (typeof reqType !== 'function') {
50
- throw new CustomError({
51
- httpCode: 400,
52
- message: 'Unable to validate request',
53
- });
54
- }
55
- const { value, error } = validateAndTransform(req, reqType);
56
- if (error) {
57
- throw new CustomError({
58
- httpCode: 400,
59
- message: error.description,
60
- info: error,
61
- });
62
- }
63
- const out = await controllerInstance[event.functionName].apply(controllerInstance, [value, socket]);
64
- callback(out);
65
- }
66
- catch (err) {
67
- logger.error(err);
68
- if (err instanceof Error) {
69
- const keys = Object.keys(err).filter((key) => !['message', 'stack'].includes(key));
70
- const { httpCode, ...info } = keys.reduce((acc, key) => {
71
- acc[key] = err[key];
72
- return acc;
73
- }, {});
74
- if (typeof callback === 'function') {
75
- callback({ error: { ...info, message: err.message, stack: err.stack } });
76
- }
77
- }
78
- else {
79
- if (typeof callback === 'function') {
80
- callback({ error: { message: 'Unspected error' } });
81
- }
82
- }
83
- }
45
+ if (event.paramsTypes[0] !== Socket) {
46
+ const reqType = event.paramsTypes[0];
47
+ if (typeof reqType !== 'function') {
48
+ throw new CustomError({
49
+ httpCode: 400,
50
+ message: 'Unable to validate request',
84
51
  });
85
- });
86
- await controllerInstance[connection.functionName].apply(controllerInstance, [socket]);
52
+ }
53
+ const { value, error } = validateAndTransform(req, reqType);
54
+ if (error) {
55
+ throw new CustomError({
56
+ httpCode: 400,
57
+ message: error.description,
58
+ info: error,
59
+ });
60
+ }
61
+ paramsValues.push(value);
62
+ }
63
+ paramsValues.push(socket);
64
+ const out = await controllerInstance[event.functionName].apply(controllerInstance, paramsValues);
65
+ if (typeof callback === 'function') {
66
+ callback(out);
67
+ }
68
+ }
69
+ catch (err) {
70
+ logger.error(err);
71
+ if (err instanceof Error) {
72
+ const keys = Object.keys(err).filter((key) => !['message', 'stack'].includes(key));
73
+ const { httpCode, ...info } = keys.reduce((acc, key) => {
74
+ acc[key] = err[key];
75
+ return acc;
76
+ }, {});
77
+ if (typeof callback === 'function') {
78
+ callback({ error: { ...info, message: err.message, stack: err.stack } });
79
+ }
80
+ }
81
+ else {
82
+ if (typeof callback === 'function') {
83
+ callback({ error: { message: 'Unspected error' } });
84
+ }
87
85
  }
88
- catch (err) {
89
- logger.error(err);
90
- socket.disconnect();
91
- connectionContainer.dispose();
86
+ }
87
+ };
88
+ namespaceServer.on('connection', async (socket) => {
89
+ logger.trace(`connection on '${namespace}'`);
90
+ const connectionContainer = socket.data.connectionContainer;
91
+ try {
92
+ const controllerInstance = connectionContainer.resolve(controllerInfo.controller.controllerConstructor);
93
+ controllerInfo.events.forEach((event) => {
94
+ logger.trace(`config listener to '${event.config.event}' event on '${namespace}'`);
95
+ if (event.config.event === 'connection') {
96
+ return;
97
+ }
98
+ socket.on(event.config.event, async (req, callback) => {
99
+ await eventListener(controllerInstance, socket, event, req, callback);
100
+ });
101
+ });
102
+ const connectionEvent = controllerInfo.events.get('connection');
103
+ if (connectionEvent) {
104
+ await eventListener(controllerInstance, socket, connectionEvent, null, null);
92
105
  }
93
- });
106
+ }
107
+ catch (err) {
108
+ logger.error(err);
109
+ socket.disconnect();
110
+ connectionContainer.dispose();
111
+ }
94
112
  });
95
113
  });
96
114
  socketServerProvider.listen();
@@ -23,11 +23,13 @@ declare class Storable<D extends IStorableData> {
23
23
 
24
24
  declare class Auth<D extends IStorableData> {
25
25
  private authInfo;
26
+ private overrided;
26
27
  require(): D;
27
28
  assign(authInfo: D): void;
28
29
  override(authInfo: D): void;
29
30
  clear(): void;
30
31
  isAssigned(): boolean;
32
+ wasOverrided(): boolean;
31
33
  }
32
34
 
33
35
  interface IEntityData extends IStorableData {
@@ -924,17 +926,11 @@ declare class SocketServerProvider {
924
926
  private createSocketServer;
925
927
  }
926
928
 
927
- interface IConnectionMiddleware {
929
+ interface IHandshakeMiddleware {
928
930
  handle(socket: Socket, container: DependencyContainer$1): Promise<void>;
929
931
  }
930
932
 
931
- declare function connectionMiddleware(middlewareConstructor: IConstructor<IConnectionMiddleware>): (target: object, propertyKey: string | symbol) => void;
932
-
933
- interface ISocketConnectionConfig {
934
- namespace: string;
935
- }
936
-
937
- declare function socketConnection(config?: string | ISocketConnectionConfig): (target: object, propertyKey: string | symbol) => void;
933
+ declare function handshakeMiddlewares(middlewares: IConstructor<IHandshakeMiddleware>[]): (target: IConstructor<any>) => void;
938
934
 
939
935
  interface ISocketControllerConfig {
940
936
  namespace: string;
@@ -943,23 +939,14 @@ interface ISocketControllerConfig {
943
939
  declare function socketController(config?: string | ISocketControllerConfig): (target: IConstructor<any>) => void;
944
940
 
945
941
  interface ISocketEventConfig {
946
- namespace?: string;
947
942
  event: string;
948
943
  }
949
944
 
950
- declare function socketEvent(config: string | ISocketEventConfig): (target: object, propertyKey: string | symbol) => void;
945
+ declare function onSocketEvent(config: string | ISocketEventConfig): (target: object, propertyKey: string | symbol) => void;
951
946
 
952
- interface IConnectionMiddlewareMetadata {
947
+ interface IHandshakeMiddlewareMetadata {
953
948
  controllerConstructor: IConstructor<any>;
954
- functionName: string;
955
- middlewareConstructor: IConstructor<IConnectionMiddleware>;
956
- }
957
-
958
- interface ISocketConnectionMetadata {
959
- config?: ISocketConnectionConfig;
960
- controllerConstructor: IConstructor<any>;
961
- functionName: string;
962
- paramsTypes: any[];
949
+ middlewareConstructor: IConstructor<IHandshakeMiddleware>;
963
950
  }
964
951
 
965
952
  interface ISocketControllerMetadata {
@@ -976,22 +963,16 @@ interface ISocketEventMetadata {
976
963
 
977
964
  declare class SocketControllerMetadataStore {
978
965
  private socketControllers;
979
- private socketConnections;
980
966
  private socketEvents;
981
- private connectionMiddlewares;
967
+ private handshakeMiddlewares;
982
968
  saveControllerMetadata(controllerMetadata: ISocketControllerMetadata): void;
983
- saveSocketConnectionMetadata(socketConnectionMetadata: ISocketConnectionMetadata): void;
984
969
  saveSocketEventMetadata(socketEventMetadata: ISocketEventMetadata): void;
985
- saveConnectionMiddlewareMetadata(middlewareMetadata: IConnectionMiddlewareMetadata): void;
986
- getControllerSockerConnectionsInfo(controllerConstructor: IConstructor<any>): {
987
- events: ISocketEventMetadata[];
988
- connectionMiddlewares: IConnectionMiddlewareMetadata[];
970
+ saveHandshakeMiddlewareMetadata(handshakeMetadata: IHandshakeMiddlewareMetadata): void;
971
+ getSocketControllerInfo(controllerConstructor: IConstructor<any>): {
989
972
  controller: ISocketControllerMetadata;
990
- config?: ISocketConnectionConfig;
991
- controllerConstructor: IConstructor<any>;
992
- functionName: string;
993
- paramsTypes: any[];
994
- }[];
973
+ events: Map<string, ISocketEventMetadata>;
974
+ handShakeMiddlewares: IHandshakeMiddlewareMetadata[] | undefined;
975
+ };
995
976
  }
996
977
 
997
978
  declare function runSocketControllers(controllers: IConstructor<any>[]): void;
@@ -1000,7 +981,7 @@ declare class PgJobRepository extends PgCrudRepository<Job> implements IJobRepos
1000
981
  constructor(pool: Pool);
1001
982
  }
1002
983
 
1003
- declare function apiKeyConnectionGuard(): (target: object, propertyKey: string | symbol) => void;
984
+ declare function apiKeyHandshakeGuard(): (target: IConstructor<any>) => void;
1004
985
 
1005
986
  declare function apiKeyGuard(): (target: object, propertyKey: string | symbol) => void;
1006
987
 
@@ -1051,7 +1032,7 @@ declare class ApiKeyRepository<A extends IStorableData> implements IApiKeyReposi
1051
1032
  findAndValidate(secret: string): Promise<A>;
1052
1033
  }
1053
1034
 
1054
- declare class ApiKeyConnectionGuardMiddleware implements IConnectionMiddleware {
1035
+ declare class ApiKeyHandshakeGuardMiddleware implements IHandshakeMiddleware {
1055
1036
  private apiKeyRepository;
1056
1037
  private auth;
1057
1038
  constructor(apiKeyRepository: ApiKeyRepository<any>, auth: Auth<any>);
@@ -1090,7 +1071,7 @@ declare class RemoteApiKeyRepository<A extends IStorableData> implements IApiKey
1090
1071
  generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
1091
1072
  }
1092
1073
 
1093
- declare function jwtConnectionGuard(): (target: object, propertyKey: string | symbol) => void;
1074
+ declare function jwtHandshakeGuard(): (target: IConstructor<any>) => void;
1094
1075
 
1095
1076
  declare function jwtGuard(): (target: object, propertyKey: string | symbol) => void;
1096
1077
 
@@ -1169,7 +1150,7 @@ declare class Jwt {
1169
1150
  findRefreshTokenAuthInfo(secret: string): Promise<any>;
1170
1151
  }
1171
1152
 
1172
- declare class JwtConnectionGuardMiddleware implements IConnectionMiddleware {
1153
+ declare class JwtHandshakeGuardMiddleware implements IHandshakeMiddleware {
1173
1154
  private config;
1174
1155
  private auth;
1175
1156
  constructor(config: JwtConfig, auth: Auth<any>);
@@ -1293,28 +1274,29 @@ declare function writeJsonToFile<T>(filename: string, data: T): void;
1293
1274
  declare function readJsonFromFile<T>(filename: string): T | null;
1294
1275
 
1295
1276
  interface ISocketChannelConfig {
1296
- channel: string;
1277
+ namespace: string;
1278
+ handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[];
1297
1279
  }
1298
1280
 
1299
1281
  declare class SocketChannelConfig implements ISocketChannelConfig {
1300
- channel: string;
1301
- constructor(channel: string);
1282
+ namespace: string;
1283
+ handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[] | undefined;
1284
+ constructor(namespace: string, handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[] | undefined);
1302
1285
  }
1303
1286
 
1304
1287
  declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
1305
1288
 
1306
1289
  interface ISocketChannelReceivedMessage {
1307
1290
  chatId: string;
1308
- userId: string;
1309
1291
  senderName: string;
1310
1292
  text: string;
1311
1293
  }
1312
1294
  declare class SocketChannel implements IChatChannel {
1313
1295
  private config;
1314
- private socketServerProvider;
1315
1296
  private callBack;
1316
- private server;
1317
- constructor(config: SocketChannelConfig, socketServerProvider: SocketServerProvider);
1297
+ private controller;
1298
+ constructor(config: SocketChannelConfig);
1299
+ private configController;
1318
1300
  listen(callback: (message: IChannelMessage) => void): void;
1319
1301
  connect(): void;
1320
1302
  }
@@ -1636,4 +1618,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
1636
1618
  new (): {};
1637
1619
  };
1638
1620
 
1639
- export { AnthropicChatAdapter, ApiKey, ApiKeyConnectionGuardMiddleware, ApiKeyGuardMiddleware, ApiKeyRepository, Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConnectionMiddleware, type IConnectionMiddlewareMetadata, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketConnectionConfig, type ISocketConnectionMetadata, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateMessage, type IWhatsAppCloudTemplateParameter, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppData, type IWhatsAppMessageListener, type IWhatsAppProxyListenMessageEventData, type IWhatsAppProxyListenMessageEventReq, type IWhatsAppProxyMessage, type IWhatsAppProxyMessageContent, type IWhatsAppProxyMessageEventReq, type IWhatsAppProxySendMessageEventReq, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtConnectionGuardMiddleware, JwtGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketControllerMetadataStore, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyConnectionGuard, apiKeyGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, connectionMiddleware, container, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtConnectionGuard, jwtGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, param, readJsonFromFile, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketConnection, socketController, socketEvent, telegram, validateAndTransform, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsApp, writeJsonToFile };
1621
+ export { AnthropicChatAdapter, ApiKey, ApiKeyGuardMiddleware, ApiKeyHandshakeGuardMiddleware, ApiKeyRepository, Async, Auth, Chat, ChatAdapter, ChatBot, ChatBotMetadataStore, ChatItem, ChatMemory, ChatRepository, ChatResolver, CmdChannel, Command, CommandMetadataStore, Container, ControllerMetadataStore, CustomError, DeepSeekChatAdapter, EXPRESS_REQ, EXPRESS_RES, Entity, Env, EnvWhatsAppRepository, ExpressProvider, GoogleChatAdapter, HtmlModule, HttpServerProvider, type IApiKeyData, type IApiKeyRepository, type IArrayValidationError, type IArrayValidationResult, type IBotMessageItem, type IChannelMessage, type IChannelMetadata, type IChatAdapter, type IChatAdapterNextItemReq, type IChatAdapterNextItemRes, type IChatBot, type IChatBotMetadata, type IChatChannel, type IChatConnection, type IChatControllerMetadata, type IChatData, type IChatItem, type IChatItemData, type IChatItemType, type IChatMemory, type IChatMessage, type IChatRepository, type IChatType, type ICommandConfig, type ICommandHandler, type ICommandHandlerConfig, type IConstructor, type ICrudRepository, type ICustomErrorData, type IEndPointConfig, type IEndPointMetadata, type IEntityData, type IEnvType, type IFunctionCall, type IFunctionCallItem, type IGenerateApiKeyReq, type IGenerateApiKeyRes, type IGetWhatsAppTemplateRequest, type IHandshakeMiddleware, type IHandshakeMiddlewareMetadata, type IHtmlModuleOptions, type IHumanMessageItem, type IJobData, type IJobEvent, type IJobEventListener, type IJobRepository, type IJwtRefreshTokenData, type IJwtRefreshTokenRepository, type ILanguageModelUsage, type IListenWhatsAppMessageRequest, type IMessageContext, type IMiddleware, type IMiddlewareMetadata, type IMindset, type IMindsetDecoration, type IMindsetFunctionConfig, type IMindsetFunctionDecoration, type IMindsetFunctionMetadata, type IMindsetFunctionParamMetadata, type IMindsetIdentity, type IMindsetLlm, type IMindsetMetadata, type IMindsetModuleConfig, type IMindsetModuleDecoration, type IMindsetModuleMetadata, type IMindsetTool, type IMindsetToolParameter, type IModelValidationError, type IModelValidationResult, type IModelValidatorsInfo, type IMoneyData, type IParamConfig, type IParamDecoration, type IPersistentData, type IPgRepositoryConfig, type IPrimitive, type IPropertyValidatorInfo, type IReceivedMessage, type IRemoteApiKeyFetcher, type IRestControllerConfig, type IRestControllerMetadata, type ISendWhatsAppRequest, type ISendWhatsAppTemplateRequest, type ISocketChannelConfig, type ISocketChannelReceivedMessage, type ISocketControllerConfig, type ISocketControllerMetadata, type ISocketEventConfig, type ISocketEventMetadata, type IStorableData, type ITelegramChannelConfig, type IValidateArrayOptions, type IValidateArrayOptionsWithItemsValidators, type IValidateInputShape, type IValidateIsInOptions, type IValidateMaxOptions, type IValidateMinOptions, type IValidationError, type IValidationResult, type IValidator, type IValidatorMetadata, type IWhatsAppBusinessAccount, type IWhatsAppBusinessNumber, type IWhatsAppCloudContact, type IWhatsAppCloudMessage, type IWhatsAppCloudMessageMetadata, type IWhatsAppCloudTemplate, type IWhatsAppCloudTemplateComponent, type IWhatsAppCloudTemplateMessage, type IWhatsAppCloudTemplateParameter, type IWhatsAppCloudTemplateResponse, type IWhatsAppCloudWebhookPayload, type IWhatsAppData, type IWhatsAppMessageListener, type IWhatsAppProxyListenMessageEventData, type IWhatsAppProxyListenMessageEventReq, type IWhatsAppProxyMessage, type IWhatsAppProxyMessageContent, type IWhatsAppProxyMessageEventReq, type IWhatsAppProxySendMessageEventReq, type IWhatsAppRepository, type IWhatsAppSenderOptions, type IWhatsappChannelConfig, type IchatControllerConfig, Job, JobRepository, JobRunner, JobsEventsHub, Jwt, JwtAccessAndRefreshTokenDto, JwtConfig, JwtGuardMiddleware, JwtHandshakeGuardMiddleware, JwtRefreshToken, JwtRefreshTokenRepository, JwtSigner, JwtTokenDto, Lifecycle, Logger, MINDSET_DECORATION_MINDSET, MINDSET_FUNCTION_DECORATION_FUNCTION, MINDSET_MODULE_DECORATION_MODULE, Mapper, Mindset, MindsetMetadataStore, MindsetOperator, Money, MoneyDto, OpenaiChatAdapter, PARAM_DECORATION_IS_OPTIONAL, PARAM_DECORATION_PARAM, Password, type PasswordHashOptions, Persistent, PgApiKeyRepository, PgChatMemory, PgChatRepository, PgCrudRepository, PgJobRepository, PgJwtRefreshTokenRepository, PgRepositoryBase, PgWhatsAppRepository, RamChatMemory, RamChatRepository, Random, RemoteApiKeyRepository, RestControllerMetadataStore, SocketChannel, SocketChannelConfig, SocketControllerMetadataStore, SocketServerProvider, Storable, TelegramChannel, TelegramChannelConfig, ValidationMetadataStore, WHATSAPP_MESSAGE_EVENT, WHATSAPP_PROXY_LISTEN_MESSAGE_EVENT, WHATSAPP_PROXY_SEND_MESSAGE_EVENT, WabotChatAdapter, WhatsApp, WhatsAppChannel, WhatsAppReceiver, WhatsAppReceiverByCloudApi, WhatsAppReceiverByWabotProxy, WhatsAppRepository, WhatsAppSender, WhatsAppSenderByCloudApi, WhatsAppSenderByWabotProxy, WhatsAppWabotProxyConnection, WhatsappChannelConfig, apiKeyGuard, apiKeyHandshakeGuard, chatBot, chatController, chatItemTypeOptions, cmd, command, commandHandler, container, handshakeMiddlewares, inject, injectable, isArray, isBoolean, isDate, isIn, isModel, isNotEmpty, isNumber, isOptional, isPresent, isString, jwtGuard, jwtHandshakeGuard, max, middleware, min, mindset, mindsetFunction, mindsetModule, modelInfo, onDelete, onGet, onPost, onPut, onSocketEvent, param, readJsonFromFile, restController, runAsyncCommandHandlers, runChatControllers, runRestControllers, runSocketControllers, scoped, singleton, socket, socketController, telegram, validateAndTransform, validateArray, validateIsBoolean, validateIsDate, validateIsIn, validateIsNotEmpty, validateIsNumber, validateIsPresent, validateIsString, validateMax, validateMin, validateModel, whatsApp, writeJsonToFile };
package/dist/src/index.js CHANGED
@@ -84,27 +84,26 @@ export { RestControllerMetadataStore } from './feature/rest-controller/metadata/
84
84
  export { runRestControllers } from './feature/rest-controller/runRestControllers.js';
85
85
  export { EXPRESS_REQ, EXPRESS_RES } from './feature/rest-controller/injection-tokens.js';
86
86
  export { SocketServerProvider } from './feature/socket/SocketServerProvider.js';
87
- export { connectionMiddleware } from './feature/socket-controller/metadata/@connectionMiddleware.js';
88
- export { socketConnection } from './feature/socket-controller/metadata/@socketConnection.js';
87
+ export { handshakeMiddlewares } from './feature/socket-controller/metadata/@handshakeMiddlewares.js';
89
88
  export { socketController } from './feature/socket-controller/metadata/@socketController.js';
90
- export { socketEvent } from './feature/socket-controller/metadata/@socketEvent.js';
89
+ export { onSocketEvent } from './feature/socket-controller/metadata/@onSocketEvent.js';
91
90
  export { SocketControllerMetadataStore } from './feature/socket-controller/metadata/SocketControllerMetadataStore.js';
92
91
  export { runSocketControllers } from './feature/socket-controller/runSocketControllers.js';
93
92
  export { PgJobRepository } from './addon/async/pg/PgJobRepository.js';
94
- export { apiKeyConnectionGuard } from './addon/auth/api-key/@apiKeyConnectionGuard.js';
93
+ export { apiKeyHandshakeGuard } from './addon/auth/api-key/@apiKeyHandshakeGuard.js';
95
94
  export { apiKeyGuard } from './addon/auth/api-key/@apiKeyGuard.js';
96
95
  export { ApiKey } from './addon/auth/api-key/ApiKey.js';
97
- export { ApiKeyConnectionGuardMiddleware } from './addon/auth/api-key/ApiKeyConnectionGuardMiddleware.js';
96
+ export { ApiKeyHandshakeGuardMiddleware } from './addon/auth/api-key/ApiKeyHandshakeGuardMiddleware.js';
98
97
  export { ApiKeyGuardMiddleware } from './addon/auth/api-key/ApiKeyGuardMiddleware.js';
99
98
  export { ApiKeyRepository } from './addon/auth/api-key/ApiKeyRepository.js';
100
99
  export { PgApiKeyRepository } from './addon/auth/api-key/PgApiKeyRepository.js';
101
100
  export { RemoteApiKeyRepository } from './addon/auth/api-key/RemoteApiKeyRepository.js';
102
- export { jwtConnectionGuard } from './addon/auth/jwt/@jwtConnectionGuard.js';
101
+ export { jwtHandshakeGuard } from './addon/auth/jwt/@jwtHandshakeGuard.js';
103
102
  export { jwtGuard } from './addon/auth/jwt/@jwtGuard.js';
104
103
  export { Jwt } from './addon/auth/jwt/Jwt.js';
105
104
  export { JwtAccessAndRefreshTokenDto } from './addon/auth/jwt/JwtAccessAndRefreshTokenDto.js';
106
105
  export { JwtConfig } from './addon/auth/jwt/JwtConfig.js';
107
- export { JwtConnectionGuardMiddleware } from './addon/auth/jwt/JwtConnectionGuardMiddleware.js';
106
+ export { JwtHandshakeGuardMiddleware } from './addon/auth/jwt/JwtHandshakeGuardMiddleware.js';
108
107
  export { JwtGuardMiddleware } from './addon/auth/jwt/JwtGuardMiddleware.js';
109
108
  export { JwtRefreshToken } from './addon/auth/jwt/JwtRefreshToken.js';
110
109
  export { JwtRefreshTokenRepository } from './addon/auth/jwt/JwtRefreshTokenRepository.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.2.0-beta.8",
3
+ "version": "0.2.0-beta.9",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -1,16 +0,0 @@
1
- import { connectionMiddleware } from '../../../feature/socket-controller/metadata/@connectionMiddleware.js';
2
- import '../../../core/injection/index.js';
3
- import '../../../feature/socket-controller/metadata/SocketControllerMetadataStore.js';
4
- import 'path';
5
- import 'debug';
6
- import '../../../feature/socket/SocketServerProvider.js';
7
- import '../../../core/validation/metadata/ValidationMetadataStore.js';
8
- import { ApiKeyConnectionGuardMiddleware } from './ApiKeyConnectionGuardMiddleware.js';
9
-
10
- function apiKeyConnectionGuard() {
11
- return function (target, propertyKey) {
12
- connectionMiddleware(ApiKeyConnectionGuardMiddleware)(target, propertyKey);
13
- };
14
- }
15
-
16
- export { apiKeyConnectionGuard };
@@ -1,16 +0,0 @@
1
- import { connectionMiddleware } from '../../../feature/socket-controller/metadata/@connectionMiddleware.js';
2
- import '../../../core/injection/index.js';
3
- import '../../../feature/socket-controller/metadata/SocketControllerMetadataStore.js';
4
- import 'path';
5
- import 'debug';
6
- import '../../../feature/socket/SocketServerProvider.js';
7
- import '../../../core/validation/metadata/ValidationMetadataStore.js';
8
- import { JwtConnectionGuardMiddleware } from './JwtConnectionGuardMiddleware.js';
9
-
10
- function jwtConnectionGuard() {
11
- return function (target, propertyKey) {
12
- connectionMiddleware(JwtConnectionGuardMiddleware)(target, propertyKey);
13
- };
14
- }
15
-
16
- export { jwtConnectionGuard };
@@ -1,16 +0,0 @@
1
- import { SocketControllerMetadataStore } from './SocketControllerMetadataStore.js';
2
- import { container } from '../../../core/injection/index.js';
3
-
4
- function connectionMiddleware(middlewareConstructor) {
5
- return function (target, propertyKey) {
6
- const functionName = propertyKey.toString();
7
- const store = container.resolve(SocketControllerMetadataStore);
8
- store.saveConnectionMiddlewareMetadata({
9
- controllerConstructor: target.constructor,
10
- functionName,
11
- middlewareConstructor: middlewareConstructor,
12
- });
13
- };
14
- }
15
-
16
- export { connectionMiddleware };
@@ -1,18 +0,0 @@
1
- import { container } from '../../../core/injection/index.js';
2
- import { SocketControllerMetadataStore } from './SocketControllerMetadataStore.js';
3
-
4
- function socketConnection(config) {
5
- return function (target, propertyKey) {
6
- const functionName = propertyKey.toString();
7
- const paramsTypes = Reflect.getMetadata('design:paramtypes', target, functionName);
8
- const store = container.resolve(SocketControllerMetadataStore);
9
- store.saveSocketConnectionMetadata({
10
- controllerConstructor: target.constructor,
11
- config: typeof config === 'string' ? { namespace: config } : config,
12
- functionName,
13
- paramsTypes,
14
- });
15
- };
16
- }
17
-
18
- export { socketConnection };