@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.
Files changed (65) hide show
  1. package/dist/authz.provider.d.ts +1 -3
  2. package/dist/authz.provider.js +29 -48
  3. package/dist/constants.d.ts +6 -8
  4. package/dist/constants.js +13 -46
  5. package/dist/errors.d.ts +3 -5
  6. package/dist/errors.js +35 -60
  7. package/dist/index.d.ts +5 -21
  8. package/dist/index.js +16 -45
  9. package/dist/jwt/extract-jwt.d.ts +4 -7
  10. package/dist/jwt/extract-jwt.js +138 -158
  11. package/dist/jwt/index.d.ts +2 -16
  12. package/dist/jwt/index.js +7 -30
  13. package/dist/jwt/jwt-authz-als.middleware.d.ts +6 -16
  14. package/dist/jwt/jwt-authz-als.middleware.js +44 -81
  15. package/dist/jwt/jwt-authz.guard.d.ts +8 -21
  16. package/dist/jwt/jwt-authz.guard.js +130 -175
  17. package/dist/jwt/jwt-authz.interface.d.ts +16 -25
  18. package/dist/jwt/jwt-authz.interface.js +69 -92
  19. package/dist/jwt/jwt-authz.module.d.ts +19 -31
  20. package/dist/jwt/jwt-authz.module.js +250 -299
  21. package/dist/jwt/jwt-authz.service.d.ts +6 -17
  22. package/dist/jwt/jwt-authz.service.js +116 -162
  23. package/dist/jwt/jwt-authz.strategy.d.ts +5 -17
  24. package/dist/jwt/jwt-authz.strategy.js +132 -192
  25. package/dist/session/index.d.ts +1 -12
  26. package/dist/session/index.js +5 -27
  27. package/dist/session/session-authz-als.middleware.d.ts +5 -12
  28. package/dist/session/session-authz-als.middleware.js +98 -130
  29. package/dist/session/session-authz.guard.d.ts +6 -15
  30. package/dist/session/session-authz.guard.js +98 -135
  31. package/dist/session/session-authz.interface.d.ts +5 -12
  32. package/dist/session/session-authz.interface.js +19 -42
  33. package/dist/session/session-authz.module.d.ts +18 -26
  34. package/dist/session/session-authz.module.js +241 -290
  35. package/dist/session/session-authz.service.d.ts +5 -13
  36. package/dist/session/session-authz.service.js +69 -105
  37. package/dist/session/session-authz.strategy.d.ts +4 -12
  38. package/dist/session/session-authz.strategy.js +68 -105
  39. package/dist/user.decorator.d.ts +3 -6
  40. package/dist/user.decorator.js +26 -35
  41. package/dist/utils/cookie-parsers.d.ts +3 -6
  42. package/dist/utils/cookie-parsers.js +66 -74
  43. package/dist/utils/create-authz-decorator-factory.d.ts +3 -9
  44. package/dist/utils/create-authz-decorator-factory.js +32 -54
  45. package/dist/utils/create-set-cookie-fn.d.ts +3 -9
  46. package/dist/utils/create-set-cookie-fn.js +23 -45
  47. package/dist/utils/generics.d.ts +4 -6
  48. package/dist/utils/generics.js +37 -63
  49. package/dist/utils/get-allow-anonymous.d.ts +2 -9
  50. package/dist/utils/get-allow-anonymous.js +7 -29
  51. package/dist/utils/get-als-store.d.ts +2 -5
  52. package/dist/utils/get-als-store.js +11 -34
  53. package/dist/utils/get-context-authz-meta-params-list.d.ts +2 -9
  54. package/dist/utils/get-context-authz-meta-params-list.js +16 -35
  55. package/dist/utils/get-passport-property.d.ts +1 -3
  56. package/dist/utils/get-passport-property.js +8 -30
  57. package/dist/utils/index.d.ts +11 -16
  58. package/dist/utils/index.js +26 -40
  59. package/dist/utils/merge-dynamic-module-configs.d.ts +2 -5
  60. package/dist/utils/merge-dynamic-module-configs.js +14 -49
  61. package/dist/utils/msgpackrs.d.ts +2 -4
  62. package/dist/utils/msgpackrs.js +11 -35
  63. package/dist/utils/types.d.ts +23 -26
  64. package/dist/utils/types.js +2 -15
  65. package/package.json +7 -7
@@ -1,194 +1,134 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12
7
  };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
20
10
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
31
- var jwt_authz_strategy_exports = {};
32
- __export(jwt_authz_strategy_exports, {
33
- createJwtStrategy: () => createJwtStrategy,
34
- createRefreshStrategy: () => createRefreshStrategy
35
- });
36
- module.exports = __toCommonJS(jwt_authz_strategy_exports);
37
- var import_node_async_hooks = require("node:async_hooks");
38
- var import_common = require("@nestjs/common");
39
- var import_passport = require("@nestjs/passport");
40
- var import_jsonwebtoken = __toESM(require("jsonwebtoken"));
41
- var import_passport_custom = require("passport-custom");
42
- var import_authz = require("../authz.provider");
43
- var import_constants = require("../constants");
44
- var import_errors = require("../errors");
45
- var import_utils = require("../utils");
46
- var import_extract_jwt = require("./extract-jwt");
47
- function _ts_decorate(decorators, target, key, desc) {
48
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
49
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
50
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
51
- return c > 3 && r && Object.defineProperty(target, key, r), r;
52
- }
53
- __name(_ts_decorate, "_ts_decorate");
54
- function _ts_metadata(k, v) {
55
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
56
- }
57
- __name(_ts_metadata, "_ts_metadata");
58
- function _ts_param(paramIndex, decorator) {
59
- return function(target, key) {
60
- decorator(target, key, paramIndex);
61
- };
62
- }
63
- __name(_ts_param, "_ts_param");
64
- const createJwtStrategy = /* @__PURE__ */ __name(([JWT_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]) => {
65
- var _a;
66
- let JwtStrategy = (_a = class extends (0, import_passport.PassportStrategy)(import_passport_custom.Strategy, JWT_STRATEGY) {
67
- constructor(authzProvider, als) {
68
- super();
69
- __publicField(this, "authzProvider");
70
- __publicField(this, "als");
71
- this.authzProvider = authzProvider, this.als = als;
72
- if (typeof this.authzProvider.authenticate !== "function") {
73
- throw new import_errors.AuthzError(`InternalError: Method 'authenticate' from abstract class 'AuthzProvider' must be implemented.`);
74
- }
75
- }
76
- async validate(req) {
77
- const store = (0, import_utils.getAlsStore)(this.als);
78
- const authOptions = store.authOptions;
79
- if (!authOptions.jwt.verify) {
80
- return [
81
- null,
82
- new import_errors.AuthzError(`InternalError: Refresh verify options must be implemented.`)
83
- ];
84
- }
85
- const extractor = import_extract_jwt.ExtractJwt.fromExtractors(authOptions.jwt.jwtFromRequest);
86
- req[import_constants.PASSPORT_PROPERTY] = authOptions.passportProperty;
87
- const token = extractor(req);
88
- if (!token) {
89
- return [
90
- null,
91
- new import_errors.AuthzAnonymousError("AnonymousError: Cannnot find token.")
92
- ];
93
- }
94
- let user = void 0;
95
- try {
96
- const payload = import_jsonwebtoken.default.verify(token, authOptions.jwt.secretOrPublicKey, authOptions.jwt.verify);
97
- user = await this.authzProvider.authenticate(payload);
98
- } catch (error) {
99
- return [
100
- null,
101
- error instanceof Error ? new import_errors.AuthzVerificationError(`${error.name}: ${error.message}`, error) : new import_errors.AuthzVerificationError(`${error}`)
102
- ];
103
- }
104
- store.user = user;
105
- store.jwtVerifiedBy = import_constants.JwtValidationType.JWT;
106
- if (!user) {
107
- return [
108
- null,
109
- new import_errors.AuthzAnonymousError("AnonymousError: Cannnot find user.")
110
- ];
111
- }
112
- return user;
113
- }
114
- }, __name(_a, "JwtStrategy"), _a);
115
- JwtStrategy = _ts_decorate([
116
- _ts_param(0, (0, import_common.Inject)(AUTHZ_PROVIDER)),
117
- _ts_param(1, (0, import_common.Inject)(ALS_PROVIDER)),
118
- _ts_metadata("design:type", Function),
119
- _ts_metadata("design:paramtypes", [
120
- typeof import_authz.AuthzProviderClass === "undefined" ? Object : import_authz.AuthzProviderClass,
121
- typeof import_node_async_hooks.AsyncLocalStorage === "undefined" ? Object : import_node_async_hooks.AsyncLocalStorage
122
- ])
123
- ], JwtStrategy);
124
- return (0, import_common.mixin)(JwtStrategy);
125
- }, "createJwtStrategy");
126
- const createRefreshStrategy = /* @__PURE__ */ __name(([JWT_REFRESH_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]) => {
127
- var _a;
128
- let RefreshStrategy = (_a = class extends (0, import_passport.PassportStrategy)(import_passport_custom.Strategy, JWT_REFRESH_STRATEGY) {
129
- constructor(authzProvider, als) {
130
- super();
131
- __publicField(this, "authzProvider");
132
- __publicField(this, "als");
133
- this.authzProvider = authzProvider, this.als = als;
134
- if (typeof this.authzProvider.authenticate !== "function") {
135
- throw new import_errors.AuthzError(`InternalError: Method 'authenticate' from abstract class 'AuthzProvider' must be implemented.`);
136
- }
137
- }
138
- async validate(req) {
139
- const store = (0, import_utils.getAlsStore)(this.als);
140
- const authOptions = store.authOptions;
141
- if (!authOptions.refresh.verify) {
142
- return [
143
- null,
144
- new import_errors.AuthzError(`InternalError: Refresh verify options must be implemented.`)
145
- ];
146
- }
147
- const extractor = import_extract_jwt.ExtractJwt.fromExtractors(authOptions.refresh.jwtFromRequest);
148
- req[import_constants.PASSPORT_PROPERTY] = authOptions.passportProperty;
149
- const token = extractor(req);
150
- if (!token) {
151
- return [
152
- null,
153
- new import_errors.AuthzAnonymousError("AnonymousError: Cannnot find token.")
154
- ];
155
- }
156
- let user = void 0;
157
- try {
158
- const payload = import_jsonwebtoken.default.verify(token, authOptions.refresh.secretOrPublicKey, authOptions.refresh.verify);
159
- const decodePayload = (0, import_utils.decodeMsgpackrString)(payload.data);
160
- user = await this.authzProvider.authenticate(decodePayload);
161
- } catch (error) {
162
- return [
163
- null,
164
- error instanceof Error ? new import_errors.AuthzVerificationError(`${error.name}: ${error.message}`, error) : new import_errors.AuthzVerificationError(`${error}`)
165
- ];
166
- }
167
- store.user = user;
168
- store.jwtVerifiedBy = import_constants.JwtValidationType.REFRESH;
169
- if (!user) {
170
- return [
171
- null,
172
- new import_errors.AuthzAnonymousError("AnonymousError: Cannnot find user.")
173
- ];
174
- }
175
- return user;
176
- }
177
- }, __name(_a, "RefreshStrategy"), _a);
178
- RefreshStrategy = _ts_decorate([
179
- (0, import_common.Injectable)(),
180
- _ts_param(0, (0, import_common.Inject)(AUTHZ_PROVIDER)),
181
- _ts_param(1, (0, import_common.Inject)(ALS_PROVIDER)),
182
- _ts_metadata("design:type", Function),
183
- _ts_metadata("design:paramtypes", [
184
- typeof import_authz.AuthzProviderClass === "undefined" ? Object : import_authz.AuthzProviderClass,
185
- typeof import_node_async_hooks.AsyncLocalStorage === "undefined" ? Object : import_node_async_hooks.AsyncLocalStorage
186
- ])
187
- ], RefreshStrategy);
188
- return (0, import_common.mixin)(RefreshStrategy);
189
- }, "createRefreshStrategy");
190
- // Annotate the CommonJS export names for ESM import in node:
191
- 0 && (module.exports = {
192
- createJwtStrategy,
193
- createRefreshStrategy
194
- });
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.createRefreshStrategy = exports.createJwtStrategy = void 0;
19
+ const node_async_hooks_1 = require("node:async_hooks");
20
+ const common_1 = require("@nestjs/common");
21
+ const passport_1 = require("@nestjs/passport");
22
+ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
23
+ const passport_custom_1 = require("passport-custom");
24
+ const authz_provider_1 = require("../authz.provider");
25
+ const constants_1 = require("../constants");
26
+ const errors_1 = require("../errors");
27
+ const utils_1 = require("../utils");
28
+ const extract_jwt_1 = require("./extract-jwt");
29
+ const createJwtStrategy = ([JWT_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]) => {
30
+ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_custom_1.Strategy, JWT_STRATEGY) {
31
+ constructor(authzProvider, als) {
32
+ super();
33
+ this.authzProvider = authzProvider;
34
+ this.als = als;
35
+ if (typeof this.authzProvider.authenticate !== 'function') {
36
+ throw new errors_1.AuthzError(`InternalError: Method 'authenticate' from abstract class 'AuthzProvider' must be implemented.`);
37
+ }
38
+ }
39
+ async validate(req) {
40
+ const store = (0, utils_1.getAlsStore)(this.als);
41
+ const authOptions = store.authOptions;
42
+ if (!authOptions.jwt.verify) {
43
+ return [null, new errors_1.AuthzError(`InternalError: Refresh verify options must be implemented.`)];
44
+ }
45
+ const extractor = extract_jwt_1.ExtractJwt.fromExtractors(authOptions.jwt.jwtFromRequest);
46
+ req[constants_1.PASSPORT_PROPERTY] = authOptions.passportProperty;
47
+ const token = extractor(req);
48
+ if (!token) {
49
+ return [null, new errors_1.AuthzAnonymousError('AnonymousError: Cannnot find token.')];
50
+ }
51
+ let user = undefined;
52
+ try {
53
+ const payload = jsonwebtoken_1.default.verify(token, authOptions.jwt.secretOrPublicKey, authOptions.jwt.verify);
54
+ user = await this.authzProvider.authenticate(payload);
55
+ }
56
+ catch (error) {
57
+ return [
58
+ null,
59
+ error instanceof Error
60
+ ? new errors_1.AuthzVerificationError(`${error.name}: ${error.message}`, error)
61
+ : new errors_1.AuthzVerificationError(`${error}`)
62
+ ];
63
+ }
64
+ store.user = user;
65
+ store.jwtVerifiedBy = constants_1.JwtValidationType.JWT;
66
+ if (!user) {
67
+ return [null, new errors_1.AuthzAnonymousError('AnonymousError: Cannnot find user.')];
68
+ }
69
+ return user;
70
+ }
71
+ };
72
+ JwtStrategy = __decorate([
73
+ __param(0, (0, common_1.Inject)(AUTHZ_PROVIDER)),
74
+ __param(1, (0, common_1.Inject)(ALS_PROVIDER)),
75
+ __metadata("design:paramtypes", [authz_provider_1.AuthzProviderClass,
76
+ node_async_hooks_1.AsyncLocalStorage])
77
+ ], JwtStrategy);
78
+ return (0, common_1.mixin)(JwtStrategy);
79
+ };
80
+ exports.createJwtStrategy = createJwtStrategy;
81
+ const createRefreshStrategy = ([JWT_REFRESH_STRATEGY, AUTHZ_PROVIDER, ALS_PROVIDER]) => {
82
+ let RefreshStrategy = class RefreshStrategy extends (0, passport_1.PassportStrategy)(passport_custom_1.Strategy, JWT_REFRESH_STRATEGY) {
83
+ constructor(authzProvider, als) {
84
+ super();
85
+ this.authzProvider = authzProvider;
86
+ this.als = als;
87
+ if (typeof this.authzProvider.authenticate !== 'function') {
88
+ throw new errors_1.AuthzError(`InternalError: Method 'authenticate' from abstract class 'AuthzProvider' must be implemented.`);
89
+ }
90
+ }
91
+ async validate(req) {
92
+ const store = (0, utils_1.getAlsStore)(this.als);
93
+ const authOptions = store.authOptions;
94
+ if (!authOptions.refresh.verify) {
95
+ return [null, new errors_1.AuthzError(`InternalError: Refresh verify options must be implemented.`)];
96
+ }
97
+ const extractor = extract_jwt_1.ExtractJwt.fromExtractors(authOptions.refresh.jwtFromRequest);
98
+ req[constants_1.PASSPORT_PROPERTY] = authOptions.passportProperty;
99
+ const token = extractor(req);
100
+ if (!token) {
101
+ return [null, new errors_1.AuthzAnonymousError('AnonymousError: Cannnot find token.')];
102
+ }
103
+ let user = undefined;
104
+ try {
105
+ const payload = jsonwebtoken_1.default.verify(token, authOptions.refresh.secretOrPublicKey, authOptions.refresh.verify);
106
+ const decodePayload = (0, utils_1.decodeMsgpackrString)(payload.data);
107
+ user = await this.authzProvider.authenticate(decodePayload);
108
+ }
109
+ catch (error) {
110
+ return [
111
+ null,
112
+ error instanceof Error
113
+ ? new errors_1.AuthzVerificationError(`${error.name}: ${error.message}`, error)
114
+ : new errors_1.AuthzVerificationError(`${error}`)
115
+ ];
116
+ }
117
+ store.user = user;
118
+ store.jwtVerifiedBy = constants_1.JwtValidationType.REFRESH;
119
+ if (!user) {
120
+ return [null, new errors_1.AuthzAnonymousError('AnonymousError: Cannnot find user.')];
121
+ }
122
+ return user;
123
+ }
124
+ };
125
+ RefreshStrategy = __decorate([
126
+ (0, common_1.Injectable)(),
127
+ __param(0, (0, common_1.Inject)(AUTHZ_PROVIDER)),
128
+ __param(1, (0, common_1.Inject)(ALS_PROVIDER)),
129
+ __metadata("design:paramtypes", [authz_provider_1.AuthzProviderClass,
130
+ node_async_hooks_1.AsyncLocalStorage])
131
+ ], RefreshStrategy);
132
+ return (0, common_1.mixin)(RefreshStrategy);
133
+ };
134
+ exports.createRefreshStrategy = createRefreshStrategy;
@@ -1,12 +1 @@
1
- export { cereateSessionAuthzModule } from './session-authz.module.js';
2
- import '@nestjs/core';
3
- import './session-authz.interface.js';
4
- import 'express-session';
5
- import '../utils/types.js';
6
- import '@nestjs/common';
7
- import '@nestjs/common/interfaces';
8
- import 'express';
9
- import '../authz.provider.js';
10
- import 'node:async_hooks';
11
- import '../errors.js';
12
- import './session-authz-als.middleware.js';
1
+ export { cereateSessionAuthzModule } from './session-authz.module';
@@ -1,27 +1,5 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
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 session_exports = {};
19
- __export(session_exports, {
20
- cereateSessionAuthzModule: () => import_session_authz.cereateSessionAuthzModule
21
- });
22
- module.exports = __toCommonJS(session_exports);
23
- var import_session_authz = require("./session-authz.module");
24
- // Annotate the CommonJS export names for ESM import in node:
25
- 0 && (module.exports = {
26
- cereateSessionAuthzModule
27
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cereateSessionAuthzModule = void 0;
4
+ var session_authz_module_1 = require("./session-authz.module");
5
+ Object.defineProperty(exports, "cereateSessionAuthzModule", { enumerable: true, get: function () { return session_authz_module_1.cereateSessionAuthzModule; } });
@@ -1,13 +1,8 @@
1
- import * as _nestjs_common from '@nestjs/common';
2
1
  import { AsyncLocalStorage } from 'node:async_hooks';
3
- import { Request, Response, NextFunction } from 'express';
4
- import { CookieOptionsWithSecret } from '../utils/types.js';
5
- import { SessionAuthzOptions } from './session-authz.interface.js';
6
- import '@nestjs/common/interfaces';
7
- import '../authz.provider.js';
8
- import 'express-session';
9
-
10
- interface SessionAlsType<P, U> {
2
+ import type { NextFunction, Request, Response } from 'express';
3
+ import { type CookieOptionsWithSecret } from '../utils';
4
+ import type { SessionAuthzOptions } from './session-authz.interface';
5
+ export interface SessionAlsType<P, U> {
11
6
  user?: U;
12
7
  allowAnonymous?: boolean;
13
8
  guardResult?: boolean;
@@ -16,10 +11,8 @@ interface SessionAlsType<P, U> {
16
11
  logOut: () => Promise<void>;
17
12
  setCookie: (name: string, value: string, options?: CookieOptionsWithSecret) => void;
18
13
  }
19
- declare const createSessionAuthzAlsMiddleware: ([ALS_PROVIDER, SESSION_AUTHZ_OPTIONS]: [any, any]) => _nestjs_common.Type<Omit<{
14
+ export declare const createSessionAuthzAlsMiddleware: ([ALS_PROVIDER, SESSION_AUTHZ_OPTIONS]: [any, any]) => import("@nestjs/common").Type<Omit<{
20
15
  readonly als: AsyncLocalStorage<SessionAlsType<unknown, unknown>>;
21
16
  readonly sessionAuthzOptions: SessionAuthzOptions;
22
17
  use(req: Request, res: Response, next: NextFunction): void;
23
18
  }, "als" | "sessionAuthzOptions">>;
24
-
25
- export { type SessionAlsType, createSessionAuthzAlsMiddleware };