@tsed/platform-middlewares 6.71.1 → 7.0.0-alpha.1
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.
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
-
export interface IAuthOptions {
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Since v6. Use @Returns from @tsed/schema
|
|
5
|
-
*/
|
|
6
|
-
responses?: {
|
|
7
|
-
[statusCode: string]: {
|
|
8
|
-
description: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Since v6. Use @Security from @tsed/schema
|
|
13
|
-
*/
|
|
14
|
-
security?: {
|
|
15
|
-
[securityName: string]: string[];
|
|
16
|
-
}[] | {
|
|
17
|
-
[securityName: string]: string[];
|
|
18
|
-
};
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
}
|
|
21
2
|
/**
|
|
22
3
|
* Change authentication options.
|
|
23
4
|
*
|
|
@@ -39,4 +20,4 @@ export interface IAuthOptions {
|
|
|
39
20
|
* @decorator
|
|
40
21
|
* @operation
|
|
41
22
|
*/
|
|
42
|
-
export declare function AuthOptions(guardAuth: Type<any>, options?:
|
|
23
|
+
export declare function AuthOptions(guardAuth: Type<any>, options?: Record<string, unknown>): Function;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
-
import { IAuthOptions } from "./authOptions";
|
|
3
2
|
/**
|
|
4
3
|
* Use custom authentication strategy on your endpoint.
|
|
5
4
|
*
|
|
@@ -20,4 +19,4 @@ import { IAuthOptions } from "./authOptions";
|
|
|
20
19
|
* @decorator
|
|
21
20
|
* @operation
|
|
22
21
|
*/
|
|
23
|
-
export declare function UseAuth(guardAuth: Type<any>, options?:
|
|
22
|
+
export declare function UseAuth(guardAuth: Type<any>, options?: Record<string, unknown>): Function;
|
package/lib/index.js
CHANGED
|
@@ -43,27 +43,6 @@ function AuthOptions(guardAuth, options = {}) {
|
|
|
43
43
|
case core.DecoratorTypes.METHOD:
|
|
44
44
|
return schema.JsonEntityFn(entity => {
|
|
45
45
|
const store = entity.store;
|
|
46
|
-
|
|
47
|
-
if (options.responses) {
|
|
48
|
-
const {
|
|
49
|
-
responses
|
|
50
|
-
} = options;
|
|
51
|
-
store.merge("responses", responses, true);
|
|
52
|
-
delete options.responses;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (options.security) {
|
|
56
|
-
const {
|
|
57
|
-
security
|
|
58
|
-
} = options;
|
|
59
|
-
[].concat(security).forEach(security => {
|
|
60
|
-
Object.entries(security).forEach(([name, scopes]) => {
|
|
61
|
-
entity.operation.addSecurityScopes(name, scopes);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
delete options.security;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
46
|
store.merge(guardAuth, options, true);
|
|
68
47
|
})(...args);
|
|
69
48
|
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/decorators/middleware.ts","../src/decorators/authOptions.ts","../src/constants/index.ts","../src/utils/mapUseOptions.ts","../src/decorators/use.ts","../src/decorators/useAfter.ts","../src/decorators/useBefore.ts","../src/decorators/useAuth.ts","../src/decorators/useBeforeEach.ts","../src/utils/getMiddlewaresForHook.ts"],"sourcesContent":["import {Injectable, ProviderType} from \"@tsed/di\";\n\n/**\n * Register a new Middleware class.\n *\n * @decorator\n * @classDecorator\n */\nexport function Middleware(): ClassDecorator {\n return Injectable({\n type: ProviderType.MIDDLEWARE\n });\n}\n","import {\n decorateMethodsOf,\n DecoratorMethodParameters,\n DecoratorParameters,\n decoratorTypeOf,\n DecoratorTypes,\n Type,\n UnsupportedDecoratorType\n} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\nexport interface IAuthOptions {\n /**\n * @deprecated Since v6. Use @Returns from @tsed/schema\n */\n responses?: {\n [statusCode: string]: {\n description: string;\n };\n };\n /**\n * @deprecated Since v6. Use @Security from @tsed/schema\n */\n security?:\n | {\n [securityName: string]: string[];\n }[]\n | {\n [securityName: string]: string[];\n };\n\n [key: string]: any;\n}\n\n/**\n * Change authentication options.\n *\n * ```typescript\n * @Controller('/mypath')\n * @UseAuth(MyAuthStrategy, {role: ''})\n * class MyCtrl {\n *\n * @Get('/')\n * @AuthOptions(MyAuthStrategy, {role: 'admin'})\n * public getResource(){}\n * }\n * ```\n *\n * @param guardAuth\n * @param options {Object} Object passed to the customer auth strategy\n * @returns {Function}\n * @decorator\n * @decorator\n * @operation\n */\nexport function AuthOptions(guardAuth: Type<any>, options: IAuthOptions = {}): Function {\n return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.METHOD:\n return JsonEntityFn((entity) => {\n const store = entity.store;\n\n if (options.responses) {\n const {responses} = options;\n store.merge(\"responses\", responses, true);\n delete options.responses;\n }\n\n if (options.security) {\n const {security} = options;\n [].concat(security as any).forEach((security) => {\n Object.entries(security).forEach(([name, scopes]: [string, string[]]) => {\n entity.operation!.addSecurityScopes(name, scopes);\n });\n });\n\n delete options.security;\n }\n\n store.merge(guardAuth, options, true);\n })(...(args as DecoratorMethodParameters));\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], AuthOptions(guardAuth, options));\n break;\n\n default:\n throw new UnsupportedDecoratorType(AuthOptions, args);\n }\n };\n}\n","export const HTTP_METHODS = [\n \"all\",\n \"checkout\",\n \"connect\",\n \"copy\",\n \"delete\",\n \"get\",\n \"head\",\n \"lock\",\n \"merge\",\n \"mkactivity\",\n \"mkcol\",\n \"move\",\n \"m-search\",\n \"notify\",\n \"options\",\n \"param\",\n \"patch\",\n \"post\",\n \"propfind\",\n \"propatch\",\n \"purge\",\n \"put\",\n \"report\",\n \"search\",\n \"subscribe\",\n \"trace\",\n \"unlock\",\n \"unsuscribe\"\n];\n","import {HTTP_METHODS} from \"../constants\";\n\nexport function mapUseOptions(args: any[]) {\n let method: string | undefined = undefined;\n let path: string | RegExp | undefined = undefined;\n\n const middlewares = args.filter((arg: any) => {\n if (typeof arg === \"string\" && HTTP_METHODS.includes(arg)) {\n method = arg;\n\n return false;\n }\n\n if (typeof arg === \"string\" || arg instanceof RegExp) {\n path = arg ? arg : \"/\";\n\n return false;\n }\n\n return !!arg;\n });\n\n return {\n path,\n method,\n middlewares\n };\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn, OperationMethods, OperationPath} from \"@tsed/schema\";\nimport {mapUseOptions} from \"../utils/mapUseOptions\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @Use(Middleware1)\n * export class Ctrl {\n *\n * @Get('/')\n * @Use(Middleware2)\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param args\n * @decorator\n * @operation\n */\nexport function Use(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n const options = mapUseOptions(args);\n\n options.path && OperationPath(options.method || OperationMethods.CUSTOM, options.path)(...parameters);\n\n entity.use(args);\n break;\n\n case DecoratorTypes.CLASS:\n entity.store.merge(\"middlewares\", {\n use: args\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(Use, parameters);\n }\n });\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseAfter(Middleware1)\n * export class Ctrl {\n *\n * @Get('/')\n * @UseAfter(Middleware2)\n * get() { }\n * }\n * ```\n *\n * @returns {function(any, any, any): *}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseAfter(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n const endpoint = entity;\n endpoint.afterMiddlewares = args.concat(endpoint.afterMiddlewares);\n\n break;\n\n case DecoratorTypes.CLASS:\n const middlewares = entity.store.get(\"middlewares\") || {};\n\n entity.store.set(\"middlewares\", {\n ...middlewares,\n useAfter: [...args, ...(middlewares.useAfter || [])]\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseAfter, parameters);\n }\n });\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseBefore(Middleware1) // called only one time before all endpoint\n * export class Ctrl {\n *\n * @Get('/')\n * @UseBefore(Middleware2)\n * get() { }\n * }\n * ```\n *\n * @returns {function(any, any, any): *}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseBefore(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n entity.beforeMiddlewares = args.concat(entity.beforeMiddlewares);\n\n break;\n\n case DecoratorTypes.CLASS:\n const middlewares = entity.store.get(\"middlewares\") || {};\n\n entity.store.set(\"middlewares\", {\n ...middlewares,\n useBefore: [...args, ...(middlewares.useBefore || [])]\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseBefore, parameters);\n }\n });\n}\n","import {\n decorateMethodsOf,\n DecoratorParameters,\n decoratorTypeOf,\n DecoratorTypes,\n Store,\n StoreFn,\n Type,\n UnsupportedDecoratorType,\n useDecorators\n} from \"@tsed/core\";\nimport {AuthOptions, IAuthOptions} from \"./authOptions\";\nimport {UseBefore} from \"./useBefore\";\n\n/**\n * Use custom authentication strategy on your endpoint.\n *\n * ```typescript\n * @Controller('/mypath')\n * @UseAuth(MyAuthStrategy)\n * class MyCtrl {\n *\n * @Get('/')\n * @UseAuth(MyAuthStrategy, {role: 'admin'})\n * public getResource(){}\n * }\n * ```\n *\n * @param guardAuth {Type<any>} A middleware which implement a custom auth strategy\n * @param options {Object} Object passed to the customer auth strategy\n * @returns {Function}\n * @decorator\n * @operation\n */\nexport function UseAuth(guardAuth: Type<any>, options: IAuthOptions = {}): Function {\n return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.METHOD:\n return useDecorators(\n StoreFn((store: Store) => {\n if (!store.has(guardAuth)) {\n return UseBefore(guardAuth);\n }\n }),\n AuthOptions(guardAuth, options)\n )(...args);\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], UseAuth(guardAuth, options));\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseAuth, args);\n }\n };\n}\n","import {decorateMethodsOf, DecoratorParameters, decoratorTypeOf, DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {UseBefore} from \"./useBefore\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseBeforeEach(Middleware1) // Called before each endpoint\n * export class Ctrl {\n *\n * @Get('/')\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseBeforeEach(...args: any[]): Function {\n return <T>(...decoratorArgs: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(decoratorArgs)) {\n case DecoratorTypes.METHOD:\n return UseBefore(...args)(...decoratorArgs);\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(decoratorArgs[0], UseBefore(...args));\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseBeforeEach, decoratorArgs);\n }\n };\n}\n","import {isFunction} from \"@tsed/core\";\nimport {PlatformMiddlewareLoadingOptions} from \"../domain/PlatformMiddlewareSettings\";\n\nexport function getMiddlewaresForHook(hook: string, settings: TsED.Configuration, defaultHook = \"\") {\n const {env, middlewares = []} = settings;\n\n return middlewares\n .map<PlatformMiddlewareLoadingOptions>((middleware) => {\n return isFunction(middleware)\n ? {\n env,\n hook: defaultHook,\n use: middleware\n }\n : {\n env,\n hook: defaultHook,\n ...middleware\n };\n })\n .filter((options) => {\n return options.use && options.env === env && options.hook === hook;\n });\n}\n"],"names":["Middleware","Injectable","type","ProviderType","MIDDLEWARE","AuthOptions","guardAuth","options","args","decoratorTypeOf","DecoratorTypes","METHOD","JsonEntityFn","entity","store","responses","merge","security","concat","forEach","Object","entries","name","scopes","operation","addSecurityScopes","CLASS","decorateMethodsOf","UnsupportedDecoratorType","HTTP_METHODS","mapUseOptions","method","undefined","path","middlewares","filter","arg","includes","RegExp","Use","parameters","decoratorType","OperationPath","OperationMethods","CUSTOM","use","UseAfter","endpoint","afterMiddlewares","get","set","useAfter","UseBefore","beforeMiddlewares","useBefore","UseAuth","useDecorators","StoreFn","has","UseBeforeEach","decoratorArgs","getMiddlewaresForHook","hook","settings","defaultHook","env","map","middleware","isFunction"],"mappings":";;;;AAEA;;;;;;;SAMgBA;AACd,SAAOC,aAAU,CAAC;AAChBC,IAAAA,IAAI,EAAEC,eAAY,CAACC;AADH,GAAD,CAAjB;AAGD;;ACsBD;;;;;;;;;;;;;;;;;;;;;;SAqBgBC,YAAYC,WAAsBC,UAAwB;AACxE,SAAO,CAAI,GAAGC,IAAP;AACL,YAAQC,oBAAe,CAACD,IAAD,CAAvB;AACE,WAAKE,mBAAc,CAACC,MAApB;AACE,eAAOC,mBAAY,CAAEC,MAAD;AAClB,gBAAMC,KAAK,GAAGD,MAAM,CAACC,KAArB;;AAEA,cAAIP,OAAO,CAACQ,SAAZ,EAAuB;AACrB,kBAAM;AAACA,cAAAA;AAAD,gBAAcR,OAApB;AACAO,YAAAA,KAAK,CAACE,KAAN,CAAY,WAAZ,EAAyBD,SAAzB,EAAoC,IAApC;AACA,mBAAOR,OAAO,CAACQ,SA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B,GAAGoD,aAAtB,CAAP;;AAEF,WAAKlD,mBAAc,CAACgB,KAApB;AACEC,QAAAA,sBAAiB,CAACiC,aAAa,CAAC,CAAD,CAAd,EAAmBR,SAAS,CAAC,GAAG5C,IAAJ,CAA5B,CAAjB;AACA;;AAEF;AACE,cAAM,IAAIoB,6BAAJ,CAA6B+B,aAA7B,EAA4CC,aAA5C,CAAN;AATJ;AAWD,GAZD;AAaD;;SClCeC,sBAAsBC,MAAcC,UAA8BC,WAAW,GAAG;AAC9F,QAAM;AAACC,IAAAA,GAAD;AAAM/B,IAAAA,WAAW,GAAG;AAApB,MAA0B6B,QAAhC;AAEA,SAAO7B,WAAW,CACfgC,GADI,CACmCC,UAAD;AACrC,WAAOC,eAAU,CAACD,UAAD,CAAV,GACH;AACEF,MAAAA,GADF;AAEEH,MAAAA,IAAI,EAAEE,WAFR;AAGEnB,MAAAA,GAAG,EAAEsB;AAHP,KADG;AAODF,MAAAA,GAPC;AAQDH,MAAAA,IAAI,EAAEE;AARL,OASEG,UATF,CAAP;AAWD,GAbI,EAcJhC,MAdI,CAcI5B,OAAD;AACN,WAAOA,OAAO,CAACsC,GAAR,IAAetC,OAAO,CAAC0D,GAAR,KAAgBA,GAA/B,IAAsC1D,OAAO,CAACuD,IAAR,KAAiBA,IAA9D;AACD,GAhBI,CAAP;AAiBD;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/decorators/middleware.ts","../src/decorators/authOptions.ts","../src/constants/index.ts","../src/utils/mapUseOptions.ts","../src/decorators/use.ts","../src/decorators/useAfter.ts","../src/decorators/useBefore.ts","../src/decorators/useAuth.ts","../src/decorators/useBeforeEach.ts","../src/utils/getMiddlewaresForHook.ts"],"sourcesContent":["import {Injectable, ProviderType} from \"@tsed/di\";\n\n/**\n * Register a new Middleware class.\n *\n * @decorator\n * @classDecorator\n */\nexport function Middleware(): ClassDecorator {\n return Injectable({\n type: ProviderType.MIDDLEWARE\n });\n}\n","import {\n decorateMethodsOf,\n DecoratorMethodParameters,\n DecoratorParameters,\n decoratorTypeOf,\n DecoratorTypes,\n Type,\n UnsupportedDecoratorType\n} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Change authentication options.\n *\n * ```typescript\n * @Controller('/mypath')\n * @UseAuth(MyAuthStrategy, {role: ''})\n * class MyCtrl {\n *\n * @Get('/')\n * @AuthOptions(MyAuthStrategy, {role: 'admin'})\n * public getResource(){}\n * }\n * ```\n *\n * @param guardAuth\n * @param options {Object} Object passed to the customer auth strategy\n * @returns {Function}\n * @decorator\n * @decorator\n * @operation\n */\nexport function AuthOptions(guardAuth: Type<any>, options: Record<string, unknown> = {}): Function {\n return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.METHOD:\n return JsonEntityFn((entity) => {\n const store = entity.store;\n\n store.merge(guardAuth, options, true);\n })(...(args as DecoratorMethodParameters));\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], AuthOptions(guardAuth, options));\n break;\n\n default:\n throw new UnsupportedDecoratorType(AuthOptions, args);\n }\n };\n}\n","export const HTTP_METHODS = [\n \"all\",\n \"checkout\",\n \"connect\",\n \"copy\",\n \"delete\",\n \"get\",\n \"head\",\n \"lock\",\n \"merge\",\n \"mkactivity\",\n \"mkcol\",\n \"move\",\n \"m-search\",\n \"notify\",\n \"options\",\n \"param\",\n \"patch\",\n \"post\",\n \"propfind\",\n \"propatch\",\n \"purge\",\n \"put\",\n \"report\",\n \"search\",\n \"subscribe\",\n \"trace\",\n \"unlock\",\n \"unsuscribe\"\n];\n","import {HTTP_METHODS} from \"../constants\";\n\nexport function mapUseOptions(args: any[]) {\n let method: string | undefined = undefined;\n let path: string | RegExp | undefined = undefined;\n\n const middlewares = args.filter((arg: any) => {\n if (typeof arg === \"string\" && HTTP_METHODS.includes(arg)) {\n method = arg;\n\n return false;\n }\n\n if (typeof arg === \"string\" || arg instanceof RegExp) {\n path = arg ? arg : \"/\";\n\n return false;\n }\n\n return !!arg;\n });\n\n return {\n path,\n method,\n middlewares\n };\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn, OperationMethods, OperationPath} from \"@tsed/schema\";\nimport {mapUseOptions} from \"../utils/mapUseOptions\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @Use(Middleware1)\n * export class Ctrl {\n *\n * @Get('/')\n * @Use(Middleware2)\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param args\n * @decorator\n * @operation\n */\nexport function Use(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n const options = mapUseOptions(args);\n\n options.path && OperationPath(options.method || OperationMethods.CUSTOM, options.path)(...parameters);\n\n entity.use(args);\n break;\n\n case DecoratorTypes.CLASS:\n entity.store.merge(\"middlewares\", {\n use: args\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(Use, parameters);\n }\n });\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseAfter(Middleware1)\n * export class Ctrl {\n *\n * @Get('/')\n * @UseAfter(Middleware2)\n * get() { }\n * }\n * ```\n *\n * @returns {function(any, any, any): *}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseAfter(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n const endpoint = entity;\n endpoint.afterMiddlewares = args.concat(endpoint.afterMiddlewares);\n\n break;\n\n case DecoratorTypes.CLASS:\n const middlewares = entity.store.get(\"middlewares\") || {};\n\n entity.store.set(\"middlewares\", {\n ...middlewares,\n useAfter: [...args, ...(middlewares.useAfter || [])]\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseAfter, parameters);\n }\n });\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseBefore(Middleware1) // called only one time before all endpoint\n * export class Ctrl {\n *\n * @Get('/')\n * @UseBefore(Middleware2)\n * get() { }\n * }\n * ```\n *\n * @returns {function(any, any, any): *}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseBefore(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n entity.beforeMiddlewares = args.concat(entity.beforeMiddlewares);\n\n break;\n\n case DecoratorTypes.CLASS:\n const middlewares = entity.store.get(\"middlewares\") || {};\n\n entity.store.set(\"middlewares\", {\n ...middlewares,\n useBefore: [...args, ...(middlewares.useBefore || [])]\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseBefore, parameters);\n }\n });\n}\n","import {\n decorateMethodsOf,\n DecoratorParameters,\n decoratorTypeOf,\n DecoratorTypes,\n Store,\n StoreFn,\n Type,\n UnsupportedDecoratorType,\n useDecorators\n} from \"@tsed/core\";\nimport {AuthOptions} from \"./authOptions\";\nimport {UseBefore} from \"./useBefore\";\n\n/**\n * Use custom authentication strategy on your endpoint.\n *\n * ```typescript\n * @Controller('/mypath')\n * @UseAuth(MyAuthStrategy)\n * class MyCtrl {\n *\n * @Get('/')\n * @UseAuth(MyAuthStrategy, {role: 'admin'})\n * public getResource(){}\n * }\n * ```\n *\n * @param guardAuth {Type<any>} A middleware which implement a custom auth strategy\n * @param options {Object} Object passed to the customer auth strategy\n * @returns {Function}\n * @decorator\n * @operation\n */\nexport function UseAuth(guardAuth: Type<any>, options: Record<string, unknown> = {}): Function {\n return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.METHOD:\n return useDecorators(\n StoreFn((store: Store) => {\n if (!store.has(guardAuth)) {\n return UseBefore(guardAuth);\n }\n }),\n AuthOptions(guardAuth, options)\n )(...args);\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], UseAuth(guardAuth, options));\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseAuth, args);\n }\n };\n}\n","import {decorateMethodsOf, DecoratorParameters, decoratorTypeOf, DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {UseBefore} from \"./useBefore\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseBeforeEach(Middleware1) // Called before each endpoint\n * export class Ctrl {\n *\n * @Get('/')\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseBeforeEach(...args: any[]): Function {\n return <T>(...decoratorArgs: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(decoratorArgs)) {\n case DecoratorTypes.METHOD:\n return UseBefore(...args)(...decoratorArgs);\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(decoratorArgs[0], UseBefore(...args));\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseBeforeEach, decoratorArgs);\n }\n };\n}\n","import {isFunction} from \"@tsed/core\";\nimport {PlatformMiddlewareLoadingOptions} from \"../domain/PlatformMiddlewareSettings\";\n\nexport function getMiddlewaresForHook(hook: string, settings: TsED.Configuration, defaultHook = \"\") {\n const {env, middlewares = []} = settings;\n\n return middlewares\n .map<PlatformMiddlewareLoadingOptions>((middleware) => {\n return isFunction(middleware)\n ? {\n env,\n hook: defaultHook,\n use: middleware\n }\n : {\n env,\n hook: defaultHook,\n ...middleware\n };\n })\n .filter((options) => {\n return options.use && options.env === env && options.hook === hook;\n });\n}\n"],"names":["Middleware","Injectable","type","ProviderType","MIDDLEWARE","AuthOptions","guardAuth","options","args","decoratorTypeOf","DecoratorTypes","METHOD","JsonEntityFn","entity","store","merge","CLASS","decorateMethodsOf","UnsupportedDecoratorType","HTTP_METHODS","mapUseOptions","method","undefined","path","middlewares","filter","arg","includes","RegExp","Use","parameters","decoratorType","OperationPath","OperationMethods","CUSTOM","use","UseAfter","endpoint","afterMiddlewares","concat","get","set","useAfter","UseBefore","beforeMiddlewares","useBefore","UseAuth","useDecorators","StoreFn","has","UseBeforeEach","decoratorArgs","getMiddlewaresForHook","hook","settings","defaultHook","env","map","middleware","isFunction"],"mappings":";;;;AAEA;;;;;;;SAMgBA;AACd,SAAOC,aAAU,CAAC;AAChBC,IAAAA,IAAI,EAAEC,eAAY,CAACC;AADH,GAAD,CAAjB;AAGD;;ACDD;;;;;;;;;;;;;;;;;;;;;;SAqBgBC,YAAYC,WAAsBC,UAAmC;AACnF,SAAO,CAAI,GAAGC,IAAP;AACL,YAAQC,oBAAe,CAACD,IAAD,CAAvB;AACE,WAAKE,mBAAc,CAACC,MAApB;AACE,eAAOC,mBAAY,CAAEC,MAAD;AAClB,gBAAMC,KAAK,GAAGD,MAAM,CAACC,KAArB;AAEAA,UAAAA,KAAK,CAACC,KAAN,CAAYT,SAAZ,EAAuBC,OAAvB,EAAgC,IAAhC;AACD,SAJkB,CAAZ,CAIJ,GAAIC,IAJA,CAAP;;AAMF,WAAKE,mBAAc,CAACM,KAApB;AACEC,QAAAA,sBAAiB,CAACT,IAAI,CAAC,CAAD,CAAL,EAAUH,WAAW,CAACC,SAAD,EAAYC,OAAZ,CAArB,CAAjB;AACA;;AAEF;AACE,cAAM,IAAIW,6BAAJ,CAA6Bb,WAA7B,EAA0CG,IAA1C,CAAN;AAbJ;AAeD,GAhBD;AAiBD;;AClDM,MAAMW,YAAY,GAAG,CAC1B,KAD0B,EAE1B,UAF0B,EAG1B,SAH0B,EAI1B,MAJ0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43,6 @@ function AuthOptions(guardAuth, options = {}) {
|
|
|
43
43
|
case DecoratorTypes.METHOD:
|
|
44
44
|
return JsonEntityFn(entity => {
|
|
45
45
|
const store = entity.store;
|
|
46
|
-
|
|
47
|
-
if (options.responses) {
|
|
48
|
-
const {
|
|
49
|
-
responses
|
|
50
|
-
} = options;
|
|
51
|
-
store.merge("responses", responses, true);
|
|
52
|
-
delete options.responses;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (options.security) {
|
|
56
|
-
const {
|
|
57
|
-
security
|
|
58
|
-
} = options;
|
|
59
|
-
[].concat(security).forEach(security => {
|
|
60
|
-
Object.entries(security).forEach(([name, scopes]) => {
|
|
61
|
-
entity.operation.addSecurityScopes(name, scopes);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
delete options.security;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
46
|
store.merge(guardAuth, options, true);
|
|
68
47
|
})(...args);
|
|
69
48
|
|
package/lib/index.modern.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/decorators/middleware.ts","../src/decorators/authOptions.ts","../src/constants/index.ts","../src/utils/mapUseOptions.ts","../src/decorators/use.ts","../src/decorators/useAfter.ts","../src/decorators/useBefore.ts","../src/decorators/useAuth.ts","../src/decorators/useBeforeEach.ts","../src/utils/getMiddlewaresForHook.ts"],"sourcesContent":["import {Injectable, ProviderType} from \"@tsed/di\";\n\n/**\n * Register a new Middleware class.\n *\n * @decorator\n * @classDecorator\n */\nexport function Middleware(): ClassDecorator {\n return Injectable({\n type: ProviderType.MIDDLEWARE\n });\n}\n","import {\n decorateMethodsOf,\n DecoratorMethodParameters,\n DecoratorParameters,\n decoratorTypeOf,\n DecoratorTypes,\n Type,\n UnsupportedDecoratorType\n} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\nexport interface IAuthOptions {\n /**\n * @deprecated Since v6. Use @Returns from @tsed/schema\n */\n responses?: {\n [statusCode: string]: {\n description: string;\n };\n };\n /**\n * @deprecated Since v6. Use @Security from @tsed/schema\n */\n security?:\n | {\n [securityName: string]: string[];\n }[]\n | {\n [securityName: string]: string[];\n };\n\n [key: string]: any;\n}\n\n/**\n * Change authentication options.\n *\n * ```typescript\n * @Controller('/mypath')\n * @UseAuth(MyAuthStrategy, {role: ''})\n * class MyCtrl {\n *\n * @Get('/')\n * @AuthOptions(MyAuthStrategy, {role: 'admin'})\n * public getResource(){}\n * }\n * ```\n *\n * @param guardAuth\n * @param options {Object} Object passed to the customer auth strategy\n * @returns {Function}\n * @decorator\n * @decorator\n * @operation\n */\nexport function AuthOptions(guardAuth: Type<any>, options: IAuthOptions = {}): Function {\n return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.METHOD:\n return JsonEntityFn((entity) => {\n const store = entity.store;\n\n if (options.responses) {\n const {responses} = options;\n store.merge(\"responses\", responses, true);\n delete options.responses;\n }\n\n if (options.security) {\n const {security} = options;\n [].concat(security as any).forEach((security) => {\n Object.entries(security).forEach(([name, scopes]: [string, string[]]) => {\n entity.operation!.addSecurityScopes(name, scopes);\n });\n });\n\n delete options.security;\n }\n\n store.merge(guardAuth, options, true);\n })(...(args as DecoratorMethodParameters));\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], AuthOptions(guardAuth, options));\n break;\n\n default:\n throw new UnsupportedDecoratorType(AuthOptions, args);\n }\n };\n}\n","export const HTTP_METHODS = [\n \"all\",\n \"checkout\",\n \"connect\",\n \"copy\",\n \"delete\",\n \"get\",\n \"head\",\n \"lock\",\n \"merge\",\n \"mkactivity\",\n \"mkcol\",\n \"move\",\n \"m-search\",\n \"notify\",\n \"options\",\n \"param\",\n \"patch\",\n \"post\",\n \"propfind\",\n \"propatch\",\n \"purge\",\n \"put\",\n \"report\",\n \"search\",\n \"subscribe\",\n \"trace\",\n \"unlock\",\n \"unsuscribe\"\n];\n","import {HTTP_METHODS} from \"../constants\";\n\nexport function mapUseOptions(args: any[]) {\n let method: string | undefined = undefined;\n let path: string | RegExp | undefined = undefined;\n\n const middlewares = args.filter((arg: any) => {\n if (typeof arg === \"string\" && HTTP_METHODS.includes(arg)) {\n method = arg;\n\n return false;\n }\n\n if (typeof arg === \"string\" || arg instanceof RegExp) {\n path = arg ? arg : \"/\";\n\n return false;\n }\n\n return !!arg;\n });\n\n return {\n path,\n method,\n middlewares\n };\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn, OperationMethods, OperationPath} from \"@tsed/schema\";\nimport {mapUseOptions} from \"../utils/mapUseOptions\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @Use(Middleware1)\n * export class Ctrl {\n *\n * @Get('/')\n * @Use(Middleware2)\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param args\n * @decorator\n * @operation\n */\nexport function Use(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n const options = mapUseOptions(args);\n\n options.path && OperationPath(options.method || OperationMethods.CUSTOM, options.path)(...parameters);\n\n entity.use(args);\n break;\n\n case DecoratorTypes.CLASS:\n entity.store.merge(\"middlewares\", {\n use: args\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(Use, parameters);\n }\n });\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseAfter(Middleware1)\n * export class Ctrl {\n *\n * @Get('/')\n * @UseAfter(Middleware2)\n * get() { }\n * }\n * ```\n *\n * @returns {function(any, any, any): *}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseAfter(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n const endpoint = entity;\n endpoint.afterMiddlewares = args.concat(endpoint.afterMiddlewares);\n\n break;\n\n case DecoratorTypes.CLASS:\n const middlewares = entity.store.get(\"middlewares\") || {};\n\n entity.store.set(\"middlewares\", {\n ...middlewares,\n useAfter: [...args, ...(middlewares.useAfter || [])]\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseAfter, parameters);\n }\n });\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseBefore(Middleware1) // called only one time before all endpoint\n * export class Ctrl {\n *\n * @Get('/')\n * @UseBefore(Middleware2)\n * get() { }\n * }\n * ```\n *\n * @returns {function(any, any, any): *}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseBefore(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n entity.beforeMiddlewares = args.concat(entity.beforeMiddlewares);\n\n break;\n\n case DecoratorTypes.CLASS:\n const middlewares = entity.store.get(\"middlewares\") || {};\n\n entity.store.set(\"middlewares\", {\n ...middlewares,\n useBefore: [...args, ...(middlewares.useBefore || [])]\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseBefore, parameters);\n }\n });\n}\n","import {\n decorateMethodsOf,\n DecoratorParameters,\n decoratorTypeOf,\n DecoratorTypes,\n Store,\n StoreFn,\n Type,\n UnsupportedDecoratorType,\n useDecorators\n} from \"@tsed/core\";\nimport {AuthOptions, IAuthOptions} from \"./authOptions\";\nimport {UseBefore} from \"./useBefore\";\n\n/**\n * Use custom authentication strategy on your endpoint.\n *\n * ```typescript\n * @Controller('/mypath')\n * @UseAuth(MyAuthStrategy)\n * class MyCtrl {\n *\n * @Get('/')\n * @UseAuth(MyAuthStrategy, {role: 'admin'})\n * public getResource(){}\n * }\n * ```\n *\n * @param guardAuth {Type<any>} A middleware which implement a custom auth strategy\n * @param options {Object} Object passed to the customer auth strategy\n * @returns {Function}\n * @decorator\n * @operation\n */\nexport function UseAuth(guardAuth: Type<any>, options: IAuthOptions = {}): Function {\n return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.METHOD:\n return useDecorators(\n StoreFn((store: Store) => {\n if (!store.has(guardAuth)) {\n return UseBefore(guardAuth);\n }\n }),\n AuthOptions(guardAuth, options)\n )(...args);\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], UseAuth(guardAuth, options));\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseAuth, args);\n }\n };\n}\n","import {decorateMethodsOf, DecoratorParameters, decoratorTypeOf, DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {UseBefore} from \"./useBefore\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseBeforeEach(Middleware1) // Called before each endpoint\n * export class Ctrl {\n *\n * @Get('/')\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseBeforeEach(...args: any[]): Function {\n return <T>(...decoratorArgs: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(decoratorArgs)) {\n case DecoratorTypes.METHOD:\n return UseBefore(...args)(...decoratorArgs);\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(decoratorArgs[0], UseBefore(...args));\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseBeforeEach, decoratorArgs);\n }\n };\n}\n","import {isFunction} from \"@tsed/core\";\nimport {PlatformMiddlewareLoadingOptions} from \"../domain/PlatformMiddlewareSettings\";\n\nexport function getMiddlewaresForHook(hook: string, settings: TsED.Configuration, defaultHook = \"\") {\n const {env, middlewares = []} = settings;\n\n return middlewares\n .map<PlatformMiddlewareLoadingOptions>((middleware) => {\n return isFunction(middleware)\n ? {\n env,\n hook: defaultHook,\n use: middleware\n }\n : {\n env,\n hook: defaultHook,\n ...middleware\n };\n })\n .filter((options) => {\n return options.use && options.env === env && options.hook === hook;\n });\n}\n"],"names":["Middleware","Injectable","type","ProviderType","MIDDLEWARE","AuthOptions","guardAuth","options","args","decoratorTypeOf","DecoratorTypes","METHOD","JsonEntityFn","entity","store","responses","merge","security","concat","forEach","Object","entries","name","scopes","operation","addSecurityScopes","CLASS","decorateMethodsOf","UnsupportedDecoratorType","HTTP_METHODS","mapUseOptions","method","undefined","path","middlewares","filter","arg","includes","RegExp","Use","parameters","decoratorType","OperationPath","OperationMethods","CUSTOM","use","UseAfter","endpoint","afterMiddlewares","get","set","useAfter","UseBefore","beforeMiddlewares","useBefore","UseAuth","useDecorators","StoreFn","has","UseBeforeEach","decoratorArgs","getMiddlewaresForHook","hook","settings","defaultHook","env","map","middleware","isFunction"],"mappings":";;;;AAEA;;;;;;;SAMgBA;AACd,SAAOC,UAAU,CAAC;AAChBC,IAAAA,IAAI,EAAEC,YAAY,CAACC;AADH,GAAD,CAAjB;AAGD;;ACsBD;;;;;;;;;;;;;;;;;;;;;;SAqBgBC,YAAYC,WAAsBC,UAAwB;AACxE,SAAO,CAAI,GAAGC,IAAP;AACL,YAAQC,eAAe,CAACD,IAAD,CAAvB;AACE,WAAKE,cAAc,CAACC,MAApB;AACE,eAAOC,YAAY,CAAEC,MAAD;AAClB,gBAAMC,KAAK,GAAGD,MAAM,CAACC,KAArB;;AAEA,cAAIP,OAAO,CAACQ,SAAZ,EAAuB;AACrB,kBAAM;AAACA,cAAAA;AAAD,gBAAcR,OAApB;AACAO,YAAAA,KAAK,CAACE,KAAN,CAAY,WAAZ,EAAyBD,SAAzB,EAAoC,IAApC;AACA,mBAAOR,OAAO,CAACQ,SAA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P;;AAEF,WAAKlD,cAAc,CAACgB,KAApB;AACEC,QAAAA,iBAAiB,CAACiC,aAAa,CAAC,CAAD,CAAd,EAAmBR,SAAS,CAAC,GAAG5C,IAAJ,CAA5B,CAAjB;AACA;;AAEF;AACE,cAAM,IAAIoB,wBAAJ,CAA6B+B,aAA7B,EAA4CC,aAA5C,CAAN;AATJ;AAWD,GAZD;AAaD;;SClCeC,sBAAsBC,MAAcC,UAA8BC,WAAW,GAAG;AAC9F,QAAM;AAACC,IAAAA,GAAD;AAAM/B,IAAAA,WAAW,GAAG;AAApB,MAA0B6B,QAAhC;AAEA,SAAO7B,WAAW,CACfgC,GADI,CACmCC,UAAD;AACrC,WAAOC,UAAU,CAACD,UAAD,CAAV,GACH;AACEF,MAAAA,GADF;AAEEH,MAAAA,IAAI,EAAEE,WAFR;AAGEnB,MAAAA,GAAG,EAAEsB;AAHP,KADG;AAODF,MAAAA,GAPC;AAQDH,MAAAA,IAAI,EAAEE;AARL,OASEG,UATF,CAAP;AAWD,GAbI,EAcJhC,MAdI,CAcI5B,OAAD;AACN,WAAOA,OAAO,CAACsC,GAAR,IAAetC,OAAO,CAAC0D,GAAR,KAAgBA,GAA/B,IAAsC1D,OAAO,CAACuD,IAAR,KAAiBA,IAA9D;AACD,GAhBI,CAAP;AAiBD;;;;"}
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/decorators/middleware.ts","../src/decorators/authOptions.ts","../src/constants/index.ts","../src/utils/mapUseOptions.ts","../src/decorators/use.ts","../src/decorators/useAfter.ts","../src/decorators/useBefore.ts","../src/decorators/useAuth.ts","../src/decorators/useBeforeEach.ts","../src/utils/getMiddlewaresForHook.ts"],"sourcesContent":["import {Injectable, ProviderType} from \"@tsed/di\";\n\n/**\n * Register a new Middleware class.\n *\n * @decorator\n * @classDecorator\n */\nexport function Middleware(): ClassDecorator {\n return Injectable({\n type: ProviderType.MIDDLEWARE\n });\n}\n","import {\n decorateMethodsOf,\n DecoratorMethodParameters,\n DecoratorParameters,\n decoratorTypeOf,\n DecoratorTypes,\n Type,\n UnsupportedDecoratorType\n} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Change authentication options.\n *\n * ```typescript\n * @Controller('/mypath')\n * @UseAuth(MyAuthStrategy, {role: ''})\n * class MyCtrl {\n *\n * @Get('/')\n * @AuthOptions(MyAuthStrategy, {role: 'admin'})\n * public getResource(){}\n * }\n * ```\n *\n * @param guardAuth\n * @param options {Object} Object passed to the customer auth strategy\n * @returns {Function}\n * @decorator\n * @decorator\n * @operation\n */\nexport function AuthOptions(guardAuth: Type<any>, options: Record<string, unknown> = {}): Function {\n return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.METHOD:\n return JsonEntityFn((entity) => {\n const store = entity.store;\n\n store.merge(guardAuth, options, true);\n })(...(args as DecoratorMethodParameters));\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], AuthOptions(guardAuth, options));\n break;\n\n default:\n throw new UnsupportedDecoratorType(AuthOptions, args);\n }\n };\n}\n","export const HTTP_METHODS = [\n \"all\",\n \"checkout\",\n \"connect\",\n \"copy\",\n \"delete\",\n \"get\",\n \"head\",\n \"lock\",\n \"merge\",\n \"mkactivity\",\n \"mkcol\",\n \"move\",\n \"m-search\",\n \"notify\",\n \"options\",\n \"param\",\n \"patch\",\n \"post\",\n \"propfind\",\n \"propatch\",\n \"purge\",\n \"put\",\n \"report\",\n \"search\",\n \"subscribe\",\n \"trace\",\n \"unlock\",\n \"unsuscribe\"\n];\n","import {HTTP_METHODS} from \"../constants\";\n\nexport function mapUseOptions(args: any[]) {\n let method: string | undefined = undefined;\n let path: string | RegExp | undefined = undefined;\n\n const middlewares = args.filter((arg: any) => {\n if (typeof arg === \"string\" && HTTP_METHODS.includes(arg)) {\n method = arg;\n\n return false;\n }\n\n if (typeof arg === \"string\" || arg instanceof RegExp) {\n path = arg ? arg : \"/\";\n\n return false;\n }\n\n return !!arg;\n });\n\n return {\n path,\n method,\n middlewares\n };\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn, OperationMethods, OperationPath} from \"@tsed/schema\";\nimport {mapUseOptions} from \"../utils/mapUseOptions\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @Use(Middleware1)\n * export class Ctrl {\n *\n * @Get('/')\n * @Use(Middleware2)\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param args\n * @decorator\n * @operation\n */\nexport function Use(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n const options = mapUseOptions(args);\n\n options.path && OperationPath(options.method || OperationMethods.CUSTOM, options.path)(...parameters);\n\n entity.use(args);\n break;\n\n case DecoratorTypes.CLASS:\n entity.store.merge(\"middlewares\", {\n use: args\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(Use, parameters);\n }\n });\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseAfter(Middleware1)\n * export class Ctrl {\n *\n * @Get('/')\n * @UseAfter(Middleware2)\n * get() { }\n * }\n * ```\n *\n * @returns {function(any, any, any): *}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseAfter(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n const endpoint = entity;\n endpoint.afterMiddlewares = args.concat(endpoint.afterMiddlewares);\n\n break;\n\n case DecoratorTypes.CLASS:\n const middlewares = entity.store.get(\"middlewares\") || {};\n\n entity.store.set(\"middlewares\", {\n ...middlewares,\n useAfter: [...args, ...(middlewares.useAfter || [])]\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseAfter, parameters);\n }\n });\n}\n","import {DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {JsonEntityFn} from \"@tsed/schema\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseBefore(Middleware1) // called only one time before all endpoint\n * export class Ctrl {\n *\n * @Get('/')\n * @UseBefore(Middleware2)\n * get() { }\n * }\n * ```\n *\n * @returns {function(any, any, any): *}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseBefore(...args: any[]): Function {\n return JsonEntityFn((entity, parameters) => {\n switch (entity.decoratorType) {\n case DecoratorTypes.METHOD:\n entity.beforeMiddlewares = args.concat(entity.beforeMiddlewares);\n\n break;\n\n case DecoratorTypes.CLASS:\n const middlewares = entity.store.get(\"middlewares\") || {};\n\n entity.store.set(\"middlewares\", {\n ...middlewares,\n useBefore: [...args, ...(middlewares.useBefore || [])]\n });\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseBefore, parameters);\n }\n });\n}\n","import {\n decorateMethodsOf,\n DecoratorParameters,\n decoratorTypeOf,\n DecoratorTypes,\n Store,\n StoreFn,\n Type,\n UnsupportedDecoratorType,\n useDecorators\n} from \"@tsed/core\";\nimport {AuthOptions} from \"./authOptions\";\nimport {UseBefore} from \"./useBefore\";\n\n/**\n * Use custom authentication strategy on your endpoint.\n *\n * ```typescript\n * @Controller('/mypath')\n * @UseAuth(MyAuthStrategy)\n * class MyCtrl {\n *\n * @Get('/')\n * @UseAuth(MyAuthStrategy, {role: 'admin'})\n * public getResource(){}\n * }\n * ```\n *\n * @param guardAuth {Type<any>} A middleware which implement a custom auth strategy\n * @param options {Object} Object passed to the customer auth strategy\n * @returns {Function}\n * @decorator\n * @operation\n */\nexport function UseAuth(guardAuth: Type<any>, options: Record<string, unknown> = {}): Function {\n return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.METHOD:\n return useDecorators(\n StoreFn((store: Store) => {\n if (!store.has(guardAuth)) {\n return UseBefore(guardAuth);\n }\n }),\n AuthOptions(guardAuth, options)\n )(...args);\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(args[0], UseAuth(guardAuth, options));\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseAuth, args);\n }\n };\n}\n","import {decorateMethodsOf, DecoratorParameters, decoratorTypeOf, DecoratorTypes, UnsupportedDecoratorType} from \"@tsed/core\";\nimport {UseBefore} from \"./useBefore\";\n\n/**\n * Mounts the specified middleware function or functions at the specified path: the middleware function is executed when\n * the base of the requested path matches `path.\n *\n * ```typescript\n * @Controller('/')\n * @UseBeforeEach(Middleware1) // Called before each endpoint\n * export class Ctrl {\n *\n * @Get('/')\n * get() { }\n * }\n *\n * ```\n *\n * @returns {Function}\n * @param args\n * @decorator\n * @operation\n */\nexport function UseBeforeEach(...args: any[]): Function {\n return <T>(...decoratorArgs: DecoratorParameters): TypedPropertyDescriptor<T> | void => {\n switch (decoratorTypeOf(decoratorArgs)) {\n case DecoratorTypes.METHOD:\n return UseBefore(...args)(...decoratorArgs);\n\n case DecoratorTypes.CLASS:\n decorateMethodsOf(decoratorArgs[0], UseBefore(...args));\n break;\n\n default:\n throw new UnsupportedDecoratorType(UseBeforeEach, decoratorArgs);\n }\n };\n}\n","import {isFunction} from \"@tsed/core\";\nimport {PlatformMiddlewareLoadingOptions} from \"../domain/PlatformMiddlewareSettings\";\n\nexport function getMiddlewaresForHook(hook: string, settings: TsED.Configuration, defaultHook = \"\") {\n const {env, middlewares = []} = settings;\n\n return middlewares\n .map<PlatformMiddlewareLoadingOptions>((middleware) => {\n return isFunction(middleware)\n ? {\n env,\n hook: defaultHook,\n use: middleware\n }\n : {\n env,\n hook: defaultHook,\n ...middleware\n };\n })\n .filter((options) => {\n return options.use && options.env === env && options.hook === hook;\n });\n}\n"],"names":["Middleware","Injectable","type","ProviderType","MIDDLEWARE","AuthOptions","guardAuth","options","args","decoratorTypeOf","DecoratorTypes","METHOD","JsonEntityFn","entity","store","merge","CLASS","decorateMethodsOf","UnsupportedDecoratorType","HTTP_METHODS","mapUseOptions","method","undefined","path","middlewares","filter","arg","includes","RegExp","Use","parameters","decoratorType","OperationPath","OperationMethods","CUSTOM","use","UseAfter","endpoint","afterMiddlewares","concat","get","set","useAfter","UseBefore","beforeMiddlewares","useBefore","UseAuth","useDecorators","StoreFn","has","UseBeforeEach","decoratorArgs","getMiddlewaresForHook","hook","settings","defaultHook","env","map","middleware","isFunction"],"mappings":";;;;AAEA;;;;;;;SAMgBA;AACd,SAAOC,UAAU,CAAC;AAChBC,IAAAA,IAAI,EAAEC,YAAY,CAACC;AADH,GAAD,CAAjB;AAGD;;ACDD;;;;;;;;;;;;;;;;;;;;;;SAqBgBC,YAAYC,WAAsBC,UAAmC;AACnF,SAAO,CAAI,GAAGC,IAAP;AACL,YAAQC,eAAe,CAACD,IAAD,CAAvB;AACE,WAAKE,cAAc,CAACC,MAApB;AACE,eAAOC,YAAY,CAAEC,MAAD;AAClB,gBAAMC,KAAK,GAAGD,MAAM,CAACC,KAArB;AAEAA,UAAAA,KAAK,CAACC,KAAN,CAAYT,SAAZ,EAAuBC,OAAvB,EAAgC,IAAhC;AACD,SAJkB,CAAZ,CAIJ,GAAIC,IAJA,CAAP;;AAMF,WAAKE,cAAc,CAACM,KAApB;AACEC,QAAAA,iBAAiB,CAACT,IAAI,CAAC,CAAD,CAAL,EAAUH,WAAW,CAACC,SAAD,EAAYC,OAAZ,CAArB,CAAjB;AACA;;AAEF;AACE,cAAM,IAAIW,wBAAJ,CAA6Bb,WAA7B,EAA0CG,IAA1C,CAAN;AAbJ;AAeD,GAhBD;AAiBD;;AClDM,MAAMW,YAAY,GAAG,CAC1B,KAD0B,EAE1B,UAF0B,EAG1B,SAH0B,EAI1B,MAJ0B,EAK1B,QAL0B,EAM1B,KAN0B,E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-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.1",
|
|
4
4
|
"description": "Middlewares module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -17,20 +17,20 @@
|
|
|
17
17
|
"tslib": "2.2.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@tsed/core": "
|
|
21
|
-
"@tsed/di": "
|
|
22
|
-
"@tsed/schema": "
|
|
20
|
+
"@tsed/core": "7.0.0-alpha.1",
|
|
21
|
+
"@tsed/di": "7.0.0-alpha.1",
|
|
22
|
+
"@tsed/schema": "7.0.0-alpha.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@tsed/core": "^
|
|
26
|
-
"@tsed/di": "^
|
|
27
|
-
"@tsed/schema": "^
|
|
25
|
+
"@tsed/core": "^7.0.0-alpha.1",
|
|
26
|
+
"@tsed/di": "^7.0.0-alpha.1",
|
|
27
|
+
"@tsed/schema": "^7.0.0-alpha.1"
|
|
28
28
|
},
|
|
29
29
|
"repository": "https://github.com/tsedio/tsed",
|
|
30
30
|
"bugs": {
|
|
31
31
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
32
32
|
},
|
|
33
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
33
|
+
"homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/platform/platform-middlewares",
|
|
34
34
|
"author": "Romain Lenzotti",
|
|
35
35
|
"license": "MIT"
|
|
36
36
|
}
|