@laboratory-one/api-components 0.0.10 → 0.0.11
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/cjs/auth/auth.service.d.ts.map +1 -1
- package/dist/cjs/auth/auth.service.js +13 -2
- package/dist/cjs/auth/auth.service.js.map +1 -1
- package/dist/esm/auth/auth.service.d.ts.map +1 -1
- package/dist/esm/auth/auth.service.js +13 -2
- package/dist/esm/auth/auth.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/auth/auth.service.ts +13 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAGvE,qBACa,WAAW;IAIV,OAAO,CAAC,aAAa;IAHjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,UAAU,CAAgB;gBAEd,aAAa,EAAE,aAAa;IAW1C,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAQlD,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CAgBxD"}
|
|
@@ -6,6 +6,7 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const stytch = tslib_1.__importStar(require("stytch"));
|
|
8
8
|
const config_1 = require("@nestjs/config");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
9
10
|
let AuthService = AuthService_1 = class AuthService {
|
|
10
11
|
constructor(configService) {
|
|
11
12
|
this.configService = configService;
|
|
@@ -25,8 +26,18 @@ let AuthService = AuthService_1 = class AuthService {
|
|
|
25
26
|
}
|
|
26
27
|
async login(data) {
|
|
27
28
|
this.logger.debug('login');
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
try {
|
|
30
|
+
const res = await this.authClient.passwords.authenticate(data);
|
|
31
|
+
return res['status_code'] === 200;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error.error_type === 'email_not_found') {
|
|
35
|
+
(0, utils_1.handleError)('Email or password is wrong');
|
|
36
|
+
}
|
|
37
|
+
if (error.error_type === 'unauthorized_credentials') {
|
|
38
|
+
(0, utils_1.handleError)('Email or password is wrong');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
30
41
|
}
|
|
31
42
|
};
|
|
32
43
|
exports.AuthService = AuthService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,uDAAiC;AACjC,2CAA+C;
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":";;;;;AAAA,2CAAoD;AACpD,uDAAiC;AACjC,2CAA+C;AAG/C,oCAAuC;AAGhC,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAItB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAH/B,WAAM,GAAW,IAAI,eAAM,CAAC,aAAW,CAAC,IAAI,CAAC,CAAC;QAI7D,IAAI,CAAC,UAAU,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC;YAClC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,mBAAmB,CAAC;YAC/D,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,eAAe,CAAC;YACvD,GAAG,EACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,YAAY,CAAC,KAAK,MAAM;gBACrD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;gBAClB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAwB;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE5B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO,GAAG,CAAC,aAAa,CAAC,KAAK,GAAG,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAwB;QAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAE3B,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YAC/D,OAAO,GAAG,CAAC,aAAa,CAAC,KAAK,GAAG,CAAC;QACpC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,UAAU,KAAK,iBAAiB,EAAE,CAAC;gBAC3C,IAAA,mBAAW,EAAC,4BAA4B,CAAC,CAAC;YAC5C,CAAC;YAED,IAAI,KAAK,CAAC,UAAU,KAAK,0BAA0B,EAAE,CAAC;gBACpD,IAAA,mBAAW,EAAC,4BAA4B,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAvCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;6CAKwB,sBAAa;GAJrC,WAAW,CAuCvB","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport * as stytch from 'stytch';\nimport { ConfigService } from '@nestjs/config';\n\nimport { RegisterRequestDto } from '../user/dtos/register.request.dto';\nimport { handleError } from '../utils';\n\n@Injectable()\nexport class AuthService {\n private readonly logger: Logger = new Logger(AuthService.name);\n private authClient: stytch.Client;\n\n constructor(private configService: ConfigService) {\n this.authClient = new stytch.Client({\n project_id: this.configService.get<string>('STYTCH_PROJECT_ID'),\n secret: this.configService.get<string>('STYTCH_SECRET'),\n env:\n this.configService.get<string>('STYTCH_ENV') === 'test'\n ? stytch.envs.test\n : stytch.envs.live,\n });\n }\n\n async signup(data: RegisterRequestDto): Promise<boolean> {\n this.logger.debug('signup');\n\n const res = await this.authClient.passwords.create(data);\n\n return res['status_code'] === 200;\n }\n\n async login(data: RegisterRequestDto): Promise<boolean> {\n this.logger.debug('login');\n\n try {\n const res = await this.authClient.passwords.authenticate(data);\n return res['status_code'] === 200;\n } catch (error: any) {\n if (error.error_type === 'email_not_found') {\n handleError('Email or password is wrong');\n }\n\n if (error.error_type === 'unauthorized_credentials') {\n handleError('Email or password is wrong');\n }\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAGvE,qBACa,WAAW;IAIV,OAAO,CAAC,aAAa;IAHjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,UAAU,CAAgB;gBAEd,aAAa,EAAE,aAAa;IAW1C,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAQlD,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CAgBxD"}
|
|
@@ -3,6 +3,7 @@ import { __decorate, __metadata } from "tslib";
|
|
|
3
3
|
import { Injectable, Logger } from '@nestjs/common';
|
|
4
4
|
import * as stytch from 'stytch';
|
|
5
5
|
import { ConfigService } from '@nestjs/config';
|
|
6
|
+
import { handleError } from '../utils';
|
|
6
7
|
let AuthService = AuthService_1 = class AuthService {
|
|
7
8
|
constructor(configService) {
|
|
8
9
|
this.configService = configService;
|
|
@@ -22,8 +23,18 @@ let AuthService = AuthService_1 = class AuthService {
|
|
|
22
23
|
}
|
|
23
24
|
async login(data) {
|
|
24
25
|
this.logger.debug('login');
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
try {
|
|
27
|
+
const res = await this.authClient.passwords.authenticate(data);
|
|
28
|
+
return res['status_code'] === 200;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error.error_type === 'email_not_found') {
|
|
32
|
+
handleError('Email or password is wrong');
|
|
33
|
+
}
|
|
34
|
+
if (error.error_type === 'unauthorized_credentials') {
|
|
35
|
+
handleError('Email or password is wrong');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
27
38
|
}
|
|
28
39
|
};
|
|
29
40
|
AuthService = AuthService_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,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AK,GAAG,CAAC;QACpC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,UAAU,KAAK,iBAAiB,EAAE,CAAC;gBAC3C,WAAW,CAAC,4BAA4B,CAAC,CAAC;YAC5C,CAAC;YAED,IAAI,KAAK,CAAC,UAAU,KAAK,0BAA0B,EAAE,CAAC;gBACpD,WAAW,CAAC,4BAA4B,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAvCY,WAAW;IADvB,UAAU,EAAE;qCAKwB,aAAa;GAJrC,WAAW,CAuCvB","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport * as stytch from 'stytch';\nimport { ConfigService } from '@nestjs/config';\n\nimport { RegisterRequestDto } from '../user/dtos/register.request.dto';\nimport { handleError } from '../utils';\n\n@Injectable()\nexport class AuthService {\n private readonly logger: Logger = new Logger(AuthService.name);\n private authClient: stytch.Client;\n\n constructor(private configService: ConfigService) {\n this.authClient = new stytch.Client({\n project_id: this.configService.get<string>('STYTCH_PROJECT_ID'),\n secret: this.configService.get<string>('STYTCH_SECRET'),\n env:\n this.configService.get<string>('STYTCH_ENV') === 'test'\n ? stytch.envs.test\n : stytch.envs.live,\n });\n }\n\n async signup(data: RegisterRequestDto): Promise<boolean> {\n this.logger.debug('signup');\n\n const res = await this.authClient.passwords.create(data);\n\n return res['status_code'] === 200;\n }\n\n async login(data: RegisterRequestDto): Promise<boolean> {\n this.logger.debug('login');\n\n try {\n const res = await this.authClient.passwords.authenticate(data);\n return res['status_code'] === 200;\n } catch (error: any) {\n if (error.error_type === 'email_not_found') {\n handleError('Email or password is wrong');\n }\n\n if (error.error_type === 'unauthorized_credentials') {\n handleError('Email or password is wrong');\n }\n }\n }\n}\n"]}
|