create-forgeon 0.1.36 → 0.1.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-forgeon",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "Forgeon project generator CLI",
5
5
  "license": "MIT",
6
6
  "author": "Forgeon",
@@ -7,6 +7,7 @@ import {
7
7
  } from '@forgeon/auth-contracts';
8
8
  import { Inject, Injectable, UnauthorizedException } from '@nestjs/common';
9
9
  import { JwtService } from '@nestjs/jwt';
10
+ import type { JwtSignOptions } from '@nestjs/jwt';
10
11
  import { compare, hash } from 'bcryptjs';
11
12
  import {
12
13
  AUTH_REFRESH_TOKEN_STORE,
@@ -16,6 +17,8 @@ import { AuthConfigService } from './auth-config.service';
16
17
  import { LoginDto, RefreshDto } from './dto';
17
18
  import { AuthJwtPayload } from './auth.types';
18
19
 
20
+ type JwtExpiresIn = NonNullable<JwtSignOptions['expiresIn']>;
21
+
19
22
  @Injectable()
20
23
  export class AuthService {
21
24
  constructor(
@@ -123,11 +126,11 @@ export class AuthService {
123
126
  const [accessToken, refreshToken] = await Promise.all([
124
127
  this.jwtService.signAsync(payload, {
125
128
  secret: this.configService.accessSecret,
126
- expiresIn: this.configService.accessExpiresIn,
129
+ expiresIn: this.toJwtExpiresIn(this.configService.accessExpiresIn),
127
130
  }),
128
131
  this.jwtService.signAsync(payload, {
129
132
  secret: this.configService.refreshSecret,
130
- expiresIn: this.configService.refreshExpiresIn,
133
+ expiresIn: this.toJwtExpiresIn(this.configService.refreshExpiresIn),
131
134
  }),
132
135
  ]);
133
136
 
@@ -152,4 +155,12 @@ export class AuthService {
152
155
  roles: Array.isArray(payload.roles) ? payload.roles : ['user'],
153
156
  };
154
157
  }
158
+
159
+ private toJwtExpiresIn(value: string): JwtExpiresIn {
160
+ const trimmed = value.trim();
161
+ if (/^\d+$/.test(trimmed)) {
162
+ return Number(trimmed);
163
+ }
164
+ return trimmed as JwtExpiresIn;
165
+ }
155
166
  }