@laboratory-one/api-components 0.0.16 → 0.0.17

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.
@@ -1,6 +1,6 @@
1
1
  import * as stytch from 'stytch';
2
2
  import { ConfigService } from '@nestjs/config';
3
- import { RegisterRequestDto } from '../user/dtos/register.request.dto';
3
+ import { RegisterRequestDto } from '../user';
4
4
  export declare class AuthService {
5
5
  private configService;
6
6
  private readonly logger;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,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,CACV,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC;IASpC,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBjD,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKhD"}
1
+ {"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7C,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,CACV,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC;IAMpC,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBjD,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKhD"}
@@ -21,8 +21,7 @@ let AuthService = AuthService_1 = class AuthService {
21
21
  }
22
22
  async signup(data) {
23
23
  this.logger.debug('signup');
24
- const res = await this.authClient.passwords.create(data);
25
- return res;
24
+ return await this.authClient.passwords.create(data);
26
25
  }
27
26
  async login(data) {
28
27
  this.logger.debug('login');
@@ -1 +1 @@
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,CACV,IAAwB;QAExB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE5B,MAAM,GAAG,GACP,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE/C,OAAO,GAAG,CAAC;IACb,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;IAED,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE5B,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF,CAAA;AAhDY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;6CAKwB,sBAAa;GAJrC,WAAW,CAgDvB","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(\n data: RegisterRequestDto,\n ): Promise<stytch.PasswordsCreateResponse> {\n this.logger.debug('signup');\n\n const res: stytch.PasswordsCreateResponse =\n await this.authClient.passwords.create(data);\n\n return res;\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 async delete(externalId: string): Promise<void> {\n this.logger.debug('delete');\n\n await this.authClient.users.delete({ user_id: externalId });\n }\n}\n"]}
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,MA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';\nimport { ConfigService } from '@nestjs/config';\n\nimport { RegisterRequestDto } from '../user';\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(\n data: RegisterRequestDto,\n ): Promise<stytch.PasswordsCreateResponse> {\n this.logger.debug('signup');\n\n return await this.authClient.passwords.create(data);\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 async delete(externalId: string): Promise<void> {\n this.logger.debug('delete');\n\n await this.authClient.users.delete({ user_id: externalId });\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import * as stytch from 'stytch';
2
2
  import { ConfigService } from '@nestjs/config';
3
- import { RegisterRequestDto } from '../user/dtos/register.request.dto';
3
+ import { RegisterRequestDto } from '../user';
4
4
  export declare class AuthService {
5
5
  private configService;
6
6
  private readonly logger;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,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,CACV,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC;IASpC,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBjD,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKhD"}
1
+ {"version":3,"file":"auth.service.d.ts","sourceRoot":"/","sources":["auth/auth.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7C,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,CACV,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAC;IAMpC,KAAK,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBjD,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAKhD"}
@@ -18,8 +18,7 @@ let AuthService = AuthService_1 = class AuthService {
18
18
  }
19
19
  async signup(data) {
20
20
  this.logger.debug('signup');
21
- const res = await this.authClient.passwords.create(data);
22
- return res;
21
+ return await this.authClient.passwords.create(data);
23
22
  }
24
23
  async login(data) {
25
24
  this.logger.debug('login');
@@ -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,OA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;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;IAED,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE5B,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF,CAAA;AAhDY,WAAW;IADvB,UAAU,EAAE;qCAKwB,aAAa;GAJrC,WAAW,CAgDvB","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(\n data: RegisterRequestDto,\n ): Promise<stytch.PasswordsCreateResponse> {\n this.logger.debug('signup');\n\n const res: stytch.PasswordsCreateResponse =\n await this.authClient.passwords.create(data);\n\n return res;\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 async delete(externalId: string): Promise<void> {\n this.logger.debug('delete');\n\n await this.authClient.users.delete({ user_id: externalId });\n }\n}\n"]}
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;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGhC,IAAM,WAAW,mBAAjB,MAAM,WAAW;IAItB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAH/B,WAAM,GAAW,IAAI,MAAM,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,CACV,IAAwB;QAExB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE5B,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtD,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,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;IAED,KAAK,CAAC,MAAM,CAAC,UAAkB;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE5B,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF,CAAA;AA7CY,WAAW;IADvB,UAAU,EAAE;qCAKwB,aAAa;GAJrC,WAAW,CA6CvB","sourcesContent":["import { Injectable, Logger } from '@nestjs/common';\nimport * as stytch from 'stytch';\nimport { ConfigService } from '@nestjs/config';\n\nimport { RegisterRequestDto } from '../user';\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(\n data: RegisterRequestDto,\n ): Promise<stytch.PasswordsCreateResponse> {\n this.logger.debug('signup');\n\n return await this.authClient.passwords.create(data);\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 async delete(externalId: string): Promise<void> {\n this.logger.debug('delete');\n\n await this.authClient.users.delete({ user_id: externalId });\n }\n}\n"]}