@builder6/core 0.0.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/admin.guard.d.ts +8 -0
- package/dist/auth/admin.guard.js +47 -0
- package/dist/auth/admin.guard.js.map +1 -0
- package/dist/auth/auth.controller.d.ts +7 -0
- package/dist/auth/auth.controller.js +80 -0
- package/dist/auth/auth.controller.js.map +1 -0
- package/dist/auth/auth.controller.spec.d.ts +1 -0
- package/dist/auth/auth.controller.spec.js +17 -0
- package/dist/auth/auth.controller.spec.js.map +1 -0
- package/dist/auth/auth.guard.d.ts +7 -0
- package/dist/auth/auth.guard.js +41 -0
- package/dist/auth/auth.guard.js.map +1 -0
- package/dist/auth/auth.module.d.ts +2 -0
- package/dist/auth/auth.module.js +34 -0
- package/dist/auth/auth.module.js.map +1 -0
- package/dist/auth/auth.service.d.ts +22 -0
- package/dist/auth/auth.service.js +175 -0
- package/dist/auth/auth.service.js.map +1 -0
- package/dist/auth/auth.service.spec.d.ts +1 -0
- package/dist/auth/auth.service.spec.js +17 -0
- package/dist/auth/auth.service.spec.js.map +1 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.js +22 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/mongodb/index.d.ts +2 -0
- package/dist/mongodb/index.js +19 -0
- package/dist/mongodb/index.js.map +1 -0
- package/dist/mongodb/mongodb.module.d.ts +2 -0
- package/dist/mongodb/mongodb.module.js +21 -0
- package/dist/mongodb/mongodb.module.js.map +1 -0
- package/dist/mongodb/mongodb.service.d.ts +17 -0
- package/dist/mongodb/mongodb.service.js +113 -0
- package/dist/mongodb/mongodb.service.js.map +1 -0
- package/package.json +15 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { AuthService } from './auth.service';
|
|
3
|
+
export declare class AdminGuard implements CanActivate {
|
|
4
|
+
private authService;
|
|
5
|
+
constructor(authService: AuthService);
|
|
6
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
7
|
+
private extractTokenFromHeader;
|
|
8
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AdminGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const auth_service_1 = require("./auth.service");
|
|
15
|
+
let AdminGuard = class AdminGuard {
|
|
16
|
+
constructor(authService) {
|
|
17
|
+
this.authService = authService;
|
|
18
|
+
}
|
|
19
|
+
async canActivate(context) {
|
|
20
|
+
const request = context.switchToHttp().getRequest();
|
|
21
|
+
const token = this.authService.extractTokenFromHeaderOrCookie(request);
|
|
22
|
+
if (!token) {
|
|
23
|
+
throw new common_1.UnauthorizedException();
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const user = (await this.authService.getUserByToken(token));
|
|
27
|
+
if (user?.profile != 'admin') {
|
|
28
|
+
throw new common_1.UnauthorizedException();
|
|
29
|
+
}
|
|
30
|
+
request['user'] = user;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw new common_1.UnauthorizedException();
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
extractTokenFromHeader(request) {
|
|
38
|
+
const [type, token] = request.headers.authorization?.split(' ') ?? [];
|
|
39
|
+
return type === 'Bearer' ? token : undefined;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.AdminGuard = AdminGuard;
|
|
43
|
+
exports.AdminGuard = AdminGuard = __decorate([
|
|
44
|
+
(0, common_1.Injectable)(),
|
|
45
|
+
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
|
46
|
+
], AdminGuard);
|
|
47
|
+
//# sourceMappingURL=admin.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.guard.js","sourceRoot":"","sources":["../../src/auth/admin.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AAExB,iDAA6C;AAGtC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;QACvE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACpC,CAAC;QACD,IAAI,CAAC;YAGH,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAQ,CAAC;YACnE,IAAI,IAAI,EAAE,OAAO,IAAI,OAAO,EAAE,CAAC;gBAC7B,MAAM,IAAI,8BAAqB,EAAE,CAAC;YACpC,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACpC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,sBAAsB,CAAC,OAAgB;QAC7C,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QACtE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/C,CAAC;CACF,CAAA;AA3BY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAEsB,0BAAW;GADjC,UAAU,CA2BtB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AuthService } from './auth.service';
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
export declare class AuthController {
|
|
4
|
+
private authService;
|
|
5
|
+
constructor(authService: AuthService);
|
|
6
|
+
login(req: Request, res: Response, signInDto: Record<string, any>): Promise<Response<any, Record<string, any>>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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.AuthController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const auth_service_1 = require("./auth.service");
|
|
18
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
19
|
+
let AuthController = class AuthController {
|
|
20
|
+
constructor(authService) {
|
|
21
|
+
this.authService = authService;
|
|
22
|
+
}
|
|
23
|
+
async login(req, res, signInDto) {
|
|
24
|
+
try {
|
|
25
|
+
const result = await this.authService.signIn(signInDto.username, signInDto.password);
|
|
26
|
+
const { user, space, authToken } = result;
|
|
27
|
+
const cookieOptions = {
|
|
28
|
+
httpOnly: true,
|
|
29
|
+
sameSite: 'strict',
|
|
30
|
+
maxAge: 2 * 365 * 24 * 60 * 60 * 1000,
|
|
31
|
+
};
|
|
32
|
+
if (process.env.STEEDOS_AUTH_COOKIES_USE_SAMESITE == 'None') {
|
|
33
|
+
cookieOptions.sameSite = 'none';
|
|
34
|
+
cookieOptions.secure = true;
|
|
35
|
+
}
|
|
36
|
+
res.cookie('X-Auth-Token', authToken, cookieOptions);
|
|
37
|
+
res.cookie('X-User-Id', user, cookieOptions);
|
|
38
|
+
res.cookie('X-Space-Id', space, cookieOptions);
|
|
39
|
+
return res.status(200).json(result);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error('Error during signIn:', error);
|
|
43
|
+
return res.status(401).json({ message: 'Authentication failed' });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.AuthController = AuthController;
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
50
|
+
(0, common_1.Post)('login'),
|
|
51
|
+
(0, swagger_1.ApiBody)({
|
|
52
|
+
schema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
username: { type: 'string' },
|
|
56
|
+
password: { type: 'string' },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
examples: {
|
|
60
|
+
test: {
|
|
61
|
+
summary: 'test',
|
|
62
|
+
value: {
|
|
63
|
+
username: 'test',
|
|
64
|
+
password: 'test',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
__param(0, (0, common_1.Req)()),
|
|
70
|
+
__param(1, (0, common_1.Res)()),
|
|
71
|
+
__param(2, (0, common_1.Body)()),
|
|
72
|
+
__metadata("design:type", Function),
|
|
73
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
74
|
+
__metadata("design:returntype", Promise)
|
|
75
|
+
], AuthController.prototype, "login", null);
|
|
76
|
+
exports.AuthController = AuthController = __decorate([
|
|
77
|
+
(0, common_1.Controller)('api/v6/auth'),
|
|
78
|
+
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
|
79
|
+
], AuthController);
|
|
80
|
+
//# sourceMappingURL=auth.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../src/auth/auth.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,iDAA6C;AAC7C,6CAA0C;AAInC,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAsB1C,AAAN,KAAK,CAAC,KAAK,CACF,GAAY,EACZ,GAAa,EACZ,SAA8B;QAEtC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAC1C,SAAS,CAAC,QAAQ,EAClB,SAAS,CAAC,QAAQ,CACnB,CAAC;YACF,MAAM,EAAE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AAE,QAAQ,EAAE;aAC7B;SACF;QACD,QAAQ,EAAE;YACR,IAAI,EAAE;gBACJ,OAAO,EAAE,MAAM;gBACf,KAAK,EAAE;oBACL,QAAQ,EAAE,MAAM;oBAChB,QAAQ,EAAE,MAAM;iBACjB;aACF;SACF;KACF,CAAC;IAEC,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,aAAI,GAAE,CAAA;;;;2CA4BR;yBAtDU,cAAc;IAD1B,IAAA,mBAAU,EAAC,aAAa,CAAC;qCAES,0BAAW;GADjC,cAAc,CAuD1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const testing_1 = require("@nestjs/testing");
|
|
4
|
+
const auth_controller_1 = require("./auth.controller");
|
|
5
|
+
describe('AuthController', () => {
|
|
6
|
+
let controller;
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
const module = await testing_1.Test.createTestingModule({
|
|
9
|
+
controllers: [auth_controller_1.AuthController],
|
|
10
|
+
}).compile();
|
|
11
|
+
controller = module.get(auth_controller_1.AuthController);
|
|
12
|
+
});
|
|
13
|
+
it('should be defined', () => {
|
|
14
|
+
expect(controller).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=auth.controller.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.controller.spec.js","sourceRoot":"","sources":["../../src/auth/auth.controller.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,uDAAmD;AAEnD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,IAAI,UAA0B,CAAC;IAE/B,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,WAAW,EAAE,CAAC,gCAAc,CAAC;SAC9B,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,UAAU,GAAG,MAAM,CAAC,GAAG,CAAiB,gCAAc,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { AuthService } from './auth.service';
|
|
3
|
+
export declare class AuthGuard implements CanActivate {
|
|
4
|
+
private authService;
|
|
5
|
+
constructor(authService: AuthService);
|
|
6
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuthGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const auth_service_1 = require("./auth.service");
|
|
15
|
+
let AuthGuard = class AuthGuard {
|
|
16
|
+
constructor(authService) {
|
|
17
|
+
this.authService = authService;
|
|
18
|
+
}
|
|
19
|
+
async canActivate(context) {
|
|
20
|
+
const request = context.switchToHttp().getRequest();
|
|
21
|
+
const token = this.authService.extractTokenFromHeaderOrCookie(request);
|
|
22
|
+
if (!token) {
|
|
23
|
+
console.error('Token not found', token);
|
|
24
|
+
throw new common_1.UnauthorizedException();
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const user = await this.authService.getUserByToken(token);
|
|
28
|
+
request['user'] = user;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
throw new common_1.UnauthorizedException();
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.AuthGuard = AuthGuard;
|
|
37
|
+
exports.AuthGuard = AuthGuard = __decorate([
|
|
38
|
+
(0, common_1.Injectable)(),
|
|
39
|
+
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
|
40
|
+
], AuthGuard);
|
|
41
|
+
//# sourceMappingURL=auth.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../src/auth/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AACxB,iDAA6C;AAGtC,IAAM,SAAS,GAAf,MAAM,SAAS;IACpB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;QACvE,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;YACxC,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACpC,CAAC;QACD,IAAI,CAAC;YAGH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC1D,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACpC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AApBY,8BAAS;oBAAT,SAAS;IADrB,IAAA,mBAAU,GAAE;qCAEsB,0BAAW;GADjC,SAAS,CAoBrB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuthModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
12
|
+
const auth_controller_1 = require("./auth.controller");
|
|
13
|
+
const auth_service_1 = require("./auth.service");
|
|
14
|
+
const mongodb_module_1 = require("../mongodb/mongodb.module");
|
|
15
|
+
const admin_guard_1 = require("./admin.guard");
|
|
16
|
+
const auth_guard_1 = require("./auth.guard");
|
|
17
|
+
let AuthModule = class AuthModule {
|
|
18
|
+
};
|
|
19
|
+
exports.AuthModule = AuthModule;
|
|
20
|
+
exports.AuthModule = AuthModule = __decorate([
|
|
21
|
+
(0, common_1.Module)({
|
|
22
|
+
imports: [
|
|
23
|
+
mongodb_module_1.MongodbModule,
|
|
24
|
+
jwt_1.JwtModule.register({
|
|
25
|
+
secret: process.env.JWT_SECRET || 'secret',
|
|
26
|
+
signOptions: { expiresIn: '60s' },
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
controllers: [auth_controller_1.AuthController],
|
|
30
|
+
providers: [auth_service_1.AuthService, admin_guard_1.AdminGuard, auth_guard_1.AuthGuard],
|
|
31
|
+
exports: [auth_service_1.AuthService, admin_guard_1.AdminGuard, auth_guard_1.AuthGuard],
|
|
32
|
+
})
|
|
33
|
+
], AuthModule);
|
|
34
|
+
//# sourceMappingURL=auth.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qCAAwC;AACxC,uDAAmD;AACnD,iDAA6C;AAC7C,8DAA0D;AAC1D,+CAA2C;AAC3C,6CAAyC;AAclC,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IAZtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,8BAAa;YACb,eAAS,CAAC,QAAQ,CAAC;gBACjB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,QAAQ;gBAC1C,WAAW,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;aAClC,CAAC;SACH;QACD,WAAW,EAAE,CAAC,gCAAc,CAAC;QAC7B,SAAS,EAAE,CAAC,0BAAW,EAAE,wBAAU,EAAE,sBAAS,CAAC;QAC/C,OAAO,EAAE,CAAC,0BAAW,EAAE,wBAAU,EAAE,sBAAS,CAAC;KAC9C,CAAC;GACW,UAAU,CAAG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MongodbService } from '../mongodb';
|
|
2
|
+
import { JwtService } from '@nestjs/jwt';
|
|
3
|
+
import { Request } from 'express';
|
|
4
|
+
export declare class AuthService {
|
|
5
|
+
private mongodbService;
|
|
6
|
+
private jwtService;
|
|
7
|
+
private masterSpaceId;
|
|
8
|
+
constructor(mongodbService: MongodbService, jwtService: JwtService);
|
|
9
|
+
signIn(username: string, password: string, spaceId?: string): Promise<any>;
|
|
10
|
+
getMasterSpaceId(): Promise<string>;
|
|
11
|
+
getSpaceUser(userId: string, spaceId: string): Promise<any>;
|
|
12
|
+
getUserByToken(token: string): Promise<any>;
|
|
13
|
+
extractTokenFromHeaderOrCookie(request: Request): string | undefined;
|
|
14
|
+
hashLoginToken(loginToken: any): string;
|
|
15
|
+
generateStampedLoginToken(token: any): {
|
|
16
|
+
token: any;
|
|
17
|
+
when: Date;
|
|
18
|
+
};
|
|
19
|
+
hashStampedToken(stampedToken: any): {
|
|
20
|
+
hashedToken: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AuthService = void 0;
|
|
13
|
+
const bcrypt = require("bcrypt");
|
|
14
|
+
const crypto = require("crypto");
|
|
15
|
+
const uuid_1 = require("uuid");
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const mongodb_1 = require("../mongodb");
|
|
18
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
19
|
+
let AuthService = class AuthService {
|
|
20
|
+
constructor(mongodbService, jwtService) {
|
|
21
|
+
this.mongodbService = mongodbService;
|
|
22
|
+
this.jwtService = jwtService;
|
|
23
|
+
}
|
|
24
|
+
async signIn(username, password, spaceId) {
|
|
25
|
+
if (!spaceId) {
|
|
26
|
+
spaceId = await this.getMasterSpaceId();
|
|
27
|
+
}
|
|
28
|
+
const hash = crypto.createHash('sha256');
|
|
29
|
+
hash.update(password);
|
|
30
|
+
const bcryptPassword = hash.digest('hex');
|
|
31
|
+
const user = (await this.mongodbService.findOne('users', {
|
|
32
|
+
$or: [
|
|
33
|
+
{ username: username },
|
|
34
|
+
{ 'emails.address': username },
|
|
35
|
+
{ mobile: username },
|
|
36
|
+
],
|
|
37
|
+
}));
|
|
38
|
+
if (!user) {
|
|
39
|
+
throw new common_1.UnauthorizedException();
|
|
40
|
+
}
|
|
41
|
+
const match = await bcrypt.compare(bcryptPassword, user.services.password.bcrypt);
|
|
42
|
+
if (!match) {
|
|
43
|
+
throw new common_1.UnauthorizedException();
|
|
44
|
+
}
|
|
45
|
+
const space_user = await this.getSpaceUser(user._id, spaceId);
|
|
46
|
+
if (!space_user) {
|
|
47
|
+
throw new common_1.UnauthorizedException();
|
|
48
|
+
}
|
|
49
|
+
const payload = {
|
|
50
|
+
sub: user._id,
|
|
51
|
+
name: space_user.name,
|
|
52
|
+
email: space_user.email,
|
|
53
|
+
space: spaceId,
|
|
54
|
+
profile: space_user.profile,
|
|
55
|
+
};
|
|
56
|
+
const access_token = this.jwtService.sign(payload);
|
|
57
|
+
const authToken = (0, uuid_1.v4)();
|
|
58
|
+
const stampedAuthToken = this.generateStampedLoginToken(authToken);
|
|
59
|
+
const hashedToken = this.hashStampedToken(stampedAuthToken);
|
|
60
|
+
if (!user['services']) {
|
|
61
|
+
user['services'] = {};
|
|
62
|
+
}
|
|
63
|
+
if (!user['services']['resume']) {
|
|
64
|
+
user['services']['resume'] = { loginTokens: [] };
|
|
65
|
+
}
|
|
66
|
+
user['services']['resume']['loginTokens'].push(hashedToken);
|
|
67
|
+
const data = { services: user['services'] };
|
|
68
|
+
await this.mongodbService.findOneAndUpdate('users', { _id: user._id }, data);
|
|
69
|
+
return {
|
|
70
|
+
access_token: access_token,
|
|
71
|
+
authToken: authToken,
|
|
72
|
+
...space_user,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async getMasterSpaceId() {
|
|
76
|
+
if (this.masterSpaceId) {
|
|
77
|
+
return this.masterSpaceId;
|
|
78
|
+
}
|
|
79
|
+
const space = await this.mongodbService.findOne('spaces', {}, { sort: { created: -1 } });
|
|
80
|
+
if (space) {
|
|
81
|
+
this.masterSpaceId = space._id;
|
|
82
|
+
}
|
|
83
|
+
return this.masterSpaceId;
|
|
84
|
+
}
|
|
85
|
+
async getSpaceUser(userId, spaceId) {
|
|
86
|
+
const spaceUser = await this.mongodbService.findOne('space_users', {
|
|
87
|
+
user: userId,
|
|
88
|
+
space: spaceId,
|
|
89
|
+
});
|
|
90
|
+
if (spaceUser) {
|
|
91
|
+
spaceUser['_id'] = userId;
|
|
92
|
+
delete spaceUser['password'];
|
|
93
|
+
}
|
|
94
|
+
return spaceUser;
|
|
95
|
+
}
|
|
96
|
+
async getUserByToken(token) {
|
|
97
|
+
const tokenArray = token.split(',');
|
|
98
|
+
let userId = null;
|
|
99
|
+
let spaceId = null;
|
|
100
|
+
if (tokenArray.length === 1) {
|
|
101
|
+
const payload = this.jwtService.decode(token);
|
|
102
|
+
console.log('payload', payload);
|
|
103
|
+
const user = (await this.mongodbService.findOne('users', {
|
|
104
|
+
_id: payload.sub,
|
|
105
|
+
}));
|
|
106
|
+
if (user) {
|
|
107
|
+
userId = user._id;
|
|
108
|
+
spaceId = payload.space;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (tokenArray.length === 2 && tokenArray[0] === 'apikey') {
|
|
112
|
+
const apiKeyString = tokenArray[1];
|
|
113
|
+
const apiKey = await this.mongodbService.findOne('api_keys', {
|
|
114
|
+
api_key: apiKeyString,
|
|
115
|
+
active: true,
|
|
116
|
+
});
|
|
117
|
+
if (apiKey) {
|
|
118
|
+
userId = apiKey.owner;
|
|
119
|
+
spaceId = apiKey.space;
|
|
120
|
+
await this.mongodbService.findOneAndUpdate('api_keys', { _id: apiKey._id }, { last_use_time: new Date() });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else if (tokenArray.length === 2) {
|
|
124
|
+
spaceId = tokenArray[0];
|
|
125
|
+
const authToken = tokenArray[1];
|
|
126
|
+
const hashedStampedToken = this.hashLoginToken(authToken);
|
|
127
|
+
const user = (await this.mongodbService.findOne('users', {
|
|
128
|
+
'services.resume.loginTokens.hashedToken': hashedStampedToken,
|
|
129
|
+
}));
|
|
130
|
+
if (user)
|
|
131
|
+
userId = user._id;
|
|
132
|
+
}
|
|
133
|
+
if (userId && spaceId) {
|
|
134
|
+
const space_user = await this.getSpaceUser(userId, spaceId);
|
|
135
|
+
return space_user;
|
|
136
|
+
}
|
|
137
|
+
throw new common_1.UnauthorizedException();
|
|
138
|
+
}
|
|
139
|
+
extractTokenFromHeaderOrCookie(request) {
|
|
140
|
+
const [type, token] = request.headers.authorization?.split(' ') ?? [];
|
|
141
|
+
let spaceToken = type === 'Bearer' ? token : undefined;
|
|
142
|
+
if (!spaceToken &&
|
|
143
|
+
request.cookies &&
|
|
144
|
+
request.cookies['X-Auth-Token'] &&
|
|
145
|
+
request.cookies['X-Space-Id']) {
|
|
146
|
+
spaceToken = `${request.cookies['X-Space-Id']},${request.cookies['X-Auth-Token']}`;
|
|
147
|
+
}
|
|
148
|
+
return spaceToken;
|
|
149
|
+
}
|
|
150
|
+
hashLoginToken(loginToken) {
|
|
151
|
+
const hash = crypto.createHash('sha256');
|
|
152
|
+
hash.update(loginToken);
|
|
153
|
+
return hash.digest('base64');
|
|
154
|
+
}
|
|
155
|
+
generateStampedLoginToken(token) {
|
|
156
|
+
return {
|
|
157
|
+
token: token,
|
|
158
|
+
when: new Date(),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
hashStampedToken(stampedToken) {
|
|
162
|
+
const hashedStampedToken = Object.keys(stampedToken).reduce((prev, key) => key === 'token' ? prev : { ...prev, [key]: stampedToken[key] }, {});
|
|
163
|
+
return {
|
|
164
|
+
...hashedStampedToken,
|
|
165
|
+
hashedToken: this.hashLoginToken(stampedToken.token),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
exports.AuthService = AuthService;
|
|
170
|
+
exports.AuthService = AuthService = __decorate([
|
|
171
|
+
(0, common_1.Injectable)(),
|
|
172
|
+
__metadata("design:paramtypes", [mongodb_1.MongodbService,
|
|
173
|
+
jwt_1.JwtService])
|
|
174
|
+
], AuthService);
|
|
175
|
+
//# sourceMappingURL=auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AACjC,iCAAiC;AACjC,+BAAkC;AAClC,2CAAmE;AACnE,wCAA4C;AAC5C,qCAAyC;AAIlC,IAAM,WAAW,GAAjB,MAAM,WAAW;IAGtB,YACU,cAA8B,EAC9B,UAAsB;QADtB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,eAAU,GAAV,UAAU,CAAY;IAC7B,CAAC;IAEJ,KAAK,CAAC,MAAM,CACV,QAAgB,EAChB,QAAgB,EAChB,OAAgB;QAEhB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1C,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wBAAc;QAClB,gBAAU;GALrB,WAAW,CAoMvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const testing_1 = require("@nestjs/testing");
|
|
4
|
+
const auth_service_1 = require("./auth.service");
|
|
5
|
+
describe('AuthService', () => {
|
|
6
|
+
let service;
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
const module = await testing_1.Test.createTestingModule({
|
|
9
|
+
providers: [auth_service_1.AuthService],
|
|
10
|
+
}).compile();
|
|
11
|
+
service = module.get(auth_service_1.AuthService);
|
|
12
|
+
});
|
|
13
|
+
it('should be defined', () => {
|
|
14
|
+
expect(service).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=auth.service.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.spec.js","sourceRoot":"","sources":["../../src/auth/auth.service.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,iDAA6C;AAE7C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,OAAoB,CAAC;IAEzB,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE,CAAC,0BAAW,CAAC;SACzB,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,OAAO,GAAG,MAAM,CAAC,GAAG,CAAc,0BAAW,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./admin.guard"), exports);
|
|
18
|
+
__exportStar(require("./auth.controller"), exports);
|
|
19
|
+
__exportStar(require("./auth.guard"), exports);
|
|
20
|
+
__exportStar(require("./auth.module"), exports);
|
|
21
|
+
__exportStar(require("./auth.service"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,oDAAkC;AAClC,+CAA6B;AAC7B,gDAA8B;AAC9B,iDAA+B"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./auth"), exports);
|
|
18
|
+
__exportStar(require("./mongodb"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,4CAA0B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./mongodb.module"), exports);
|
|
18
|
+
__exportStar(require("./mongodb.service"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mongodb/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,oDAAkC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MongodbModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const mongodb_service_1 = require("./mongodb.service");
|
|
12
|
+
let MongodbModule = class MongodbModule {
|
|
13
|
+
};
|
|
14
|
+
exports.MongodbModule = MongodbModule;
|
|
15
|
+
exports.MongodbModule = MongodbModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
providers: [mongodb_service_1.MongodbService],
|
|
18
|
+
exports: [mongodb_service_1.MongodbService],
|
|
19
|
+
})
|
|
20
|
+
], MongodbModule);
|
|
21
|
+
//# sourceMappingURL=mongodb.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongodb.module.js","sourceRoot":"","sources":["../../src/mongodb/mongodb.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,uDAAmD;AAM5C,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IAJzB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,gCAAc,CAAC;QAC3B,OAAO,EAAE,CAAC,gCAAc,CAAC;KAC1B,CAAC;GACW,aAAa,CAAG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import 'regenerator-runtime/runtime';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
export declare class MongodbService {
|
|
4
|
+
private configService;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private db;
|
|
7
|
+
private client;
|
|
8
|
+
constructor(configService: ConfigService);
|
|
9
|
+
insertOne(collectionName: string, data: any): Promise<any>;
|
|
10
|
+
find(collectionName: string, query: object, options?: object): Promise<any>;
|
|
11
|
+
findOne(collectionName: string, query: object, options?: object): Promise<any>;
|
|
12
|
+
objectqlFind(collectionName: string, queryOptions: any, processingOptions?: any): Promise<any>;
|
|
13
|
+
objectqlFindOne(collectionName: string, options: any): Promise<any>;
|
|
14
|
+
findOneAndUpdate(collectionName: string, query: object, data: any): Promise<any>;
|
|
15
|
+
deleteOne(collectionName: string, query: object): Promise<any>;
|
|
16
|
+
deleteMany(collectionName: string, query: object): Promise<any>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
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 MongodbService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.MongodbService = void 0;
|
|
14
|
+
require("regenerator-runtime/runtime");
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
16
|
+
const mongodb_1 = require("mongodb");
|
|
17
|
+
const uuid_1 = require("uuid");
|
|
18
|
+
const devextremeQuery = require("devextreme-query-mongodb");
|
|
19
|
+
const config_1 = require("@nestjs/config");
|
|
20
|
+
let MongodbService = MongodbService_1 = class MongodbService {
|
|
21
|
+
constructor(configService) {
|
|
22
|
+
this.configService = configService;
|
|
23
|
+
this.logger = new common_1.Logger(MongodbService_1.name);
|
|
24
|
+
const mongoUrl = configService.get('mongo.url');
|
|
25
|
+
this.client = new mongodb_1.MongoClient(mongoUrl, {});
|
|
26
|
+
this.client
|
|
27
|
+
.connect()
|
|
28
|
+
.then(() => {
|
|
29
|
+
this.db = this.client.db();
|
|
30
|
+
this.logger.log('Connected to Steedos MongoDB');
|
|
31
|
+
})
|
|
32
|
+
.catch((err) => {
|
|
33
|
+
this.logger.error('Error connecting to Steedos MongoDB', err);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async insertOne(collectionName, data) {
|
|
37
|
+
const collection = this.db.collection(collectionName);
|
|
38
|
+
const entry = { _id: (0, uuid_1.v4)(), ...data };
|
|
39
|
+
await collection.insertOne(entry);
|
|
40
|
+
return entry;
|
|
41
|
+
}
|
|
42
|
+
async find(collectionName, query, options = {}) {
|
|
43
|
+
const collection = this.db.collection(collectionName);
|
|
44
|
+
return await collection.find(query, options).toArray();
|
|
45
|
+
}
|
|
46
|
+
async findOne(collectionName, query, options = {}) {
|
|
47
|
+
const collection = this.db.collection(collectionName);
|
|
48
|
+
if (typeof query === 'string') {
|
|
49
|
+
return await collection.findOne({ _id: query }, options);
|
|
50
|
+
}
|
|
51
|
+
return await collection.findOne(query, options);
|
|
52
|
+
}
|
|
53
|
+
async objectqlFind(collectionName, queryOptions, processingOptions = { replaceIds: false }) {
|
|
54
|
+
const { top, skip, filters, sort, fields, ...restOptions } = queryOptions;
|
|
55
|
+
const loadOptions = {
|
|
56
|
+
take: top,
|
|
57
|
+
skip,
|
|
58
|
+
requireTotalCount: true,
|
|
59
|
+
...restOptions,
|
|
60
|
+
};
|
|
61
|
+
if (filters) {
|
|
62
|
+
loadOptions.filter = filters;
|
|
63
|
+
}
|
|
64
|
+
if (sort) {
|
|
65
|
+
const sortFields = sort.split(',');
|
|
66
|
+
loadOptions.sort = sortFields.map((sortField) => {
|
|
67
|
+
const [field, dir] = sortField.split(' ');
|
|
68
|
+
return { selector: field, desc: dir === 'desc' };
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (fields) {
|
|
72
|
+
if (typeof fields === 'object') {
|
|
73
|
+
loadOptions.select = fields;
|
|
74
|
+
}
|
|
75
|
+
else if (typeof fields === 'string') {
|
|
76
|
+
loadOptions.select = fields.split(',');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const collection = this.db.collection(collectionName);
|
|
80
|
+
return devextremeQuery(collection, loadOptions, processingOptions);
|
|
81
|
+
}
|
|
82
|
+
async objectqlFindOne(collectionName, options) {
|
|
83
|
+
const { filters, fields } = options;
|
|
84
|
+
const result = (await this.objectqlFind(collectionName, {
|
|
85
|
+
filters,
|
|
86
|
+
fields,
|
|
87
|
+
}));
|
|
88
|
+
if (result.data && result.data.length > 0) {
|
|
89
|
+
return result.data[0];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async findOneAndUpdate(collectionName, query, data) {
|
|
93
|
+
const collection = this.db.collection(collectionName);
|
|
94
|
+
const result = await collection.findOneAndUpdate(query, { $set: data }, { returnDocument: 'after' });
|
|
95
|
+
return result.value;
|
|
96
|
+
}
|
|
97
|
+
async deleteOne(collectionName, query) {
|
|
98
|
+
const collection = this.db.collection(collectionName);
|
|
99
|
+
const result = await collection.deleteOne(query);
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
async deleteMany(collectionName, query) {
|
|
103
|
+
const collection = this.db.collection(collectionName);
|
|
104
|
+
const result = await collection.deleteOne(query);
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
exports.MongodbService = MongodbService;
|
|
109
|
+
exports.MongodbService = MongodbService = MongodbService_1 = __decorate([
|
|
110
|
+
(0, common_1.Injectable)(),
|
|
111
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
112
|
+
], MongodbService);
|
|
113
|
+
//# sourceMappingURL=mongodb.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongodb.service.js","sourceRoot":"","sources":["../../src/mongodb/mongodb.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,uCAAqC;AAErC,2CAAoD;AACpD,qCAA0C;AAC1C,+BAAoC;AACpC,4DAA4D;AAC5D,2CAA+C;AAGxC,IAAM,cAAc,sBAApB,MAAM,cAAc;IAKzB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAJ/B,WAAM,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAC;QAKxD,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAW,CAAC,QAAQ,EAAE,EAGvC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM;aACR,OAAO,EAAE;aACT,IAAI,CAAC,GAAG,EAAE;YACT,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,8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1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@builder6/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "rm -rf dist && tsc -b",
|
|
11
|
+
"build:watch": "rm -rf dist && tsc --watch"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
}
|
|
15
|
+
}
|