@nestjs-kitchen/authz 2.0.3 → 2.0.4
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/authz.provider.d.ts +1 -3
- package/dist/authz.provider.js +27 -43
- package/dist/constants.d.ts +6 -8
- package/dist/constants.js +13 -46
- package/dist/errors.d.ts +3 -5
- package/dist/errors.js +29 -44
- package/dist/index.d.ts +5 -21
- package/dist/index.js +16 -45
- package/dist/jwt/extract-jwt.d.ts +4 -7
- package/dist/jwt/extract-jwt.js +136 -152
- package/dist/jwt/index.d.ts +2 -16
- package/dist/jwt/index.js +7 -30
- package/dist/jwt/jwt-authz-als.middleware.d.ts +6 -16
- package/dist/jwt/jwt-authz-als.middleware.js +40 -60
- package/dist/jwt/jwt-authz.guard.d.ts +8 -21
- package/dist/jwt/jwt-authz.guard.js +126 -148
- package/dist/jwt/jwt-authz.interface.d.ts +16 -25
- package/dist/jwt/jwt-authz.interface.js +66 -114
- package/dist/jwt/jwt-authz.module.d.ts +19 -31
- package/dist/jwt/jwt-authz.module.js +240 -242
- package/dist/jwt/jwt-authz.service.d.ts +6 -17
- package/dist/jwt/jwt-authz.service.js +113 -144
- package/dist/jwt/jwt-authz.strategy.d.ts +5 -17
- package/dist/jwt/jwt-authz.strategy.js +127 -150
- package/dist/session/index.d.ts +1 -12
- package/dist/session/index.js +5 -27
- package/dist/session/session-authz-als.middleware.d.ts +5 -12
- package/dist/session/session-authz-als.middleware.js +95 -109
- package/dist/session/session-authz.guard.d.ts +6 -15
- package/dist/session/session-authz.guard.js +96 -116
- package/dist/session/session-authz.interface.d.ts +5 -12
- package/dist/session/session-authz.interface.js +18 -40
- package/dist/session/session-authz.module.d.ts +18 -26
- package/dist/session/session-authz.module.js +231 -237
- package/dist/session/session-authz.service.d.ts +5 -13
- package/dist/session/session-authz.service.js +66 -83
- package/dist/session/session-authz.strategy.d.ts +4 -12
- package/dist/session/session-authz.strategy.js +65 -78
- package/dist/user.decorator.d.ts +3 -6
- package/dist/user.decorator.js +25 -33
- package/dist/utils/cookie-parsers.d.ts +3 -6
- package/dist/utils/cookie-parsers.js +62 -63
- package/dist/utils/create-authz-decorator-factory.d.ts +3 -9
- package/dist/utils/create-authz-decorator-factory.js +29 -50
- package/dist/utils/create-set-cookie-fn.d.ts +3 -9
- package/dist/utils/create-set-cookie-fn.js +21 -42
- package/dist/utils/generics.d.ts +4 -6
- package/dist/utils/generics.js +31 -54
- package/dist/utils/get-allow-anonymous.d.ts +2 -9
- package/dist/utils/get-allow-anonymous.js +6 -27
- package/dist/utils/get-als-store.d.ts +2 -5
- package/dist/utils/get-als-store.js +10 -32
- package/dist/utils/get-context-authz-meta-params-list.d.ts +2 -9
- package/dist/utils/get-context-authz-meta-params-list.js +15 -33
- package/dist/utils/get-passport-property.d.ts +1 -3
- package/dist/utils/get-passport-property.js +7 -28
- package/dist/utils/index.d.ts +11 -16
- package/dist/utils/index.js +26 -40
- package/dist/utils/merge-dynamic-module-configs.d.ts +2 -5
- package/dist/utils/merge-dynamic-module-configs.js +13 -38
- package/dist/utils/msgpackrs.d.ts +2 -4
- package/dist/utils/msgpackrs.js +9 -32
- package/dist/utils/types.d.ts +23 -26
- package/dist/utils/types.js +2 -15
- package/package.json +4 -4
|
@@ -1,40 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var merge_dynamic_module_configs_exports = {};
|
|
19
|
-
__export(merge_dynamic_module_configs_exports, {
|
|
20
|
-
mergeDynamicModuleConfigs: () => mergeDynamicModuleConfigs
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(merge_dynamic_module_configs_exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeDynamicModuleConfigs = void 0;
|
|
23
4
|
const mergeDynamicModuleConfigs = (...configs) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{}
|
|
34
|
-
);
|
|
35
|
-
return merged;
|
|
5
|
+
const merged = configs.reduce((acc, curr) => ({
|
|
6
|
+
global: acc?.global || curr?.global,
|
|
7
|
+
module: acc?.module || curr?.module,
|
|
8
|
+
imports: [...(acc?.imports || []), ...(curr?.imports || [])],
|
|
9
|
+
controllers: [...(acc?.controllers || []), ...(curr?.controllers || [])],
|
|
10
|
+
providers: [...(acc?.providers || []), ...(curr?.providers || [])],
|
|
11
|
+
exports: [...(acc?.exports || []), ...(curr?.exports || [])]
|
|
12
|
+
}), {});
|
|
13
|
+
return merged;
|
|
36
14
|
};
|
|
37
|
-
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
mergeDynamicModuleConfigs
|
|
40
|
-
});
|
|
15
|
+
exports.mergeDynamicModuleConfigs = mergeDynamicModuleConfigs;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
declare const encodeMsgpackrString: <T extends object>(payload: T) => string;
|
|
2
|
-
declare const decodeMsgpackrString: <T extends object>(msgpackrString: string) => T;
|
|
3
|
-
|
|
4
|
-
export { decodeMsgpackrString, encodeMsgpackrString };
|
|
1
|
+
export declare const encodeMsgpackrString: <T extends object>(payload: T) => string;
|
|
2
|
+
export declare const decodeMsgpackrString: <T extends object>(msgpackrString: string) => T;
|
package/dist/utils/msgpackrs.js
CHANGED
|
@@ -1,36 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var msgpackrs_exports = {};
|
|
19
|
-
__export(msgpackrs_exports, {
|
|
20
|
-
decodeMsgpackrString: () => decodeMsgpackrString,
|
|
21
|
-
encodeMsgpackrString: () => encodeMsgpackrString
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(msgpackrs_exports);
|
|
24
|
-
var import_msgpackr = require("msgpackr");
|
|
25
|
-
const packr = new import_msgpackr.Packr();
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeMsgpackrString = exports.encodeMsgpackrString = void 0;
|
|
4
|
+
const msgpackr_1 = require("msgpackr");
|
|
5
|
+
const packr = new msgpackr_1.Packr();
|
|
26
6
|
const encodeMsgpackrString = (payload) => {
|
|
27
|
-
|
|
7
|
+
return Buffer.from(packr.pack(payload)).toString('base64');
|
|
28
8
|
};
|
|
9
|
+
exports.encodeMsgpackrString = encodeMsgpackrString;
|
|
29
10
|
const decodeMsgpackrString = (msgpackrString) => {
|
|
30
|
-
|
|
11
|
+
return packr.unpack(Buffer.from(msgpackrString, 'base64'));
|
|
31
12
|
};
|
|
32
|
-
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
decodeMsgpackrString,
|
|
35
|
-
encodeMsgpackrString
|
|
36
|
-
});
|
|
13
|
+
exports.decodeMsgpackrString = decodeMsgpackrString;
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import { applyDecorators } from '@nestjs/common';
|
|
2
|
-
import {
|
|
3
|
-
import { CookieOptions } from 'express';
|
|
4
|
-
import { AuthzProviderClass } from '../authz.provider
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
type SetRequired<T, K extends keyof T> = T & {
|
|
1
|
+
import type { applyDecorators } from '@nestjs/common';
|
|
2
|
+
import type { RouteInfo, Type } from '@nestjs/common/interfaces';
|
|
3
|
+
import type { CookieOptions } from 'express';
|
|
4
|
+
import type { AuthzProviderClass } from '../authz.provider';
|
|
5
|
+
export type OmitClassInstance<T extends abstract new (...args: any) => any, K extends keyof any> = Type<Omit<InstanceType<T>, K>>;
|
|
6
|
+
export type SetRequired<T, K extends keyof T> = T & {
|
|
8
7
|
[P in K]-?: NonNullable<T[P]>;
|
|
9
8
|
};
|
|
10
|
-
type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2 ? true : false;
|
|
11
|
-
type IsNull<T> = [T] extends [null] ? true : false;
|
|
12
|
-
type IsUnknown<T> = unknown extends T ? IsNull<T> extends false ? true : false : false;
|
|
13
|
-
type DeepReadonly<T> = {
|
|
9
|
+
export type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2 ? true : false;
|
|
10
|
+
export type IsNull<T> = [T] extends [null] ? true : false;
|
|
11
|
+
export type IsUnknown<T> = unknown extends T ? IsNull<T> extends false ? true : false : false;
|
|
12
|
+
export type DeepReadonly<T> = {
|
|
14
13
|
readonly [K in keyof T]: T[K] extends object ? DeepReadonly<T[K]> : T[K];
|
|
15
14
|
};
|
|
16
|
-
type CookieOptionsWithSecret = CookieOptions & {
|
|
15
|
+
export type CookieOptionsWithSecret = CookieOptions & {
|
|
17
16
|
/**
|
|
18
17
|
* a string or array used to sign cookies.
|
|
19
18
|
*/
|
|
20
19
|
secret?: string | string[];
|
|
21
20
|
};
|
|
22
|
-
interface AuthzDecoBaseOptions {
|
|
21
|
+
export interface AuthzDecoBaseOptions {
|
|
23
22
|
/**
|
|
24
23
|
* When set, overrides the previous metadatas during the authorization, instead of inheriting.
|
|
25
24
|
*/
|
|
@@ -29,19 +28,19 @@ interface AuthzDecoBaseOptions {
|
|
|
29
28
|
*/
|
|
30
29
|
allowAnonymous?: boolean;
|
|
31
30
|
}
|
|
32
|
-
interface AuthzDecoOptions extends AuthzDecoBaseOptions {
|
|
31
|
+
export interface AuthzDecoOptions extends AuthzDecoBaseOptions {
|
|
33
32
|
public?: boolean;
|
|
34
33
|
}
|
|
35
|
-
interface AuthzMetaParams {
|
|
34
|
+
export interface AuthzMetaParams {
|
|
36
35
|
metaData?: unknown;
|
|
37
36
|
options?: AuthzDecoOptions;
|
|
38
37
|
}
|
|
39
|
-
type AuthzDecoParams<MetaData> = IsUnknown<MetaData> extends false ? IncludesUndefined<MetaData> extends false ? [metaData: MetaData, options?: AuthzDecoBaseOptions] : IsEqual<MetaData, undefined> extends false ? [metaData?: MetaData, options?: AuthzDecoBaseOptions] : [options?: AuthzDecoBaseOptions] : [options?: AuthzDecoBaseOptions];
|
|
40
|
-
type SingleOrArray<T> = T | T[];
|
|
41
|
-
type IncludesUndefined<T> = undefined extends T ? true : false;
|
|
42
|
-
type AbstractConstructor<T, T1, T2> = new (...args: any[]) => T & AuthzProviderClass<T1, T2>;
|
|
43
|
-
type MethodParameters<T, Method extends keyof T> = T[Method] extends (...args: infer P) => any ? P : never;
|
|
44
|
-
interface AuthzModuleBaseOptions {
|
|
38
|
+
export type AuthzDecoParams<MetaData> = IsUnknown<MetaData> extends false ? IncludesUndefined<MetaData> extends false ? [metaData: MetaData, options?: AuthzDecoBaseOptions] : IsEqual<MetaData, undefined> extends false ? [metaData?: MetaData, options?: AuthzDecoBaseOptions] : [options?: AuthzDecoBaseOptions] : [options?: AuthzDecoBaseOptions];
|
|
39
|
+
export type SingleOrArray<T> = T | T[];
|
|
40
|
+
export type IncludesUndefined<T> = undefined extends T ? true : false;
|
|
41
|
+
export type AbstractConstructor<T, T1, T2> = new (...args: any[]) => T & AuthzProviderClass<T1, T2>;
|
|
42
|
+
export type MethodParameters<T, Method extends keyof T> = T[Method] extends (...args: infer P) => any ? P : never;
|
|
43
|
+
export interface AuthzModuleBaseOptions {
|
|
45
44
|
/**
|
|
46
45
|
* Property name for registering authenticated user on the HTTP request object.
|
|
47
46
|
*
|
|
@@ -67,7 +66,7 @@ interface AuthzModuleBaseOptions {
|
|
|
67
66
|
*/
|
|
68
67
|
defaultAllowAnonymous: boolean;
|
|
69
68
|
}
|
|
70
|
-
type AuthzModuleRoutesOptions = {
|
|
69
|
+
export type AuthzModuleRoutesOptions = {
|
|
71
70
|
/**
|
|
72
71
|
* When enabled, becomes a global module and will apply strategy to all routes in the application.
|
|
73
72
|
*
|
|
@@ -87,11 +86,9 @@ type AuthzModuleRoutesOptions = {
|
|
|
87
86
|
*/
|
|
88
87
|
excludes?: SingleOrArray<string | RouteInfo>;
|
|
89
88
|
};
|
|
90
|
-
type RoutesOptions = {
|
|
89
|
+
export type RoutesOptions = {
|
|
91
90
|
global: boolean;
|
|
92
91
|
routes: (string | Type | RouteInfo)[];
|
|
93
92
|
excludes: (string | RouteInfo)[];
|
|
94
93
|
};
|
|
95
|
-
type ApplyDecorators = ReturnType<typeof applyDecorators>;
|
|
96
|
-
|
|
97
|
-
export type { AbstractConstructor, ApplyDecorators, AuthzDecoBaseOptions, AuthzDecoOptions, AuthzDecoParams, AuthzMetaParams, AuthzModuleBaseOptions, AuthzModuleRoutesOptions, CookieOptionsWithSecret, DeepReadonly, IncludesUndefined, IsEqual, IsNull, IsUnknown, MethodParameters, OmitClassInstance, RoutesOptions, SetRequired, SingleOrArray };
|
|
94
|
+
export type ApplyDecorators = ReturnType<typeof applyDecorators>;
|
package/dist/utils/types.js
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
-
var types_exports = {};
|
|
15
|
-
module.exports = __toCommonJS(types_exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nestjs-kitchen/authz",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "Simplest authentication & authorization module in NextJS",
|
|
5
|
-
"version": "2.0.
|
|
5
|
+
"version": "2.0.4",
|
|
6
6
|
"homepage": "https://github.com/yikenman/nestjs-kitchen",
|
|
7
7
|
"repository": "https://github.com/yikenman/nestjs-kitchen",
|
|
8
8
|
"author": "yikenman",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"@types/passport": "^1.0.17",
|
|
38
38
|
"@types/supertest": "^6.0.2",
|
|
39
39
|
"jest": "^29.7.0",
|
|
40
|
+
"rimraf": "^6.0.1",
|
|
40
41
|
"supertest": "^7.1.0",
|
|
41
42
|
"ts-jest": "^29.3.0",
|
|
42
43
|
"ts-node": "^10.9.2",
|
|
43
44
|
"tsconfig-paths": "^4.2.0",
|
|
44
|
-
"tsup": "^8.4.0",
|
|
45
45
|
"typescript": "^5.8.2"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"rxjs": "^7.8.2"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
|
-
"build": "
|
|
71
|
-
"dev": "
|
|
70
|
+
"build": "rimraf dist && tsc -p tsconfig.build.json",
|
|
71
|
+
"dev": "rimraf dist && tsc -p tsconfig.build.json --watch",
|
|
72
72
|
"test": "jest",
|
|
73
73
|
"test:ci": "jest --coverage && jest --config ./test/jest-e2e.config.json",
|
|
74
74
|
"test:cov": "jest --coverage",
|