addons-scanner-utils 14.0.0 → 15.1.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.
@@ -16,11 +16,15 @@ export type RequestWithExtraProps = Request & {
16
16
  * @property _process - Process object for environment variables (for testing
17
17
  * purposes)
18
18
  * @property apiKeyEnvVarName - Environment variable name for the API key
19
+ * @property maxRequestBodySize - Controls the maximum request body size. If
20
+ * this is a number, then the value specifies the number of bytes; if it is a
21
+ * string, the value is passed to the bytes library for parsing.
19
22
  */
20
23
  export type FunctionConfig = {
21
24
  _console?: typeof console;
22
25
  _process?: typeof process;
23
26
  apiKeyEnvVarName?: string;
27
+ maxRequestBodySize?: string | number;
24
28
  };
25
29
  /**
26
30
  * Easily create a new scanner application with built-in authentication
@@ -41,11 +45,10 @@ export type FunctionConfig = {
41
45
  * via `apiKeyEnvVarName`)
42
46
  *
43
47
  * **Authentication:**
44
- * - Bearer token: `Authorization: Bearer <api_key>` (deprecated)
45
48
  * - HMAC-SHA256: `Authorization: HMAC-SHA256 <digest>` (digest of request
46
49
  * body)
47
50
  */
48
- export declare const createExpressApp: ({ _console, _process, apiKeyEnvVarName, }?: FunctionConfig) => (handler: RequestHandler) => import("express-serve-static-core").Express;
51
+ export declare const createExpressApp: ({ _console, _process, apiKeyEnvVarName, maxRequestBodySize, }?: FunctionConfig) => (handler: RequestHandler) => import("express-serve-static-core").Express;
49
52
  export * from './api';
50
53
  export * from './auth';
51
54
  export * from './download';
@@ -50,11 +50,10 @@ const error_1 = require("./error");
50
50
  * via `apiKeyEnvVarName`)
51
51
  *
52
52
  * **Authentication:**
53
- * - Bearer token: `Authorization: Bearer <api_key>` (deprecated)
54
53
  * - HMAC-SHA256: `Authorization: HMAC-SHA256 <digest>` (digest of request
55
54
  * body)
56
55
  */
57
- const createExpressApp = ({ _console = console, _process = process, apiKeyEnvVarName = 'LAMBDA_API_KEY', } = {}) => (handler) => {
56
+ const createExpressApp = ({ _console = console, _process = process, apiKeyEnvVarName = 'LAMBDA_API_KEY', maxRequestBodySize = '1mb', } = {}) => (handler) => {
58
57
  const app = (0, express_1.default)();
59
58
  const apiKey = _process.env[apiKeyEnvVarName] || null;
60
59
  if (apiKey) {
@@ -64,6 +63,7 @@ const createExpressApp = ({ _console = console, _process = process, apiKeyEnvVar
64
63
  }
65
64
  // This is the options we pass to the `json()` middleware.
66
65
  const jsonOptions = {
66
+ limit: maxRequestBodySize,
67
67
  // This is a hack to retain the raw body on the request object. We need
68
68
  // this to verify the signature of the request.
69
69
  verify(req, res, buf) {
@@ -115,15 +115,6 @@ const createExpressApp = ({ _console = console, _process = process, apiKeyEnvVar
115
115
  return;
116
116
  }
117
117
  }
118
- else if (authorization.startsWith('Bearer ')) {
119
- if (!(0, safe_compare_1.default)(`Bearer ${apiKey}`, authorization)) {
120
- next((0, error_1.createAppError)({
121
- message: 'authentication has failed',
122
- status: 401,
123
- }));
124
- return;
125
- }
126
- }
127
118
  else {
128
119
  next((0, error_1.createAppError)({
129
120
  message: 'unsupported authorization scheme',
package/package.json CHANGED
@@ -1,9 +1,35 @@
1
1
  {
2
2
  "name": "addons-scanner-utils",
3
- "version": "14.0.0",
3
+ "version": "15.1.0",
4
4
  "description": "Various addons related helpers to build CLIs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./functions": {
13
+ "types": "./dist/functions/index.d.ts",
14
+ "default": "./dist/functions/index.js"
15
+ },
16
+ "./functions/*": {
17
+ "types": "./dist/functions/*.d.ts",
18
+ "default": "./dist/functions/*.js"
19
+ },
20
+ "./io": {
21
+ "types": "./dist/io/index.d.ts",
22
+ "default": "./dist/io/index.js"
23
+ },
24
+ "./io/*": {
25
+ "types": "./dist/io/*.d.ts",
26
+ "default": "./dist/io/*.js"
27
+ },
28
+ "./*": {
29
+ "types": "./dist/*.d.ts",
30
+ "default": "./dist/*.js"
31
+ }
32
+ },
7
33
  "files": [
8
34
  "dist/**/*"
9
35
  ],
@@ -14,8 +40,8 @@
14
40
  "first-chunk-stream": "3.0.0",
15
41
  "jsonwebtoken": "^9.0.3",
16
42
  "strip-bom-stream": "4.0.0",
17
- "upath": "2.0.1",
18
- "yauzl": "3.2.1"
43
+ "upath": "3.0.7",
44
+ "yauzl": "3.3.0"
19
45
  },
20
46
  "peerDependencies": {
21
47
  "express": "5.2.1",
@@ -46,7 +72,7 @@
46
72
  "eslint-plugin-amo": "^3.0.0",
47
73
  "express": "5.2.1",
48
74
  "jest": "^30.2.0",
49
- "prettier": "3.8.1",
75
+ "prettier": "3.8.3",
50
76
  "pretty-quick": "4.2.2",
51
77
  "rimraf": "^6.1.0",
52
78
  "safe-compare": "1.1.4",