addons-scanner-utils 17.1.0 → 17.2.0
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/dist/functions/auth.d.ts
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Configuration for makeJWT.
|
|
3
3
|
*
|
|
4
4
|
* @property env - Environment variables object (default: process.env)
|
|
5
|
+
* @property expiresIn - Token lifetime in seconds (default: 60)
|
|
5
6
|
*/
|
|
6
7
|
export type MakeJWTConfig = {
|
|
7
8
|
env?: NodeJS.ProcessEnv;
|
|
9
|
+
expiresIn?: number;
|
|
8
10
|
};
|
|
9
11
|
/**
|
|
10
12
|
* Create a signed JWT token for AMO API authentication using the
|
|
@@ -13,4 +15,4 @@ export type MakeJWTConfig = {
|
|
|
13
15
|
* @returns A signed HS256 JWT string
|
|
14
16
|
* @throws Error if the required environment variables are not set
|
|
15
17
|
*/
|
|
16
|
-
export declare const makeJWT: ({ env }?: MakeJWTConfig) => string;
|
|
18
|
+
export declare const makeJWT: ({ env, expiresIn, }?: MakeJWTConfig) => string;
|
package/dist/functions/auth.js
CHANGED
|
@@ -13,7 +13,7 @@ const JWT_EXPIRY_SECONDS = 60;
|
|
|
13
13
|
* @returns A signed HS256 JWT string
|
|
14
14
|
* @throws Error if the required environment variables are not set
|
|
15
15
|
*/
|
|
16
|
-
const makeJWT = ({ env = process.env } = {}) => {
|
|
16
|
+
const makeJWT = ({ env = process.env, expiresIn = JWT_EXPIRY_SECONDS, } = {}) => {
|
|
17
17
|
const issKey = env.AMO_JWT_ISS_KEY;
|
|
18
18
|
const secret = env.AMO_JWT_SECRET;
|
|
19
19
|
if (!issKey) {
|
|
@@ -27,7 +27,7 @@ const makeJWT = ({ env = process.env } = {}) => {
|
|
|
27
27
|
iss: issKey,
|
|
28
28
|
jti: Math.random().toString(),
|
|
29
29
|
iat: issuedAt,
|
|
30
|
-
exp: issuedAt +
|
|
30
|
+
exp: issuedAt + expiresIn,
|
|
31
31
|
};
|
|
32
32
|
return jsonwebtoken_1.default.sign(payload, secret, { algorithm: 'HS256' });
|
|
33
33
|
};
|