@tc-libs/authentication 0.9.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/README.md +11 -0
- package/package.json +11 -0
- package/src/authentication.module.d.ts +6 -0
- package/src/authentication.module.js +39 -0
- package/src/authentication.module.js.map +1 -0
- package/src/authentication.module.options.d.ts +41 -0
- package/src/authentication.module.options.js +5 -0
- package/src/authentication.module.options.js.map +1 -0
- package/src/constants/auth.constant.d.ts +3 -0
- package/src/constants/auth.constant.js +7 -0
- package/src/constants/auth.constant.js.map +1 -0
- package/src/constants/auth.enum.constant.d.ts +17 -0
- package/src/constants/auth.enum.constant.js +19 -0
- package/src/constants/auth.enum.constant.js.map +1 -0
- package/src/constants/index.d.ts +2 -0
- package/src/constants/index.js +6 -0
- package/src/constants/index.js.map +1 -0
- package/src/decorators/auth.combined.decorator.d.ts +2 -0
- package/src/decorators/auth.combined.decorator.js +27 -0
- package/src/decorators/auth.combined.decorator.js.map +1 -0
- package/src/decorators/auth.current-user.decorator.d.ts +2 -0
- package/src/decorators/auth.current-user.decorator.js +25 -0
- package/src/decorators/auth.current-user.decorator.js.map +1 -0
- package/src/decorators/auth.jwt.decorator.d.ts +7 -0
- package/src/decorators/auth.jwt.decorator.js +48 -0
- package/src/decorators/auth.jwt.decorator.js.map +1 -0
- package/src/decorators/auth.permission.decorator.d.ts +2 -0
- package/src/decorators/auth.permission.decorator.js +16 -0
- package/src/decorators/auth.permission.decorator.js.map +1 -0
- package/src/decorators/index.d.ts +4 -0
- package/src/decorators/index.js +8 -0
- package/src/decorators/index.js.map +1 -0
- package/src/guards/combined/auth.combined.guard.d.ts +8 -0
- package/src/guards/combined/auth.combined.guard.js +40 -0
- package/src/guards/combined/auth.combined.guard.js.map +1 -0
- package/src/guards/index.d.ts +7 -0
- package/src/guards/index.js +11 -0
- package/src/guards/index.js.map +1 -0
- package/src/guards/jwt-access/auth.jwt-access.guard.d.ts +5 -0
- package/src/guards/jwt-access/auth.jwt-access.guard.js +20 -0
- package/src/guards/jwt-access/auth.jwt-access.guard.js.map +1 -0
- package/src/guards/jwt-access/auth.jwt-access.strategy.d.ts +13 -0
- package/src/guards/jwt-access/auth.jwt-access.strategy.js +40 -0
- package/src/guards/jwt-access/auth.jwt-access.strategy.js.map +1 -0
- package/src/guards/jwt-refresh/auth.jwt-refresh.guard.d.ts +5 -0
- package/src/guards/jwt-refresh/auth.jwt-refresh.guard.js +20 -0
- package/src/guards/jwt-refresh/auth.jwt-refresh.guard.js.map +1 -0
- package/src/guards/jwt-refresh/auth.jwt-refresh.strategy.d.ts +13 -0
- package/src/guards/jwt-refresh/auth.jwt-refresh.strategy.js +45 -0
- package/src/guards/jwt-refresh/auth.jwt-refresh.strategy.js.map +1 -0
- package/src/guards/payload/auth.payload.access-for.guard.d.ts +7 -0
- package/src/guards/payload/auth.payload.access-for.guard.js +33 -0
- package/src/guards/payload/auth.payload.access-for.guard.js.map +1 -0
- package/src/guards/payload/auth.payload.permission.guard.d.ts +7 -0
- package/src/guards/payload/auth.payload.permission.guard.js +42 -0
- package/src/guards/payload/auth.payload.permission.guard.js.map +1 -0
- package/src/guards/permission/auth.permission.guard.d.ts +12 -0
- package/src/guards/permission/auth.permission.guard.js +55 -0
- package/src/guards/permission/auth.permission.guard.js.map +1 -0
- package/src/index.d.ts +7 -0
- package/src/index.js +11 -0
- package/src/index.js.map +1 -0
- package/src/interfaces/auth.interface.d.ts +10 -0
- package/src/interfaces/auth.interface.js +3 -0
- package/src/interfaces/auth.interface.js.map +1 -0
- package/src/interfaces/auth.service.interface.d.ts +11 -0
- package/src/interfaces/auth.service.interface.js +3 -0
- package/src/interfaces/auth.service.interface.js.map +1 -0
- package/src/interfaces/index.d.ts +4 -0
- package/src/interfaces/index.js +8 -0
- package/src/interfaces/index.js.map +1 -0
- package/src/interfaces/module-permissions.interface.d.ts +15 -0
- package/src/interfaces/module-permissions.interface.js +9 -0
- package/src/interfaces/module-permissions.interface.js.map +1 -0
- package/src/interfaces/permission.interface.d.ts +4 -0
- package/src/interfaces/permission.interface.js +3 -0
- package/src/interfaces/permission.interface.js.map +1 -0
- package/src/serializations/index.d.ts +1 -0
- package/src/serializations/index.js +5 -0
- package/src/serializations/index.js.map +1 -0
- package/src/serializations/token.payload.serialization.d.ts +3 -0
- package/src/serializations/token.payload.serialization.js +7 -0
- package/src/serializations/token.payload.serialization.js.map +1 -0
- package/src/services/auth.service.d.ts +46 -0
- package/src/services/auth.service.js +104 -0
- package/src/services/auth.service.js.map +1 -0
- package/src/services/index.d.ts +1 -0
- package/src/services/index.js +5 -0
- package/src/services/index.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# authentication
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build authentication` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test authentication` to execute the unit tests via [Jest](https://jestjs.io).
|
package/package.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import AuthenticationModuleAsyncOptions, { AuthenticationModuleOptions } from './authentication.module.options';
|
|
3
|
+
export declare class AuthModule {
|
|
4
|
+
static register(options: AuthenticationModuleOptions, isGlobal?: boolean): DynamicModule;
|
|
5
|
+
static registerAsync(options: AuthenticationModuleAsyncOptions, isGlobal?: boolean): DynamicModule;
|
|
6
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthModule = void 0;
|
|
4
|
+
const guards_1 = require("./guards");
|
|
5
|
+
const services_1 = require("./services");
|
|
6
|
+
const authentication_module_options_1 = require("./authentication.module.options");
|
|
7
|
+
const providers = [services_1.AuthService, guards_1.AuthJwtAccessStrategy, guards_1.AuthJwtRefreshStrategy];
|
|
8
|
+
class AuthModule {
|
|
9
|
+
static register(options, isGlobal) {
|
|
10
|
+
return {
|
|
11
|
+
module: AuthModule,
|
|
12
|
+
imports: [],
|
|
13
|
+
providers: [
|
|
14
|
+
{ provide: authentication_module_options_1.AUTHENTICATION_CONFIG_OPTIONS, useValue: options },
|
|
15
|
+
...providers,
|
|
16
|
+
],
|
|
17
|
+
exports: [services_1.AuthService],
|
|
18
|
+
global: isGlobal,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
static registerAsync(options, isGlobal) {
|
|
22
|
+
return {
|
|
23
|
+
module: AuthModule,
|
|
24
|
+
imports: [...(options.imports || [])],
|
|
25
|
+
providers: [
|
|
26
|
+
{
|
|
27
|
+
provide: authentication_module_options_1.AUTHENTICATION_CONFIG_OPTIONS,
|
|
28
|
+
useFactory: options.useFactory,
|
|
29
|
+
inject: options.inject,
|
|
30
|
+
},
|
|
31
|
+
...providers,
|
|
32
|
+
],
|
|
33
|
+
exports: [services_1.AuthService],
|
|
34
|
+
global: isGlobal,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.AuthModule = AuthModule;
|
|
39
|
+
//# sourceMappingURL=authentication.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.module.js","sourceRoot":"","sources":["../../../../packages/authentication/src/authentication.module.ts"],"names":[],"mappings":";;;AACA,qCAAyE;AACzE,yCAAyC;AACzC,mFAGyC;AAEzC,MAAM,SAAS,GAAG,CAAC,sBAAW,EAAE,8BAAqB,EAAE,+BAAsB,CAAC,CAAC;AAE/E,MAAa,UAAU;IACrB,MAAM,CAAC,QAAQ,CACb,OAAoC,EACpC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,6DAA6B,EAAE,QAAQ,EAAE,OAAO,EAAE;gBAC7D,GAAG,SAAS;aACb;YACD,OAAO,EAAE,CAAC,sBAAW,CAAC;YACtB,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,aAAa,CAClB,OAAyC,EACzC,QAAkB;QAElB,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;YACrC,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,6DAA6B;oBACtC,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;iBACvB;gBACD,GAAG,SAAS;aACb;YACD,OAAO,EAAE,CAAC,sBAAW,CAAC;YACtB,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;CACF;AApCD,gCAoCC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface';
|
|
3
|
+
export declare const AUTHENTICATION_CONFIG_OPTIONS = "AUTHENTICATION_CONFIG_OPTIONS";
|
|
4
|
+
export interface AuthenticationModuleOptions {
|
|
5
|
+
jwt: {
|
|
6
|
+
defaultSecretKey: string;
|
|
7
|
+
defaultExpirationTime: number;
|
|
8
|
+
};
|
|
9
|
+
auth: {
|
|
10
|
+
prefixAuthorization: string;
|
|
11
|
+
subject: string;
|
|
12
|
+
audience: string;
|
|
13
|
+
issuer: string;
|
|
14
|
+
payloadEncryption: boolean;
|
|
15
|
+
accessToken: {
|
|
16
|
+
secretKey: string;
|
|
17
|
+
expirationTime: number;
|
|
18
|
+
notBeforeExpirationTime: number;
|
|
19
|
+
encryptKey: string;
|
|
20
|
+
encryptIv: string;
|
|
21
|
+
};
|
|
22
|
+
refreshToken: {
|
|
23
|
+
secretKey: string;
|
|
24
|
+
expirationTime: number;
|
|
25
|
+
expirationTimeRememberMe: number;
|
|
26
|
+
notBeforeExpirationTime: number;
|
|
27
|
+
encryptKey: string;
|
|
28
|
+
encryptIv: string;
|
|
29
|
+
};
|
|
30
|
+
permissionToken: {
|
|
31
|
+
headerName: string;
|
|
32
|
+
secretKey: string;
|
|
33
|
+
expirationTime: number;
|
|
34
|
+
notBeforeExpirationTime: number;
|
|
35
|
+
encryptKey: string;
|
|
36
|
+
encryptIv: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
type AuthenticationModuleAsyncOptions = Pick<ModuleMetadata, 'imports'> & Pick<FactoryProvider<AuthenticationModuleOptions>, 'useFactory' | 'inject'>;
|
|
41
|
+
export default AuthenticationModuleAsyncOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authentication.module.options.js","sourceRoot":"","sources":["../../../../packages/authentication/src/authentication.module.options.ts"],"names":[],"mappings":";;;AAGa,QAAA,6BAA6B,GAAG,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUTH_PERMISSION_PERMISSIONS_META_KEY = exports.AUTH_PERMISSION_GROUP_META_KEY = exports.AUTH_ACCESS_FOR_META_KEY = void 0;
|
|
4
|
+
exports.AUTH_ACCESS_FOR_META_KEY = 'AuthAccessForMetaKey';
|
|
5
|
+
exports.AUTH_PERMISSION_GROUP_META_KEY = 'AuthPermissionGroupMetaKey';
|
|
6
|
+
exports.AUTH_PERMISSION_PERMISSIONS_META_KEY = 'AuthPermissionPERMISSIONSMetaKey';
|
|
7
|
+
//# sourceMappingURL=auth.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.constant.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/constants/auth.constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,wBAAwB,GAAG,sBAAsB,CAAC;AAClD,QAAA,8BAA8B,GAAG,4BAA4B,CAAC;AAC9D,QAAA,oCAAoC,GAC/C,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN {
|
|
2
|
+
SUPER_ADMIN = "SUPER_ADMIN"
|
|
3
|
+
}
|
|
4
|
+
export declare enum ENUM_AUTH_ACCESS_FOR_DEFAULT {
|
|
5
|
+
USER = "USER",
|
|
6
|
+
ADMIN = "ADMIN",
|
|
7
|
+
EDITOR = "EDITOR",
|
|
8
|
+
LOGISTIC = "LOGISTIC"
|
|
9
|
+
}
|
|
10
|
+
export declare const ENUM_AUTH_ACCESS_FOR: {
|
|
11
|
+
USER: ENUM_AUTH_ACCESS_FOR_DEFAULT.USER;
|
|
12
|
+
ADMIN: ENUM_AUTH_ACCESS_FOR_DEFAULT.ADMIN;
|
|
13
|
+
EDITOR: ENUM_AUTH_ACCESS_FOR_DEFAULT.EDITOR;
|
|
14
|
+
LOGISTIC: ENUM_AUTH_ACCESS_FOR_DEFAULT.LOGISTIC;
|
|
15
|
+
SUPER_ADMIN: ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN.SUPER_ADMIN;
|
|
16
|
+
};
|
|
17
|
+
export type ENUM_AUTH_ACCESS_FOR = ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN | ENUM_AUTH_ACCESS_FOR_DEFAULT;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENUM_AUTH_ACCESS_FOR = exports.ENUM_AUTH_ACCESS_FOR_DEFAULT = exports.ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN = void 0;
|
|
4
|
+
var ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN;
|
|
5
|
+
(function (ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN) {
|
|
6
|
+
ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN["SUPER_ADMIN"] = "SUPER_ADMIN";
|
|
7
|
+
})(ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN || (exports.ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN = ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN = {}));
|
|
8
|
+
var ENUM_AUTH_ACCESS_FOR_DEFAULT;
|
|
9
|
+
(function (ENUM_AUTH_ACCESS_FOR_DEFAULT) {
|
|
10
|
+
ENUM_AUTH_ACCESS_FOR_DEFAULT["USER"] = "USER";
|
|
11
|
+
ENUM_AUTH_ACCESS_FOR_DEFAULT["ADMIN"] = "ADMIN";
|
|
12
|
+
ENUM_AUTH_ACCESS_FOR_DEFAULT["EDITOR"] = "EDITOR";
|
|
13
|
+
ENUM_AUTH_ACCESS_FOR_DEFAULT["LOGISTIC"] = "LOGISTIC";
|
|
14
|
+
})(ENUM_AUTH_ACCESS_FOR_DEFAULT || (exports.ENUM_AUTH_ACCESS_FOR_DEFAULT = ENUM_AUTH_ACCESS_FOR_DEFAULT = {}));
|
|
15
|
+
exports.ENUM_AUTH_ACCESS_FOR = {
|
|
16
|
+
...ENUM_AUTH_ACCESS_FOR_SUPER_ADMIN,
|
|
17
|
+
...ENUM_AUTH_ACCESS_FOR_DEFAULT,
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=auth.enum.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.enum.constant.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/constants/auth.enum.constant.ts"],"names":[],"mappings":";;;AAAA,IAAY,gCAEX;AAFD,WAAY,gCAAgC;IAC1C,+DAA2B,CAAA;AAC7B,CAAC,EAFW,gCAAgC,gDAAhC,gCAAgC,QAE3C;AAED,IAAY,4BAKX;AALD,WAAY,4BAA4B;IACtC,6CAAa,CAAA;IACb,+CAAe,CAAA;IACf,iDAAiB,CAAA;IACjB,qDAAqB,CAAA;AACvB,CAAC,EALW,4BAA4B,4CAA5B,4BAA4B,QAKvC;AAEY,QAAA,oBAAoB,GAAG;IAClC,GAAG,gCAAgC;IACnC,GAAG,4BAA4B;CAChC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./auth.constant"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./auth.enum.constant"), exports);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/constants/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,+DAAqC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthCombinedPublicAccessClassProtected = AuthCombinedPublicAccessClassProtected;
|
|
4
|
+
exports.AuthCombinedAdminAccessClassProtected = AuthCombinedAdminAccessClassProtected;
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const auth_constant_1 = require("../constants/auth.constant");
|
|
7
|
+
const auth_enum_constant_1 = require("../constants/auth.enum.constant");
|
|
8
|
+
const auth_combined_guard_1 = require("../guards/combined/auth.combined.guard");
|
|
9
|
+
const auth_payload_access_for_guard_1 = require("../guards/payload/auth.payload.access-for.guard");
|
|
10
|
+
function AuthCombinedPublicAccessClassProtected() {
|
|
11
|
+
return function (constructor) {
|
|
12
|
+
// Applica UseGuards e SetMetadata a livello di classe
|
|
13
|
+
(0, common_1.UseGuards)(auth_combined_guard_1.CombinedAuthGuard, auth_payload_access_for_guard_1.AuthPayloadAccessForGuard)(constructor);
|
|
14
|
+
(0, common_1.SetMetadata)(auth_constant_1.AUTH_ACCESS_FOR_META_KEY, [auth_enum_constant_1.ENUM_AUTH_ACCESS_FOR.USER])(constructor);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function AuthCombinedAdminAccessClassProtected() {
|
|
18
|
+
return function (constructor) {
|
|
19
|
+
// Applica UseGuards e SetMetadata a livello di classe
|
|
20
|
+
(0, common_1.UseGuards)(auth_combined_guard_1.CombinedAuthGuard, auth_payload_access_for_guard_1.AuthPayloadAccessForGuard)(constructor);
|
|
21
|
+
(0, common_1.SetMetadata)(auth_constant_1.AUTH_ACCESS_FOR_META_KEY, [
|
|
22
|
+
auth_enum_constant_1.ENUM_AUTH_ACCESS_FOR.SUPER_ADMIN,
|
|
23
|
+
auth_enum_constant_1.ENUM_AUTH_ACCESS_FOR.ADMIN,
|
|
24
|
+
])(constructor);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=auth.combined.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.combined.decorator.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/decorators/auth.combined.decorator.ts"],"names":[],"mappings":";;AAMA,wFAQC;AAED,sFASC;AAzBD,2CAAwD;AACxD,8DAAsE;AACtE,wEAAuE;AACvE,gFAA2E;AAC3E,mGAA4F;AAE5F,SAAgB,sCAAsC;IACpD,OAAO,UAAU,WAAgB;QAC/B,sDAAsD;QACtD,IAAA,kBAAS,EAAC,uCAAiB,EAAE,yDAAyB,CAAC,CAAC,WAAW,CAAC,CAAC;QACrE,IAAA,oBAAW,EAAC,wCAAwB,EAAE,CAAC,yCAAoB,CAAC,IAAI,CAAC,CAAC,CAChE,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,qCAAqC;IACnD,OAAO,UAAU,WAAgB;QAC/B,sDAAsD;QACtD,IAAA,kBAAS,EAAC,uCAAiB,EAAE,yDAAyB,CAAC,CAAC,WAAW,CAAC,CAAC;QACrE,IAAA,oBAAW,EAAC,wCAAwB,EAAE;YACpC,yCAAoB,CAAC,WAAW;YAChC,yCAAoB,CAAC,KAAK;SAC3B,CAAC,CAAC,WAAW,CAAC,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const CurrentUser: (...dataOrPipes: (boolean | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
2
|
+
export declare const User: (...dataOrPipes: (boolean | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.User = exports.CurrentUser = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.CurrentUser = (0, common_1.createParamDecorator)((returnPlain, context) => {
|
|
6
|
+
if (context.getType() === 'http') {
|
|
7
|
+
const { __user } = context.switchToHttp().getRequest();
|
|
8
|
+
return returnPlain ? __user.toObject() : __user;
|
|
9
|
+
}
|
|
10
|
+
if (context.getType() === 'rpc') {
|
|
11
|
+
const { user } = context.switchToRpc().getData();
|
|
12
|
+
return returnPlain ? user.toObject() : user;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
exports.User = (0, common_1.createParamDecorator)((returnPlain, context) => {
|
|
16
|
+
if (context.getType() === 'http') {
|
|
17
|
+
const { user } = context.switchToHttp().getRequest();
|
|
18
|
+
return returnPlain ? user.toObject() : user;
|
|
19
|
+
}
|
|
20
|
+
if (context.getType() === 'rpc') {
|
|
21
|
+
const { user } = context.switchToRpc().getData();
|
|
22
|
+
return returnPlain ? user.toObject() : user;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=auth.current-user.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.current-user.decorator.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/decorators/auth.current-user.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAE3D,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC7C,CAAC,WAAoB,EAAE,OAAyB,EAAO,EAAE;IACvD,IAAI,OAAO,CAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;QACjC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACvD,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAClD,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,EAAE,KAAK,KAAK,EAAE,CAAC;QAChC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;QACjD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC;AACH,CAAC,CACF,CAAC;AAEW,QAAA,IAAI,GAAG,IAAA,6BAAoB,EACtC,CAAC,WAAoB,EAAE,OAAyB,EAAO,EAAE;IACvD,IAAI,OAAO,CAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;QACjC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACrD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,EAAE,KAAK,KAAK,EAAE,CAAC;QAChC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;QACjD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC;AACH,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const AuthJwtPayload: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
2
|
+
export declare const AuthJwtToken: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
3
|
+
export declare function AuthJwtAccessProtected(): MethodDecorator;
|
|
4
|
+
export declare function AuthJwtPublicAccessProtected(): MethodDecorator;
|
|
5
|
+
export declare function AuthJwtPublicAccessClassProtected(): ClassDecorator;
|
|
6
|
+
export declare function AuthJwtAdminAccessProtected(): MethodDecorator;
|
|
7
|
+
export declare function AuthJwtRefreshProtected(): MethodDecorator;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthJwtToken = exports.AuthJwtPayload = void 0;
|
|
4
|
+
exports.AuthJwtAccessProtected = AuthJwtAccessProtected;
|
|
5
|
+
exports.AuthJwtPublicAccessProtected = AuthJwtPublicAccessProtected;
|
|
6
|
+
exports.AuthJwtPublicAccessClassProtected = AuthJwtPublicAccessClassProtected;
|
|
7
|
+
exports.AuthJwtAdminAccessProtected = AuthJwtAdminAccessProtected;
|
|
8
|
+
exports.AuthJwtRefreshProtected = AuthJwtRefreshProtected;
|
|
9
|
+
const common_1 = require("@nestjs/common");
|
|
10
|
+
const common_2 = require("@nestjs/common");
|
|
11
|
+
const auth_constant_1 = require("../constants/auth.constant");
|
|
12
|
+
const auth_enum_constant_1 = require("../constants/auth.enum.constant");
|
|
13
|
+
const auth_jwt_access_guard_1 = require("../guards/jwt-access/auth.jwt-access.guard");
|
|
14
|
+
const auth_jwt_refresh_guard_1 = require("../guards/jwt-refresh/auth.jwt-refresh.guard");
|
|
15
|
+
const auth_payload_access_for_guard_1 = require("../guards/payload/auth.payload.access-for.guard");
|
|
16
|
+
exports.AuthJwtPayload = (0, common_2.createParamDecorator)((data, ctx) => {
|
|
17
|
+
const { user } = ctx.switchToHttp().getRequest();
|
|
18
|
+
return data ? user[data] : user;
|
|
19
|
+
});
|
|
20
|
+
exports.AuthJwtToken = (0, common_2.createParamDecorator)((data, ctx) => {
|
|
21
|
+
const { headers } = ctx.switchToHttp().getRequest();
|
|
22
|
+
const { authorization } = headers;
|
|
23
|
+
const authorizations = authorization.split(' ');
|
|
24
|
+
return authorizations.length >= 2 ? authorizations[1] : undefined;
|
|
25
|
+
});
|
|
26
|
+
function AuthJwtAccessProtected() {
|
|
27
|
+
return (0, common_1.applyDecorators)((0, common_1.UseGuards)(auth_jwt_access_guard_1.AuthJwtAccessGuard));
|
|
28
|
+
}
|
|
29
|
+
function AuthJwtPublicAccessProtected() {
|
|
30
|
+
return (0, common_1.applyDecorators)((0, common_1.UseGuards)(auth_jwt_access_guard_1.AuthJwtAccessGuard, auth_payload_access_for_guard_1.AuthPayloadAccessForGuard), (0, common_1.SetMetadata)(auth_constant_1.AUTH_ACCESS_FOR_META_KEY, [auth_enum_constant_1.ENUM_AUTH_ACCESS_FOR.USER]));
|
|
31
|
+
}
|
|
32
|
+
function AuthJwtPublicAccessClassProtected() {
|
|
33
|
+
return function (constructor) {
|
|
34
|
+
// Applica UseGuards e SetMetadata a livello di classe
|
|
35
|
+
(0, common_1.UseGuards)(auth_jwt_access_guard_1.AuthJwtAccessGuard, auth_payload_access_for_guard_1.AuthPayloadAccessForGuard)(constructor);
|
|
36
|
+
(0, common_1.SetMetadata)(auth_constant_1.AUTH_ACCESS_FOR_META_KEY, [auth_enum_constant_1.ENUM_AUTH_ACCESS_FOR.USER])(constructor);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function AuthJwtAdminAccessProtected() {
|
|
40
|
+
return (0, common_1.applyDecorators)((0, common_1.UseGuards)(auth_jwt_access_guard_1.AuthJwtAccessGuard, auth_payload_access_for_guard_1.AuthPayloadAccessForGuard), (0, common_1.SetMetadata)(auth_constant_1.AUTH_ACCESS_FOR_META_KEY, [
|
|
41
|
+
auth_enum_constant_1.ENUM_AUTH_ACCESS_FOR.SUPER_ADMIN,
|
|
42
|
+
auth_enum_constant_1.ENUM_AUTH_ACCESS_FOR.ADMIN,
|
|
43
|
+
]));
|
|
44
|
+
}
|
|
45
|
+
function AuthJwtRefreshProtected() {
|
|
46
|
+
return (0, common_1.applyDecorators)((0, common_1.UseGuards)(auth_jwt_refresh_guard_1.AuthJwtRefreshGuard));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=auth.jwt.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.jwt.decorator.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/decorators/auth.jwt.decorator.ts"],"names":[],"mappings":";;;AAyBA,wDAEC;AAED,oEAKC;AAED,8EAQC;AAED,kEAQC;AAED,0DAEC;AA1DD,2CAAyE;AACzE,2CAAwE;AACxE,8DAAsE;AACtE,wEAAuE;AACvE,sFAAgF;AAChF,yFAAmF;AACnF,mGAA4F;AAE/E,QAAA,cAAc,GAAG,IAAA,6BAAoB,EAChD,CAAC,IAAY,EAAE,GAAqB,EAAuB,EAAE;IAC3D,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IACjD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAClC,CAAC,CACF,CAAC;AAEW,QAAA,YAAY,GAAG,IAAA,6BAAoB,EAC9C,CAAC,IAAY,EAAE,GAAqB,EAAsB,EAAE;IAC1D,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IACpD,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAClC,MAAM,cAAc,GAAa,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE1D,OAAO,cAAc,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC,CACF,CAAC;AAEF,SAAgB,sBAAsB;IACpC,OAAO,IAAA,wBAAe,EAAC,IAAA,kBAAS,EAAC,0CAAkB,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,SAAgB,4BAA4B;IAC1C,OAAO,IAAA,wBAAe,EACpB,IAAA,kBAAS,EAAC,0CAAkB,EAAE,yDAAyB,CAAC,EACxD,IAAA,oBAAW,EAAC,wCAAwB,EAAE,CAAC,yCAAoB,CAAC,IAAI,CAAC,CAAC,CACnE,CAAC;AACJ,CAAC;AAED,SAAgB,iCAAiC;IAC/C,OAAO,UAAU,WAAgB;QAC/B,sDAAsD;QACtD,IAAA,kBAAS,EAAC,0CAAkB,EAAE,yDAAyB,CAAC,CAAC,WAAW,CAAC,CAAC;QACtE,IAAA,oBAAW,EAAC,wCAAwB,EAAE,CAAC,yCAAoB,CAAC,IAAI,CAAC,CAAC,CAChE,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,2BAA2B;IACzC,OAAO,IAAA,wBAAe,EACpB,IAAA,kBAAS,EAAC,0CAAkB,EAAE,yDAAyB,CAAC,EACxD,IAAA,oBAAW,EAAC,wCAAwB,EAAE;QACpC,yCAAoB,CAAC,WAAW;QAChC,yCAAoB,CAAC,KAAK;KAC3B,CAAC,CACH,CAAC;AACJ,CAAC;AAED,SAAgB,uBAAuB;IACrC,OAAO,IAAA,wBAAe,EAAC,IAAA,kBAAS,EAAC,4CAAmB,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const AuthPermissionPayload: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
2
|
+
export declare function AuthPermissionProtected(group: string, ...permissions: string[]): MethodDecorator;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthPermissionPayload = void 0;
|
|
4
|
+
exports.AuthPermissionProtected = AuthPermissionProtected;
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const auth_constant_1 = require("../constants/auth.constant");
|
|
7
|
+
const auth_payload_permission_guard_1 = require("../guards/payload/auth.payload.permission.guard");
|
|
8
|
+
const auth_permission_guard_1 = require("../guards/permission/auth.permission.guard");
|
|
9
|
+
exports.AuthPermissionPayload = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
10
|
+
const { permissions } = ctx.switchToHttp().getRequest();
|
|
11
|
+
return permissions;
|
|
12
|
+
});
|
|
13
|
+
function AuthPermissionProtected(group, ...permissions) {
|
|
14
|
+
return (0, common_1.applyDecorators)((0, common_1.UseGuards)(auth_permission_guard_1.AuthPermissionGuard, auth_payload_permission_guard_1.AuthPayloadPermissionGuard), (0, common_1.SetMetadata)(auth_constant_1.AUTH_PERMISSION_GROUP_META_KEY, group), (0, common_1.SetMetadata)(auth_constant_1.AUTH_PERMISSION_PERMISSIONS_META_KEY, permissions));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=auth.permission.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.permission.decorator.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/decorators/auth.permission.decorator.ts"],"names":[],"mappings":";;;AAqBA,0DASC;AA9BD,2CAMwB;AACxB,8DAGoC;AACpC,mGAA6F;AAC7F,sFAAiF;AAEpE,QAAA,qBAAqB,GAAG,IAAA,6BAAoB,EACvD,CAAC,IAAY,EAAE,GAAqB,EAAuB,EAAE;IAC3D,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IACxD,OAAO,WAAW,CAAC;AACrB,CAAC,CACF,CAAC;AAEF,SAAgB,uBAAuB,CACrC,KAAa,EACb,GAAG,WAAqB;IAExB,OAAO,IAAA,wBAAe,EACpB,IAAA,kBAAS,EAAC,2CAAmB,EAAE,0DAA0B,CAAC,EAC1D,IAAA,oBAAW,EAAC,8CAA8B,EAAE,KAAK,CAAC,EAClD,IAAA,oBAAW,EAAC,oDAAoC,EAAE,WAAW,CAAC,CAC/D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./auth.jwt.decorator"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./auth.combined.decorator"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./auth.permission.decorator"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./auth.current-user.decorator"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,+DAAqC;AACrC,oEAA0C;AAC1C,sEAA4C;AAC5C,wEAA8C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
declare const CombinedAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
4
|
+
export declare class CombinedAuthGuard extends CombinedAuthGuard_base {
|
|
5
|
+
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean>;
|
|
6
|
+
private validateRequest;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CombinedAuthGuard = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const passport_1 = require("@nestjs/passport");
|
|
7
|
+
const errors_1 = require("@tc-libs/errors");
|
|
8
|
+
let CombinedAuthGuard = class CombinedAuthGuard extends (0, passport_1.AuthGuard)(['jwt', 'api-key']) {
|
|
9
|
+
canActivate(context) {
|
|
10
|
+
return this.validateRequest(context);
|
|
11
|
+
}
|
|
12
|
+
async validateRequest(context) {
|
|
13
|
+
const request = context.switchToHttp().getRequest();
|
|
14
|
+
// Prima prova con JWT
|
|
15
|
+
try {
|
|
16
|
+
await super.canActivate(context);
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Se JWT fallisce, prova con API Key
|
|
21
|
+
if (request.headers['x-api-key']) {
|
|
22
|
+
try {
|
|
23
|
+
await super.canActivate(context);
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
throw new errors_1.Api401GenericError();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new errors_1.Api401GenericError();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.CombinedAuthGuard = CombinedAuthGuard;
|
|
37
|
+
exports.CombinedAuthGuard = CombinedAuthGuard = tslib_1.__decorate([
|
|
38
|
+
(0, common_1.Injectable)()
|
|
39
|
+
], CombinedAuthGuard);
|
|
40
|
+
//# sourceMappingURL=auth.combined.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.combined.guard.js","sourceRoot":"","sources":["../../../../../../packages/authentication/src/guards/combined/auth.combined.guard.ts"],"names":[],"mappings":";;;;AAAA,2CAA8D;AAC9D,+CAA6C;AAC7C,4CAAqD;AAI9C,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,IAAA,oBAAS,EAAC,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACzD,WAAW,CAClB,OAAyB;QAEzB,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,OAAyB;QACrD,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAEpD,sBAAsB;QACtB,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,qCAAqC;YACrC,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;gBACjC,IAAI,CAAC;oBACH,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;oBACjC,OAAO,IAAI,CAAC;gBACd,CAAC;gBAAC,MAAM,CAAC;oBACP,MAAM,IAAI,2BAAkB,EAAE,CAAC;gBACjC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,2BAAkB,EAAE,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AA5BY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CA4B7B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './jwt-access/auth.jwt-access.guard';
|
|
2
|
+
export * from './jwt-access/auth.jwt-access.strategy';
|
|
3
|
+
export * from './jwt-refresh/auth.jwt-refresh.guard';
|
|
4
|
+
export * from './jwt-refresh/auth.jwt-refresh.strategy';
|
|
5
|
+
export * from './payload/auth.payload.access-for.guard';
|
|
6
|
+
export * from './payload/auth.payload.permission.guard';
|
|
7
|
+
export * from './permission/auth.permission.guard';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./jwt-access/auth.jwt-access.guard"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./jwt-access/auth.jwt-access.strategy"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./jwt-refresh/auth.jwt-refresh.guard"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./jwt-refresh/auth.jwt-refresh.strategy"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./payload/auth.payload.access-for.guard"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./payload/auth.payload.permission.guard"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./permission/auth.permission.guard"), exports);
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/authentication/src/guards/index.ts"],"names":[],"mappings":";;;AAAA,6EAAmD;AACnD,gFAAsD;AACtD,+EAAqD;AACrD,kFAAwD;AACxD,kFAAwD;AACxD,kFAAwD;AACxD,6EAAmD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const AuthJwtAccessGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
2
|
+
export declare class AuthJwtAccessGuard extends AuthJwtAccessGuard_base {
|
|
3
|
+
handleRequest<TUser = any>(err: Error, user: TUser, info: Error): TUser;
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthJwtAccessGuard = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const passport_1 = require("@nestjs/passport");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const errors_1 = require("@tc-libs/errors");
|
|
8
|
+
let AuthJwtAccessGuard = class AuthJwtAccessGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
9
|
+
handleRequest(err, user, info) {
|
|
10
|
+
if (err || !user) {
|
|
11
|
+
throw new errors_1.Api401JWTAccessTokenUnauthorizedError(err ? err.message : info.message);
|
|
12
|
+
}
|
|
13
|
+
return user;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.AuthJwtAccessGuard = AuthJwtAccessGuard;
|
|
17
|
+
exports.AuthJwtAccessGuard = AuthJwtAccessGuard = tslib_1.__decorate([
|
|
18
|
+
(0, common_1.Injectable)()
|
|
19
|
+
], AuthJwtAccessGuard);
|
|
20
|
+
//# sourceMappingURL=auth.jwt-access.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.jwt-access.guard.js","sourceRoot":"","sources":["../../../../../../packages/authentication/src/guards/jwt-access/auth.jwt-access.guard.ts"],"names":[],"mappings":";;;;AAAA,+CAA6C;AAC7C,2CAA4C;AAC5C,4CAAwE;AAEjE,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,IAAA,oBAAS,EAAC,KAAK,CAAC;IAC7C,aAAa,CACpB,GAAU,EACV,IAAW,EACX,IAAW;QAEX,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,8CAAqC,CAC7C,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CACjC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAdY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAc9B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Strategy } from 'passport-jwt';
|
|
2
|
+
import { AuthService } from '../../services/auth.service';
|
|
3
|
+
import { TokenService } from '@tc-libs/helper';
|
|
4
|
+
import { AuthenticationModuleOptions } from '../../authentication.module.options';
|
|
5
|
+
declare const AuthJwtAccessStrategy_base: new (...args: any[]) => Strategy;
|
|
6
|
+
export declare class AuthJwtAccessStrategy extends AuthJwtAccessStrategy_base {
|
|
7
|
+
readonly _options: AuthenticationModuleOptions;
|
|
8
|
+
private readonly _auth;
|
|
9
|
+
private readonly _token;
|
|
10
|
+
constructor(_options: AuthenticationModuleOptions, _auth: AuthService, _token: TokenService);
|
|
11
|
+
validate({ data }: Record<string, any>): Promise<Record<string, any>>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthJwtAccessStrategy = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const passport_jwt_1 = require("passport-jwt");
|
|
6
|
+
const passport_1 = require("@nestjs/passport");
|
|
7
|
+
const common_1 = require("@nestjs/common");
|
|
8
|
+
const auth_service_1 = require("../../services/auth.service");
|
|
9
|
+
const helper_1 = require("@tc-libs/helper");
|
|
10
|
+
const authentication_module_options_1 = require("../../authentication.module.options");
|
|
11
|
+
let AuthJwtAccessStrategy = class AuthJwtAccessStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy, 'jwt') {
|
|
12
|
+
constructor(_options, _auth, _token) {
|
|
13
|
+
super({
|
|
14
|
+
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderWithScheme(_options.auth.prefixAuthorization),
|
|
15
|
+
ignoreExpiration: false,
|
|
16
|
+
jsonWebTokenOptions: {
|
|
17
|
+
ignoreNotBefore: false,
|
|
18
|
+
audience: _options.auth.audience,
|
|
19
|
+
issuer: _options.auth.issuer,
|
|
20
|
+
subject: _options.auth.subject,
|
|
21
|
+
},
|
|
22
|
+
secretOrKey: _options.auth.accessToken.secretKey,
|
|
23
|
+
});
|
|
24
|
+
this._options = _options;
|
|
25
|
+
this._auth = _auth;
|
|
26
|
+
this._token = _token;
|
|
27
|
+
}
|
|
28
|
+
async validate({ data }) {
|
|
29
|
+
const payloadEncryption = await this._auth.getPayloadEncryption();
|
|
30
|
+
return payloadEncryption ? this._token.decryptAccessToken({ data }) : data;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.AuthJwtAccessStrategy = AuthJwtAccessStrategy;
|
|
34
|
+
exports.AuthJwtAccessStrategy = AuthJwtAccessStrategy = tslib_1.__decorate([
|
|
35
|
+
(0, common_1.Injectable)(),
|
|
36
|
+
tslib_1.__param(0, (0, common_1.Inject)(authentication_module_options_1.AUTHENTICATION_CONFIG_OPTIONS)),
|
|
37
|
+
tslib_1.__metadata("design:paramtypes", [Object, auth_service_1.AuthService,
|
|
38
|
+
helper_1.TokenService])
|
|
39
|
+
], AuthJwtAccessStrategy);
|
|
40
|
+
//# sourceMappingURL=auth.jwt-access.strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.jwt-access.strategy.js","sourceRoot":"","sources":["../../../../../../packages/authentication/src/guards/jwt-access/auth.jwt-access.strategy.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,+CAAoD;AACpD,2CAAoD;AACpD,8DAA0D;AAC1D,4CAA+C;AAC/C,uFAG6C;AAGtC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,EAAE,KAAK,CAAC;IAC1E,YAEW,QAAqC,EAC7B,KAAkB,EAClB,MAAoB;QAErC,KAAK,CAAC;YACJ,cAAc,EAAE,yBAAU,CAAC,wBAAwB,CACjD,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAClC;YACD,gBAAgB,EAAE,KAAK;YACvB,mBAAmB,EAAE;gBACnB,eAAe,EAAE,KAAK;gBACtB,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ;gBAChC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;gBAC5B,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO;aAC/B;YACD,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS;SACjD,CAAC,CAAC;QAhBM,aAAQ,GAAR,QAAQ,CAA6B;QAC7B,UAAK,GAAL,KAAK,CAAa;QAClB,WAAM,GAAN,MAAM,CAAc;IAevC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAuB;QAC1C,MAAM,iBAAiB,GAAY,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC;QAE3E,OAAO,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7E,CAAC;CACF,CAAA;AA3BY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAGR,mBAAA,IAAA,eAAM,EAAC,6DAA6B,CAAC,CAAA;qDAEd,0BAAW;QACV,qBAAY;GAL5B,qBAAqB,CA2BjC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare const AuthJwtRefreshGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
2
|
+
export declare class AuthJwtRefreshGuard extends AuthJwtRefreshGuard_base {
|
|
3
|
+
handleRequest<TUser = any>(err: Error, user: TUser, info: Error): TUser;
|
|
4
|
+
}
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthJwtRefreshGuard = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const passport_1 = require("@nestjs/passport");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const errors_1 = require("@tc-libs/errors");
|
|
8
|
+
let AuthJwtRefreshGuard = class AuthJwtRefreshGuard extends (0, passport_1.AuthGuard)('jwtRefresh') {
|
|
9
|
+
handleRequest(err, user, info) {
|
|
10
|
+
if (err || !user) {
|
|
11
|
+
throw new errors_1.Api401RefreshTokenUnauthorizedError(err ? err.message : info.message);
|
|
12
|
+
}
|
|
13
|
+
return user;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.AuthJwtRefreshGuard = AuthJwtRefreshGuard;
|
|
17
|
+
exports.AuthJwtRefreshGuard = AuthJwtRefreshGuard = tslib_1.__decorate([
|
|
18
|
+
(0, common_1.Injectable)()
|
|
19
|
+
], AuthJwtRefreshGuard);
|
|
20
|
+
//# sourceMappingURL=auth.jwt-refresh.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.jwt-refresh.guard.js","sourceRoot":"","sources":["../../../../../../packages/authentication/src/guards/jwt-refresh/auth.jwt-refresh.guard.ts"],"names":[],"mappings":";;;;AAAA,+CAA6C;AAC7C,2CAA4C;AAC5C,4CAAsE;AAG/D,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,IAAA,oBAAS,EAAC,YAAY,CAAC;IACrD,aAAa,CACpB,GAAU,EACV,IAAW,EACX,IAAW;QAEX,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,4CAAmC,CAC3C,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CACjC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAdY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;GACA,mBAAmB,CAc/B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Strategy } from 'passport-jwt';
|
|
2
|
+
import { AuthService } from '../../services/auth.service';
|
|
3
|
+
import { TokenService } from '@tc-libs/helper';
|
|
4
|
+
import { AuthenticationModuleOptions } from '../../authentication.module.options';
|
|
5
|
+
declare const AuthJwtRefreshStrategy_base: new (...args: any[]) => Strategy;
|
|
6
|
+
export declare class AuthJwtRefreshStrategy extends AuthJwtRefreshStrategy_base {
|
|
7
|
+
readonly _options: AuthenticationModuleOptions;
|
|
8
|
+
private readonly _auth;
|
|
9
|
+
private readonly _token;
|
|
10
|
+
constructor(_options: AuthenticationModuleOptions, _auth: AuthService, _token: TokenService);
|
|
11
|
+
validate({ data }: Record<string, any>): Promise<Record<string, any>>;
|
|
12
|
+
}
|
|
13
|
+
export {};
|