@maximemrf/adonisjs-jwt 1.0.0-rc.5 → 1.0.0-rc.6

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.
@@ -12,8 +12,8 @@ export declare class AsymmetricDriver implements JwtDriver {
12
12
  audience?: string | string[];
13
13
  clockTolerance?: number;
14
14
  });
15
- sign(payload: Record<string, any>, options?: {
16
- expiresIn?: number | StringValue;
15
+ sign(payload: Record<string, any>, options: {
16
+ expiresIn: number | StringValue;
17
17
  }): string;
18
18
  verify(token: string): Record<string, any> | string;
19
19
  }
@@ -45,7 +45,7 @@ export class AsymmetricDriver {
45
45
  }
46
46
  sign(payload, options) {
47
47
  const signOptions = {
48
- ...(options?.expiresIn !== undefined ? { expiresIn: options.expiresIn } : {}),
48
+ expiresIn: options.expiresIn,
49
49
  algorithm: this.#algorithm,
50
50
  ...(this.#issuer ? { issuer: this.#issuer } : {}),
51
51
  ...(this.#audience ? { audience: this.#audience } : {}),
@@ -23,8 +23,8 @@ export declare class JwksDriver implements JwtDriver {
23
23
  clockTolerance?: number;
24
24
  verifiesPayload?: boolean;
25
25
  });
26
- sign(_payload: Record<string, any>, _options?: {
27
- expiresIn?: number | StringValue;
26
+ sign(_payload: Record<string, any>, _options: {
27
+ expiresIn: number | StringValue;
28
28
  }): never;
29
29
  verify(token: string): Promise<Record<string, any> | string>;
30
30
  }
@@ -53,7 +53,7 @@ export class JwksDriver {
53
53
  const key = await this.#jwksManager.getSigningKey(decoded.header.kid);
54
54
  const verifyOptions = {
55
55
  algorithms: [...this.#algorithms],
56
- ...(this.#issuer ? { issuer: this.#issuer } : {}),
56
+ issuer: this.#issuer,
57
57
  ...(this.#audience ? { audience: this.#audience } : {}),
58
58
  ...(this.#clockTolerance !== undefined ? { clockTolerance: this.#clockTolerance } : {}),
59
59
  };
@@ -9,8 +9,8 @@ export declare class SymmetricDriver implements JwtDriver {
9
9
  audience?: string | string[];
10
10
  clockTolerance?: number;
11
11
  });
12
- sign(payload: Record<string, any>, options?: {
13
- expiresIn?: number | StringValue;
12
+ sign(payload: Record<string, any>, options: {
13
+ expiresIn: number | StringValue;
14
14
  }): string;
15
15
  verify(token: string): Record<string, any> | string;
16
16
  }
@@ -20,7 +20,7 @@ export class SymmetricDriver {
20
20
  }
21
21
  sign(payload, options) {
22
22
  const signOptions = {
23
- ...(options?.expiresIn !== undefined ? { expiresIn: options.expiresIn } : {}),
23
+ expiresIn: options.expiresIn,
24
24
  ...(this.#issuer ? { issuer: this.#issuer } : {}),
25
25
  ...(this.#audience ? { audience: this.#audience } : {}),
26
26
  };
@@ -1,8 +1,11 @@
1
1
  import type { StringValue } from 'ms';
2
2
  export interface JwtDriver {
3
3
  readonly canSign: boolean;
4
- sign(payload: Record<string, any>, options?: {
5
- expiresIn?: number | StringValue;
4
+ /**
5
+ * The guard rejects tokens without `exp`, so drivers never sign one
6
+ */
7
+ sign(payload: Record<string, any>, options: {
8
+ expiresIn: number | StringValue;
6
9
  }): string;
7
10
  verify(token: string): Promise<Record<string, any> | string> | Record<string, any> | string;
8
11
  }
@@ -110,11 +110,11 @@ export class JwtGuard {
110
110
  const token = this.#signAccessToken(signPayload);
111
111
  let refreshToken;
112
112
  if (this.#refreshTokenUserProvider) {
113
- const generatedRefreshToken = await this.#refreshTokenUserProvider.createToken(user, this.#options.refreshTokenAbilities ?? [], this.#options.refreshTokenExpiresIn
114
- ? {
115
- expiresIn: this.#options.refreshTokenExpiresIn,
116
- }
117
- : undefined);
113
+ const generatedRefreshToken = await this.#refreshTokenUserProvider.createToken(user, this.#options.refreshTokenAbilities ?? [],
114
+ /**
115
+ * Always set when there is a refresh token provider (7 days by default)
116
+ */
117
+ { expiresIn: this.#options.refreshTokenExpiresIn });
118
118
  refreshToken = generatedRefreshToken.value.release();
119
119
  this.#issuedRefreshToken = refreshToken;
120
120
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maximemrf/adonisjs-jwt",
3
3
  "description": "AdonisJS package for authentication with JWT tokens",
4
- "version": "1.0.0-rc.5",
4
+ "version": "1.0.0-rc.6",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },