@wabot-dev/framework 0.2.0-beta.1 → 0.2.0-beta.11
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/src/addon/auth/api-key/@apiKeyHandshakeGuard.js +16 -0
- package/dist/src/addon/auth/api-key/ApiKey.js +3 -0
- package/dist/src/addon/auth/api-key/ApiKeyGuardMiddleware.js +1 -4
- package/dist/src/addon/auth/api-key/{ApiKeyConnectionGuardMiddleware.js → ApiKeyHandshakeGuardMiddleware.js} +5 -8
- package/dist/src/addon/auth/api-key/ApiKeyRepository.js +8 -5
- package/dist/src/addon/auth/api-key/PgApiKeyRepository.js +10 -2
- package/dist/src/addon/auth/api-key/RemoteApiKeyRepository.js +13 -25
- package/dist/src/addon/auth/jwt/@jwtHandshakeGuard.js +16 -0
- package/dist/src/addon/auth/jwt/Jwt.js +7 -9
- package/dist/src/addon/auth/jwt/{JwtConnectionGuardMiddleware.js → JwtHandshakeGuardMiddleware.js} +4 -4
- package/dist/src/addon/auth/jwt/JwtRefreshToken.js +40 -35
- package/dist/src/addon/auth/jwt/JwtRefreshTokenRepository.js +6 -0
- package/dist/src/addon/auth/jwt/JwtSigner.js +1 -1
- package/dist/src/addon/auth/jwt/PgJwtRefreshTokenRepository.js +27 -0
- package/dist/src/addon/chat-controller/cmd/CmdChannel.js +12 -7
- package/dist/src/addon/chat-controller/socket/@socket.js +1 -1
- package/dist/src/addon/chat-controller/socket/SocketChannel.js +74 -33
- package/dist/src/addon/chat-controller/socket/SocketChannelConfig.js +6 -4
- package/dist/src/core/auth/Auth.js +6 -0
- package/dist/src/core/mapper/Mapper.js +22 -6
- package/dist/src/core/validation/core/validateModel.js +37 -4
- package/dist/src/core/validation/{validate.js → validateAndTransform.js} +2 -2
- package/dist/src/feature/chat-controller/runChatControllers.js +6 -7
- package/dist/src/feature/rest-controller/runRestControllers.js +2 -2
- package/dist/src/feature/socket-controller/metadata/@handshakeMiddlewares.js +16 -0
- package/dist/src/feature/socket-controller/metadata/{@socketEvent.js → @onSocketEvent.js} +2 -2
- package/dist/src/feature/socket-controller/metadata/SocketControllerMetadataStore.js +12 -34
- package/dist/src/feature/socket-controller/runSocketControllers.js +97 -78
- package/dist/src/index.d.ts +112 -110
- package/dist/src/index.js +8 -9
- package/package.json +4 -5
- package/dist/src/addon/auth/api-key/@apiKeyConnectionGuard.js +0 -16
- package/dist/src/addon/auth/jwt/@jwtConnectionGuard.js +0 -16
- package/dist/src/feature/socket-controller/metadata/@connectionMiddleware.js +0 -16
- package/dist/src/feature/socket-controller/metadata/@socketConnection.js +0 -18
package/dist/src/index.d.ts
CHANGED
|
@@ -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 {
|
|
@@ -129,47 +131,6 @@ declare class Logger {
|
|
|
129
131
|
private log;
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
declare class Mapper {
|
|
133
|
-
map<T>(data: any, ctor: IConstructor<T>): T;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
interface PasswordHashOptions {
|
|
137
|
-
password: string;
|
|
138
|
-
saltLength?: number;
|
|
139
|
-
keyLength?: number;
|
|
140
|
-
}
|
|
141
|
-
declare class Password {
|
|
142
|
-
static hash(options: PasswordHashOptions): string;
|
|
143
|
-
static isValid(req: {
|
|
144
|
-
password: string;
|
|
145
|
-
hash: string;
|
|
146
|
-
}): boolean;
|
|
147
|
-
static generate(length: number): string;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
declare class Random {
|
|
151
|
-
static integer(options: {
|
|
152
|
-
min: number;
|
|
153
|
-
max: number;
|
|
154
|
-
}): number;
|
|
155
|
-
static slug(name: string, options: {
|
|
156
|
-
randomLength: number;
|
|
157
|
-
}): string;
|
|
158
|
-
static alphaNumeric(length: number): string;
|
|
159
|
-
static alphaNumericLowerCase(length: number): string;
|
|
160
|
-
static numberCode(length: number): string;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
interface ICrudRepository<T> {
|
|
164
|
-
find(id: string): Promise<T | null>;
|
|
165
|
-
findOrThrow(id: string): Promise<T>;
|
|
166
|
-
findByIds(ids: string[]): Promise<T[]>;
|
|
167
|
-
findAll(id: string): Promise<T[]>;
|
|
168
|
-
create(item: T): Promise<void>;
|
|
169
|
-
update(item: T): Promise<void>;
|
|
170
|
-
delete(item: T): Promise<void>;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
134
|
declare function isModel(model: IConstructor<any>): (target: object, propertyKey: string | symbol) => void;
|
|
174
135
|
|
|
175
136
|
declare function isOptional(): (target: object, propertyKey: string | symbol) => void;
|
|
@@ -252,7 +213,10 @@ declare class ValidationMetadataStore {
|
|
|
252
213
|
|
|
253
214
|
declare function validateModel<V>(value: any, info: IModelValidatorsInfo<V>): IModelValidationResult<V>;
|
|
254
215
|
|
|
255
|
-
|
|
216
|
+
type IValidateInputShape<T> = T extends Date ? Date : T extends Array<infer U> ? Array<IValidateInputShape<U>> : T extends object ? {
|
|
217
|
+
[K in keyof T]: IValidateInputShape<T[K]>;
|
|
218
|
+
} : T;
|
|
219
|
+
declare function validateAndTransform<V>(value: IValidateInputShape<V>, modelConstructor: IConstructor<V>): IModelValidationResult<V>;
|
|
256
220
|
|
|
257
221
|
declare function modelInfo<V>(modelConstructor: IConstructor<V>): IModelValidatorsInfo<V>;
|
|
258
222
|
|
|
@@ -301,6 +265,47 @@ interface IValidateMinOptions {
|
|
|
301
265
|
}
|
|
302
266
|
declare function validateMin(value: any, options: IValidateMinOptions): IValidationResult<any>;
|
|
303
267
|
|
|
268
|
+
declare class Mapper {
|
|
269
|
+
map<T>(data: IValidateInputShape<T>, ctor: IConstructor<T>): T;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
interface PasswordHashOptions {
|
|
273
|
+
password: string;
|
|
274
|
+
saltLength?: number;
|
|
275
|
+
keyLength?: number;
|
|
276
|
+
}
|
|
277
|
+
declare class Password {
|
|
278
|
+
static hash(options: PasswordHashOptions): string;
|
|
279
|
+
static isValid(req: {
|
|
280
|
+
password: string;
|
|
281
|
+
hash: string;
|
|
282
|
+
}): boolean;
|
|
283
|
+
static generate(length: number): string;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
declare class Random {
|
|
287
|
+
static integer(options: {
|
|
288
|
+
min: number;
|
|
289
|
+
max: number;
|
|
290
|
+
}): number;
|
|
291
|
+
static slug(name: string, options: {
|
|
292
|
+
randomLength: number;
|
|
293
|
+
}): string;
|
|
294
|
+
static alphaNumeric(length: number): string;
|
|
295
|
+
static alphaNumericLowerCase(length: number): string;
|
|
296
|
+
static numberCode(length: number): string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
interface ICrudRepository<T> {
|
|
300
|
+
find(id: string): Promise<T | null>;
|
|
301
|
+
findOrThrow(id: string): Promise<T>;
|
|
302
|
+
findByIds(ids: string[]): Promise<T[]>;
|
|
303
|
+
findAll(id: string): Promise<T[]>;
|
|
304
|
+
create(item: T): Promise<void>;
|
|
305
|
+
update(item: T): Promise<void>;
|
|
306
|
+
delete(item: T): Promise<void>;
|
|
307
|
+
}
|
|
308
|
+
|
|
304
309
|
interface ICommandConfig {
|
|
305
310
|
name?: string;
|
|
306
311
|
}
|
|
@@ -704,8 +709,7 @@ interface IReceivedMessage {
|
|
|
704
709
|
|
|
705
710
|
interface IChannelMessage extends IReceivedMessage {
|
|
706
711
|
chatConnection: IChatConnection;
|
|
707
|
-
|
|
708
|
-
setAuthInfo?: (authInfo: IStorableData | undefined) => void;
|
|
712
|
+
injectInstances?: [any, any][];
|
|
709
713
|
}
|
|
710
714
|
|
|
711
715
|
interface IChatChannel {
|
|
@@ -921,17 +925,11 @@ declare class SocketServerProvider {
|
|
|
921
925
|
private createSocketServer;
|
|
922
926
|
}
|
|
923
927
|
|
|
924
|
-
interface
|
|
928
|
+
interface IHandshakeMiddleware {
|
|
925
929
|
handle(socket: Socket, container: DependencyContainer$1): Promise<void>;
|
|
926
930
|
}
|
|
927
931
|
|
|
928
|
-
declare function
|
|
929
|
-
|
|
930
|
-
interface ISocketConnectionConfig {
|
|
931
|
-
namespace: string;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
declare function socketConnection(config?: string | ISocketConnectionConfig): (target: object, propertyKey: string | symbol) => void;
|
|
932
|
+
declare function handshakeMiddlewares(middlewares: IConstructor<IHandshakeMiddleware>[]): (target: IConstructor<any>) => void;
|
|
935
933
|
|
|
936
934
|
interface ISocketControllerConfig {
|
|
937
935
|
namespace: string;
|
|
@@ -940,23 +938,14 @@ interface ISocketControllerConfig {
|
|
|
940
938
|
declare function socketController(config?: string | ISocketControllerConfig): (target: IConstructor<any>) => void;
|
|
941
939
|
|
|
942
940
|
interface ISocketEventConfig {
|
|
943
|
-
namespace?: string;
|
|
944
941
|
event: string;
|
|
945
942
|
}
|
|
946
943
|
|
|
947
|
-
declare function
|
|
948
|
-
|
|
949
|
-
interface IConnectionMiddlewareMetadata {
|
|
950
|
-
controllerConstructor: IConstructor<any>;
|
|
951
|
-
functionName: string;
|
|
952
|
-
middlewareConstructor: IConstructor<IConnectionMiddleware>;
|
|
953
|
-
}
|
|
944
|
+
declare function onSocketEvent(config: string | ISocketEventConfig): (target: object, propertyKey: string | symbol) => void;
|
|
954
945
|
|
|
955
|
-
interface
|
|
956
|
-
config?: ISocketConnectionConfig;
|
|
946
|
+
interface IHandshakeMiddlewareMetadata {
|
|
957
947
|
controllerConstructor: IConstructor<any>;
|
|
958
|
-
|
|
959
|
-
paramsTypes: any[];
|
|
948
|
+
middlewareConstructor: IConstructor<IHandshakeMiddleware>;
|
|
960
949
|
}
|
|
961
950
|
|
|
962
951
|
interface ISocketControllerMetadata {
|
|
@@ -973,22 +962,16 @@ interface ISocketEventMetadata {
|
|
|
973
962
|
|
|
974
963
|
declare class SocketControllerMetadataStore {
|
|
975
964
|
private socketControllers;
|
|
976
|
-
private socketConnections;
|
|
977
965
|
private socketEvents;
|
|
978
|
-
private
|
|
966
|
+
private handshakeMiddlewares;
|
|
979
967
|
saveControllerMetadata(controllerMetadata: ISocketControllerMetadata): void;
|
|
980
|
-
saveSocketConnectionMetadata(socketConnectionMetadata: ISocketConnectionMetadata): void;
|
|
981
968
|
saveSocketEventMetadata(socketEventMetadata: ISocketEventMetadata): void;
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
events: ISocketEventMetadata[];
|
|
985
|
-
connectionMiddlewares: IConnectionMiddlewareMetadata[];
|
|
969
|
+
saveHandshakeMiddlewareMetadata(handshakeMetadata: IHandshakeMiddlewareMetadata): void;
|
|
970
|
+
getSocketControllerInfo(controllerConstructor: IConstructor<any>): {
|
|
986
971
|
controller: ISocketControllerMetadata;
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
paramsTypes: any[];
|
|
991
|
-
}[];
|
|
972
|
+
events: Map<string, ISocketEventMetadata>;
|
|
973
|
+
handShakeMiddlewares: IHandshakeMiddlewareMetadata[] | undefined;
|
|
974
|
+
};
|
|
992
975
|
}
|
|
993
976
|
|
|
994
977
|
declare function runSocketControllers(controllers: IConstructor<any>[]): void;
|
|
@@ -997,7 +980,7 @@ declare class PgJobRepository extends PgCrudRepository<Job> implements IJobRepos
|
|
|
997
980
|
constructor(pool: Pool);
|
|
998
981
|
}
|
|
999
982
|
|
|
1000
|
-
declare function
|
|
983
|
+
declare function apiKeyHandshakeGuard(): (target: IConstructor<any>) => void;
|
|
1001
984
|
|
|
1002
985
|
declare function apiKeyGuard(): (target: object, propertyKey: string | symbol) => void;
|
|
1003
986
|
|
|
@@ -1012,6 +995,7 @@ declare class ApiKey<A extends IStorableData> extends Entity<IApiKeyData<A>> {
|
|
|
1012
995
|
static hashSecret(secret: string): string;
|
|
1013
996
|
get authInfo(): A;
|
|
1014
997
|
get metadata(): Record<string, string>;
|
|
998
|
+
get name(): string;
|
|
1015
999
|
setAuthInfo(authInfo: A): void;
|
|
1016
1000
|
generateSecret(): string;
|
|
1017
1001
|
isValidSecret(secret: string): boolean;
|
|
@@ -1024,7 +1008,8 @@ interface IApiKeyRepository<A extends IStorableData> {
|
|
|
1024
1008
|
findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
|
|
1025
1009
|
create(item: ApiKey<A>): Promise<void>;
|
|
1026
1010
|
generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
|
|
1027
|
-
|
|
1011
|
+
findBySecret(secret: string): Promise<ApiKey<A> | null>;
|
|
1012
|
+
findAndValidate(secret: string): Promise<A>;
|
|
1028
1013
|
}
|
|
1029
1014
|
interface IGenerateApiKeyReq<A extends IStorableData> extends IStorableData {
|
|
1030
1015
|
name: string;
|
|
@@ -1037,15 +1022,16 @@ interface IGenerateApiKeyRes<A extends IStorableData> {
|
|
|
1037
1022
|
}
|
|
1038
1023
|
|
|
1039
1024
|
declare class ApiKeyRepository<A extends IStorableData> implements IApiKeyRepository<A> {
|
|
1040
|
-
findAuthInfoBySecret(secret: string): Promise<A>;
|
|
1041
|
-
findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
|
|
1042
1025
|
find(id: string): Promise<ApiKey<A> | null>;
|
|
1043
1026
|
findOrThrow(id: string): Promise<ApiKey<A>>;
|
|
1027
|
+
findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
|
|
1044
1028
|
create(item: ApiKey<A>): Promise<void>;
|
|
1045
1029
|
generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
|
|
1030
|
+
findBySecret(secret: string): Promise<ApiKey<A> | null>;
|
|
1031
|
+
findAndValidate(secret: string): Promise<A>;
|
|
1046
1032
|
}
|
|
1047
1033
|
|
|
1048
|
-
declare class
|
|
1034
|
+
declare class ApiKeyHandshakeGuardMiddleware implements IHandshakeMiddleware {
|
|
1049
1035
|
private apiKeyRepository;
|
|
1050
1036
|
private auth;
|
|
1051
1037
|
constructor(apiKeyRepository: ApiKeyRepository<any>, auth: Auth<any>);
|
|
@@ -1061,55 +1047,58 @@ declare class ApiKeyGuardMiddleware implements IMiddleware {
|
|
|
1061
1047
|
|
|
1062
1048
|
declare class PgApiKeyRepository<A extends IStorableData> extends PgCrudRepository<ApiKey<A>> implements IApiKeyRepository<A> {
|
|
1063
1049
|
constructor(pool: Pool);
|
|
1064
|
-
|
|
1050
|
+
findAndValidate(secret: string): Promise<A>;
|
|
1051
|
+
findBySecret(secret: string): Promise<ApiKey<A> | null>;
|
|
1065
1052
|
findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
|
|
1066
1053
|
generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
|
|
1067
1054
|
}
|
|
1068
1055
|
|
|
1069
1056
|
interface IRemoteApiKeyFetcher<A extends IStorableData> {
|
|
1070
|
-
|
|
1071
|
-
fetchBySecret: (secret: string) => Promise<ApiKey<A> | null>;
|
|
1057
|
+
fetchAuthInfoBySecret: (secret: string) => Promise<A | null>;
|
|
1072
1058
|
}
|
|
1073
1059
|
declare class RemoteApiKeyRepository<A extends IStorableData> implements IApiKeyRepository<A> {
|
|
1074
1060
|
private fetcher;
|
|
1075
1061
|
private cacheSeconds;
|
|
1076
|
-
private cacheById;
|
|
1077
1062
|
private cacheBySecret;
|
|
1078
1063
|
constructor(fetcher: IRemoteApiKeyFetcher<A>, cacheSeconds: number);
|
|
1064
|
+
findAndValidate(secret: string): Promise<A>;
|
|
1079
1065
|
find(id: string): Promise<ApiKey<A> | null>;
|
|
1080
1066
|
findOrThrow(id: string): Promise<ApiKey<A>>;
|
|
1081
|
-
|
|
1067
|
+
findBySecret(secret: string): Promise<ApiKey<A> | null>;
|
|
1082
1068
|
findByMetadata(metadata: Record<string, string>): Promise<ApiKey<A>[]>;
|
|
1083
1069
|
create(item: ApiKey<A>): Promise<void>;
|
|
1084
1070
|
generate(req: IGenerateApiKeyReq<A>): Promise<IGenerateApiKeyRes<A>>;
|
|
1085
1071
|
}
|
|
1086
1072
|
|
|
1087
|
-
declare function
|
|
1073
|
+
declare function jwtHandshakeGuard(): (target: IConstructor<any>) => void;
|
|
1088
1074
|
|
|
1089
1075
|
declare function jwtGuard(): (target: object, propertyKey: string | symbol) => void;
|
|
1090
1076
|
|
|
1091
1077
|
interface IJwtRefreshTokenData<A extends IStorableData> extends IEntityData {
|
|
1078
|
+
secretHash?: string;
|
|
1079
|
+
metadata?: Record<string, string>;
|
|
1092
1080
|
authInfo: A;
|
|
1093
|
-
passwordHash?: string;
|
|
1094
1081
|
expirationTime: number;
|
|
1082
|
+
revokedAt?: number;
|
|
1095
1083
|
}
|
|
1096
1084
|
declare class JwtRefreshToken<A extends IStorableData> extends Entity<IJwtRefreshTokenData<A>> {
|
|
1085
|
+
static PREFIX: string;
|
|
1086
|
+
static hashSecret(secret: string): string;
|
|
1097
1087
|
get authInfo(): A;
|
|
1088
|
+
get metadata(): Record<string, string>;
|
|
1098
1089
|
get expirationTime(): Date;
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
static deflate(data: {
|
|
1107
|
-
id: string;
|
|
1108
|
-
pass: string;
|
|
1109
|
-
}): string;
|
|
1090
|
+
isExpired(): boolean;
|
|
1091
|
+
revoke(): void;
|
|
1092
|
+
isRevoked(): boolean;
|
|
1093
|
+
generateSecret(): string;
|
|
1094
|
+
isValidSecret(secret: string): boolean;
|
|
1095
|
+
isValidToken(secret: string): boolean;
|
|
1096
|
+
validateToken(secret: string): void;
|
|
1110
1097
|
}
|
|
1111
1098
|
|
|
1112
1099
|
interface IJwtRefreshTokenRepository<D extends IStorableData> extends ICrudRepository<JwtRefreshToken<D>> {
|
|
1100
|
+
findAndValidate(secret: string): Promise<D>;
|
|
1101
|
+
findByMetadata(metadata: Record<string, string>): Promise<JwtRefreshToken<D>[]>;
|
|
1113
1102
|
}
|
|
1114
1103
|
|
|
1115
1104
|
declare class JwtTokenDto {
|
|
@@ -1139,6 +1128,8 @@ declare class JwtSigner {
|
|
|
1139
1128
|
}
|
|
1140
1129
|
|
|
1141
1130
|
declare class JwtRefreshTokenRepository<D extends IStorableData> implements IJwtRefreshTokenRepository<D> {
|
|
1131
|
+
findByMetadata(metadata: Record<string, string>): Promise<JwtRefreshToken<D>[]>;
|
|
1132
|
+
findAndValidate(secret: string): Promise<D>;
|
|
1142
1133
|
find(id: string): Promise<JwtRefreshToken<D> | null>;
|
|
1143
1134
|
findOrThrow(id: string): Promise<JwtRefreshToken<D>>;
|
|
1144
1135
|
findByIds(ids: string[]): Promise<JwtRefreshToken<D>[]>;
|
|
@@ -1154,11 +1145,11 @@ declare class Jwt {
|
|
|
1154
1145
|
private jwtRefreshTokenRepository;
|
|
1155
1146
|
private config;
|
|
1156
1147
|
constructor(auth: Auth<any>, jwtSigner: JwtSigner, jwtRefreshTokenRepository: JwtRefreshTokenRepository<any>, config: JwtConfig);
|
|
1157
|
-
createToken(): Promise<JwtAccessAndRefreshTokenDto>;
|
|
1158
|
-
|
|
1148
|
+
createToken(metadata?: Record<string, string>): Promise<JwtAccessAndRefreshTokenDto>;
|
|
1149
|
+
findRefreshTokenAuthInfo(secret: string): Promise<any>;
|
|
1159
1150
|
}
|
|
1160
1151
|
|
|
1161
|
-
declare class
|
|
1152
|
+
declare class JwtHandshakeGuardMiddleware implements IHandshakeMiddleware {
|
|
1162
1153
|
private config;
|
|
1163
1154
|
private auth;
|
|
1164
1155
|
constructor(config: JwtConfig, auth: Auth<any>);
|
|
@@ -1174,6 +1165,9 @@ declare class JwtGuardMiddleware implements IMiddleware {
|
|
|
1174
1165
|
|
|
1175
1166
|
declare class PgJwtRefreshTokenRepository<D extends IStorableData> extends PgCrudRepository<JwtRefreshToken<D>> implements IJwtRefreshTokenRepository<D> {
|
|
1176
1167
|
constructor(pool: Pool);
|
|
1168
|
+
findAndValidate(secret: string): Promise<D>;
|
|
1169
|
+
findBySecret(secret: string): Promise<JwtRefreshToken<D> | null>;
|
|
1170
|
+
findByMetadata(metadata: Record<string, string>): Promise<JwtRefreshToken<D>[]>;
|
|
1177
1171
|
}
|
|
1178
1172
|
|
|
1179
1173
|
declare class AnthropicChatAdapter implements IChatAdapter {
|
|
@@ -1268,10 +1262,12 @@ declare class WabotChatAdapter implements IChatAdapter {
|
|
|
1268
1262
|
declare function cmd(): (target: object, propertyKey: string | symbol) => void;
|
|
1269
1263
|
|
|
1270
1264
|
declare class CmdChannel implements IChatChannel {
|
|
1265
|
+
private auth;
|
|
1271
1266
|
private authInfo;
|
|
1272
1267
|
private chatId;
|
|
1273
1268
|
private rl;
|
|
1274
1269
|
private callBack;
|
|
1270
|
+
constructor(auth: Auth<any>);
|
|
1275
1271
|
listen(callback: (message: IChannelMessage) => void): void;
|
|
1276
1272
|
connect(): void;
|
|
1277
1273
|
}
|
|
@@ -1279,28 +1275,34 @@ declare function writeJsonToFile<T>(filename: string, data: T): void;
|
|
|
1279
1275
|
declare function readJsonFromFile<T>(filename: string): T | null;
|
|
1280
1276
|
|
|
1281
1277
|
interface ISocketChannelConfig {
|
|
1282
|
-
|
|
1278
|
+
namespace: string;
|
|
1279
|
+
handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[];
|
|
1283
1280
|
}
|
|
1284
1281
|
|
|
1285
1282
|
declare class SocketChannelConfig implements ISocketChannelConfig {
|
|
1286
|
-
|
|
1287
|
-
|
|
1283
|
+
namespace: string;
|
|
1284
|
+
handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[] | undefined;
|
|
1285
|
+
constructor(namespace: string, handshakeMidlewares?: IConstructor<IHandshakeMiddleware>[] | undefined);
|
|
1288
1286
|
}
|
|
1289
1287
|
|
|
1290
1288
|
declare function socket(config: SocketChannelConfig): (target: object, propertyKey: string | symbol) => void;
|
|
1291
1289
|
|
|
1292
1290
|
interface ISocketChannelReceivedMessage {
|
|
1293
1291
|
chatId: string;
|
|
1294
|
-
|
|
1292
|
+
senderName: string;
|
|
1293
|
+
text: string;
|
|
1294
|
+
}
|
|
1295
|
+
declare class SocketChannelReceivedMessage implements ISocketChannelReceivedMessage {
|
|
1296
|
+
chatId: string;
|
|
1295
1297
|
senderName: string;
|
|
1296
1298
|
text: string;
|
|
1297
1299
|
}
|
|
1298
1300
|
declare class SocketChannel implements IChatChannel {
|
|
1299
1301
|
private config;
|
|
1300
|
-
private socketServerProvider;
|
|
1301
1302
|
private callBack;
|
|
1302
|
-
private
|
|
1303
|
-
constructor(config: SocketChannelConfig
|
|
1303
|
+
private controller;
|
|
1304
|
+
constructor(config: SocketChannelConfig);
|
|
1305
|
+
private configController;
|
|
1304
1306
|
listen(callback: (message: IChannelMessage) => void): void;
|
|
1305
1307
|
connect(): void;
|
|
1306
1308
|
}
|
|
@@ -1622,4 +1624,4 @@ declare function HtmlModule(options: IHtmlModuleOptions): {
|
|
|
1622
1624
|
new (): {};
|
|
1623
1625
|
};
|
|
1624
1626
|
|
|
1625
|
-
export { AnthropicChatAdapter, ApiKey,
|
|
1627
|
+
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, SocketChannelReceivedMessage, 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
|
@@ -14,7 +14,7 @@ export { isArray } from './core/validation/metadata/@isArray.js';
|
|
|
14
14
|
export { ValidationMetadataStore } from './core/validation/metadata/ValidationMetadataStore.js';
|
|
15
15
|
export { validateModel } from './core/validation/core/validateModel.js';
|
|
16
16
|
export { validateArray } from './core/validation/core/validateArray.js';
|
|
17
|
-
export {
|
|
17
|
+
export { validateAndTransform } from './core/validation/validateAndTransform.js';
|
|
18
18
|
export { modelInfo } from './core/validation/modelInfo.js';
|
|
19
19
|
export { isBoolean } from './core/validation/validators/is-boolean/@isBoolean.js';
|
|
20
20
|
export { validateIsBoolean } from './core/validation/validators/is-boolean/validateIsBoolean.js';
|
|
@@ -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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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';
|
|
@@ -123,7 +122,7 @@ export { WabotChatAdapter } from './addon/chat-bot/wabot/WabotChatAdapter.js';
|
|
|
123
122
|
export { cmd } from './addon/chat-controller/cmd/@cmd.js';
|
|
124
123
|
export { CmdChannel, readJsonFromFile, writeJsonToFile } from './addon/chat-controller/cmd/CmdChannel.js';
|
|
125
124
|
export { socket } from './addon/chat-controller/socket/@socket.js';
|
|
126
|
-
export { SocketChannel } from './addon/chat-controller/socket/SocketChannel.js';
|
|
125
|
+
export { SocketChannel, SocketChannelReceivedMessage } from './addon/chat-controller/socket/SocketChannel.js';
|
|
127
126
|
export { SocketChannelConfig } from './addon/chat-controller/socket/SocketChannelConfig.js';
|
|
128
127
|
export { telegram } from './addon/chat-controller/telegram/@telegram.js';
|
|
129
128
|
export { TelegramChannelConfig } from './addon/chat-controller/telegram/TelegramChannelConfig.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wabot-dev/framework",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.11",
|
|
4
4
|
"description": "Framework for IA Chat Bots",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -24,10 +24,6 @@
|
|
|
24
24
|
"@rollup/plugin-json": "6.1.0",
|
|
25
25
|
"@rollup/plugin-node-resolve": "16.0.1",
|
|
26
26
|
"@rollup/plugin-typescript": "12.1.2",
|
|
27
|
-
"@types/big.js": "^6.2.2",
|
|
28
|
-
"@types/html-to-text": "^9.0.4",
|
|
29
|
-
"@types/node": "22.14.1",
|
|
30
|
-
"@types/react": "^19.1.2",
|
|
31
27
|
"@yucacodes/ts": "^0.0.4",
|
|
32
28
|
"prettier": "^3.5.3",
|
|
33
29
|
"resend": "^4.4.1",
|
|
@@ -38,10 +34,13 @@
|
|
|
38
34
|
"peerDependencies": {
|
|
39
35
|
"@anthropic-ai/sdk": "^0.60.0",
|
|
40
36
|
"@google/genai": "^1.16.0",
|
|
37
|
+
"@types/big.js": "^6.2.2",
|
|
41
38
|
"@types/debug": "^4.1.12",
|
|
42
39
|
"@types/express": "^5.0.1",
|
|
43
40
|
"@types/jsonwebtoken": "^9.0.10",
|
|
44
41
|
"@types/pg": "^8.11.14",
|
|
42
|
+
"@types/html-to-text": "^9.0.4",
|
|
43
|
+
"@types/node": "22.14.1",
|
|
45
44
|
"@yucacodes/ts": "^0.0.4",
|
|
46
45
|
"big.js": "^7.0.1",
|
|
47
46
|
"body-parser": "^2.2.0",
|
|
@@ -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 };
|