addons-scanner-utils 17.0.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.
@@ -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;
@@ -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 + JWT_EXPIRY_SECONDS,
30
+ exp: issuedAt + expiresIn,
31
31
  };
32
32
  return jsonwebtoken_1.default.sign(payload, secret, { algorithm: 'HS256' });
33
33
  };
@@ -38,6 +38,9 @@ const createLogger = ({ level, destination, _process = process, } = {}) => {
38
38
  // `K_SERVICE` is set by Cloud Run.
39
39
  serviceContext: {
40
40
  service: _process.env.K_SERVICE || _process.env.npm_package_name || 'local',
41
+ version: _process.env.SCANNER_VERSION ||
42
+ _process.env.npm_package_version ||
43
+ 'unknown',
41
44
  },
42
45
  },
43
46
  formatters: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "addons-scanner-utils",
3
- "version": "17.0.0",
3
+ "version": "17.2.0",
4
4
  "description": "Various addons related helpers to build CLIs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",