nestjs-authentication 0.4.2 → 0.5.0
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/CHANGELOG.md +77 -2
- package/README.md +108 -0
- package/SECURITY.md +15 -0
- package/dist/classes/email.password.user.d.ts +13 -0
- package/dist/classes/email.password.user.d.ts.map +1 -0
- package/dist/classes/email.password.user.js +3 -0
- package/dist/classes/email.password.user.js.map +1 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +14 -1
- package/dist/constants.js.map +1 -1
- package/dist/context/auth.context.d.ts +38 -0
- package/dist/context/auth.context.d.ts.map +1 -0
- package/dist/context/auth.context.js +39 -0
- package/dist/context/auth.context.js.map +1 -0
- package/dist/context/decorators.d.ts +25 -0
- package/dist/context/decorators.d.ts.map +1 -0
- package/dist/context/decorators.js +38 -0
- package/dist/context/decorators.js.map +1 -0
- package/dist/context/index.d.ts +5 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +21 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/interceptor.d.ts +15 -0
- package/dist/context/interceptor.d.ts.map +1 -0
- package/dist/context/interceptor.js +51 -0
- package/dist/context/interceptor.js.map +1 -0
- package/dist/context/service.d.ts +18 -0
- package/dist/context/service.d.ts.map +1 -0
- package/dist/context/service.js +45 -0
- package/dist/context/service.js.map +1 -0
- package/dist/encryptor.d.ts +20 -0
- package/dist/encryptor.d.ts.map +1 -1
- package/dist/encryptor.js +36 -6
- package/dist/encryptor.js.map +1 -1
- package/dist/encryptors/index.d.ts +3 -0
- package/dist/encryptors/index.d.ts.map +1 -0
- package/dist/encryptors/index.js +19 -0
- package/dist/encryptors/index.js.map +1 -0
- package/dist/encryptors/migrating.d.ts +28 -0
- package/dist/encryptors/migrating.d.ts.map +1 -0
- package/dist/encryptors/migrating.js +72 -0
- package/dist/encryptors/migrating.js.map +1 -0
- package/dist/encryptors/scrypt.d.ts +42 -0
- package/dist/encryptors/scrypt.d.ts.map +1 -0
- package/dist/encryptors/scrypt.js +85 -0
- package/dist/encryptors/scrypt.js.map +1 -0
- package/dist/errors.d.ts +32 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +63 -0
- package/dist/errors.js.map +1 -0
- package/dist/guard.d.ts +115 -15
- package/dist/guard.d.ts.map +1 -1
- package/dist/guard.js +302 -90
- package/dist/guard.js.map +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/injection.d.ts +3 -0
- package/dist/injection.d.ts.map +1 -0
- package/dist/injection.js +9 -0
- package/dist/injection.js.map +1 -0
- package/dist/interfaces/auth.user.d.ts +16 -5
- package/dist/interfaces/auth.user.d.ts.map +1 -1
- package/dist/interfaces/auth.user.js +6 -0
- package/dist/interfaces/auth.user.js.map +1 -1
- package/dist/interfaces/encrypt.d.ts +29 -1
- package/dist/interfaces/encrypt.d.ts.map +1 -1
- package/dist/interfaces/options.d.ts +52 -5
- package/dist/interfaces/options.d.ts.map +1 -1
- package/dist/interfaces/provider.d.ts +26 -3
- package/dist/interfaces/provider.d.ts.map +1 -1
- package/dist/module.d.ts +48 -6
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +153 -50
- package/dist/module.js.map +1 -1
- package/dist/providers/auth.provider.d.ts +12 -4
- package/dist/providers/auth.provider.d.ts.map +1 -1
- package/dist/providers/auth.provider.js +7 -1
- package/dist/providers/auth.provider.js.map +1 -1
- package/dist/providers/email.password.auth.provider.d.ts +75 -0
- package/dist/providers/email.password.auth.provider.d.ts.map +1 -0
- package/dist/providers/email.password.auth.provider.js +120 -0
- package/dist/providers/email.password.auth.provider.js.map +1 -0
- package/dist/providers/memory.user.provider.d.ts +39 -6
- package/dist/providers/memory.user.provider.d.ts.map +1 -1
- package/dist/providers/memory.user.provider.js +70 -15
- package/dist/providers/memory.user.provider.js.map +1 -1
- package/dist/scopes/decorators.d.ts +41 -0
- package/dist/scopes/decorators.d.ts.map +1 -0
- package/dist/scopes/decorators.js +44 -0
- package/dist/scopes/decorators.js.map +1 -0
- package/dist/scopes/index.d.ts +4 -0
- package/dist/scopes/index.d.ts.map +1 -0
- package/dist/scopes/index.js +20 -0
- package/dist/scopes/index.js.map +1 -0
- package/dist/scopes/service.d.ts +32 -0
- package/dist/scopes/service.d.ts.map +1 -0
- package/dist/scopes/service.js +90 -0
- package/dist/scopes/service.js.map +1 -0
- package/dist/scopes/utils.d.ts +8 -0
- package/dist/scopes/utils.d.ts.map +1 -0
- package/dist/scopes/utils.js +29 -0
- package/dist/scopes/utils.js.map +1 -0
- package/dist/service.d.ts +25 -6
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +36 -5
- package/dist/service.js.map +1 -1
- package/dist/session/index.d.ts +3 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +19 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/manager.d.ts +32 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +131 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/session/request.d.ts +14 -0
- package/dist/session/request.d.ts.map +1 -0
- package/dist/session/request.js +59 -0
- package/dist/session/request.js.map +1 -0
- package/dist/strategies/emailpassword.d.ts +20 -7
- package/dist/strategies/emailpassword.d.ts.map +1 -1
- package/dist/strategies/emailpassword.js +42 -19
- package/dist/strategies/emailpassword.js.map +1 -1
- package/dist/strategies/extract.d.ts +23 -0
- package/dist/strategies/extract.d.ts.map +1 -0
- package/dist/strategies/extract.js +57 -0
- package/dist/strategies/extract.js.map +1 -0
- package/dist/strategies/index.d.ts +8 -0
- package/dist/strategies/index.d.ts.map +1 -0
- package/dist/strategies/index.js +24 -0
- package/dist/strategies/index.js.map +1 -0
- package/dist/strategies/interfaces.d.ts +65 -0
- package/dist/strategies/interfaces.d.ts.map +1 -0
- package/dist/{classes/memory.user.js → strategies/interfaces.js} +1 -1
- package/dist/strategies/interfaces.js.map +1 -0
- package/dist/strategies/jwt.d.ts +87 -15
- package/dist/strategies/jwt.d.ts.map +1 -1
- package/dist/strategies/jwt.js +140 -9
- package/dist/strategies/jwt.js.map +1 -1
- package/dist/strategies/passport.d.ts +22 -0
- package/dist/strategies/passport.d.ts.map +1 -0
- package/dist/strategies/passport.js +90 -0
- package/dist/strategies/passport.js.map +1 -0
- package/dist/strategies/registry.d.ts +33 -0
- package/dist/strategies/registry.d.ts.map +1 -0
- package/dist/strategies/registry.js +67 -0
- package/dist/strategies/registry.js.map +1 -0
- package/dist/strategies/session.d.ts +18 -0
- package/dist/strategies/session.d.ts.map +1 -0
- package/dist/strategies/session.js +79 -0
- package/dist/strategies/session.js.map +1 -0
- package/dist/transports/graphql.d.ts +28 -0
- package/dist/transports/graphql.d.ts.map +1 -0
- package/dist/transports/graphql.js +59 -0
- package/dist/transports/graphql.js.map +1 -0
- package/dist/transports/http.d.ts +13 -0
- package/dist/transports/http.d.ts.map +1 -0
- package/dist/transports/http.js +31 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/transports/index.d.ts +8 -0
- package/dist/transports/index.d.ts.map +1 -0
- package/dist/transports/index.js +24 -0
- package/dist/transports/index.js.map +1 -0
- package/dist/transports/interfaces.d.ts +36 -0
- package/dist/transports/interfaces.d.ts.map +1 -0
- package/dist/transports/interfaces.js +3 -0
- package/dist/transports/interfaces.js.map +1 -0
- package/dist/transports/registry.d.ts +25 -0
- package/dist/transports/registry.d.ts.map +1 -0
- package/dist/transports/registry.js +55 -0
- package/dist/transports/registry.js.map +1 -0
- package/dist/transports/rpc.d.ts +23 -0
- package/dist/transports/rpc.d.ts.map +1 -0
- package/dist/transports/rpc.js +54 -0
- package/dist/transports/rpc.js.map +1 -0
- package/dist/transports/utils.d.ts +21 -0
- package/dist/transports/utils.d.ts.map +1 -0
- package/dist/transports/utils.js +86 -0
- package/dist/transports/utils.js.map +1 -0
- package/dist/transports/ws.d.ts +31 -0
- package/dist/transports/ws.d.ts.map +1 -0
- package/dist/transports/ws.js +52 -0
- package/dist/transports/ws.js.map +1 -0
- package/package.json +102 -60
- package/dist/classes/memory.user.d.ts +0 -7
- package/dist/classes/memory.user.d.ts.map +0 -1
- package/dist/classes/memory.user.js.map +0 -1
- package/dist/providers/auth.memory.user.provider.d.ts +0 -15
- package/dist/providers/auth.memory.user.provider.d.ts.map +0 -1
- package/dist/providers/auth.memory.user.provider.js +0 -30
- package/dist/providers/auth.memory.user.provider.js.map +0 -1
- package/dist/user.serializer.d.ts +0 -10
- package/dist/user.serializer.d.ts.map +0 -1
- package/dist/user.serializer.js +0 -53
- package/dist/user.serializer.js.map +0 -1
package/dist/guard.d.ts
CHANGED
|
@@ -1,26 +1,126 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { CanActivate, ExecutionContext, Type } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { AuthContext } from './context/auth.context';
|
|
4
|
+
import { AuthExceptionFactory } from './errors';
|
|
5
|
+
import { AuthUserPayload } from './interfaces/auth.user';
|
|
6
|
+
import { IAuthModuleOptions } from './interfaces/options';
|
|
7
|
+
import { ScopesRequirement } from './scopes/decorators';
|
|
8
|
+
import { AuthStrategy, AuthStrategyOptions, AuthStrategyResult } from './strategies/interfaces';
|
|
9
|
+
import { AuthStrategyRegistry } from './strategies/registry';
|
|
10
|
+
import { AuthRequest, AuthTransport } from './transports/interfaces';
|
|
11
|
+
/**
|
|
12
|
+
* Options of the {@link AuthGuard}.
|
|
13
|
+
*/
|
|
5
14
|
export interface AuthGuardOptions {
|
|
15
|
+
/** Reads the user of the session first (requires a session middleware, e.g. express-session). Default `false`. */
|
|
6
16
|
fromSession?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Saves the user into the session when a strategy authenticates the request: a login route.
|
|
19
|
+
* The session is regenerated (a new id, against session fixation). Default `false`.
|
|
20
|
+
*/
|
|
21
|
+
saveSession?: boolean;
|
|
22
|
+
/** With `saveSession`: keeps the data of the session (e.g. a cart) when it is regenerated. Default `false`. */
|
|
23
|
+
keepSessionInfo?: boolean;
|
|
24
|
+
/** Rejects the requests that are not authenticated (403, see `exceptionFactory`). If `false`, they go through without a user. */
|
|
7
25
|
required?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The strategies to try, in order, with their options: the native ones (`jwt`, `emailpassword`, `session`, yours)
|
|
28
|
+
* and the passport strategies. The first one that authenticates the request wins.
|
|
29
|
+
*/
|
|
8
30
|
strategies: {
|
|
9
|
-
[strategyName: string]:
|
|
31
|
+
[strategyName: string]: AuthStrategyOptions;
|
|
10
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Creates the error thrown when a `required` request is not authenticated. If not set, the guard returns `false`
|
|
35
|
+
* and NestJS throws a 403 Forbidden. Use {@link unauthorized} for a 401.
|
|
36
|
+
*/
|
|
37
|
+
exceptionFactory?: AuthExceptionFactory;
|
|
38
|
+
/** Creates the error thrown when the request does not have the required scopes. Default: 403 `Insufficient scope`. */
|
|
39
|
+
scopeExceptionFactory?: AuthExceptionFactory;
|
|
40
|
+
/** Transports tried before the registered and built-in ones, for this guard only. */
|
|
41
|
+
transports?: AuthTransport[];
|
|
11
42
|
}
|
|
43
|
+
/** The request, response and next function of an execution context. */
|
|
44
|
+
export interface AuthGuardRequestResponse {
|
|
45
|
+
request: AuthRequest;
|
|
46
|
+
response: any;
|
|
47
|
+
next: (err?: any) => void;
|
|
48
|
+
}
|
|
49
|
+
/** The default `scopeExceptionFactory`: 403 Insufficient scope, converted for the transport. */
|
|
50
|
+
export declare const insufficientScope: AuthExceptionFactory;
|
|
51
|
+
/**
|
|
52
|
+
* Authenticates the requests with the strategies, on every transport (http, GraphQL, websockets, microservices),
|
|
53
|
+
* and checks the required scopes.
|
|
54
|
+
*
|
|
55
|
+
* Use it in two ways:
|
|
56
|
+
*
|
|
57
|
+
* - **global** (registered by the {@link AuthModule}): configure the routes with {@link Auth}, {@link Public},
|
|
58
|
+
* {@link RequireScopes}, and the `defaults` / `globalGuard` options of the module
|
|
59
|
+
* - **per route**: `@UseGuards(new AuthGuard({ strategies: { jwt: {} }, required: true }))`
|
|
60
|
+
*
|
|
61
|
+
* On success, the user is set in `request.user`, the auth info of each strategy in `request.authInfo[strategyName]`,
|
|
62
|
+
* and the {@link AuthContext} is available with {@link CurrentUser}, {@link CurrentAuth} and the {@link AuthContextService}.
|
|
63
|
+
*/
|
|
12
64
|
export declare class AuthGuard implements CanActivate {
|
|
13
|
-
protected readonly
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
65
|
+
protected readonly registry?: AuthStrategyRegistry | undefined;
|
|
66
|
+
protected readonly moduleOptions?: IAuthModuleOptions | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Returns a guard class with default options, merged with the options of each guard.
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* export const ApiGuard = AuthGuard.withDefaults({ required: true, exceptionFactory: unauthorized() });
|
|
72
|
+
* @UseGuards(new ApiGuard({ strategies: { jwt: {} } }))
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
static withDefaults(defaults: Partial<AuthGuardOptions>): Type<AuthGuard> & {
|
|
76
|
+
new (options?: Partial<AuthGuardOptions>): AuthGuard;
|
|
21
77
|
};
|
|
22
|
-
|
|
78
|
+
protected readonly options?: AuthGuardOptions;
|
|
79
|
+
protected readonly reflector: Reflector;
|
|
80
|
+
/**
|
|
81
|
+
* @param options the options of a guard created with `new AuthGuard()`; the global guard has none and reads the
|
|
82
|
+
* metadata and the module options
|
|
83
|
+
*/
|
|
84
|
+
constructor(options?: AuthGuardOptions, registry?: AuthStrategyRegistry | undefined, reflector?: Reflector, moduleOptions?: IAuthModuleOptions | undefined);
|
|
85
|
+
protected normalizeStrategyOptions(options: AuthStrategyOptions | undefined): AuthStrategyOptions;
|
|
86
|
+
/** Returns the transport of the context. */
|
|
87
|
+
protected getTransport(context: ExecutionContext): AuthTransport;
|
|
88
|
+
/**
|
|
89
|
+
* Returns the request, response and next function of the context.
|
|
90
|
+
*
|
|
91
|
+
* @throws NotImplementedException if no transport supports the context
|
|
92
|
+
*/
|
|
93
|
+
getRequestResponse(context: ExecutionContext): AuthGuardRequestResponse;
|
|
94
|
+
protected getRegistry(): AuthStrategyRegistry;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the options of the guard for a context: the options of `new AuthGuard()`, or the module `defaults`,
|
|
97
|
+
* overridden by the {@link Auth} metadata of the class, then of the method. `undefined` if the guard does not
|
|
98
|
+
* apply (global guard on a route without metadata, and `globalGuard` is not set).
|
|
99
|
+
*/
|
|
100
|
+
protected resolveOptions(context: ExecutionContext): AuthGuardOptions | undefined;
|
|
101
|
+
/** The module options: injected in the global guard, read from the registry for `new AuthGuard()`. */
|
|
102
|
+
protected getModuleOptions(): IAuthModuleOptions | undefined;
|
|
103
|
+
/** Returns the scopes required by the class and the method. */
|
|
104
|
+
protected getScopesRequirements(context: ExecutionContext): ScopesRequirement[];
|
|
105
|
+
/** Restores the user from the session. Returns `true` if the request is authenticated. */
|
|
106
|
+
authenticateFromSession(request: AuthRequest, response: any, context?: ExecutionContext): Promise<boolean>;
|
|
107
|
+
/** Authenticates the request with a strategy. Returns its result, or `undefined` if it did not authenticate it. */
|
|
108
|
+
protected authenticateWithStrategy(strategy: AuthStrategy, options: AuthStrategyOptions, { request, response }: AuthGuardRequestResponse, context: ExecutionContext): Promise<AuthStrategyResult | undefined>;
|
|
109
|
+
/** Stores the {@link AuthContext} on the request, with the scopes of the strategy and of the `scopes` option. */
|
|
110
|
+
protected setAuthContext(request: AuthRequest, strategy: string, result: AuthStrategyResult, context: ExecutionContext): Promise<AuthContext>;
|
|
111
|
+
protected reject(context: ExecutionContext, options: AuthGuardOptions): boolean;
|
|
23
112
|
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
24
|
-
|
|
113
|
+
/** Returns the payload of a user for the session (see {@link AuthService.serializeUser}). */
|
|
114
|
+
protected serializeUser(user: unknown, namespace?: string): AuthUserPayload;
|
|
115
|
+
/**
|
|
116
|
+
* Logs the user in: sets `request.user`, and saves it into the session with `saveSession`.
|
|
117
|
+
*
|
|
118
|
+
* @param options `saveSession`, `keepSessionInfo`, and the `namespace` of the user (to serialize it)
|
|
119
|
+
*/
|
|
120
|
+
login<U>(user: U, request: AuthRequest, options?: {
|
|
121
|
+
saveSession?: boolean;
|
|
122
|
+
keepSessionInfo?: boolean;
|
|
123
|
+
namespace?: string;
|
|
124
|
+
}): Promise<U>;
|
|
25
125
|
}
|
|
26
126
|
//# sourceMappingURL=guard.d.ts.map
|
package/dist/guard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAoD,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACvH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,WAAW,EAAgD,MAAM,wBAAwB,CAAC;AACnG,OAAO,EAAE,oBAAoB,EAAwB,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAIH,iBAAiB,EACpB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGrE;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,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO;IAOzE,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAsD9D,6FAA6F;IAC7F,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe;IAW3E;;;;OAIG;IACG,KAAK,CAAC,CAAC,EACT,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACvF,OAAO,CAAC,CAAC,CAAC;CAUhB"}
|
package/dist/guard.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
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;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
2
14
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
15
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
16
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,118 +20,318 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
20
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
21
|
});
|
|
10
22
|
};
|
|
11
|
-
var
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
23
|
+
var AuthGuard_1;
|
|
14
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.AuthGuard = void 0;
|
|
25
|
+
exports.AuthGuard = exports.insufficientScope = void 0;
|
|
16
26
|
const common_1 = require("@nestjs/common");
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const core_1 = require("@nestjs/core");
|
|
28
|
+
const constants_1 = require("./constants");
|
|
29
|
+
const auth_context_1 = require("./context/auth.context");
|
|
30
|
+
const errors_1 = require("./errors");
|
|
31
|
+
const decorators_1 = require("./scopes/decorators");
|
|
32
|
+
const utils_1 = require("./scopes/utils");
|
|
33
|
+
const manager_1 = require("./session/manager");
|
|
34
|
+
const request_1 = require("./session/request");
|
|
35
|
+
const registry_1 = require("./strategies/registry");
|
|
36
|
+
const registry_2 = require("./transports/registry");
|
|
37
|
+
function throwError(err) {
|
|
38
|
+
if (err !== undefined && err !== null) {
|
|
39
|
+
throw err;
|
|
28
40
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
}
|
|
42
|
+
/** The default `scopeExceptionFactory`: 403 Insufficient scope, converted for the transport. */
|
|
43
|
+
const insufficientScope = (_context, transport) => (0, errors_1.toTransportException)(new common_1.ForbiddenException('Insufficient scope'), transport);
|
|
44
|
+
exports.insufficientScope = insufficientScope;
|
|
45
|
+
/**
|
|
46
|
+
* Authenticates the requests with the strategies, on every transport (http, GraphQL, websockets, microservices),
|
|
47
|
+
* and checks the required scopes.
|
|
48
|
+
*
|
|
49
|
+
* Use it in two ways:
|
|
50
|
+
*
|
|
51
|
+
* - **global** (registered by the {@link AuthModule}): configure the routes with {@link Auth}, {@link Public},
|
|
52
|
+
* {@link RequireScopes}, and the `defaults` / `globalGuard` options of the module
|
|
53
|
+
* - **per route**: `@UseGuards(new AuthGuard({ strategies: { jwt: {} }, required: true }))`
|
|
54
|
+
*
|
|
55
|
+
* On success, the user is set in `request.user`, the auth info of each strategy in `request.authInfo[strategyName]`,
|
|
56
|
+
* and the {@link AuthContext} is available with {@link CurrentUser}, {@link CurrentAuth} and the {@link AuthContextService}.
|
|
57
|
+
*/
|
|
58
|
+
let AuthGuard = AuthGuard_1 = class AuthGuard {
|
|
59
|
+
/**
|
|
60
|
+
* Returns a guard class with default options, merged with the options of each guard.
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* export const ApiGuard = AuthGuard.withDefaults({ required: true, exceptionFactory: unauthorized() });
|
|
64
|
+
* @UseGuards(new ApiGuard({ strategies: { jwt: {} } }))
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
static withDefaults(defaults) {
|
|
68
|
+
return class extends AuthGuard_1 {
|
|
69
|
+
constructor(options = {}) {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
super(Object.assign(Object.assign(Object.assign({}, defaults), options), { strategies: Object.assign({}, ((_b = (_a = options.strategies) !== null && _a !== void 0 ? _a : defaults.strategies) !== null && _b !== void 0 ? _b : {})) }));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @param options the options of a guard created with `new AuthGuard()`; the global guard has none and reads the
|
|
77
|
+
* metadata and the module options
|
|
78
|
+
*/
|
|
79
|
+
constructor(options, registry, reflector, moduleOptions) {
|
|
80
|
+
var _a;
|
|
81
|
+
this.registry = registry;
|
|
82
|
+
this.moduleOptions = moduleOptions;
|
|
83
|
+
this.reflector = reflector !== null && reflector !== void 0 ? reflector : new core_1.Reflector();
|
|
84
|
+
if (options !== undefined && options !== null) {
|
|
85
|
+
const strategies = {};
|
|
86
|
+
for (const name in (_a = options.strategies) !== null && _a !== void 0 ? _a : {}) {
|
|
87
|
+
strategies[name] = this.normalizeStrategyOptions(options.strategies[name]);
|
|
88
|
+
}
|
|
89
|
+
options.strategies = strategies;
|
|
90
|
+
this.options = options;
|
|
32
91
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
92
|
+
}
|
|
93
|
+
normalizeStrategyOptions(options) {
|
|
94
|
+
// the session options are options of the guard: fail loudly instead of ignoring them
|
|
95
|
+
for (const option of ['session', 'keepSessionInfo']) {
|
|
96
|
+
if (options !== undefined && options !== null && option in options) {
|
|
97
|
+
throw new Error(`The "${option}" option of a strategy is not supported: set "${option === 'session' ? 'saveSession' : option}" on the guard, e.g. @Auth({ strategies: { emailpassword: {} }, saveSession: true })`);
|
|
98
|
+
}
|
|
36
99
|
}
|
|
37
|
-
|
|
38
|
-
|
|
100
|
+
return Object.assign({ authInfo: true }, (options !== null && options !== void 0 ? options : {}));
|
|
101
|
+
}
|
|
102
|
+
/** Returns the transport of the context. */
|
|
103
|
+
getTransport(context) {
|
|
104
|
+
var _a;
|
|
105
|
+
return registry_2.AuthTransports.get(context, (_a = this.options) === null || _a === void 0 ? void 0 : _a.transports);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Returns the request, response and next function of the context.
|
|
109
|
+
*
|
|
110
|
+
* @throws NotImplementedException if no transport supports the context
|
|
111
|
+
*/
|
|
112
|
+
getRequestResponse(context) {
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
const transport = this.getTransport(context);
|
|
115
|
+
return {
|
|
116
|
+
request: transport.getRequest(context),
|
|
117
|
+
response: (_a = transport.getResponse) === null || _a === void 0 ? void 0 : _a.call(transport, context),
|
|
118
|
+
next: (_c = (_b = transport.getNext) === null || _b === void 0 ? void 0 : _b.call(transport, context)) !== null && _c !== void 0 ? _c : throwError
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
getRegistry() {
|
|
122
|
+
var _a;
|
|
123
|
+
const registry = (_a = this.registry) !== null && _a !== void 0 ? _a : registry_1.AuthStrategyRegistry.current;
|
|
124
|
+
if (registry === undefined) {
|
|
125
|
+
throw new Error('AuthGuard: the AuthModule is not initialized (import AuthModule.forRoot())');
|
|
39
126
|
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
127
|
+
return registry;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Returns the options of the guard for a context: the options of `new AuthGuard()`, or the module `defaults`,
|
|
131
|
+
* overridden by the {@link Auth} metadata of the class, then of the method. `undefined` if the guard does not
|
|
132
|
+
* apply (global guard on a route without metadata, and `globalGuard` is not set).
|
|
133
|
+
*/
|
|
134
|
+
resolveOptions(context) {
|
|
135
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
136
|
+
const handler = (_a = context.getHandler) === null || _a === void 0 ? void 0 : _a.call(context);
|
|
137
|
+
const type = (_b = context.getClass) === null || _b === void 0 ? void 0 : _b.call(context);
|
|
138
|
+
const read = (key, target) => target !== undefined && target !== null ? this.reflector.get(key, target) : undefined;
|
|
139
|
+
const classAuth = read(decorators_1.AUTH_OPTIONS_METADATA, type);
|
|
140
|
+
const handlerAuth = read(decorators_1.AUTH_OPTIONS_METADATA, handler);
|
|
141
|
+
const isPublic = ((_c = read(decorators_1.AUTH_PUBLIC_METADATA, handler)) !== null && _c !== void 0 ? _c : read(decorators_1.AUTH_PUBLIC_METADATA, type)) === true;
|
|
142
|
+
const hasMetadata = classAuth !== undefined || handlerAuth !== undefined || isPublic;
|
|
143
|
+
let base = this.options;
|
|
144
|
+
if (base === undefined) {
|
|
145
|
+
const global = ((_d = this.getModuleOptions()) === null || _d === void 0 ? void 0 : _d.globalGuard) === true;
|
|
146
|
+
if (!hasMetadata && !global && this.getScopesRequirements(context).length === 0) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
base = (_f = (_e = this.getModuleOptions()) === null || _e === void 0 ? void 0 : _e.defaults) !== null && _f !== void 0 ? _f : {};
|
|
49
150
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
next = (err) => {
|
|
55
|
-
throw err;
|
|
56
|
-
};
|
|
151
|
+
const strategiesSource = (_j = (_h = (_g = handlerAuth === null || handlerAuth === void 0 ? void 0 : handlerAuth.strategies) !== null && _g !== void 0 ? _g : classAuth === null || classAuth === void 0 ? void 0 : classAuth.strategies) !== null && _h !== void 0 ? _h : base.strategies) !== null && _j !== void 0 ? _j : {};
|
|
152
|
+
const strategies = {};
|
|
153
|
+
for (const name in strategiesSource) {
|
|
154
|
+
strategies[name] = this.normalizeStrategyOptions(strategiesSource[name]);
|
|
57
155
|
}
|
|
58
|
-
|
|
59
|
-
|
|
156
|
+
const options = Object.assign(Object.assign(Object.assign(Object.assign({}, base), classAuth), handlerAuth), { strategies });
|
|
157
|
+
if (isPublic) {
|
|
158
|
+
options.required = false;
|
|
60
159
|
}
|
|
61
|
-
return
|
|
160
|
+
return options;
|
|
161
|
+
}
|
|
162
|
+
/** The module options: injected in the global guard, read from the registry for `new AuthGuard()`. */
|
|
163
|
+
getModuleOptions() {
|
|
164
|
+
var _a, _b, _c;
|
|
165
|
+
return (_a = this.moduleOptions) !== null && _a !== void 0 ? _a : (_c = ((_b = this.registry) !== null && _b !== void 0 ? _b : registry_1.AuthStrategyRegistry.current)) === null || _c === void 0 ? void 0 : _c.moduleOptions;
|
|
62
166
|
}
|
|
63
|
-
|
|
167
|
+
/** Returns the scopes required by the class and the method. */
|
|
168
|
+
getScopesRequirements(context) {
|
|
169
|
+
var _a, _b;
|
|
170
|
+
const targets = [(_a = context.getClass) === null || _a === void 0 ? void 0 : _a.call(context), (_b = context.getHandler) === null || _b === void 0 ? void 0 : _b.call(context)].filter((t) => t !== undefined);
|
|
171
|
+
return targets
|
|
172
|
+
.map((t) => this.reflector.get(decorators_1.AUTH_SCOPES_METADATA, t))
|
|
173
|
+
.filter((r) => r !== undefined);
|
|
174
|
+
}
|
|
175
|
+
/** Restores the user from the session. Returns `true` if the request is authenticated. */
|
|
176
|
+
authenticateFromSession(request, response, context) {
|
|
64
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
178
|
+
const result = yield this.getRegistry()
|
|
179
|
+
.get('session')
|
|
180
|
+
.authenticate({
|
|
181
|
+
request,
|
|
182
|
+
response,
|
|
183
|
+
transport: context !== undefined ? this.getTransport(context).name : 'http',
|
|
184
|
+
executionContext: context,
|
|
185
|
+
options: {}
|
|
186
|
+
});
|
|
187
|
+
if (result === undefined) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
request.user = result.user;
|
|
191
|
+
if (context !== undefined) {
|
|
192
|
+
yield this.setAuthContext(request, 'session', result, context);
|
|
193
|
+
}
|
|
194
|
+
return true;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/** Authenticates the request with a strategy. Returns its result, or `undefined` if it did not authenticate it. */
|
|
198
|
+
authenticateWithStrategy(strategy_1, options_1, _a, context_1) {
|
|
199
|
+
return __awaiter(this, arguments, void 0, function* (strategy, options, { request, response }, context) {
|
|
200
|
+
const result = yield strategy.authenticate({
|
|
201
|
+
request,
|
|
202
|
+
response,
|
|
203
|
+
transport: this.getTransport(context).name,
|
|
204
|
+
executionContext: context,
|
|
205
|
+
options
|
|
206
|
+
});
|
|
207
|
+
if (request.authInfo === undefined || request.authInfo === null) {
|
|
208
|
+
request.authInfo = {};
|
|
209
|
+
}
|
|
210
|
+
request.authInfo[strategy.name] = result === null || result === void 0 ? void 0 : result.info;
|
|
211
|
+
if (result === undefined ||
|
|
212
|
+
result.handled === true ||
|
|
213
|
+
typeof result.user !== 'object' ||
|
|
214
|
+
result.user === null) {
|
|
215
|
+
return (result === null || result === void 0 ? void 0 : result.handled) === true ? result : undefined;
|
|
216
|
+
}
|
|
217
|
+
return result;
|
|
71
218
|
});
|
|
72
219
|
}
|
|
220
|
+
/** Stores the {@link AuthContext} on the request, with the scopes of the strategy and of the `scopes` option. */
|
|
221
|
+
setAuthContext(request, strategy, result, context) {
|
|
222
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
var _a, _b;
|
|
224
|
+
const auth = {
|
|
225
|
+
user: result.user,
|
|
226
|
+
strategy,
|
|
227
|
+
namespace: result.namespace,
|
|
228
|
+
info: result.info,
|
|
229
|
+
transport: this.getTransport(context).name,
|
|
230
|
+
scopes: (0, utils_1.normalizeScopes)(result.scopes)
|
|
231
|
+
};
|
|
232
|
+
const resolver = (_a = this.getModuleOptions()) === null || _a === void 0 ? void 0 : _a.scopes;
|
|
233
|
+
if (resolver !== undefined) {
|
|
234
|
+
auth.scopes = (0, utils_1.normalizeScopes)([...((_b = auth.scopes) !== null && _b !== void 0 ? _b : []), ...(yield resolver(auth))]);
|
|
235
|
+
}
|
|
236
|
+
(0, auth_context_1.setRequestAuthContext)(request, auth);
|
|
237
|
+
return auth;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
reject(context, options) {
|
|
241
|
+
if (options.exceptionFactory !== undefined) {
|
|
242
|
+
throw options.exceptionFactory(context, this.getTransport(context).name);
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
73
246
|
canActivate(context) {
|
|
74
247
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
248
|
+
var _a, _b, _c, _d;
|
|
249
|
+
const options = this.resolveOptions(context);
|
|
250
|
+
if (options === undefined) {
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
const ctx = this.getRequestResponse(context);
|
|
254
|
+
const { request, response } = ctx;
|
|
255
|
+
(0, request_1.decorateRequest)(request, {
|
|
256
|
+
key: (_a = this.getModuleOptions()) === null || _a === void 0 ? void 0 : _a.sessionKey,
|
|
257
|
+
serialize: (user) => { var _a; return this.serializeUser(user, (_a = (0, auth_context_1.getRequestAuthContext)(request)) === null || _a === void 0 ? void 0 : _a.namespace); }
|
|
258
|
+
});
|
|
259
|
+
const scopes = this.getScopesRequirements(context);
|
|
260
|
+
const required = options.required === true || scopes.length > 0;
|
|
261
|
+
let authenticated = false;
|
|
262
|
+
if (options.fromSession === true) {
|
|
263
|
+
authenticated = yield this.authenticateFromSession(request, response, context);
|
|
81
264
|
}
|
|
82
|
-
for (const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (err !== undefined && err !== null) {
|
|
91
|
-
return reject(err);
|
|
92
|
-
}
|
|
93
|
-
if (typeof user === 'object' && typeof user !== null) {
|
|
94
|
-
yield this.login(user, options, request);
|
|
95
|
-
return resolve(true);
|
|
96
|
-
}
|
|
97
|
-
return resolve(false);
|
|
98
|
-
}
|
|
99
|
-
catch (e) {
|
|
100
|
-
return reject(e);
|
|
101
|
-
}
|
|
102
|
-
}))(request, response, next));
|
|
103
|
-
if (success === true) {
|
|
104
|
-
return success;
|
|
265
|
+
for (const name in options.strategies) {
|
|
266
|
+
if (authenticated) {
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
const result = yield this.authenticateWithStrategy(this.getRegistry().get(name), options.strategies[name], ctx, context);
|
|
270
|
+
if ((result === null || result === void 0 ? void 0 : result.handled) === true) {
|
|
271
|
+
// the strategy sent the response (e.g. an OAuth redirect)
|
|
272
|
+
return false;
|
|
105
273
|
}
|
|
274
|
+
if (result !== undefined) {
|
|
275
|
+
yield this.login(result.user, request, {
|
|
276
|
+
saveSession: options.saveSession,
|
|
277
|
+
keepSessionInfo: options.keepSessionInfo,
|
|
278
|
+
namespace: result.namespace
|
|
279
|
+
});
|
|
280
|
+
yield this.setAuthContext(request, name, result, context);
|
|
281
|
+
authenticated = true;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
authenticated = authenticated || request.isAuthenticated();
|
|
285
|
+
if (!authenticated) {
|
|
286
|
+
return required ? this.reject(context, options) : true;
|
|
106
287
|
}
|
|
107
|
-
|
|
288
|
+
const granted = (_c = (_b = (0, auth_context_1.getRequestAuthContext)(request)) === null || _b === void 0 ? void 0 : _b.scopes) !== null && _c !== void 0 ? _c : [];
|
|
289
|
+
if (!scopes.every((requirement) => (0, utils_1.hasScopes)(granted, requirement))) {
|
|
290
|
+
throw ((_d = options.scopeExceptionFactory) !== null && _d !== void 0 ? _d : exports.insufficientScope)(context, this.getTransport(context).name);
|
|
291
|
+
}
|
|
292
|
+
return true;
|
|
108
293
|
});
|
|
109
294
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
295
|
+
/** Returns the payload of a user for the session (see {@link AuthService.serializeUser}). */
|
|
296
|
+
serializeUser(user, namespace) {
|
|
297
|
+
const authService = this.getRegistry().authService;
|
|
298
|
+
if (authService !== undefined) {
|
|
299
|
+
return authService.serializeUser(user, namespace);
|
|
300
|
+
}
|
|
301
|
+
if (typeof (user === null || user === void 0 ? void 0 : user.authSerialize) === 'function') {
|
|
302
|
+
return user.authSerialize();
|
|
303
|
+
}
|
|
304
|
+
throw new Error('Cannot store the user in the session: the AuthModule is not initialized');
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Logs the user in: sets `request.user`, and saves it into the session with `saveSession`.
|
|
308
|
+
*
|
|
309
|
+
* @param options `saveSession`, `keepSessionInfo`, and the `namespace` of the user (to serialize it)
|
|
310
|
+
*/
|
|
311
|
+
login(user_1, request_2) {
|
|
312
|
+
return __awaiter(this, arguments, void 0, function* (user, request, options = {}) {
|
|
313
|
+
var _a, _b;
|
|
314
|
+
if (options.saveSession === true) {
|
|
315
|
+
yield (0, manager_1.sessionLogIn)(request, this.serializeUser(user, options.namespace), {
|
|
316
|
+
keepSessionInfo: options.keepSessionInfo === true,
|
|
317
|
+
key: (_b = (_a = this.getModuleOptions()) === null || _a === void 0 ? void 0 : _a.sessionKey) !== null && _b !== void 0 ? _b : manager_1.DEFAULT_SESSION_KEY
|
|
118
318
|
});
|
|
119
|
-
}
|
|
319
|
+
}
|
|
320
|
+
request.user = user;
|
|
321
|
+
return user;
|
|
120
322
|
});
|
|
121
323
|
}
|
|
122
|
-
}
|
|
324
|
+
};
|
|
123
325
|
exports.AuthGuard = AuthGuard;
|
|
124
|
-
AuthGuard
|
|
326
|
+
exports.AuthGuard = AuthGuard = AuthGuard_1 = __decorate([
|
|
327
|
+
(0, common_1.Injectable)(),
|
|
328
|
+
__param(0, (0, common_1.Optional)()),
|
|
329
|
+
__param(0, (0, common_1.Inject)('nestjs-authentication:guard.options')),
|
|
330
|
+
__param(1, (0, common_1.Optional)()),
|
|
331
|
+
__param(2, (0, common_1.Optional)()),
|
|
332
|
+
__param(3, (0, common_1.Optional)()),
|
|
333
|
+
__param(3, (0, common_1.Inject)(constants_1.MODULE_OPTIONS_TOKEN)),
|
|
334
|
+
__metadata("design:paramtypes", [Object, registry_1.AuthStrategyRegistry,
|
|
335
|
+
core_1.Reflector, Object])
|
|
336
|
+
], AuthGuard);
|
|
125
337
|
//# sourceMappingURL=guard.js.map
|
package/dist/guard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../src/guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;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