@nest-boot/auth 3.2.1 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.guard.d.ts +13 -0
- package/dist/auth.guard.js +75 -0
- package/dist/auth.guard.js.map +1 -0
- package/dist/{middlewares/auth.middleware.d.ts → auth.middleware.d.ts} +5 -1
- package/dist/auth.middleware.js +60 -0
- package/dist/auth.middleware.js.map +1 -0
- package/dist/auth.module-definition.d.ts +4 -0
- package/dist/auth.module-definition.js +10 -0
- package/dist/auth.module-definition.js.map +1 -0
- package/dist/auth.module.d.ts +8 -0
- package/dist/auth.module.js +56 -0
- package/dist/auth.module.js.map +1 -0
- package/dist/auth.service.d.ts +12 -0
- package/dist/auth.service.js +65 -0
- package/dist/auth.service.js.map +1 -0
- package/dist/decorators/can.decorator.d.ts +1 -0
- package/dist/decorators/can.decorator.js +8 -0
- package/dist/decorators/can.decorator.js.map +1 -0
- package/dist/decorators/current-entity.decorator.d.ts +2 -0
- package/dist/decorators/current-entity.decorator.js +11 -0
- package/dist/decorators/current-entity.decorator.js.map +1 -0
- package/dist/decorators/current-personal-access-token.decorator.d.ts +1 -0
- package/dist/decorators/current-personal-access-token.decorator.js +10 -0
- package/dist/decorators/current-personal-access-token.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +4 -0
- package/dist/{middlewares → decorators}/index.js +4 -1
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/require-auth.decorator.d.ts +1 -0
- package/dist/decorators/require-auth.decorator.js +8 -0
- package/dist/decorators/require-auth.decorator.js.map +1 -0
- package/dist/index.d.ts +5 -15
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/interfaces/auth-module-options.interface.d.ts +12 -0
- package/dist/interfaces/auth-module-options.interface.js +3 -0
- package/dist/interfaces/auth-module-options.interface.js.map +1 -0
- package/dist/interfaces/auth-payload.interface.d.ts +6 -0
- package/dist/interfaces/auth-payload.interface.js +3 -0
- package/dist/interfaces/auth-payload.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/personal-access-token.interface.d.ts +9 -0
- package/dist/interfaces/personal-access-token.interface.js +3 -0
- package/dist/interfaces/personal-access-token.interface.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/mixin-permissions.utils.d.ts +2 -4
- package/dist/utils/mixin-permissions.utils.js +5 -1
- package/dist/utils/mixin-permissions.utils.js.map +1 -1
- package/package.json +34 -19
- package/dist/entities/index.d.ts +0 -2
- package/dist/entities/index.js +0 -19
- package/dist/entities/index.js.map +0 -1
- package/dist/entities/permission.entity.d.ts +0 -3
- package/dist/entities/permission.entity.js +0 -24
- package/dist/entities/permission.entity.js.map +0 -1
- package/dist/entities/personal-access-token.entity.d.ts +0 -5
- package/dist/entities/personal-access-token.entity.js +0 -40
- package/dist/entities/personal-access-token.entity.js.map +0 -1
- package/dist/guards/base-auth.guard.d.ts +0 -7
- package/dist/guards/base-auth.guard.js +0 -23
- package/dist/guards/base-auth.guard.js.map +0 -1
- package/dist/guards/index.d.ts +0 -1
- package/dist/guards/index.js +0 -18
- package/dist/guards/index.js.map +0 -1
- package/dist/middlewares/auth.middleware.js +0 -56
- package/dist/middlewares/auth.middleware.js.map +0 -1
- package/dist/middlewares/index.d.ts +0 -1
- package/dist/middlewares/index.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EntityManager } from "@mikro-orm/core";
|
|
2
|
+
import { Context } from "@nest-boot/common";
|
|
3
|
+
import { CanActivate, ExecutionContext } from "@nestjs/common";
|
|
4
|
+
import { Reflector } from "@nestjs/core";
|
|
5
|
+
import { AuthModuleOptions } from "./interfaces";
|
|
6
|
+
export declare class AuthGuard implements CanActivate {
|
|
7
|
+
private readonly options;
|
|
8
|
+
private readonly reflector;
|
|
9
|
+
private readonly entityManager;
|
|
10
|
+
constructor(options: AuthModuleOptions, reflector: Reflector, entityManager: EntityManager);
|
|
11
|
+
canActivate(executionContext: ExecutionContext): Promise<boolean>;
|
|
12
|
+
getPermissions(ctx: Context): Promise<string[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
};
|
|
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.AuthGuard = void 0;
|
|
19
|
+
const core_1 = require("@mikro-orm/core");
|
|
20
|
+
const common_1 = require("@nest-boot/common");
|
|
21
|
+
const common_2 = require("@nestjs/common");
|
|
22
|
+
const core_2 = require("@nestjs/core");
|
|
23
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
24
|
+
const auth_module_definition_1 = require("./auth.module-definition");
|
|
25
|
+
let AuthGuard = class AuthGuard {
|
|
26
|
+
constructor(options, reflector, entityManager) {
|
|
27
|
+
this.options = options;
|
|
28
|
+
this.reflector = reflector;
|
|
29
|
+
this.entityManager = entityManager;
|
|
30
|
+
this.reflector = reflector;
|
|
31
|
+
}
|
|
32
|
+
async canActivate(executionContext) {
|
|
33
|
+
var _a;
|
|
34
|
+
const ctx = common_1.Context.get();
|
|
35
|
+
const requireAuth = this.reflector.get(auth_module_definition_1.REQUIRE_AUTH_METADATA_KEY, executionContext.getHandler());
|
|
36
|
+
if (!((_a = requireAuth !== null && requireAuth !== void 0 ? requireAuth : this.options.defaultRequireAuth) !== null && _a !== void 0 ? _a : false)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const authPayload = ctx.get("auth");
|
|
40
|
+
if (typeof authPayload === "undefined") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const permissions = this.reflector.get(auth_module_definition_1.PERMISSIONS_METADATA_KEY, executionContext.getHandler());
|
|
44
|
+
if (typeof permissions === "undefined" ||
|
|
45
|
+
lodash_1.default.intersection(await this.getPermissions(ctx), permissions).length > 0) {
|
|
46
|
+
authPayload.personalAccessToken.lastUsedAt = new Date();
|
|
47
|
+
await this.entityManager.flush();
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
async getPermissions(ctx) {
|
|
53
|
+
let permissions = [];
|
|
54
|
+
const payload = ctx.get("auth");
|
|
55
|
+
if (typeof payload !== "undefined") {
|
|
56
|
+
if (typeof payload.entity.permissions !== "undefined") {
|
|
57
|
+
permissions = permissions.concat(payload.entity.permissions);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const newPermissions = await core_1.Reference.create(payload.entity).load("permissions");
|
|
61
|
+
if (typeof newPermissions !== "undefined") {
|
|
62
|
+
permissions = permissions.concat(newPermissions);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return permissions;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
AuthGuard = __decorate([
|
|
70
|
+
__param(0, (0, common_2.Inject)(auth_module_definition_1.MODULE_OPTIONS_TOKEN)),
|
|
71
|
+
__metadata("design:paramtypes", [Object, core_2.Reflector,
|
|
72
|
+
core_1.EntityManager])
|
|
73
|
+
], AuthGuard);
|
|
74
|
+
exports.AuthGuard = AuthGuard;
|
|
75
|
+
//# sourceMappingURL=auth.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../src/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0CAA2D;AAC3D,8CAA4C;AAC5C,2CAAuE;AACvE,uCAAyC;AACzC,oDAAuB;AAEvB,qEAIkC;AAG3B,IAAM,SAAS,GAAf,MAAM,SAAS;IACpB,YAEmB,OAA0B,EAC1B,SAAoB,EACpB,aAA4B;QAF5B,YAAO,GAAP,OAAO,CAAmB;QAC1B,cAAS,GAAT,SAAS,CAAW;QACpB,kBAAa,GAAb,aAAa,CAAe;QAE7C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,WAAW,CACtB,gBAAkC;;QAGlC,MAAM,GAAG,GAAG,gBAAO,CAAC,GAAG,EAAE,CAAC;QAG1B,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CACpC,kDAAyB,EACzB,gBAAgB,CAAC,UAAU,EAAE,CAC9B,CAAC;QAGF,IAAI,CAAC,CAAC,MAAA,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,IAAI,CAAC,OAAO,CAAC,kBAAkB,mCAAI,KAAK,CAAC,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;QAED,MAAM,WAAW,GAAG,GAAG,CAAC,GAAG,CAAc,MAAM,CAAC,CAAC;QAGjD,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE;YACtC,OAAO,KAAK,CAAC;SACd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1,13 @@
|
|
|
1
1
|
import { EntityManager } from "@mikro-orm/core";
|
|
2
2
|
import { NestMiddleware } from "@nestjs/common";
|
|
3
3
|
import { Request, Response } from "express";
|
|
4
|
+
import { AuthService } from "./auth.service";
|
|
5
|
+
import { AuthModuleOptions } from "./interfaces";
|
|
4
6
|
export declare class AuthMiddleware implements NestMiddleware {
|
|
7
|
+
private readonly options;
|
|
5
8
|
private readonly entityManager;
|
|
6
|
-
|
|
9
|
+
private readonly authService;
|
|
10
|
+
constructor(options: AuthModuleOptions, entityManager: EntityManager, authService: AuthService);
|
|
7
11
|
use(req: Request, res: Response, next: () => void): Promise<void>;
|
|
8
12
|
private extractAccessToken;
|
|
9
13
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuthMiddleware = void 0;
|
|
16
|
+
const core_1 = require("@mikro-orm/core");
|
|
17
|
+
const common_1 = require("@nest-boot/common");
|
|
18
|
+
const common_2 = require("@nestjs/common");
|
|
19
|
+
const auth_module_definition_1 = require("./auth.module-definition");
|
|
20
|
+
const auth_service_1 = require("./auth.service");
|
|
21
|
+
let AuthMiddleware = class AuthMiddleware {
|
|
22
|
+
constructor(options, entityManager, authService) {
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.entityManager = entityManager;
|
|
25
|
+
this.authService = authService;
|
|
26
|
+
}
|
|
27
|
+
async use(req, res, next) {
|
|
28
|
+
const accessToken = this.extractAccessToken(req);
|
|
29
|
+
if (accessToken !== null) {
|
|
30
|
+
const personalAccessToken = await this.authService.getToken(accessToken);
|
|
31
|
+
if (personalAccessToken !== null) {
|
|
32
|
+
const entity = await this.entityManager
|
|
33
|
+
.getRepository(personalAccessToken.entityName)
|
|
34
|
+
.findOne(personalAccessToken.entityId);
|
|
35
|
+
if (entity !== null) {
|
|
36
|
+
common_1.Context.set("auth", { entity, personalAccessToken });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return next();
|
|
41
|
+
}
|
|
42
|
+
extractAccessToken(req) {
|
|
43
|
+
const authorizationHeader = req.get("authorization");
|
|
44
|
+
if (typeof authorizationHeader === "string") {
|
|
45
|
+
const matched = authorizationHeader.match(/(\S+)\s+(\S+)/);
|
|
46
|
+
if (matched !== null && matched[1].toLowerCase() === "bearer") {
|
|
47
|
+
return matched[2];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
AuthMiddleware = __decorate([
|
|
54
|
+
(0, common_2.Injectable)({ scope: common_2.Scope.REQUEST }),
|
|
55
|
+
__param(0, (0, common_2.Inject)(auth_module_definition_1.MODULE_OPTIONS_TOKEN)),
|
|
56
|
+
__metadata("design:paramtypes", [Object, core_1.EntityManager,
|
|
57
|
+
auth_service_1.AuthService])
|
|
58
|
+
], AuthMiddleware);
|
|
59
|
+
exports.AuthMiddleware = AuthMiddleware;
|
|
60
|
+
//# sourceMapping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AAe,CAAC,CAAC;YAE3D,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE;gBAC7D,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;aACnB;SACF;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAzCY,cAAc;IAD1B,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;IAGhC,WAAA,IAAA,eAAM,EAAC,6CAAoB,CAAC,CAAA;6CAEG,oBAAa;QACf,0BAAW;GALhC,cAAc,CAyC1B;AAzCY,wCAAc"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AuthModuleOptions } from "./interfaces";
|
|
2
|
+
export declare const PERMISSIONS_METADATA_KEY: string;
|
|
3
|
+
export declare const REQUIRE_AUTH_METADATA_KEY: string;
|
|
4
|
+
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<AuthModuleOptions, "register", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MODULE_OPTIONS_TOKEN = exports.ConfigurableModuleClass = exports.REQUIRE_AUTH_METADATA_KEY = exports.PERMISSIONS_METADATA_KEY = void 0;
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
7
|
+
exports.PERMISSIONS_METADATA_KEY = (0, crypto_1.randomUUID)();
|
|
8
|
+
exports.REQUIRE_AUTH_METADATA_KEY = (0, crypto_1.randomUUID)();
|
|
9
|
+
_a = new common_1.ConfigurableModuleBuilder().build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN;
|
|
10
|
+
//# sourceMappingURL=auth.module-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.module-definition.js","sourceRoot":"","sources":["../src/auth.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA2D;AAC3D,mCAAoC;AAIvB,QAAA,wBAAwB,GAAG,IAAA,mBAAU,GAAE,CAAC;AAExC,QAAA,yBAAyB,GAAG,IAAA,mBAAU,GAAE,CAAC;AAEzC,KACX,IAAI,kCAAyB,EAAqB,CAAC,KAAK,EAAE,EAD7C,+BAAuB,+BAAE,4BAAoB,2BACC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MiddlewareConsumer, NestModule } from "@nestjs/common";
|
|
2
|
+
import { ConfigurableModuleClass } from "./auth.module-definition";
|
|
3
|
+
import { AuthModuleOptions } from "./interfaces";
|
|
4
|
+
export declare class AuthModule extends ConfigurableModuleClass implements NestModule {
|
|
5
|
+
private readonly options;
|
|
6
|
+
constructor(options: AuthModuleOptions);
|
|
7
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuthModule = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@nestjs/core");
|
|
18
|
+
const auth_guard_1 = require("./auth.guard");
|
|
19
|
+
const auth_middleware_1 = require("./auth.middleware");
|
|
20
|
+
const auth_module_definition_1 = require("./auth.module-definition");
|
|
21
|
+
const auth_service_1 = require("./auth.service");
|
|
22
|
+
let AuthModule = class AuthModule extends auth_module_definition_1.ConfigurableModuleClass {
|
|
23
|
+
constructor(options) {
|
|
24
|
+
super();
|
|
25
|
+
this.options = options;
|
|
26
|
+
}
|
|
27
|
+
configure(consumer) {
|
|
28
|
+
const middlewareConfigProxy = consumer.apply(auth_middleware_1.AuthMiddleware);
|
|
29
|
+
if (typeof this.options.excludeRoutes !== "undefined") {
|
|
30
|
+
middlewareConfigProxy.exclude(...this.options.excludeRoutes);
|
|
31
|
+
}
|
|
32
|
+
if (typeof this.options.includeRoutes !== "undefined") {
|
|
33
|
+
middlewareConfigProxy.forRoutes(...this.options.includeRoutes);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
middlewareConfigProxy.forRoutes("*");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
AuthModule = __decorate([
|
|
41
|
+
(0, common_1.Global)(),
|
|
42
|
+
(0, common_1.Module)({
|
|
43
|
+
providers: [
|
|
44
|
+
{
|
|
45
|
+
provide: core_1.APP_GUARD,
|
|
46
|
+
useClass: auth_guard_1.AuthGuard,
|
|
47
|
+
},
|
|
48
|
+
auth_service_1.AuthService,
|
|
49
|
+
],
|
|
50
|
+
exports: [auth_service_1.AuthService],
|
|
51
|
+
}),
|
|
52
|
+
__param(0, (0, common_1.Inject)(auth_module_definition_1.MODULE_OPTIONS_TOKEN)),
|
|
53
|
+
__metadata("design:paramtypes", [Object])
|
|
54
|
+
], AuthModule);
|
|
55
|
+
exports.AuthModule = AuthModule;
|
|
56
|
+
//# sourceMappingURL=auth.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../src/auth.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAMwB;AACxB,uCAAyC;AAEzC,6CAAyC;AACzC,uDAAmD;AACnD,qEAGkC;AAClC,iDAA6C;AActC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,gDAAuB;IACrD,YAEmB,OAA0B;QAE3C,KAAK,EAAE,CAAC;QAFS,YAAO,GAAP,OAAO,CAAmB;IAG7C,CAAC;IAED,SAAS,CAAC,QAA4B;QACpC,MAAM,qBAAqB,GAAG,QAAQ,CAAC,KAAK,CAAC,gCAAc,CAAC,CAAC;QAE7D,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,KAAK,WAAW,EAAE;YACrD,qBAAqB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;SAC9D;QAED,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,KAAK,WAAW,EAAE;YACrD,qBAAqB,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;SAChE;aAAM;YACL,qBAAqB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SACtC;IACH,CAAC;CACF,CAAA;AArBY,UAAU;IAXtB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,gBAAS;gBAClB,QAAQ,EAAE,sBAAS;aACpB;YACD,0BAAW;SACZ;QACD,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;IAGG,WAAA,IAAA,eAAM,EAAC,6CAAoB,CAAC,CAAA;;GAFpB,UAAU,CAqBtB;AArBY,gCAAU"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AnyEntity, EntityManager, Loaded } from "@mikro-orm/core";
|
|
2
|
+
import { AuthModuleOptions, PersonalAccessTokenInterface } from "./interfaces";
|
|
3
|
+
export declare class AuthService {
|
|
4
|
+
private readonly options;
|
|
5
|
+
private readonly entityManager;
|
|
6
|
+
private readonly personalAccessTokenEntity;
|
|
7
|
+
constructor(options: AuthModuleOptions, entityManager: EntityManager);
|
|
8
|
+
createToken(entity: AnyEntity, name: string, expiresIn?: string | number): Promise<PersonalAccessTokenInterface>;
|
|
9
|
+
getToken(token?: string): Promise<Loaded<PersonalAccessTokenInterface> | null>;
|
|
10
|
+
verifyToken(token?: string): Promise<boolean>;
|
|
11
|
+
revokeToken(token?: string): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuthService = void 0;
|
|
16
|
+
const core_1 = require("@mikro-orm/core");
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const crypto_1 = require("crypto");
|
|
19
|
+
const auth_module_definition_1 = require("./auth.module-definition");
|
|
20
|
+
const ms = require("ms");
|
|
21
|
+
const common_2 = require("@nest-boot/common");
|
|
22
|
+
let AuthService = class AuthService {
|
|
23
|
+
constructor(options, entityManager) {
|
|
24
|
+
this.options = options;
|
|
25
|
+
this.entityManager = entityManager;
|
|
26
|
+
this.personalAccessTokenEntity = this.entityManager.getRepository(this.options.personalAccessTokenEntity);
|
|
27
|
+
}
|
|
28
|
+
async createToken(entity, name, expiresIn) {
|
|
29
|
+
const token = (0, crypto_1.randomBytes)(32).toString("hex");
|
|
30
|
+
const _expiresIn = expiresIn !== null && expiresIn !== void 0 ? expiresIn : this.options.expiresIn;
|
|
31
|
+
const _expiresInMs = typeof _expiresIn === "string" ? ms(_expiresIn) : _expiresIn;
|
|
32
|
+
const personalAccessToken = this.personalAccessTokenEntity.create({
|
|
33
|
+
name,
|
|
34
|
+
token,
|
|
35
|
+
entityId: entity.id,
|
|
36
|
+
entityName: entity.constructor.name,
|
|
37
|
+
expiresAt: _expiresInMs != null ? new Date(Date.now() + _expiresInMs) : undefined,
|
|
38
|
+
});
|
|
39
|
+
await this.personalAccessTokenEntity.persistAndFlush(personalAccessToken);
|
|
40
|
+
return personalAccessToken;
|
|
41
|
+
}
|
|
42
|
+
async getToken(token) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
if (typeof token === "undefined") {
|
|
45
|
+
return (_b = (_a = common_2.Context.get("auth")) === null || _a === void 0 ? void 0 : _a.personalAccessToken) !== null && _b !== void 0 ? _b : null;
|
|
46
|
+
}
|
|
47
|
+
return await this.personalAccessTokenEntity.findOne({ token });
|
|
48
|
+
}
|
|
49
|
+
async verifyToken(token) {
|
|
50
|
+
return (await this.getToken(token)) !== null;
|
|
51
|
+
}
|
|
52
|
+
async revokeToken(token) {
|
|
53
|
+
const personalAccessToken = await this.getToken(token);
|
|
54
|
+
if (personalAccessToken !== null) {
|
|
55
|
+
await this.personalAccessTokenEntity.remove(personalAccessToken).flush();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
AuthService = __decorate([
|
|
60
|
+
(0, common_1.Injectable)(),
|
|
61
|
+
__param(0, (0, common_1.Inject)(auth_module_definition_1.MODULE_OPTIONS_TOKEN)),
|
|
62
|
+
__metadata("design:paramtypes", [Object, core_1.EntityManager])
|
|
63
|
+
], AuthService);
|
|
64
|
+
exports.AuthService = AuthService;
|
|
65
|
+
//# sourceMappingURL=auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0CAKyB;AACzB,2CAAoD;AACpD,mCAAqC;AAErC,qEAAgE;AAMhE,yBAA0B;AAC1B,8CAA4C;AAGrC,IAAM,WAAW,GAAjB,MAAM,WAAW;IAGtB,YAEmB,OAA0B,EAC1B,aAA4B;QAD5B,YAAO,GAAP,OAAO,CAAmB;QAC1B,kBAAa,GAAb,aAAa,CAAe;QAE7C,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAC/D,IAAI,CAAC,OAAO,CAAC,yBAAyB,CACvC,CAAC;IACJ,CAAC;IAQD,KAAK,CAAC,WAAW,CACf,MAAiB,EACjB,IAAY,EACZ,SAA2B;QAE3B,MAAM,KAAK,GAAG,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE9C,MAAM,UAAU,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;QACvD,MAAM,YAAY,GAChB,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QAE/D,MAAM,m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6EvB;AA7EY,kCAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Can: (...roles: string[]) => ClassDecorator & MethodDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Can = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const auth_module_definition_1 = require("../auth.module-definition");
|
|
6
|
+
const Can = (...roles) => (0, common_1.SetMetadata)(auth_module_definition_1.PERMISSIONS_METADATA_KEY, roles);
|
|
7
|
+
exports.Can = Can;
|
|
8
|
+
//# sourceMappingURL=can.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"can.decorator.js","sourceRoot":"","sources":["../../src/decorators/can.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C,sEAAqE;AAE9D,MAAM,GAAG,GAAG,CAAC,GAAG,KAAe,EAAoC,EAAE,CAC1E,IAAA,oBAAW,EAAC,iDAAwB,EAAE,KAAK,CAAC,CAAC;AADlC,QAAA,GAAG,OAC+B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrentUser = exports.CurrentEntity = void 0;
|
|
4
|
+
const common_1 = require("@nest-boot/common");
|
|
5
|
+
const common_2 = require("@nestjs/common");
|
|
6
|
+
exports.CurrentEntity = (0, common_2.createParamDecorator)(() => {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = common_1.Context.get("auth")) === null || _a === void 0 ? void 0 : _a.entity;
|
|
9
|
+
});
|
|
10
|
+
exports.CurrentUser = exports.CurrentEntity;
|
|
11
|
+
//# sourceMappingURL=current-entity.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-entity.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-entity.decorator.ts"],"names":[],"mappings":";;;AAAA,8CAA4C;AAC5C,2CAAsD;AAIzC,QAAA,aAAa,GAAG,IAAA,6BAAoB,EAAC,GAAG,EAAE;;IACrD,OAAO,MAAA,gBAAO,CAAC,GAAG,CAAc,MAAM,CAAC,0CAAE,MAAM,CAAC;AAClD,CAAC,CAAC,CAAC;AAEU,QAAA,WAAW,GAAG,qBAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CurrentPersonalAccessToken: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrentPersonalAccessToken = void 0;
|
|
4
|
+
const common_1 = require("@nest-boot/common");
|
|
5
|
+
const common_2 = require("@nestjs/common");
|
|
6
|
+
exports.CurrentPersonalAccessToken = (0, common_2.createParamDecorator)(() => {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = common_1.Context.get("auth")) === null || _a === void 0 ? void 0 : _a.personalAccessToken;
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=current-personal-access-token.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-personal-access-token.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-personal-access-token.decorator.ts"],"names":[],"mappings":";;;AAAA,8CAA4C;AAC5C,2CAAsD;AAIzC,QAAA,0BAA0B,GAAG,IAAA,6BAAoB,EAAC,GAAG,EAAE;;IAClE,OAAO,MAAA,gBAAO,CAAC,GAAG,CAAc,MAAM,CAAC,0CAAE,mBAAmB,CAAC;AAC/D,CAAC,CAAC,CAAC"}
|
|
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./can.decorator"), exports);
|
|
18
|
+
__exportStar(require("./current-entity.decorator"), exports);
|
|
19
|
+
__exportStar(require("./current-personal-access-token.decorator"), exports);
|
|
20
|
+
__exportStar(require("./require-auth.decorator"), exports);
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,6DAA2C;AAC3C,4EAA0D;AAC1D,2DAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RequireAuth: (requireAuth?: boolean) => ClassDecorator & MethodDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequireAuth = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const auth_module_definition_1 = require("../auth.module-definition");
|
|
6
|
+
const RequireAuth = (requireAuth = true) => (0, common_1.SetMetadata)(auth_module_definition_1.REQUIRE_AUTH_METADATA_KEY, requireAuth);
|
|
7
|
+
exports.RequireAuth = RequireAuth;
|
|
8
|
+
//# sourceMappingURL=require-auth.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-auth.decorator.js","sourceRoot":"","sources":["../../src/decorators/require-auth.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C,sEAAsE;AAE/D,MAAM,WAAW,GAAG,CACzB,WAAW,GAAG,IAAI,EACgB,EAAE,CACpC,IAAA,oBAAW,EAAC,kDAAyB,EAAE,WAAW,CAAC,CAAC;AAHzC,QAAA,WAAW,eAG8B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
namespace NestBootAuth {
|
|
9
|
-
interface User {
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export * from "./entities";
|
|
14
|
-
export * from "./guards";
|
|
1
|
+
export * from "./auth.guard";
|
|
2
|
+
export * from "./auth.middleware";
|
|
3
|
+
export * from "./auth.module";
|
|
4
|
+
export * from "./auth.service";
|
|
5
|
+
export * from "./decorators";
|
|
15
6
|
export * from "./interfaces";
|
|
16
|
-
export * from "./middlewares";
|
|
17
7
|
export * from "./utils";
|
package/dist/index.js
CHANGED
|
@@ -14,9 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./auth.guard"), exports);
|
|
18
|
+
__exportStar(require("./auth.middleware"), exports);
|
|
19
|
+
__exportStar(require("./auth.module"), exports);
|
|
20
|
+
__exportStar(require("./auth.service"), exports);
|
|
21
|
+
__exportStar(require("./decorators"), exports);
|
|
19
22
|
__exportStar(require("./interfaces"), exports);
|
|
20
|
-
__exportStar(require("./middlewares"), exports);
|
|
21
23
|
__exportStar(require("./utils"), exports);
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,oDAAkC;AAClC,gDAA8B;AAC9B,iDAA+B;AAC/B,+CAA6B;AAC7B,+CAA6B;AAC7B,0CAAwB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EntityClass } from "@mikro-orm/core";
|
|
3
|
+
import { RouteInfo, Type } from "@nestjs/common/interfaces";
|
|
4
|
+
import { PersonalAccessTokenInterface } from "./personal-access-token.interface";
|
|
5
|
+
export interface AuthModuleOptions {
|
|
6
|
+
personalAccessTokenEntity: EntityClass<PersonalAccessTokenInterface>;
|
|
7
|
+
secret: string | Buffer;
|
|
8
|
+
expiresIn?: string | number;
|
|
9
|
+
defaultRequireAuth?: boolean;
|
|
10
|
+
includeRoutes?: Array<string | Type<any> | RouteInfo>;
|
|
11
|
+
excludeRoutes?: Array<string | RouteInfo>;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-module-options.interface.js","sourceRoot":"","sources":["../../src/interfaces/auth-module-options.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-payload.interface.js","sourceRoot":"","sources":["../../src/interfaces/auth-payload.interface.ts"],"names":[],"mappings":""}
|
package/dist/interfaces/index.js
CHANGED
|
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./auth-module-options.interface"), exports);
|
|
18
|
+
__exportStar(require("./auth-payload.interface"), exports);
|
|
17
19
|
__exportStar(require("./has-permission.interface"), exports);
|
|
20
|
+
__exportStar(require("./personal-access-token.interface"), exports);
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAgD;AAChD,2DAAyC;AACzC,6DAA2C;AAC3C,oEAAkD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personal-access-token.interface.js","sourceRoot":"","sources":["../../src/interfaces/personal-access-token.interface.ts"],"names":[],"mappings":""}
|