@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.
- package/build/src/drivers/asymmetric.d.ts +2 -2
- package/build/src/drivers/asymmetric.js +1 -1
- package/build/src/drivers/jwks.d.ts +2 -2
- package/build/src/drivers/jwks.js +1 -1
- package/build/src/drivers/symmetric.d.ts +2 -2
- package/build/src/drivers/symmetric.js +1 -1
- package/build/src/drivers/types.d.ts +5 -2
- package/build/src/guard.js +5 -5
- package/package.json +1 -1
|
@@ -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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
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
|
}
|
package/build/src/guard.js
CHANGED
|
@@ -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 ?? [],
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
}
|