@loopstack/auth 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/LICENSE +43 -21
- package/dist/auth.module.d.ts +2 -2
- package/dist/auth.module.js +29 -24
- package/dist/auth.module.js.map +1 -1
- package/dist/controllers/auth.controller.d.ts +9 -16
- package/dist/controllers/auth.controller.js +40 -95
- package/dist/controllers/auth.controller.js.map +1 -1
- package/dist/dtos/hub-login-request.dto.d.ts +4 -0
- package/dist/dtos/hub-login-request.dto.js +30 -0
- package/dist/dtos/hub-login-request.dto.js.map +1 -0
- package/dist/dtos/worker-info.dto.d.ts +5 -0
- package/dist/dtos/worker-info.dto.js +42 -0
- package/dist/dtos/worker-info.dto.js.map +1 -0
- package/dist/exceptions/hub.exceptions.d.ts +16 -0
- package/dist/exceptions/hub.exceptions.js +35 -0
- package/dist/exceptions/hub.exceptions.js.map +1 -0
- package/dist/guards/hub-auth.guard.d.ts +4 -0
- package/dist/guards/{dev-auth.guard.js → hub-auth.guard.js} +6 -6
- package/dist/guards/hub-auth.guard.js.map +1 -0
- package/dist/guards/index.d.ts +0 -3
- package/dist/guards/index.js +0 -3
- package/dist/guards/index.js.map +1 -1
- package/dist/guards/jwt-auth.guard.d.ts +5 -3
- package/dist/guards/jwt-auth.guard.js +14 -4
- package/dist/guards/jwt-auth.guard.js.map +1 -1
- package/dist/guards/worker-auth.guard.d.ts +7 -0
- package/dist/{strategies/dev.strategy.js → guards/worker-auth.guard.js} +15 -20
- package/dist/guards/worker-auth.guard.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/auth-config.interface.d.ts +3 -13
- package/dist/interfaces/hub-service.interfaces.d.ts +16 -0
- package/dist/interfaces/hub-service.interfaces.js +3 -0
- package/dist/interfaces/hub-service.interfaces.js.map +1 -0
- package/dist/repositories/user.repository.d.ts +0 -1
- package/dist/repositories/user.repository.js +0 -6
- package/dist/repositories/user.repository.js.map +1 -1
- package/dist/services/auth.service.d.ts +7 -11
- package/dist/services/auth.service.js +32 -46
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/config-validation.service.d.ts +8 -0
- package/dist/services/config-validation.service.js +44 -0
- package/dist/services/config-validation.service.js.map +1 -0
- package/dist/services/hub-audit.service.d.ts +14 -0
- package/dist/services/hub-audit.service.js +47 -0
- package/dist/services/hub-audit.service.js.map +1 -0
- package/dist/services/hub.service.d.ts +20 -0
- package/dist/services/hub.service.js +179 -0
- package/dist/services/hub.service.js.map +1 -0
- package/dist/services/index.d.ts +1 -2
- package/dist/services/index.js +1 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/token.service.d.ts +10 -6
- package/dist/services/token.service.js +26 -23
- package/dist/services/token.service.js.map +1 -1
- package/dist/strategies/hub.strategy.d.ts +17 -0
- package/dist/strategies/hub.strategy.js +67 -0
- package/dist/strategies/hub.strategy.js.map +1 -0
- package/dist/strategies/index.d.ts +1 -3
- package/dist/strategies/index.js +1 -3
- package/dist/strategies/index.js.map +1 -1
- package/dist/strategies/jwt.strategy.d.ts +1 -1
- package/dist/strategies/jwt.strategy.js +10 -7
- package/dist/strategies/jwt.strategy.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -11
- package/dist/decorators/current-user.decorator.d.ts +0 -1
- package/dist/decorators/current-user.decorator.js +0 -9
- package/dist/decorators/current-user.decorator.js.map +0 -1
- package/dist/decorators/index.d.ts +0 -3
- package/dist/decorators/index.js +0 -20
- package/dist/decorators/index.js.map +0 -1
- package/dist/decorators/public.decorator.d.ts +0 -1
- package/dist/decorators/public.decorator.js +0 -8
- package/dist/decorators/public.decorator.js.map +0 -1
- package/dist/decorators/roles.decorator.d.ts +0 -1
- package/dist/decorators/roles.decorator.js +0 -8
- package/dist/decorators/roles.decorator.js.map +0 -1
- package/dist/guards/dev-auth.guard.d.ts +0 -4
- package/dist/guards/dev-auth.guard.js.map +0 -1
- package/dist/guards/google-auth.guard.d.ts +0 -5
- package/dist/guards/google-auth.guard.js +0 -23
- package/dist/guards/google-auth.guard.js.map +0 -1
- package/dist/guards/local-auth.guard.d.ts +0 -4
- package/dist/guards/local-auth.guard.js +0 -18
- package/dist/guards/local-auth.guard.js.map +0 -1
- package/dist/repositories/auth-provider.repository.d.ts +0 -9
- package/dist/repositories/auth-provider.repository.js +0 -47
- package/dist/repositories/auth-provider.repository.js.map +0 -1
- package/dist/services/oauth.service.d.ts +0 -15
- package/dist/services/oauth.service.js +0 -91
- package/dist/services/oauth.service.js.map +0 -1
- package/dist/services/password.service.d.ts +0 -5
- package/dist/services/password.service.js +0 -25
- package/dist/services/password.service.js.map +0 -1
- package/dist/strategies/dev.strategy.d.ts +0 -9
- package/dist/strategies/dev.strategy.js.map +0 -1
- package/dist/strategies/google.strategy.d.ts +0 -8
- package/dist/strategies/google.strategy.js +0 -51
- package/dist/strategies/google.strategy.js.map +0 -1
- package/dist/strategies/local.strategy.d.ts +0 -8
- package/dist/strategies/local.strategy.js +0 -36
- package/dist/strategies/local.strategy.js.map +0 -1
package/package.json
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
"name": "@loopstack/auth",
|
|
3
3
|
"displayName": "Loopstack Auth Module",
|
|
4
4
|
"description": "The auth module of the loopstack automation framework",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.10.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Jakob Klippel",
|
|
8
8
|
"url": "https://www.linkedin.com/in/jakob-klippel/"
|
|
9
9
|
},
|
|
10
|
-
"license": "
|
|
10
|
+
"license": "BSL",
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"types": "dist/index.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@loopstack/core": "^0.
|
|
15
|
-
"@loopstack/shared": "^0.
|
|
14
|
+
"@loopstack/core": "^0.10.0",
|
|
15
|
+
"@loopstack/shared": "^0.10.0",
|
|
16
16
|
"@nestjs/common": "^11.0.1",
|
|
17
17
|
"@nestjs/config": "^4.0.0",
|
|
18
18
|
"@nestjs/core": "^11.0.1",
|
|
@@ -22,20 +22,19 @@
|
|
|
22
22
|
"@nestjs/passport": "^11.0.5",
|
|
23
23
|
"@nestjs/platform-express": "^11.0.1",
|
|
24
24
|
"@nestjs/swagger": "^11.0.5",
|
|
25
|
-
"
|
|
26
|
-
"bcrypt": "^6.0.0",
|
|
25
|
+
"axios": "^1.11.0",
|
|
27
26
|
"class-transformer": "^0.5.1",
|
|
28
27
|
"class-validator": "^0.14.1",
|
|
29
28
|
"cookie-parser": "^1.4.7",
|
|
30
29
|
"lodash": "^4.17.21",
|
|
31
30
|
"passport-custom": "^1.1.1",
|
|
32
|
-
"passport-google-oauth20": "^2.0.0",
|
|
33
31
|
"passport-jwt": "^4.0.1",
|
|
34
|
-
"passport-local": "^1.0.0",
|
|
35
|
-
"passport-strategy": "^1.0.0",
|
|
36
32
|
"reflect-metadata": "^0.2.2",
|
|
37
|
-
"rxjs": "^7.8.1"
|
|
38
|
-
|
|
33
|
+
"rxjs": "^7.8.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@nestjs/typeorm": "^11.0.0",
|
|
37
|
+
"typeorm": "^0.3.25"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
40
|
"@eslint/eslintrc": "^3.2.0",
|
|
@@ -43,6 +42,7 @@
|
|
|
43
42
|
"@nestjs/cli": "^11.0.0",
|
|
44
43
|
"@nestjs/schematics": "^11.0.0",
|
|
45
44
|
"@nestjs/testing": "^11.0.1",
|
|
45
|
+
"@nestjs/typeorm": "^11.0.0",
|
|
46
46
|
"@swc/cli": "^0.6.0",
|
|
47
47
|
"@swc/core": "^1.10.7",
|
|
48
48
|
"@types/express": "^5.0.0",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"ts-loader": "^9.5.2",
|
|
63
63
|
"ts-node": "^10.9.2",
|
|
64
64
|
"tsconfig-paths": "^4.2.0",
|
|
65
|
+
"typeorm": "^0.3.25",
|
|
65
66
|
"typescript": "^5.7.3",
|
|
66
67
|
"typescript-eslint": "^8.20.0"
|
|
67
68
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CurrentUser = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
exports.CurrentUser = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
6
|
-
const request = ctx.switchToHttp().getRequest();
|
|
7
|
-
return request.user;
|
|
8
|
-
});
|
|
9
|
-
//# sourceMappingURL=current-user.decorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-user.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAE3D,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC7C,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IACvC,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CACF,CAAC"}
|
package/dist/decorators/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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("./current-user.decorator"), exports);
|
|
18
|
-
__exportStar(require("./public.decorator"), exports);
|
|
19
|
-
__exportStar(require("./roles.decorator"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAwC;AACxC,qDAAkC;AAClC,oDAAiC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Public: () => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Public = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const shared_1 = require("@loopstack/shared");
|
|
6
|
-
const Public = () => (0, common_1.SetMetadata)(shared_1.IS_PUBLIC_KEY, true);
|
|
7
|
-
exports.Public = Public;
|
|
8
|
-
//# sourceMappingURL=public.decorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../src/decorators/public.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAC7C,8CAAkD;AAE3C,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,sBAAa,EAAE,IAAI,CAAC,CAAC;AAAhD,QAAA,MAAM,UAA0C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Roles: (...roles: string[]) => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Roles = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const shared_1 = require("@loopstack/shared");
|
|
6
|
-
const Roles = (...roles) => (0, common_1.SetMetadata)(shared_1.ROLES_KEY, roles);
|
|
7
|
-
exports.Roles = Roles;
|
|
8
|
-
//# sourceMappingURL=roles.decorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"roles.decorator.js","sourceRoot":"","sources":["../../src/decorators/roles.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAC7C,8CAA8C;AAEvC,MAAM,KAAK,GAAG,CAAC,GAAG,KAAe,EAAE,EAAE,CAAC,IAAA,oBAAW,EAAC,kBAAS,EAAE,KAAK,CAAC,CAAC;AAA9D,QAAA,KAAK,SAAyD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dev-auth.guard.js","sourceRoot":"","sources":["../../src/guards/dev-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA6C;AAGtC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,IAAA,oBAAS,EAAC,KAAK,CAAC;CAAG,CAAA;AAAxC,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;GACA,YAAY,CAA4B"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
declare const GoogleAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
2
|
-
export declare class GoogleAuthGuard extends GoogleAuthGuard_base {
|
|
3
|
-
}
|
|
4
|
-
export declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
5
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
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.CurrentUser = exports.GoogleAuthGuard = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const passport_1 = require("@nestjs/passport");
|
|
12
|
-
let GoogleAuthGuard = class GoogleAuthGuard extends (0, passport_1.AuthGuard)('google') {
|
|
13
|
-
};
|
|
14
|
-
exports.GoogleAuthGuard = GoogleAuthGuard;
|
|
15
|
-
exports.GoogleAuthGuard = GoogleAuthGuard = __decorate([
|
|
16
|
-
(0, common_1.Injectable)()
|
|
17
|
-
], GoogleAuthGuard);
|
|
18
|
-
const common_2 = require("@nestjs/common");
|
|
19
|
-
exports.CurrentUser = (0, common_2.createParamDecorator)((data, ctx) => {
|
|
20
|
-
const request = ctx.switchToHttp().getRequest();
|
|
21
|
-
return request.user;
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=google-auth.guard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google-auth.guard.js","sourceRoot":"","sources":["../../src/guards/google-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA6C;AAGtC,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,IAAA,oBAAS,EAAC,QAAQ,CAAC;CAAG,CAAA;AAA9C,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;GACA,eAAe,CAA+B;AAG3D,2CAAwE;AAE3D,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC7C,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IACvC,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC,CACF,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
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.LocalAuthGuard = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const passport_1 = require("@nestjs/passport");
|
|
12
|
-
let LocalAuthGuard = class LocalAuthGuard extends (0, passport_1.AuthGuard)('local') {
|
|
13
|
-
};
|
|
14
|
-
exports.LocalAuthGuard = LocalAuthGuard;
|
|
15
|
-
exports.LocalAuthGuard = LocalAuthGuard = __decorate([
|
|
16
|
-
(0, common_1.Injectable)()
|
|
17
|
-
], LocalAuthGuard);
|
|
18
|
-
//# sourceMappingURL=local-auth.guard.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-auth.guard.js","sourceRoot":"","sources":["../../src/guards/local-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA6C;AAGtC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,IAAA,oBAAS,EAAC,OAAO,CAAC;CAAG,CAAA;AAA5C,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;GACA,cAAc,CAA8B"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Repository } from 'typeorm';
|
|
2
|
-
import { AuthProvider } from '@loopstack/shared';
|
|
3
|
-
export declare class AuthProviderRepository {
|
|
4
|
-
private repository;
|
|
5
|
-
constructor(repository: Repository<AuthProvider>);
|
|
6
|
-
findByProviderAndId(provider: string, providerId: string): Promise<AuthProvider | null>;
|
|
7
|
-
findByUserId(userId: string): Promise<AuthProvider[]>;
|
|
8
|
-
create(providerData: Partial<AuthProvider>): Promise<AuthProvider>;
|
|
9
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
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.AuthProviderRepository = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
-
const typeorm_2 = require("typeorm");
|
|
19
|
-
const shared_1 = require("@loopstack/shared");
|
|
20
|
-
let AuthProviderRepository = class AuthProviderRepository {
|
|
21
|
-
repository;
|
|
22
|
-
constructor(repository) {
|
|
23
|
-
this.repository = repository;
|
|
24
|
-
}
|
|
25
|
-
async findByProviderAndId(provider, providerId) {
|
|
26
|
-
return this.repository.findOne({
|
|
27
|
-
where: { provider, providerId },
|
|
28
|
-
relations: ['user', 'user.roles'],
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
async findByUserId(userId) {
|
|
32
|
-
return this.repository.find({
|
|
33
|
-
where: { user: { id: userId } },
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
async create(providerData) {
|
|
37
|
-
const provider = this.repository.create(providerData);
|
|
38
|
-
return this.repository.save(provider);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
exports.AuthProviderRepository = AuthProviderRepository;
|
|
42
|
-
exports.AuthProviderRepository = AuthProviderRepository = __decorate([
|
|
43
|
-
(0, common_1.Injectable)(),
|
|
44
|
-
__param(0, (0, typeorm_1.InjectRepository)(shared_1.AuthProvider)),
|
|
45
|
-
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
46
|
-
], AuthProviderRepository);
|
|
47
|
-
//# sourceMappingURL=auth-provider.repository.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-provider.repository.js","sourceRoot":"","sources":["../../src/repositories/auth-provider.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AACrC,8CAAiD;AAG1C,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAGvB;IAFV,YAEU,UAAoC;QAApC,eAAU,GAAV,UAAU,CAA0B;IAC3C,CAAC;IAEJ,KAAK,CAAC,mBAAmB,CAAC,QAAgB,EAAE,UAAkB;QAC5D,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YAC7B,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE;YAC/B,SAAS,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAc;QAC/B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAC1B,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;SAChC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,YAAmC;QAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AAvBY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,qBAAY,CAAC,CAAA;qCACX,oBAAU;GAHrB,sBAAsB,CAuBlC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TokenService } from './token.service';
|
|
2
|
-
import { AuthService } from './auth.service';
|
|
3
|
-
import { UserRepository } from '../repositories';
|
|
4
|
-
import { AuthResponseDto, LinkProviderDto, OAuthProfileInterface, UserResponseDto } from '@loopstack/shared';
|
|
5
|
-
import { AuthProviderRepository } from '../repositories/auth-provider.repository';
|
|
6
|
-
export declare class OAuthService {
|
|
7
|
-
private userRepository;
|
|
8
|
-
private authProviderRepository;
|
|
9
|
-
private tokenService;
|
|
10
|
-
private authService;
|
|
11
|
-
constructor(userRepository: UserRepository, authProviderRepository: AuthProviderRepository, tokenService: TokenService, authService: AuthService);
|
|
12
|
-
handleOAuthLogin(profile: OAuthProfileInterface): Promise<AuthResponseDto>;
|
|
13
|
-
linkProvider(userId: string, linkProviderDto: LinkProviderDto): Promise<UserResponseDto>;
|
|
14
|
-
getUserProviders(userId: string): Promise<string[]>;
|
|
15
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
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.OAuthService = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const token_service_1 = require("./token.service");
|
|
15
|
-
const auth_service_1 = require("./auth.service");
|
|
16
|
-
const repositories_1 = require("../repositories");
|
|
17
|
-
const auth_provider_repository_1 = require("../repositories/auth-provider.repository");
|
|
18
|
-
let OAuthService = class OAuthService {
|
|
19
|
-
userRepository;
|
|
20
|
-
authProviderRepository;
|
|
21
|
-
tokenService;
|
|
22
|
-
authService;
|
|
23
|
-
constructor(userRepository, authProviderRepository, tokenService, authService) {
|
|
24
|
-
this.userRepository = userRepository;
|
|
25
|
-
this.authProviderRepository = authProviderRepository;
|
|
26
|
-
this.tokenService = tokenService;
|
|
27
|
-
this.authService = authService;
|
|
28
|
-
}
|
|
29
|
-
async handleOAuthLogin(profile) {
|
|
30
|
-
let authProvider = await this.authProviderRepository.findByProviderAndId(profile.provider, profile.id);
|
|
31
|
-
let user;
|
|
32
|
-
if (authProvider) {
|
|
33
|
-
user = authProvider.user;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
user = await this.userRepository.findByEmail(profile.email);
|
|
37
|
-
if (!user) {
|
|
38
|
-
user = await this.userRepository.create({
|
|
39
|
-
email: profile.email,
|
|
40
|
-
firstName: profile.firstName || profile.displayName?.split(' ')[0] || '',
|
|
41
|
-
lastName: profile.lastName || profile.displayName?.split(' ').slice(1).join(' ') || '',
|
|
42
|
-
isActive: true,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
await this.authProviderRepository.create({
|
|
46
|
-
provider: profile.provider,
|
|
47
|
-
providerId: profile.id,
|
|
48
|
-
user: user,
|
|
49
|
-
profile: profile._json,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const tokens = await this.tokenService.generateTokens(user);
|
|
53
|
-
return {
|
|
54
|
-
...tokens,
|
|
55
|
-
tokenType: 'Bearer',
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
async linkProvider(userId, linkProviderDto) {
|
|
59
|
-
const user = await this.userRepository.findById(userId);
|
|
60
|
-
if (!user) {
|
|
61
|
-
throw new common_1.NotFoundException('User not found');
|
|
62
|
-
}
|
|
63
|
-
const existingProvider = await this.authProviderRepository.findByProviderAndId(linkProviderDto.provider, linkProviderDto.code);
|
|
64
|
-
if (existingProvider) {
|
|
65
|
-
throw new common_1.ConflictException('This provider is already linked to another account');
|
|
66
|
-
}
|
|
67
|
-
await this.authProviderRepository.create({
|
|
68
|
-
provider: linkProviderDto.provider,
|
|
69
|
-
providerId: linkProviderDto.code,
|
|
70
|
-
user: user,
|
|
71
|
-
});
|
|
72
|
-
const updatedUser = await this.userRepository.findById(userId);
|
|
73
|
-
if (!updatedUser) {
|
|
74
|
-
throw new common_1.NotFoundException('User not found');
|
|
75
|
-
}
|
|
76
|
-
return this.authService.mapUserToResponse(updatedUser);
|
|
77
|
-
}
|
|
78
|
-
async getUserProviders(userId) {
|
|
79
|
-
const providers = await this.authProviderRepository.findByUserId(userId);
|
|
80
|
-
return providers.map(p => p.provider);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
exports.OAuthService = OAuthService;
|
|
84
|
-
exports.OAuthService = OAuthService = __decorate([
|
|
85
|
-
(0, common_1.Injectable)(),
|
|
86
|
-
__metadata("design:paramtypes", [repositories_1.UserRepository,
|
|
87
|
-
auth_provider_repository_1.AuthProviderRepository,
|
|
88
|
-
token_service_1.TokenService,
|
|
89
|
-
auth_service_1.AuthService])
|
|
90
|
-
], OAuthService);
|
|
91
|
-
//# sourceMappingURL=oauth.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.service.js","sourceRoot":"","sources":["../../src/services/oauth.service.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,25 +0,0 @@
|
|
|
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.PasswordService = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const bcrypt = require("bcrypt");
|
|
12
|
-
let PasswordService = class PasswordService {
|
|
13
|
-
saltRounds = 10;
|
|
14
|
-
async hash(password) {
|
|
15
|
-
return bcrypt.hash(password, this.saltRounds);
|
|
16
|
-
}
|
|
17
|
-
async compare(password, hash) {
|
|
18
|
-
return bcrypt.compare(password, hash);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
exports.PasswordService = PasswordService;
|
|
22
|
-
exports.PasswordService = PasswordService = __decorate([
|
|
23
|
-
(0, common_1.Injectable)()
|
|
24
|
-
], PasswordService);
|
|
25
|
-
//# sourceMappingURL=password.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"password.service.js","sourceRoot":"","sources":["../../src/services/password.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,iCAAiC;AAG1B,IAAM,eAAe,GAArB,MAAM,eAAe;IACT,UAAU,GAAG,EAAE,CAAC;IAEjC,KAAK,CAAC,IAAI,CAAC,QAAgB;QACzB,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAAgB,EAAE,IAAY;QAC1C,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AAVY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;GACA,eAAe,CAU3B"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Strategy } from 'passport-custom';
|
|
2
|
-
declare const DevStrategy_base: new () => Strategy & {
|
|
3
|
-
validate(...args: any[]): unknown;
|
|
4
|
-
};
|
|
5
|
-
export declare class DevStrategy extends DevStrategy_base {
|
|
6
|
-
constructor();
|
|
7
|
-
validate(req: Request): Promise<any>;
|
|
8
|
-
}
|
|
9
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dev.strategy.js","sourceRoot":"","sources":["../../src/strategies/dev.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoD;AACpD,2CAA4C;AAC5C,qDAA2C;AAGpC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,0BAAQ,EAAE,KAAK,CAAC;IAChE;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAY;QACzB,OAAO;YACL,EAAE,EAAE,IAAI;YACR,KAAK,EAAE,eAAe;YACtB,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;CACF,CAAA;AAfY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;;GACA,WAAW,CAevB"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { VerifyCallback } from 'passport-google-oauth20';
|
|
2
|
-
import { AuthConfig } from '../interfaces';
|
|
3
|
-
declare const GoogleStrategy_base: new (...args: any) => any;
|
|
4
|
-
export declare class GoogleStrategy extends GoogleStrategy_base {
|
|
5
|
-
constructor(config: AuthConfig);
|
|
6
|
-
validate(accessToken: string, refreshToken: string, profile: any, done: VerifyCallback): Promise<any>;
|
|
7
|
-
}
|
|
8
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
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.GoogleStrategy = void 0;
|
|
16
|
-
const passport_1 = require("@nestjs/passport");
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const constants_1 = require("../constants");
|
|
19
|
-
const passport_google_oauth20_1 = require("passport-google-oauth20");
|
|
20
|
-
let GoogleStrategy = class GoogleStrategy extends (0, passport_1.PassportStrategy)(passport_google_oauth20_1.Strategy, 'google') {
|
|
21
|
-
constructor(config) {
|
|
22
|
-
super({
|
|
23
|
-
clientID: config.oauth?.google?.clientId,
|
|
24
|
-
clientSecret: config.oauth?.google?.clientSecret,
|
|
25
|
-
callbackURL: config.oauth?.google?.callbackUrl,
|
|
26
|
-
scope: config.oauth?.google?.scope || ['email', 'profile'],
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
async validate(accessToken, refreshToken, profile, done) {
|
|
30
|
-
const { id, name, emails, photos } = profile;
|
|
31
|
-
const user = {
|
|
32
|
-
id,
|
|
33
|
-
email: emails[0].value,
|
|
34
|
-
firstName: name.givenName,
|
|
35
|
-
lastName: name.familyName,
|
|
36
|
-
displayName: profile.displayName,
|
|
37
|
-
photos,
|
|
38
|
-
provider: 'google',
|
|
39
|
-
_raw: profile._raw,
|
|
40
|
-
_json: profile._json,
|
|
41
|
-
};
|
|
42
|
-
done(null, user);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
exports.GoogleStrategy = GoogleStrategy;
|
|
46
|
-
exports.GoogleStrategy = GoogleStrategy = __decorate([
|
|
47
|
-
(0, common_1.Injectable)(),
|
|
48
|
-
__param(0, (0, common_1.Inject)(constants_1.AUTH_CONFIG)),
|
|
49
|
-
__metadata("design:paramtypes", [Object])
|
|
50
|
-
], GoogleStrategy);
|
|
51
|
-
//# sourceMappingURL=google.strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google.strategy.js","sourceRoot":"","sources":["../../src/strategies/google.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,2CAAoD;AACpD,4CAA2C;AAC3C,qEAAmE;AAK5D,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,IAAA,2BAAgB,EAAC,kCAAQ,EAAE,QAAQ,CAAC;IACtE,YAAiC,MAAkB;QACjD,KAAK,CAAC;YACJ,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ;YACxC,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY;YAChD,WAAW,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW;YAC9C,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC;SAC3D,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,WAAmB,EACnB,YAAoB,EACpB,OAAY,EACZ,IAAoB;QAEpB,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAE7C,MAAM,IAAI,GAA0B;YAClC,EAAE;YACF,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;YACtB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,UAAU;YACzB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,MAAM;YACN,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC;QAEF,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnB,CAAC;CACF,CAAA;AAhCY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,uBAAW,CAAC,CAAA;;GADrB,cAAc,CAgC1B"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AuthService } from '../services';
|
|
2
|
-
declare const LocalStrategy_base: new (...args: any) => any;
|
|
3
|
-
export declare class LocalStrategy extends LocalStrategy_base {
|
|
4
|
-
private authService;
|
|
5
|
-
constructor(authService: AuthService);
|
|
6
|
-
validate(email: string, password: string): Promise<any>;
|
|
7
|
-
}
|
|
8
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
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.LocalStrategy = void 0;
|
|
13
|
-
const passport_local_1 = require("passport-local");
|
|
14
|
-
const passport_1 = require("@nestjs/passport");
|
|
15
|
-
const common_1 = require("@nestjs/common");
|
|
16
|
-
const services_1 = require("../services");
|
|
17
|
-
let LocalStrategy = class LocalStrategy extends (0, passport_1.PassportStrategy)(passport_local_1.Strategy) {
|
|
18
|
-
authService;
|
|
19
|
-
constructor(authService) {
|
|
20
|
-
super({ usernameField: 'email' });
|
|
21
|
-
this.authService = authService;
|
|
22
|
-
}
|
|
23
|
-
async validate(email, password) {
|
|
24
|
-
const user = await this.authService.validateUser(email, password);
|
|
25
|
-
if (!user) {
|
|
26
|
-
throw new common_1.UnauthorizedException('Invalid credentials');
|
|
27
|
-
}
|
|
28
|
-
return user;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
exports.LocalStrategy = LocalStrategy;
|
|
32
|
-
exports.LocalStrategy = LocalStrategy = __decorate([
|
|
33
|
-
(0, common_1.Injectable)(),
|
|
34
|
-
__metadata("design:paramtypes", [services_1.AuthService])
|
|
35
|
-
], LocalStrategy);
|
|
36
|
-
//# sourceMappingURL=local.strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local.strategy.js","sourceRoot":"","sources":["../../src/strategies/local.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA0C;AAC1C,+CAAoD;AACpD,2CAAmE;AACnE,0CAA0C;AAGnC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,IAAA,2BAAgB,EAAC,yBAAQ,CAAC;IACvC;IAApB,YAAoB,WAAwB;QAC1C,KAAK,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;QADhB,gBAAW,GAAX,WAAW,CAAa;IAE5C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAa,EAAE,QAAgB;QAC5C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,8BAAqB,CAAC,qBAAqB,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAZY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAEsB,sBAAW;GADjC,aAAa,CAYzB"}
|