@tsed/platform-middlewares 6.97.2 → 7.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/decorators/authOptions.js +0 -14
- package/lib/cjs/decorators/authOptions.js.map +1 -1
- package/lib/cjs/decorators/useAuth.js.map +1 -1
- package/lib/cjs/domain/MiddlewareMethods.js.map +1 -1
- package/lib/esm/decorators/authOptions.js +0 -14
- package/lib/esm/decorators/authOptions.js.map +1 -1
- package/lib/esm/decorators/useAuth.js.map +1 -1
- package/lib/esm/domain/MiddlewareMethods.js.map +1 -1
- package/lib/types/decorators/authOptions.d.ts +1 -20
- package/lib/types/decorators/useAuth.d.ts +1 -2
- package/lib/types/domain/MiddlewareMethods.d.ts +0 -5
- package/package.json +8 -8
|
@@ -30,20 +30,6 @@ function AuthOptions(guardAuth, options = {}) {
|
|
|
30
30
|
case core_1.DecoratorTypes.METHOD:
|
|
31
31
|
return (0, schema_1.JsonEntityFn)((entity) => {
|
|
32
32
|
const store = entity.store;
|
|
33
|
-
if (options.responses) {
|
|
34
|
-
const { responses } = options;
|
|
35
|
-
store.merge("responses", responses, true);
|
|
36
|
-
delete options.responses;
|
|
37
|
-
}
|
|
38
|
-
if (options.security) {
|
|
39
|
-
const { security } = options;
|
|
40
|
-
[].concat(security).forEach((security) => {
|
|
41
|
-
Object.entries(security).forEach(([name, scopes]) => {
|
|
42
|
-
entity.operation.addSecurityScopes(name, scopes);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
delete options.security;
|
|
46
|
-
}
|
|
47
33
|
store.merge(guardAuth, options, true);
|
|
48
34
|
})(...args);
|
|
49
35
|
case core_1.DecoratorTypes.CLASS:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authOptions.js","sourceRoot":"","sources":["../../../src/decorators/authOptions.ts"],"names":[],"mappings":";;;AAAA,qCAQoB;AACpB,yCAA0C;
|
|
1
|
+
{"version":3,"file":"authOptions.js","sourceRoot":"","sources":["../../../src/decorators/authOptions.ts"],"names":[],"mappings":";;;AAAA,qCAQoB;AACpB,yCAA0C;AAE1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,WAAW,CAAC,SAAoB,EAAE,UAAmC,EAAE;IACrF,OAAO,CAAI,GAAG,IAAyB,EAAqC,EAAE;QAC5E,QAAQ,IAAA,sBAAe,EAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,qBAAc,CAAC,MAAM;gBACxB,OAAO,IAAA,qBAAY,EAAC,CAAC,MAAM,EAAE,EAAE;oBAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;oBAE3B,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;gBACxC,CAAC,CAAC,CAAC,GAAI,IAAkC,CAAC,CAAC;YAE7C,KAAK,qBAAc,CAAC,KAAK;gBACvB,IAAA,wBAAiB,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;gBAC5D,MAAM;YAER;gBACE,MAAM,IAAI,+BAAwB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;SACzD;IACH,CAAC,CAAC;AACJ,CAAC;AAlBD,kCAkBC","sourcesContent":["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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../../src/decorators/useAuth.ts"],"names":[],"mappings":";;;AAAA,qCAUoB;AACpB,+
|
|
1
|
+
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../../src/decorators/useAuth.ts"],"names":[],"mappings":";;;AAAA,qCAUoB;AACpB,+CAA0C;AAC1C,2CAAsC;AAEtC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,OAAO,CAAC,SAAoB,EAAE,UAAmC,EAAE;IACjF,OAAO,CAAI,GAAG,IAAyB,EAAqC,EAAE;QAC5E,QAAQ,IAAA,sBAAe,EAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,qBAAc,CAAC,MAAM;gBACxB,OAAO,IAAA,oBAAa,EAClB,IAAA,cAAO,EAAC,CAAC,KAAY,EAAE,EAAE;oBACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;wBACzB,OAAO,IAAA,qBAAS,EAAC,SAAS,CAAC,CAAC;qBAC7B;gBACH,CAAC,CAAC,EACF,IAAA,yBAAW,EAAC,SAAS,EAAE,OAAO,CAAC,CAChC,CAAC,GAAG,IAAI,CAAC,CAAC;YAEb,KAAK,qBAAc,CAAC,KAAK;gBACvB,IAAA,wBAAiB,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;gBACxD,MAAM;YAER;gBACE,MAAM,IAAI,+BAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACrD;IACH,CAAC,CAAC;AACJ,CAAC;AArBD,0BAqBC","sourcesContent":["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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddlewareMethods.js","sourceRoot":"","sources":["../../../src/domain/MiddlewareMethods.ts"],"names":[],"mappings":"","sourcesContent":["export interface MiddlewareMethods {\n use(...args: any[]): void | any | Promise<any>;\n}\n
|
|
1
|
+
{"version":3,"file":"MiddlewareMethods.js","sourceRoot":"","sources":["../../../src/domain/MiddlewareMethods.ts"],"names":[],"mappings":"","sourcesContent":["export interface MiddlewareMethods {\n use(...args: any[]): void | any | Promise<any>;\n}\n"]}
|
|
@@ -27,20 +27,6 @@ export function AuthOptions(guardAuth, options = {}) {
|
|
|
27
27
|
case DecoratorTypes.METHOD:
|
|
28
28
|
return JsonEntityFn((entity) => {
|
|
29
29
|
const store = entity.store;
|
|
30
|
-
if (options.responses) {
|
|
31
|
-
const { responses } = options;
|
|
32
|
-
store.merge("responses", responses, true);
|
|
33
|
-
delete options.responses;
|
|
34
|
-
}
|
|
35
|
-
if (options.security) {
|
|
36
|
-
const { security } = options;
|
|
37
|
-
[].concat(security).forEach((security) => {
|
|
38
|
-
Object.entries(security).forEach(([name, scopes]) => {
|
|
39
|
-
entity.operation.addSecurityScopes(name, scopes);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
delete options.security;
|
|
43
|
-
}
|
|
44
30
|
store.merge(guardAuth, options, true);
|
|
45
31
|
})(...args);
|
|
46
32
|
case DecoratorTypes.CLASS:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authOptions.js","sourceRoot":"","sources":["../../../src/decorators/authOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,eAAe,EACf,cAAc,EAEd,wBAAwB,EACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"authOptions.js","sourceRoot":"","sources":["../../../src/decorators/authOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,eAAe,EACf,cAAc,EAEd,wBAAwB,EACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CAAC,SAAoB,EAAE,UAAmC,EAAE;IACrF,OAAO,CAAI,GAAG,IAAyB,EAAqC,EAAE;QAC5E,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,MAAM;gBACxB,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;oBAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;oBAE3B,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;gBACxC,CAAC,CAAC,CAAC,GAAI,IAAkC,CAAC,CAAC;YAE7C,KAAK,cAAc,CAAC,KAAK;gBACvB,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;gBAC5D,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;SACzD;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../../src/decorators/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,eAAe,EACf,cAAc,EAEd,OAAO,EAEP,wBAAwB,EACxB,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"useAuth.js","sourceRoot":"","sources":["../../../src/decorators/useAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAEjB,eAAe,EACf,cAAc,EAEd,OAAO,EAEP,wBAAwB,EACxB,aAAa,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CAAC,SAAoB,EAAE,UAAmC,EAAE;IACjF,OAAO,CAAI,GAAG,IAAyB,EAAqC,EAAE;QAC5E,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,MAAM;gBACxB,OAAO,aAAa,CAClB,OAAO,CAAC,CAAC,KAAY,EAAE,EAAE;oBACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;wBACzB,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC;qBAC7B;gBACH,CAAC,CAAC,EACF,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAChC,CAAC,GAAG,IAAI,CAAC,CAAC;YAEb,KAAK,cAAc,CAAC,KAAK;gBACvB,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;gBACxD,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SACrD;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddlewareMethods.js","sourceRoot":"","sources":["../../../src/domain/MiddlewareMethods.ts"],"names":[],"mappings":"","sourcesContent":["export interface MiddlewareMethods {\n use(...args: any[]): void | any | Promise<any>;\n}\n
|
|
1
|
+
{"version":3,"file":"MiddlewareMethods.js","sourceRoot":"","sources":["../../../src/domain/MiddlewareMethods.ts"],"names":[],"mappings":"","sourcesContent":["export interface MiddlewareMethods {\n use(...args: any[]): void | any | Promise<any>;\n}\n"]}
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/platform-middlewares",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.2",
|
|
4
4
|
"description": "Middlewares module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
"tslib": "2.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@tsed/core": "
|
|
25
|
-
"@tsed/di": "
|
|
26
|
-
"@tsed/schema": "
|
|
24
|
+
"@tsed/core": "7.0.0-beta.2",
|
|
25
|
+
"@tsed/di": "7.0.0-beta.2",
|
|
26
|
+
"@tsed/schema": "7.0.0-beta.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@tsed/core": "^
|
|
30
|
-
"@tsed/di": "^
|
|
31
|
-
"@tsed/schema": "^
|
|
29
|
+
"@tsed/core": "^7.0.0-beta.2",
|
|
30
|
+
"@tsed/di": "^7.0.0-beta.2",
|
|
31
|
+
"@tsed/schema": "^7.0.0-beta.2"
|
|
32
32
|
},
|
|
33
33
|
"repository": "https://github.com/tsedio/tsed",
|
|
34
34
|
"bugs": {
|
|
35
35
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
36
36
|
},
|
|
37
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
37
|
+
"homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/platform/platform-middlewares",
|
|
38
38
|
"author": "Romain Lenzotti",
|
|
39
39
|
"license": "MIT"
|
|
40
40
|
}
|