@mrxsys/mrx-core 2.11.0-1-develop-20251030 → 2.11.0-1-and-278-20251030
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.
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
SignJWT,
|
|
18
18
|
jwtVerify
|
|
19
19
|
} from "jose";
|
|
20
|
-
var signJWT = (secret, payload, expiration =
|
|
21
|
-
const exp = expiration instanceof Date ? Math.floor(expiration.getTime() / 1000) : typeof expiration === "number" ? expiration : Math.floor(Date.now() / 1000) + parseHumanTimeToSeconds(expiration);
|
|
20
|
+
var signJWT = (secret, payload, expiration = 60 * 15) => {
|
|
21
|
+
const exp = expiration instanceof Date ? Math.floor(expiration.getTime() / 1000) : typeof expiration === "number" ? Math.floor(Date.now() / 1000) + expiration : Math.floor(Date.now() / 1000) + parseHumanTimeToSeconds(expiration);
|
|
22
22
|
if (exp <= Math.floor(Date.now() / 1000))
|
|
23
23
|
throw new HttpError(JWT_ERROR_KEYS.JWT_EXPIRATION_PASSED, "BAD_REQUEST");
|
|
24
24
|
const finalPayload = {
|
|
@@ -32,7 +32,7 @@ var signJWT = (secret, payload, expiration = Math.floor(Date.now() / 1000) + 60
|
|
|
32
32
|
...payload
|
|
33
33
|
};
|
|
34
34
|
try {
|
|
35
|
-
const jwt = new SignJWT(finalPayload).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuer(finalPayload.iss).setSubject(finalPayload.sub).setAudience(finalPayload.aud).setJti(finalPayload.jti).setNotBefore(finalPayload.nbf).setIssuedAt(finalPayload.iat).setExpirationTime(
|
|
35
|
+
const jwt = new SignJWT(finalPayload).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuer(finalPayload.iss).setSubject(finalPayload.sub).setAudience(finalPayload.aud).setJti(finalPayload.jti).setNotBefore(finalPayload.nbf).setIssuedAt(finalPayload.iat).setExpirationTime(exp).sign(new TextEncoder().encode(secret));
|
|
36
36
|
return jwt;
|
|
37
37
|
} catch (error) {
|
|
38
38
|
throw new HttpError(JWT_ERROR_KEYS.JWT_SIGN_ERROR, "INTERNAL_SERVER_ERROR", error);
|