@nestjs-kitchen/authz 2.0.2 → 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 +29 -48
- package/dist/constants.d.ts +6 -8
- package/dist/constants.js +13 -46
- package/dist/errors.d.ts +3 -5
- package/dist/errors.js +35 -60
- 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 +138 -158
- 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 +44 -81
- package/dist/jwt/jwt-authz.guard.d.ts +8 -21
- package/dist/jwt/jwt-authz.guard.js +130 -175
- package/dist/jwt/jwt-authz.interface.d.ts +16 -25
- package/dist/jwt/jwt-authz.interface.js +69 -92
- package/dist/jwt/jwt-authz.module.d.ts +19 -31
- package/dist/jwt/jwt-authz.module.js +250 -299
- package/dist/jwt/jwt-authz.service.d.ts +6 -17
- package/dist/jwt/jwt-authz.service.js +116 -162
- package/dist/jwt/jwt-authz.strategy.d.ts +5 -17
- package/dist/jwt/jwt-authz.strategy.js +132 -192
- 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 +98 -130
- package/dist/session/session-authz.guard.d.ts +6 -15
- package/dist/session/session-authz.guard.js +98 -135
- package/dist/session/session-authz.interface.d.ts +5 -12
- package/dist/session/session-authz.interface.js +19 -42
- package/dist/session/session-authz.module.d.ts +18 -26
- package/dist/session/session-authz.module.js +241 -290
- package/dist/session/session-authz.service.d.ts +5 -13
- package/dist/session/session-authz.service.js +69 -105
- package/dist/session/session-authz.strategy.d.ts +4 -12
- package/dist/session/session-authz.strategy.js +68 -105
- package/dist/user.decorator.d.ts +3 -6
- package/dist/user.decorator.js +26 -35
- package/dist/utils/cookie-parsers.d.ts +3 -6
- package/dist/utils/cookie-parsers.js +66 -74
- package/dist/utils/create-authz-decorator-factory.d.ts +3 -9
- package/dist/utils/create-authz-decorator-factory.js +32 -54
- package/dist/utils/create-set-cookie-fn.d.ts +3 -9
- package/dist/utils/create-set-cookie-fn.js +23 -45
- package/dist/utils/generics.d.ts +4 -6
- package/dist/utils/generics.js +37 -63
- package/dist/utils/get-allow-anonymous.d.ts +2 -9
- package/dist/utils/get-allow-anonymous.js +7 -29
- package/dist/utils/get-als-store.d.ts +2 -5
- package/dist/utils/get-als-store.js +11 -34
- package/dist/utils/get-context-authz-meta-params-list.d.ts +2 -9
- package/dist/utils/get-context-authz-meta-params-list.js +16 -35
- package/dist/utils/get-passport-property.d.ts +1 -3
- package/dist/utils/get-passport-property.js +8 -30
- 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 +14 -49
- package/dist/utils/msgpackrs.d.ts +2 -4
- package/dist/utils/msgpackrs.js +11 -35
- package/dist/utils/types.d.ts +23 -26
- package/dist/utils/types.js +2 -15
- package/package.json +7 -7
|
@@ -1,77 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var cookie_parsers_exports = {};
|
|
30
|
-
__export(cookie_parsers_exports, {
|
|
31
|
-
customCookieParser: () => customCookieParser,
|
|
32
|
-
normalCookieParser: () => normalCookieParser
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
33
17
|
});
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.customCookieParser = exports.normalCookieParser = void 0;
|
|
40
|
+
const cookie = __importStar(require("cookie"));
|
|
41
|
+
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
42
|
+
const normalCookieParser = (req, _secrets = [], decode) => {
|
|
43
|
+
let cookies = req.cookies || {};
|
|
44
|
+
let signedCookies = req.signedCookies || {};
|
|
45
|
+
if (!req.cookies && req.headers.cookie) {
|
|
46
|
+
const parsedCookies = cookie.parse(req.headers.cookie, { decode });
|
|
47
|
+
if (req.secret) {
|
|
48
|
+
signedCookies = cookie_parser_1.default.JSONCookies(cookie_parser_1.default.signedCookies(parsedCookies, [req.secret]));
|
|
49
|
+
}
|
|
50
|
+
cookies = cookie_parser_1.default.JSONCookies(parsedCookies);
|
|
48
51
|
}
|
|
49
|
-
cookies
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (secrets.length) {
|
|
64
|
-
signedCookies = import_cookie_parser.default.JSONCookies(import_cookie_parser.default.signedCookies(parsedCookies, secrets));
|
|
52
|
+
return { cookies, signedCookies };
|
|
53
|
+
};
|
|
54
|
+
exports.normalCookieParser = normalCookieParser;
|
|
55
|
+
const customCookieParser = (req, secrets = [], decode) => {
|
|
56
|
+
let cookies = {};
|
|
57
|
+
let signedCookies = {};
|
|
58
|
+
if (req.headers.cookie) {
|
|
59
|
+
const parsedCookies = cookie.parse(req.headers.cookie, {
|
|
60
|
+
decode
|
|
61
|
+
});
|
|
62
|
+
if (secrets.length) {
|
|
63
|
+
signedCookies = cookie_parser_1.default.JSONCookies(cookie_parser_1.default.signedCookies(parsedCookies, secrets));
|
|
64
|
+
}
|
|
65
|
+
cookies = cookie_parser_1.default.JSONCookies(parsedCookies);
|
|
65
66
|
}
|
|
66
|
-
cookies
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
cookies,
|
|
70
|
-
signedCookies
|
|
71
|
-
};
|
|
72
|
-
}, "customCookieParser");
|
|
73
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
-
0 && (module.exports = {
|
|
75
|
-
customCookieParser,
|
|
76
|
-
normalCookieParser
|
|
77
|
-
});
|
|
67
|
+
return { cookies, signedCookies };
|
|
68
|
+
};
|
|
69
|
+
exports.customCookieParser = customCookieParser;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { AuthzProviderClass } from '../authz.provider
|
|
2
|
-
import { AuthzDecoParams, MethodParameters
|
|
3
|
-
|
|
4
|
-
import '@nestjs/common/interfaces';
|
|
5
|
-
import 'express';
|
|
6
|
-
|
|
7
|
-
declare const createAuthzDecoratorFactory: <T extends AuthzProviderClass<unknown, unknown>>(metaKey: string | Symbol) => (...args: AuthzDecoParams<MethodParameters<T, "authorize">[1]>) => ApplyDecorators;
|
|
8
|
-
|
|
9
|
-
export { createAuthzDecoratorFactory };
|
|
1
|
+
import { AuthzProviderClass } from '../authz.provider';
|
|
2
|
+
import type { ApplyDecorators, AuthzDecoParams, MethodParameters } from './types';
|
|
3
|
+
export declare const createAuthzDecoratorFactory: <T extends AuthzProviderClass<unknown, unknown>>(metaKey: string | Symbol) => (...args: AuthzDecoParams<MethodParameters<T, "authorize">[1]>) => ApplyDecorators;
|
|
@@ -1,56 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAuthzDecoratorFactory = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const isOptions = (val) => {
|
|
6
|
+
if (!val) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const keySet = new Set(Object.keys(val));
|
|
10
|
+
if (keySet.size === 1) {
|
|
11
|
+
return keySet.has('override') || keySet.has('allowAnonymous');
|
|
12
|
+
}
|
|
13
|
+
if (keySet.size === 2) {
|
|
14
|
+
return keySet.has('override') && keySet.has('allowAnonymous');
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
9
17
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const createAuthzDecoratorFactory = (metaKey) => (...args) => {
|
|
19
|
+
const [metaDataOrOptions, optionsOrUndefined] = args;
|
|
20
|
+
let metaData;
|
|
21
|
+
let options;
|
|
22
|
+
if (isOptions(metaDataOrOptions)) {
|
|
23
|
+
options = metaDataOrOptions;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
metaData = metaDataOrOptions;
|
|
27
|
+
options = optionsOrUndefined;
|
|
28
|
+
}
|
|
29
|
+
return (0, common_1.SetMetadata)(metaKey, {
|
|
30
|
+
metaData,
|
|
31
|
+
options
|
|
32
|
+
});
|
|
17
33
|
};
|
|
18
|
-
|
|
19
|
-
var create_authz_decorator_factory_exports = {};
|
|
20
|
-
__export(create_authz_decorator_factory_exports, {
|
|
21
|
-
createAuthzDecoratorFactory: () => createAuthzDecoratorFactory
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(create_authz_decorator_factory_exports);
|
|
24
|
-
var import_common = require("@nestjs/common");
|
|
25
|
-
const isOptions = /* @__PURE__ */ __name((val) => {
|
|
26
|
-
if (!val) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
const keySet = new Set(Object.keys(val));
|
|
30
|
-
if (keySet.size === 1) {
|
|
31
|
-
return keySet.has("override") || keySet.has("allowAnonymous");
|
|
32
|
-
}
|
|
33
|
-
if (keySet.size === 2) {
|
|
34
|
-
return keySet.has("override") && keySet.has("allowAnonymous");
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
37
|
-
}, "isOptions");
|
|
38
|
-
const createAuthzDecoratorFactory = /* @__PURE__ */ __name((metaKey) => (...args) => {
|
|
39
|
-
const [metaDataOrOptions, optionsOrUndefined] = args;
|
|
40
|
-
let metaData;
|
|
41
|
-
let options;
|
|
42
|
-
if (isOptions(metaDataOrOptions)) {
|
|
43
|
-
options = metaDataOrOptions;
|
|
44
|
-
} else {
|
|
45
|
-
metaData = metaDataOrOptions;
|
|
46
|
-
options = optionsOrUndefined;
|
|
47
|
-
}
|
|
48
|
-
return (0, import_common.SetMetadata)(metaKey, {
|
|
49
|
-
metaData,
|
|
50
|
-
options
|
|
51
|
-
});
|
|
52
|
-
}, "createAuthzDecoratorFactory");
|
|
53
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
-
0 && (module.exports = {
|
|
55
|
-
createAuthzDecoratorFactory
|
|
56
|
-
});
|
|
34
|
+
exports.createAuthzDecoratorFactory = createAuthzDecoratorFactory;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
|
-
import { CookieOptionsWithSecret } from './types
|
|
3
|
-
|
|
4
|
-
import '@nestjs/common/interfaces';
|
|
5
|
-
import '../authz.provider.js';
|
|
6
|
-
|
|
7
|
-
declare const createSetCookieFn: (req: Request, res: Response) => (name: string, value: string, options?: CookieOptionsWithSecret) => void;
|
|
8
|
-
|
|
9
|
-
export { createSetCookieFn };
|
|
1
|
+
import type { Request, Response } from 'express';
|
|
2
|
+
import type { CookieOptionsWithSecret } from './types';
|
|
3
|
+
export declare const createSetCookieFn: (req: Request, res: Response) => (name: string, value: string, options?: CookieOptionsWithSecret) => void;
|
|
@@ -1,46 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var create_set_cookie_fn_exports = {};
|
|
20
|
-
__export(create_set_cookie_fn_exports, {
|
|
21
|
-
createSetCookieFn: () => createSetCookieFn
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(create_set_cookie_fn_exports);
|
|
24
|
-
var import_generics = require("./generics");
|
|
25
|
-
const createSetCookieFn = /* @__PURE__ */ __name((req, res) => (name, value, options = {}) => {
|
|
26
|
-
const { secret, signed: optSigned, ...restOpts } = options;
|
|
27
|
-
const secrets = (0, import_generics.normalizedArray)(secret) ?? [];
|
|
28
|
-
const signed = optSigned ?? Boolean(secrets.length);
|
|
29
|
-
const reqSecret = req.secret;
|
|
30
|
-
if (signed) {
|
|
31
|
-
if (secrets.length) {
|
|
32
|
-
req.secret = secrets[0];
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSetCookieFn = void 0;
|
|
4
|
+
const generics_1 = require("./generics");
|
|
5
|
+
const createSetCookieFn = (req, res) => (name, value, options = {}) => {
|
|
6
|
+
const { secret, signed: optSigned, ...restOpts } = options;
|
|
7
|
+
const secrets = (0, generics_1.normalizedArray)(secret) ?? [];
|
|
8
|
+
const signed = optSigned ?? Boolean(secrets.length);
|
|
9
|
+
const reqSecret = req.secret;
|
|
10
|
+
if (signed) {
|
|
11
|
+
if (secrets.length) {
|
|
12
|
+
req.secret = secrets[0];
|
|
13
|
+
}
|
|
33
14
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
createSetCookieFn
|
|
46
|
-
});
|
|
15
|
+
else {
|
|
16
|
+
req.secret = undefined;
|
|
17
|
+
}
|
|
18
|
+
res.cookie(name, value, {
|
|
19
|
+
signed,
|
|
20
|
+
...restOpts
|
|
21
|
+
});
|
|
22
|
+
req.secret = reqSecret;
|
|
23
|
+
};
|
|
24
|
+
exports.createSetCookieFn = createSetCookieFn;
|
package/dist/utils/generics.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
declare const isNotFalsy: <T>(val: T) => val is T;
|
|
2
|
-
declare const normalizedArray: <T>(val?: T | T[]) => undefined extends T ? T[] | undefined : NonNullable<T>[];
|
|
3
|
-
declare const normalizedObject: <T extends Record<string, any>>(obj?: T) => T | undefined;
|
|
4
|
-
declare const merge: <T extends Record<string, any>, U extends Record<string, any>>(obj1: T, obj2?: U) => T & U;
|
|
5
|
-
|
|
6
|
-
export { isNotFalsy, merge, normalizedArray, normalizedObject };
|
|
1
|
+
export declare const isNotFalsy: <T>(val: T) => val is T;
|
|
2
|
+
export declare const normalizedArray: <T>(val?: T | T[]) => undefined extends T ? T[] | undefined : NonNullable<T>[];
|
|
3
|
+
export declare const normalizedObject: <T extends Record<string, any>>(obj?: T) => T | undefined;
|
|
4
|
+
export declare const merge: <T extends Record<string, any>, U extends Record<string, any>>(obj1: T, obj2?: U) => T & U;
|
package/dist/utils/generics.js
CHANGED
|
@@ -1,66 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.merge = exports.normalizedObject = exports.normalizedArray = exports.isNotFalsy = void 0;
|
|
4
|
+
const isNotFalsy = (val) => {
|
|
5
|
+
return val !== undefined && val !== null && !Number.isNaN(val);
|
|
9
6
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
exports.isNotFalsy = isNotFalsy;
|
|
8
|
+
const normalizedArray = (val) => {
|
|
9
|
+
if (!val) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
return (Array.isArray(val) ? val : [val]).filter(exports.isNotFalsy);
|
|
13
|
+
};
|
|
14
|
+
exports.normalizedArray = normalizedArray;
|
|
15
|
+
const normalizedObject = (obj) => {
|
|
16
|
+
if (!obj) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
const entries = Object.entries(obj);
|
|
20
|
+
if (!entries.length) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const filtered = entries.filter(([_, value]) => value !== undefined);
|
|
24
|
+
if (!filtered.length) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return Object.fromEntries(filtered);
|
|
17
28
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
module.exports = __toCommonJS(generics_exports);
|
|
27
|
-
const isNotFalsy = /* @__PURE__ */ __name((val) => {
|
|
28
|
-
return val !== void 0 && val !== null && !Number.isNaN(val);
|
|
29
|
-
}, "isNotFalsy");
|
|
30
|
-
const normalizedArray = /* @__PURE__ */ __name((val) => {
|
|
31
|
-
if (!val) {
|
|
32
|
-
return void 0;
|
|
33
|
-
}
|
|
34
|
-
return (Array.isArray(val) ? val : [
|
|
35
|
-
val
|
|
36
|
-
]).filter(isNotFalsy);
|
|
37
|
-
}, "normalizedArray");
|
|
38
|
-
const normalizedObject = /* @__PURE__ */ __name((obj) => {
|
|
39
|
-
if (!obj) {
|
|
40
|
-
return void 0;
|
|
41
|
-
}
|
|
42
|
-
const entries = Object.entries(obj);
|
|
43
|
-
if (!entries.length) {
|
|
44
|
-
return void 0;
|
|
45
|
-
}
|
|
46
|
-
const filtered = entries.filter(([_, value]) => value !== void 0);
|
|
47
|
-
if (!filtered.length) {
|
|
48
|
-
return void 0;
|
|
49
|
-
}
|
|
50
|
-
return Object.fromEntries(filtered);
|
|
51
|
-
}, "normalizedObject");
|
|
52
|
-
const merge = /* @__PURE__ */ __name((obj1, obj2) => {
|
|
53
|
-
if (obj1 && obj2) {
|
|
54
|
-
for (var key in obj2) {
|
|
55
|
-
obj1[key] = obj2[key];
|
|
29
|
+
exports.normalizedObject = normalizedObject;
|
|
30
|
+
// ref: https://github.com/jaredhanson/utils-merge/blob/master/index.js
|
|
31
|
+
const merge = (obj1, obj2) => {
|
|
32
|
+
if (obj1 && obj2) {
|
|
33
|
+
for (var key in obj2) {
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
obj1[key] = obj2[key];
|
|
36
|
+
}
|
|
56
37
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
-
0 && (module.exports = {
|
|
62
|
-
isNotFalsy,
|
|
63
|
-
merge,
|
|
64
|
-
normalizedArray,
|
|
65
|
-
normalizedObject
|
|
66
|
-
});
|
|
38
|
+
return obj1;
|
|
39
|
+
};
|
|
40
|
+
exports.merge = merge;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import { AuthzMetaParams } from './types
|
|
2
|
-
|
|
3
|
-
import '@nestjs/common/interfaces';
|
|
4
|
-
import 'express';
|
|
5
|
-
import '../authz.provider.js';
|
|
6
|
-
|
|
7
|
-
declare const getAllowAnonymous: (authzMetaCollection: AuthzMetaParams[], options?: {
|
|
1
|
+
import type { AuthzMetaParams } from './types';
|
|
2
|
+
export declare const getAllowAnonymous: (authzMetaCollection: AuthzMetaParams[], options?: {
|
|
8
3
|
defaultAllowAnonymous?: boolean;
|
|
9
4
|
}) => boolean;
|
|
10
|
-
|
|
11
|
-
export { getAllowAnonymous };
|
|
@@ -1,30 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllowAnonymous = void 0;
|
|
4
|
+
const getAllowAnonymous = (authzMetaCollection, options) => {
|
|
5
|
+
return (options?.defaultAllowAnonymous ||
|
|
6
|
+
Boolean(authzMetaCollection[authzMetaCollection.length - 1]?.options?.allowAnonymous));
|
|
9
7
|
};
|
|
10
|
-
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var get_allow_anonymous_exports = {};
|
|
20
|
-
__export(get_allow_anonymous_exports, {
|
|
21
|
-
getAllowAnonymous: () => getAllowAnonymous
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(get_allow_anonymous_exports);
|
|
24
|
-
const getAllowAnonymous = /* @__PURE__ */ __name((authzMetaCollection, options) => {
|
|
25
|
-
return options?.defaultAllowAnonymous || Boolean(authzMetaCollection[authzMetaCollection.length - 1]?.options?.allowAnonymous);
|
|
26
|
-
}, "getAllowAnonymous");
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
getAllowAnonymous
|
|
30
|
-
});
|
|
8
|
+
exports.getAllowAnonymous = getAllowAnonymous;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
|
|
3
|
-
declare const getAlsStore: <T>(als: AsyncLocalStorage<T>) => NonNullable<T>;
|
|
4
|
-
|
|
5
|
-
export { getAlsStore };
|
|
1
|
+
import type { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
export declare const getAlsStore: <T>(als: AsyncLocalStorage<T>) => NonNullable<T>;
|
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAlsStore = void 0;
|
|
4
|
+
const errors_1 = require("../errors");
|
|
5
|
+
const getAlsStore = (als) => {
|
|
6
|
+
const store = als.getStore();
|
|
7
|
+
if (!store) {
|
|
8
|
+
throw new errors_1.AuthzError(`InternalError: Unable to retrieve user data`);
|
|
9
|
+
}
|
|
10
|
+
return store;
|
|
9
11
|
};
|
|
10
|
-
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var get_als_store_exports = {};
|
|
20
|
-
__export(get_als_store_exports, {
|
|
21
|
-
getAlsStore: () => getAlsStore
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(get_als_store_exports);
|
|
24
|
-
var import_errors = require("../errors");
|
|
25
|
-
const getAlsStore = /* @__PURE__ */ __name((als) => {
|
|
26
|
-
const store = als.getStore();
|
|
27
|
-
if (!store) {
|
|
28
|
-
throw new import_errors.AuthzError(`InternalError: Unable to retrieve user data`);
|
|
29
|
-
}
|
|
30
|
-
return store;
|
|
31
|
-
}, "getAlsStore");
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
getAlsStore
|
|
35
|
-
});
|
|
12
|
+
exports.getAlsStore = getAlsStore;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { AuthzMetaParams } from './types
|
|
2
|
-
|
|
3
|
-
import '@nestjs/common/interfaces';
|
|
4
|
-
import 'express';
|
|
5
|
-
import '../authz.provider.js';
|
|
6
|
-
|
|
7
|
-
declare const getContextAuthzMetaParamsList: (authzMetaCollection: AuthzMetaParams[], options?: {
|
|
1
|
+
import type { AuthzMetaParams } from './types';
|
|
2
|
+
export declare const getContextAuthzMetaParamsList: (authzMetaCollection: AuthzMetaParams[], options?: {
|
|
8
3
|
defaultOverride?: boolean;
|
|
9
4
|
skipFalsyMetadata?: boolean;
|
|
10
5
|
}) => AuthzMetaParams[];
|
|
11
|
-
|
|
12
|
-
export { getContextAuthzMetaParamsList };
|
|
@@ -1,36 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getContextAuthzMetaParamsList = void 0;
|
|
4
|
+
const generics_1 = require("./generics");
|
|
5
|
+
const getContextAuthzMetaParamsList = (authzMetaCollection, options) => {
|
|
6
|
+
const lastOverrideIdx = options?.defaultOverride
|
|
7
|
+
? authzMetaCollection.length - 1
|
|
8
|
+
: authzMetaCollection.findLastIndex((ele) => ele?.options?.override);
|
|
9
|
+
const contextAuthzMetaCollection = authzMetaCollection
|
|
10
|
+
.slice(lastOverrideIdx === -1 ? 0 : lastOverrideIdx)
|
|
11
|
+
.filter((ele) => !ele.options?.public);
|
|
12
|
+
if (options?.skipFalsyMetadata) {
|
|
13
|
+
return contextAuthzMetaCollection.filter((ele) => (0, generics_1.isNotFalsy)(ele.metaData));
|
|
14
|
+
}
|
|
15
|
+
return contextAuthzMetaCollection;
|
|
9
16
|
};
|
|
10
|
-
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var get_context_authz_meta_params_list_exports = {};
|
|
20
|
-
__export(get_context_authz_meta_params_list_exports, {
|
|
21
|
-
getContextAuthzMetaParamsList: () => getContextAuthzMetaParamsList
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(get_context_authz_meta_params_list_exports);
|
|
24
|
-
var import_generics = require("./generics");
|
|
25
|
-
const getContextAuthzMetaParamsList = /* @__PURE__ */ __name((authzMetaCollection, options) => {
|
|
26
|
-
const lastOverrideIdx = options?.defaultOverride ? authzMetaCollection.length - 1 : authzMetaCollection.findLastIndex((ele) => ele?.options?.override);
|
|
27
|
-
const contextAuthzMetaCollection = authzMetaCollection.slice(lastOverrideIdx === -1 ? 0 : lastOverrideIdx).filter((ele) => !ele.options?.public);
|
|
28
|
-
if (options?.skipFalsyMetadata) {
|
|
29
|
-
return contextAuthzMetaCollection.filter((ele) => (0, import_generics.isNotFalsy)(ele.metaData));
|
|
30
|
-
}
|
|
31
|
-
return contextAuthzMetaCollection;
|
|
32
|
-
}, "getContextAuthzMetaParamsList");
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
getContextAuthzMetaParamsList
|
|
36
|
-
});
|
|
17
|
+
exports.getContextAuthzMetaParamsList = getContextAuthzMetaParamsList;
|