@suveren/gateway 0.20.2 → 0.22.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.
Files changed (28) hide show
  1. package/content/integrations/erp.json +15 -3
  2. package/dist/control-plane/index.mjs +179 -46
  3. package/dist/mcp-server/http.mjs +623 -181
  4. package/dist/ui/assets/{index-blnpvM2g.css → index-BSAkn_Of.css} +1 -1
  5. package/dist/ui/assets/index-CBoGbefI.js +116 -0
  6. package/dist/ui/index.html +2 -2
  7. package/node_modules/@modelcontextprotocol/sdk/node_modules/content-disposition/README.md +105 -35
  8. package/node_modules/@modelcontextprotocol/sdk/node_modules/content-disposition/dist/index.d.ts +72 -0
  9. package/node_modules/@modelcontextprotocol/sdk/node_modules/content-disposition/dist/index.js +388 -0
  10. package/node_modules/@modelcontextprotocol/sdk/node_modules/content-disposition/dist/index.js.map +1 -0
  11. package/node_modules/@modelcontextprotocol/sdk/node_modules/content-disposition/package.json +31 -19
  12. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/Readme.md +15 -9
  13. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/lib/application.js +2 -2
  14. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/lib/request.js +32 -19
  15. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/lib/response.js +27 -30
  16. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/content-type/LICENSE +22 -0
  17. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/content-type/README.md +71 -0
  18. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/content-type/dist/index.d.ts +46 -0
  19. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/content-type/dist/index.js +176 -0
  20. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/content-type/dist/index.js.map +1 -0
  21. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/node_modules/content-type/package.json +52 -0
  22. package/node_modules/@modelcontextprotocol/sdk/node_modules/express/package.json +10 -10
  23. package/node_modules/@types/node/README.md +1 -1
  24. package/node_modules/@types/node/package.json +2 -2
  25. package/node_modules/@types/node/util.d.ts +6 -3
  26. package/package.json +1 -1
  27. package/dist/ui/assets/index-1s1q-XLL.js +0 -116
  28. package/node_modules/@modelcontextprotocol/sdk/node_modules/content-disposition/index.js +0 -536
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAsCH,wBAKC;AA0BD,sBAoHC;AAwFD,wCAyBC;AAkED,wBA8CC;AA6CD,wCAOC;AAjcD;;GAEG;AACH,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE;IACvC,MAAM,CAAC,GAAG,cAAa,CAAC,CAAC;IACzB,CAAC,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,CAAC,CAAC;AACX,CAAC,CAAC,EAAgC,CAAC;AAenC;;GAEG;AACH,SAAgB,MAAM,CAAC,QAAiB,EAAE,OAAuB;IAC/D,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,YAAY,CAAC;IAC3C,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEjE,OAAO,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM;AACrB,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,OAAO;AACvB,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,MAAM;AACvB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM;AACrB,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,MAAM;AACzB,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,OAA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AAG,CAAC,CAAC,EAAE,EAAE,CAAC,CACjD,CAAC;YACF,GAAG,IAAI,CAAC,CAAC;QACX,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/*!\n * content-disposition\n * Copyright(c) 2014-2017 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nexport interface ContentDisposition {\n /**\n * Content-Disposition type, such as \"attachment\" or \"inline\"\n */\n type: string;\n /**\n * Content-Disposition parameters, such as \"filename\"\n */\n parameters: Record<string, string>;\n}\n\n/**\n * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`.\n */\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () {};\n C.prototype = Object.create(null);\n return C;\n})() as unknown as { new (): any };\n\nexport interface CreateOptions {\n /**\n * Content-Disposition type, defaults to \"attachment\"\n * @default \"attachment\"\n */\n type?: string;\n /**\n * Fallback filename for non-US-ASCII strings. If true, a fallback will be generated by replacing non-US-ASCII characters with \"?\". If false, no fallback will be generated.\n * @default true\n */\n fallback?: string | boolean;\n}\n\n/**\n * Create an attachment Content-Disposition header.\n */\nexport function create(filename?: string, options?: CreateOptions): string {\n const type = options?.type || 'attachment';\n const parameters = createParameters(filename, options?.fallback);\n\n return format({ type, parameters }, { extended: false });\n}\n\nconst SP = 32; // \" \"\nconst HTAB = 9; // \"\\t\"\nconst SEMI = 59; // \";\"\nconst EQ = 61; // \"=\"\nconst DQUOTE = 34; // '\"'\nconst BSLASH = 92; // \"\\\\\"\nconst ASTERISK = 42; // \"*\"\n\nexport interface ParseOptions {\n /**\n * Whether to decode RFC 8187 encoded parameters.\n * @default true\n */\n extended?: boolean;\n /**\n * Parse parameters as sent by browsers in `multipart/form-data`.\n * @default false\n */\n multipart?: boolean;\n}\n\n/**\n * Parse Content-Disposition header string.\n */\nexport function parse(\n header: string,\n options?: ParseOptions,\n): ContentDisposition {\n const len = header.length;\n const multipart = options?.multipart === true;\n const extended = options?.extended !== false;\n let index = skipOWS(header, 0, header.length);\n\n const typeStart = index;\n index = parseToken(header, index, len);\n const typeEnd = trailingOWS(header, typeStart, index);\n const type = header.slice(typeStart, typeEnd).toLowerCase();\n\n const parameters: Record<string, string> = new NullObject();\n\n parameter: while (index < len) {\n index = skipOWS(header, index + 1, len); // Skip over semicolon.\n\n const keyStart = index;\n\n while (index < len) {\n const char = header.charCodeAt(index);\n if (char === SEMI) continue parameter;\n\n if (char === EQ) {\n const keyEnd = trailingOWS(header, keyStart, index);\n const key = header.slice(keyStart, keyEnd).toLowerCase();\n\n index = skipOWS(header, index + 1, len);\n\n if (index < len && header.charCodeAt(index) === DQUOTE) {\n index++;\n\n let value = '';\n\n if (multipart) {\n while (index < len) {\n const code = header.charCodeAt(index++);\n if (code === DQUOTE) {\n index = parseToken(header, index, len);\n if (parameters[key] === undefined) parameters[key] = value;\n break;\n }\n\n if (code === /* % */ 37 && index + 1 < len) {\n const code2 = header.charCodeAt(index);\n const code3 = header.charCodeAt(index + 1);\n\n if (code2 === 50 /* \"2\" */ && code3 === 50 /* \"2\" */) {\n value += '\"';\n index += 2;\n continue;\n }\n\n if (code2 === 48 /* \"0\" */) {\n if (code3 === 100 /* \"d\" */ || code3 === 68 /* \"D\" */) {\n value += '\\r';\n index += 2;\n continue;\n }\n\n if (code3 === 97 /* \"a\" */ || code3 === 65 /* \"A\" */) {\n value += '\\n';\n index += 2;\n continue;\n }\n }\n }\n\n value += String.fromCharCode(code);\n }\n } else {\n while (index < len) {\n const code = header.charCodeAt(index++);\n if (code === DQUOTE) {\n index = parseToken(header, index, len);\n if (parameters[key] === undefined) parameters[key] = value;\n break;\n }\n\n if (code === BSLASH && index < len) {\n value += header[index++];\n continue;\n }\n\n value += String.fromCharCode(code);\n }\n }\n\n continue parameter;\n }\n\n const valueStart = index;\n index = parseToken(header, index, len);\n const valueEnd = trailingOWS(header, valueStart, index);\n const value = header.slice(valueStart, valueEnd);\n\n if (parameters[key] === undefined) {\n parameters[key] = value;\n\n if (extended && key.charCodeAt(key.length - 1) === ASTERISK) {\n const normalizedKey = key.slice(0, -1);\n const decoded = decodeExtended(value);\n if (decoded !== undefined) parameters[normalizedKey] = decoded;\n }\n }\n\n continue parameter;\n }\n\n index++;\n }\n }\n\n return { type, parameters };\n}\n\n/**\n * RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including \"%\")\n */\nconst ENCODE_URL_ATTR_CHAR_REGEXP = /[\\x00-\\x20\"'()*,/:;<=>?@[\\\\\\]{}\\x7f]/g; // eslint-disable-line no-control-regex\n\n/**\n * RegExp to match non-US-ASCII characters.\n */\nconst NON_ASCII_REGEXP = /[^\\x20-\\x7e]/g;\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 2616\n */\nconst QUOTE_REGEXP = /[\\\\\"]/g;\n\n/**\n * Match chars that can't be used in the filename for compatibility.\n */\nconst INVALID_FILENAME_REGEXP = /%[0-9A-Fa-f]{2}/;\n\n/**\n * RegExp for various RFC 2616 grammar\n *\n * parameter = token \"=\" ( token | quoted-string )\n * token = 1*<any CHAR except CTLs or separators>\n * separators = \"(\" | \")\" | \"<\" | \">\" | \"@\"\n * | \",\" | \";\" | \":\" | \"\\\" | <\">\n * | \"/\" | \"[\" | \"]\" | \"?\" | \"=\"\n * | \"{\" | \"}\" | SP | HT\n * quoted-string = ( <\"> *(qdtext | quoted-pair ) <\"> )\n * qdtext = <any TEXT except <\">>\n * quoted-pair = \"\\\" CHAR\n * CHAR = <any US-ASCII character (octets 0 - 127)>\n * TEXT = <any OCTET except CTLs, but including LWS>\n * LWS = [CRLF] 1*( SP | HT )\n * CRLF = CR LF\n * CR = <US-ASCII CR, carriage return (13)>\n * LF = <US-ASCII LF, linefeed (10)>\n * SP = <US-ASCII SP, space (32)>\n * HT = <US-ASCII HT, horizontal-tab (9)>\n * CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>\n * OCTET = <any 8-bit sequence of data>\n */\nconst TEXT_REGEXP = /^[\\x20-\\x7e\\x80-\\xff]*$/;\nconst ASCII_TEXT_REGEXP = /^[\\x20-\\x7e]*$/;\nconst TOKEN_REGEXP = /^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/;\n\n/**\n * Create parameters object from filename and fallback.\n */\nfunction createParameters(\n filename?: string,\n fallback: string | boolean = true,\n): Record<string, string> | undefined {\n if (filename === undefined) return;\n\n if (typeof fallback === 'string') {\n if (!ASCII_TEXT_REGEXP.test(fallback)) {\n throw new TypeError('Fallback must be valid US-ASCII: ' + fallback);\n }\n\n if (fallback === filename) return { filename };\n return { filename: fallback, 'filename*': encodeExtended(filename) };\n }\n\n // Use `filename` when possible, otherwise use `filename*`.\n if (\n ASCII_TEXT_REGEXP.test(filename) &&\n !INVALID_FILENAME_REGEXP.test(filename)\n ) {\n return { filename };\n }\n\n if (fallback === false) {\n return { 'filename*': encodeExtended(filename) };\n }\n\n return {\n filename: getAscii(filename),\n 'filename*': encodeExtended(filename),\n };\n}\n\n/**\n * Decode a RFC 8187 field value (gracefully).\n */\nexport function decodeExtended(str: string): string | undefined {\n const charsetEnd = str.indexOf(\"'\");\n if (charsetEnd <= 0) {\n return undefined;\n }\n\n const languageEnd = str.indexOf(\"'\", charsetEnd + 1);\n if (languageEnd === -1) {\n return undefined;\n }\n\n const charset = str.slice(0, charsetEnd).toLowerCase();\n const encoded = str.slice(languageEnd + 1);\n\n switch (charset) {\n case 'iso-8859-1': {\n return decodeHexEscapes(encoded);\n }\n case 'utf-8':\n case 'utf8': {\n return tryDecodeURIComponent(encoded);\n }\n }\n\n return undefined;\n}\n\n/**\n * Decode URI component but return `undefined` on error.\n */\nfunction tryDecodeURIComponent(str: string): string | undefined {\n try {\n return decodeURIComponent(str);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Parse a token starting at the provided index.\n */\nfunction parseToken(str: string, index: number, len: number): number {\n while (index < len) {\n const char = str.charCodeAt(index);\n if (char === SEMI) break;\n index++;\n }\n return index;\n}\n\n/**\n * Skip RFC 2616 linear whitespace (space / tab).\n */\nfunction skipOWS(str: string, index: number, len: number): number {\n while (index < len) {\n const char = str.charCodeAt(index);\n if (char !== SP && char !== HTAB) break;\n index++;\n }\n return index;\n}\n\n/**\n * Skip RFC 2616 linear whitespace (space / tab) from the end of a string.\n */\nfunction trailingOWS(str: string, start: number, end: number): number {\n while (end > start) {\n const char = str.charCodeAt(end - 1);\n if (char !== SP && char !== HTAB) break;\n end--;\n }\n return end;\n}\n\nexport interface FormatOptions {\n /**\n * Whether to use extended parameter encoding for non-ISO-8859-1 strings.\n * If false, an error will be thrown when formatting such strings.\n * @default true\n */\n extended?: boolean;\n /**\n * Format parameters as sent by browsers in `multipart/form-data`.\n * @default false\n */\n multipart?: boolean;\n}\n\n/**\n * Format object to Content-Disposition header.\n */\nexport function format(\n obj: Partial<ContentDisposition>,\n options?: FormatOptions,\n): string {\n const { type, parameters } = obj;\n const multipart = options?.multipart === true;\n const extended = options?.extended !== false;\n\n if (!type || !TOKEN_REGEXP.test(type)) {\n throw new TypeError('Invalid type: ' + type);\n }\n\n let result = type;\n\n if (parameters) {\n for (const param of Object.keys(parameters)) {\n const value = parameters[param];\n\n if (!TOKEN_REGEXP.test(param)) {\n throw new TypeError('Invalid parameter name: ' + param);\n }\n\n if (multipart) {\n result += '; ' + param + '=' + qmultipart(value);\n continue;\n }\n\n if (TOKEN_REGEXP.test(value)) {\n result += '; ' + param + '=' + value;\n continue;\n }\n\n if (TEXT_REGEXP.test(value)) {\n result += '; ' + param + '=' + qstring(value);\n continue;\n }\n\n if (!extended) {\n throw new TypeError('Invalid parameter value: ' + value);\n }\n\n result += '; ' + param + '*=' + encodeExtended(value);\n }\n }\n\n return result;\n}\n\n/**\n * Get US-ASCII version of string.\n */\nfunction getAscii(val: string): string {\n // simple Unicode -> US-ASCII transformation\n return val.replace(NON_ASCII_REGEXP, '?');\n}\n\n/**\n * Percent encode a single character.\n */\nfunction pencode(char: string): string {\n return '%' + char.charCodeAt(0).toString(16).toUpperCase();\n}\n\n/**\n * Quote a string for HTTP.\n */\nfunction qstring(str: string): string {\n return '\"' + str.replace(QUOTE_REGEXP, '\\\\$&') + '\"';\n}\n\n/**\n * Quote a string for multipart/form-data.\n *\n * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart-form-data\n */\nfunction qmultipart(str: string): string {\n return '\"' + str.replace(/[\\n\\r\"]/g, multipartEscape) + '\"';\n}\n\n/**\n * Escape a multipart/form-data string character.\n */\nfunction multipartEscape(char: string): string {\n if (char === '\\n') return '%0A';\n if (char === '\\r') return '%0D';\n return '%22';\n}\n\n/**\n * Encode a Unicode string for HTTP (RFC 8187).\n */\nexport function encodeExtended(str: string): string {\n const encoded = encodeURIComponent(str).replace(\n ENCODE_URL_ATTR_CHAR_REGEXP,\n pencode,\n );\n\n return \"UTF-8''\" + encoded;\n}\n\n/**\n * Check if a character is a hex digit [0-9A-Fa-f]\n */\nfunction isHexDigit(char: string): boolean {\n const code = char.charCodeAt(0);\n return (\n (code >= 48 && code <= 57) || // 0-9\n (code >= 65 && code <= 70) || // A-F\n (code >= 97 && code <= 102) // a-f\n );\n}\n\n/**\n * Decode hex escapes in a string (e.g., %20 -> space)\n */\nfunction decodeHexEscapes(str: string): string {\n const firstEscape = str.indexOf('%');\n if (firstEscape === -1) return str;\n\n let result = str.slice(0, firstEscape);\n for (let idx = firstEscape; idx < str.length; idx++) {\n if (\n str[idx] === '%' &&\n idx + 2 < str.length &&\n isHexDigit(str[idx + 1]) &&\n isHexDigit(str[idx + 2])\n ) {\n result += String.fromCharCode(\n Number.parseInt(str[idx + 1] + str[idx + 2], 16),\n );\n idx += 2;\n } else {\n result += str[idx];\n }\n }\n return result;\n}\n"]}
@@ -1,9 +1,7 @@
1
1
  {
2
2
  "name": "content-disposition",
3
+ "version": "2.0.1",
3
4
  "description": "Create and parse Content-Disposition header",
4
- "version": "1.1.0",
5
- "author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
6
- "license": "MIT",
7
5
  "keywords": [
8
6
  "content-disposition",
9
7
  "http",
@@ -15,26 +13,40 @@
15
13
  "type": "opencollective",
16
14
  "url": "https://opencollective.com/express"
17
15
  },
18
- "devDependencies": {
19
- "c8": "^10.1.2",
20
- "eslint": "^8.57.1",
21
- "eslint-config-standard": "^14.1.1",
22
- "eslint-plugin-import": "^2.32.0",
23
- "eslint-plugin-markdown": "^3.0.1",
24
- "eslint-plugin-node": "^11.1.0",
25
- "eslint-plugin-promise": "^6.6.0",
26
- "eslint-plugin-standard": "^4.1.0"
27
- },
16
+ "license": "MIT",
17
+ "author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
18
+ "type": "commonjs",
19
+ "exports": "./dist/index.js",
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
28
22
  "files": [
29
- "index.js"
23
+ "dist/"
30
24
  ],
25
+ "scripts": {
26
+ "bench": "vitest bench",
27
+ "build": "ts-scripts build",
28
+ "demo": "node demo/server.js",
29
+ "format": "ts-scripts format",
30
+ "lint": "ts-scripts lint",
31
+ "prepare": "ts-scripts install && npm run build",
32
+ "specs": "ts-scripts specs",
33
+ "test": "ts-scripts test"
34
+ },
35
+ "devDependencies": {
36
+ "@borderless/ts-scripts": "^0.15.0",
37
+ "@vitest/coverage-v8": "^3.2.4",
38
+ "typescript": "^5.9.3",
39
+ "vitest": "^3.2.4"
40
+ },
31
41
  "engines": {
32
42
  "node": ">=18"
33
43
  },
34
- "scripts": {
35
- "lint": "eslint .",
36
- "test": "node --test --test-reporter spec",
37
- "test-ci": "c8 --reporter=lcovonly --reporter=text npm test",
38
- "test-cov": "c8 --reporter=html --reporter=text npm test"
44
+ "ts-scripts": {
45
+ "dist": [
46
+ "dist"
47
+ ],
48
+ "project": [
49
+ "tsconfig.build.json"
50
+ ]
39
51
  }
40
52
  }
@@ -1,12 +1,14 @@
1
- [![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](https://expressjs.com/)
1
+ <a href="https://expressjs.com/">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://expressjs.com/images/logos/logo-express-white.svg">
4
+ <img alt="Express Logo" src="https://expressjs.com/images/logos/logo-express-black.svg" width="280">
5
+ </picture>
6
+ </a>
2
7
 
3
8
  **Fast, unopinionated, minimalist web framework for [Node.js](https://nodejs.org).**
4
9
 
5
- **This project has a [Code of Conduct].**
6
-
7
10
  ## Table of contents
8
11
 
9
- - [Table of contents](#table-of-contents)
10
12
  - [Installation](#installation)
11
13
  - [Features](#features)
12
14
  - [Docs \& Community](#docs--community)
@@ -57,7 +59,7 @@ If this is a brand new project, make sure to create a `package.json` first with
57
59
  the [`npm init` command](https://docs.npmjs.com/creating-a-package-json-file).
58
60
 
59
61
  Installation is done using the
60
- [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
62
+ [`npm install` command](https://docs.npmjs.com/downloading-and-installing-packages-locally):
61
63
 
62
64
  ```bash
63
65
  npm install express
@@ -80,7 +82,7 @@ for more information.
80
82
 
81
83
  * [Website and Documentation](https://expressjs.com/) - [[website repo](https://github.com/expressjs/expressjs.com)]
82
84
  * [GitHub Organization](https://github.com/expressjs) for Official Middleware & Modules
83
- * [Github Discussions](https://github.com/expressjs/discussions) for discussion on the development and usage of Express
85
+ * [GitHub Discussions](https://github.com/expressjs/discussions) for discussion on the development and usage of Express
84
86
 
85
87
  **PROTIP** Be sure to read the [migration guide to v5](https://expressjs.com/en/guide/migrating-5)
86
88
 
@@ -152,9 +154,11 @@ tests, triaging incoming pull requests and issues, and more!
152
154
 
153
155
  See the [Contributing Guide] for more technical details on contributing.
154
156
 
157
+ This project has a [Code of Conduct]. By participating, you are expected to uphold this code.
158
+
155
159
  ### Security Issues
156
160
 
157
- If you discover a security vulnerability in Express, please see [Security Policies and Procedures](SECURITY.md).
161
+ If you discover a security vulnerability in Express, please see [Security Policies and Procedures](https://github.com/expressjs/express/security/policy).
158
162
 
159
163
  ### Running Tests
160
164
 
@@ -212,7 +216,9 @@ The original author of Express is [TJ Holowaychuk](https://github.com/tj)
212
216
  * [IamLizu](https://github.com/IamLizu) - **S M Mahmudul Hasan** (he/him)
213
217
  * [Phillip9587](https://github.com/Phillip9587) - **Phillip Barta**
214
218
  * [efekrskl](https://github.com/efekrskl) - **Efe Karasakal**
215
-
219
+ * [rxmarbles](https://github.com/rxmarbles) - **Rick Markins** (he/him)
220
+ * [krzysdz](https://github.com/krzysdz)
221
+ * [GroophyLifefor](https://github.com/GroophyLifefor) - **Murat Kirazkaya**
216
222
 
217
223
  <details>
218
224
  <summary>Triagers emeriti members</summary>
@@ -247,7 +253,7 @@ The original author of Express is [TJ Holowaychuk](https://github.com/tj)
247
253
  * [tunniclm](https://github.com/tunniclm) - **Mike Tunnicliffe**
248
254
  * [enyoghasim](https://github.com/enyoghasim) - **David Enyoghasim**
249
255
  * [0ss](https://github.com/0ss) - **Salah**
250
- * [import-brain](https://github.com/import-brain) - **Eric Cheng** (he/him)
256
+ * [ejcheng](https://github.com/ejcheng)- **Eric Cheng** (he/him)
251
257
  * [dakshkhetan](https://github.com/dakshkhetan) - **Daksh Khetan** (he/him)
252
258
  * [lucasraziel](https://github.com/lucasraziel) - **Lucas Soares Do Rego**
253
259
  * [mertcanaltin](https://github.com/mertcanaltin) - **Mert Can Altin**
@@ -523,7 +523,7 @@ app.render = function render(name, options, callback) {
523
523
  var cache = this.cache;
524
524
  var done = callback;
525
525
  var engines = this.engines;
526
- var opts = options;
526
+ var opts = options || {};
527
527
  var view;
528
528
 
529
529
  // support callback function as second arg
@@ -614,7 +614,7 @@ app.listen = function listen() {
614
614
 
615
615
  function logerror(err) {
616
616
  /* istanbul ignore next */
617
- if (this.get('env') !== 'test') console.error(err.stack || err.toString());
617
+ if (this.get('env') !== 'test') console.error(err);
618
618
  }
619
619
 
620
620
  /**
@@ -83,16 +83,13 @@ req.header = function header(name) {
83
83
  };
84
84
 
85
85
  /**
86
- * To do: update docs.
87
- *
88
86
  * Check if the given `type(s)` is acceptable, returning
89
- * the best match when true, otherwise `undefined`, in which
87
+ * the best match when true, otherwise `false`, in which
90
88
  * case you should respond with 406 "Not Acceptable".
91
89
  *
92
90
  * The `type` value may be a single MIME type string
93
91
  * such as "application/json", an extension name
94
- * such as "json", a comma-delimited list such as "json, html, text/plain",
95
- * an argument list such as `"json", "html", "text/plain"`,
92
+ * such as "json", an argument list such as `"json", "html", "text/plain"`,
96
93
  * or an array `["json", "html", "text/plain"]`. When a list
97
94
  * or array is given, the _best_ match, if any is returned.
98
95
  *
@@ -107,7 +104,7 @@ req.header = function header(name) {
107
104
  * // => "html"
108
105
  * req.accepts('text/html');
109
106
  * // => "text/html"
110
- * req.accepts('json, text');
107
+ * req.accepts('json', 'text');
111
108
  * // => "json"
112
109
  * req.accepts('application/json');
113
110
  * // => "application/json"
@@ -115,12 +112,11 @@ req.header = function header(name) {
115
112
  * // Accept: text/*, application/json
116
113
  * req.accepts('image/png');
117
114
  * req.accepts('png');
118
- * // => undefined
115
+ * // => false
119
116
  *
120
117
  * // Accept: text/*;q=.5, application/json
121
118
  * req.accepts(['html', 'json']);
122
119
  * req.accepts('html', 'json');
123
- * req.accepts('html, json');
124
120
  * // => "json"
125
121
  *
126
122
  * @param {String|Array} type(s)
@@ -147,17 +143,34 @@ req.acceptsEncodings = function(){
147
143
  };
148
144
 
149
145
  /**
150
- * Check if the given `charset`s are acceptable,
151
- * otherwise you should respond with 406 "Not Acceptable".
146
+ * Checks if the specified `charset`s are acceptable based on the request's `Accept-Charset` header.
147
+ * Returns the best matching charset or an array of acceptable charsets.
152
148
  *
153
- * @param {String} ...charset
154
- * @return {String|Array}
149
+ * The `charset` argument(s) can be:
150
+ * - A single charset string (e.g., "utf-8")
151
+ * - Multiple charset strings as arguments (e.g., `"utf-8", "iso-8859-1"`)
152
+ * - A comma-delimited list of charsets (e.g., `"utf-8, iso-8859-1"`)
153
+ *
154
+ * Examples:
155
+ *
156
+ * // Accept-Charset: utf-8, iso-8859-1
157
+ * req.acceptsCharsets('utf-8');
158
+ * // => "utf-8"
159
+ *
160
+ * req.acceptsCharsets('utf-8', 'iso-8859-1');
161
+ * // => "utf-8"
162
+ *
163
+ * req.acceptsCharsets('utf-8, utf-16');
164
+ * // => "utf-8"
165
+ *
166
+ * @param {...String} charsets - The charset(s) to check against the `Accept-Charset` header.
167
+ * @return {String|Array} - The best matching charset, or an array of acceptable charsets.
155
168
  * @public
156
169
  */
157
170
 
158
- req.acceptsCharsets = function(){
159
- var accept = accepts(this);
160
- return accept.charsets.apply(accept, arguments);
171
+ req.acceptsCharsets = function(...charsets) {
172
+ const accept = accepts(this);
173
+ return accept.charsets(...charsets);
161
174
  };
162
175
 
163
176
  /**
@@ -317,7 +330,7 @@ defineGetter(req, 'secure', function secure(){
317
330
  /**
318
331
  * Return the remote address from the trusted proxy.
319
332
  *
320
- * The is the remote address on the socket unless
333
+ * This is the remote address on the socket unless
321
334
  * "trust proxy" is set.
322
335
  *
323
336
  * @return {String}
@@ -411,7 +424,7 @@ defineGetter(req, 'host', function host(){
411
424
  } else if (val.indexOf(',') !== -1) {
412
425
  // Note: X-Forwarded-Host is normally only ever a
413
426
  // single value, but this is to be safe.
414
- val = val.substring(0, val.indexOf(',')).trimRight()
427
+ val = val.substring(0, val.indexOf(',')).trimEnd()
415
428
  }
416
429
 
417
430
  return val || undefined;
@@ -458,8 +471,8 @@ defineGetter(req, 'fresh', function(){
458
471
  var res = this.res
459
472
  var status = res.statusCode
460
473
 
461
- // GET or HEAD for weak freshness validation only
462
- if ('GET' !== method && 'HEAD' !== method) return false;
474
+ // GET, HEAD, or QUERY for weak freshness validation only
475
+ if ('GET' !== method && 'HEAD' !== method && 'QUERY' !== method) return false;
463
476
 
464
477
  // 2xx or 304 as per rfc2616 14.26
465
478
  if ((status >= 200 && status < 300) || 304 === status) {
@@ -31,6 +31,7 @@ var cookie = require('cookie');
31
31
  var send = require('send');
32
32
  var extname = path.extname;
33
33
  var resolve = path.resolve;
34
+ var basename = path.basename;
34
35
  var vary = require('vary');
35
36
  const { Buffer } = require('node:buffer');
36
37
 
@@ -126,7 +127,6 @@ res.send = function send(body) {
126
127
  var chunk = body;
127
128
  var encoding;
128
129
  var req = this.req;
129
- var type;
130
130
 
131
131
  // settings
132
132
  var app = this.app;
@@ -134,7 +134,12 @@ res.send = function send(body) {
134
134
  switch (typeof chunk) {
135
135
  // string defaulting to html
136
136
  case 'string':
137
- if (!this.get('Content-Type')) {
137
+ encoding = 'utf8';
138
+ const type = this.get('Content-Type');
139
+
140
+ if (typeof type === 'string') {
141
+ this.set('Content-Type', setCharset(type, 'utf-8'));
142
+ } else {
138
143
  this.type('html');
139
144
  }
140
145
  break;
@@ -153,23 +158,11 @@ res.send = function send(body) {
153
158
  break;
154
159
  }
155
160
 
156
- // write strings in utf-8
157
- if (typeof chunk === 'string') {
158
- encoding = 'utf8';
159
- type = this.get('Content-Type');
160
-
161
- // reflect this in content-type
162
- if (typeof type === 'string') {
163
- this.set('Content-Type', setCharset(type, 'utf-8'));
164
- }
165
- }
166
-
167
161
  // determine if ETag should be generated
168
162
  var etagFn = app.get('etag fn')
169
163
  var generateETag = !this.get('ETag') && typeof etagFn === 'function'
170
164
 
171
- // populate Content-Length
172
- var len
165
+ var len;
173
166
  if (chunk !== undefined) {
174
167
  if (Buffer.isBuffer(chunk)) {
175
168
  // get length of Buffer
@@ -184,7 +177,11 @@ res.send = function send(body) {
184
177
  len = chunk.length
185
178
  }
186
179
 
187
- this.set('Content-Length', len);
180
+ // Because Content-Length and Transfer-Encoding can't be present in the response headers together,
181
+ // Content-Length should be added only if there is no Transfer-Encoding header
182
+ if (!this.get('Transfer-Encoding')) {
183
+ this.set('Content-Length', len);
184
+ }
188
185
  }
189
186
 
190
187
  // populate ETag
@@ -367,7 +364,7 @@ res.sendStatus = function sendStatus(statusCode) {
367
364
  * if (yes) {
368
365
  * res.sendFile('/uploads/' + uid + '/' + file);
369
366
  * } else {
370
- * res.send(403, 'Sorry! you cant see that.');
367
+ * res.send(403, 'Sorry! you can\'t see that.');
371
368
  * }
372
369
  * });
373
370
  * });
@@ -452,7 +449,7 @@ res.download = function download (path, filename, options, callback) {
452
449
  opts = null
453
450
  }
454
451
 
455
- // support optional filename, where options may be in it's place
452
+ // support optional filename, where options may be in its place
456
453
  if (typeof filename === 'object' &&
457
454
  (typeof options === 'function' || options === undefined)) {
458
455
  name = null
@@ -461,7 +458,7 @@ res.download = function download (path, filename, options, callback) {
461
458
 
462
459
  // set Content-Disposition when file is sent
463
460
  var headers = {
464
- 'Content-Disposition': contentDisposition(name || path)
461
+ 'Content-Disposition': contentDisposition.create(basename(name || path))
465
462
  };
466
463
 
467
464
  // merge user-provided headers
@@ -491,7 +488,7 @@ res.download = function download (path, filename, options, callback) {
491
488
  /**
492
489
  * Set _Content-Type_ response header with `type` through `mime.contentType()`
493
490
  * when it does not contain "/", or set the Content-Type to `type` otherwise.
494
- * When no mapping is found though `mime.contentType()`, the type is set to
491
+ * When no mapping is found through `mime.contentType()`, the type is set to
495
492
  * "application/octet-stream".
496
493
  *
497
494
  * Examples:
@@ -520,8 +517,9 @@ res.type = function contentType(type) {
520
517
  * Respond to the Acceptable formats using an `obj`
521
518
  * of mime-type callbacks.
522
519
  *
523
- * This method uses `req.accepted`, an array of
524
- * acceptable types ordered by their quality values.
520
+ * This method uses `req.accepts()`, which returns the
521
+ * best match from the acceptable types ordered by
522
+ * their quality values.
525
523
  * When "Accept" is not present the _first_ callback
526
524
  * is invoked, otherwise the first match is used. When
527
525
  * no match is performed the server responds with
@@ -609,11 +607,12 @@ res.format = function(obj){
609
607
  */
610
608
 
611
609
  res.attachment = function attachment(filename) {
612
- if (filename) {
613
- this.type(extname(filename));
610
+ const name = filename !== undefined ? basename(filename) : undefined;
611
+ if (name) {
612
+ this.type(extname(name));
614
613
  }
615
614
 
616
- this.set('Content-Disposition', contentDisposition(filename));
615
+ this.set('Content-Disposition', contentDisposition.create(name));
617
616
 
618
617
  return this;
619
618
  };
@@ -784,12 +783,9 @@ res.cookie = function (name, value, options) {
784
783
  /**
785
784
  * Set the location header to `url`.
786
785
  *
787
- * The given `url` can also be "back", which redirects
788
- * to the _Referrer_ or _Referer_ headers or "/".
789
- *
790
786
  * Examples:
791
787
  *
792
- * res.location('/foo/bar').;
788
+ * res.location('/foo/bar');
793
789
  * res.location('http://example.com');
794
790
  * res.location('../login');
795
791
  *
@@ -850,7 +846,8 @@ res.redirect = function redirect(url) {
850
846
 
851
847
  html: function(){
852
848
  var u = escapeHtml(address);
853
- body = '<p>' + statuses.message[status] + '. Redirecting to ' + u + '</p>'
849
+ body = '<!DOCTYPE html><head><title>' + statuses.message[status] + '</title></head>'
850
+ + '<body><p>' + statuses.message[status] + '. Redirecting to ' + u + '</p></body>'
854
851
  },
855
852
 
856
853
  default: function(){
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2015 Douglas Christopher Wilson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,71 @@
1
+ # content-type
2
+
3
+ [![NPM version][npm-image]][npm-url]
4
+ [![NPM downloads][downloads-image]][downloads-url]
5
+ [![Build status][build-image]][build-url]
6
+ [![Build coverage][coverage-image]][coverage-url]
7
+ [![License][license-image]][license-url]
8
+
9
+ Create and parse HTTP `Content-Type` header.
10
+
11
+ ## Installation
12
+
13
+ ```sh
14
+ npm install content-type
15
+ ```
16
+
17
+ ## API
18
+
19
+ ```js
20
+ const contentType = require("content-type");
21
+ ```
22
+
23
+ ### contentType.parse(string, options?)
24
+
25
+ ```js
26
+ const obj = contentType.parse("image/svg+xml; charset=utf-8");
27
+ ```
28
+
29
+ Parse a `Content-Type` header. This will return an object with the following properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
30
+
31
+ - `type`: The media type. Example: `'image/svg+xml'`.
32
+ - `parameters`: An object of the parameters in the media type (parameter name is always lower case). Example: `{charset: 'utf-8'}`.
33
+
34
+ The parser is lenient and does not error. You should validate `type` and `parameters` before trusting them.
35
+
36
+ #### Options
37
+
38
+ - `parameters` (default: `true`): Set to `false` to skip parameters.
39
+ - `comma` (default: `false`): Set to `true` to stop on a comma. This can be used to parse the media range in an `Accept` header.
40
+ - `start` (default: `0`): Set index to start parsing from.
41
+
42
+ ### contentType.format(obj)
43
+
44
+ ```js
45
+ const str = contentType.format({
46
+ type: "image/svg+xml",
47
+ parameters: { charset: "utf-8" },
48
+ });
49
+ ```
50
+
51
+ Format an object into a `Content-Type` header. This will return a string of the content type for the given object with the following properties (examples are shown that produce the string `'image/svg+xml; charset=utf-8'`):
52
+
53
+ - `type`: The media type. Example: `'image/svg+xml'`.
54
+ - `parameters`: An optional object of the parameters in the media type. Example: `{charset: 'utf-8'}`.
55
+
56
+ Throws a `TypeError` if the object contains an invalid type or parameter names.
57
+
58
+ ## License
59
+
60
+ [MIT](LICENSE)
61
+
62
+ [npm-image]: https://img.shields.io/npm/v/content-type
63
+ [npm-url]: https://npmjs.org/package/content-type
64
+ [downloads-image]: https://img.shields.io/npm/dm/content-type
65
+ [downloads-url]: https://npmjs.org/package/content-type
66
+ [build-image]: https://img.shields.io/github/actions/workflow/status/jshttp/content-type/ci.yml?branch=master
67
+ [build-url]: https://github.com/jshttp/content-type/actions/workflows/ci.yml?query=branch%3Amaster
68
+ [coverage-image]: https://img.shields.io/codecov/c/gh/jshttp/content-type
69
+ [coverage-url]: https://codecov.io/gh/jshttp/content-type
70
+ [license-image]: http://img.shields.io/npm/l/content-type.svg?style=flat
71
+ [license-url]: LICENSE
@@ -0,0 +1,46 @@
1
+ /*!
2
+ * content-type
3
+ * Copyright(c) 2015 Douglas Christopher Wilson
4
+ * MIT Licensed
5
+ */
6
+ /**
7
+ * The content type object contains a type string and optional parameters.
8
+ */
9
+ export interface ContentType {
10
+ type: string;
11
+ index: number;
12
+ parameters: Record<string, string>;
13
+ }
14
+ /**
15
+ * Format an object into a `Content-Type` header.
16
+ */
17
+ export declare function format(obj: Partial<ContentType>): string;
18
+ /**
19
+ * Options for parsing a `Content-Type` header.
20
+ */
21
+ export interface ParseOptions {
22
+ /**
23
+ * Exit early on the first semicolon, returning only the type.
24
+ * This is useful for parsing the MIME from `Content-Type` headers.
25
+ *
26
+ * @default false
27
+ */
28
+ parameters?: boolean;
29
+ /**
30
+ * Exits early on a comma, returning the first value and parameters.
31
+ * This is useful for parsing `Accept` headers.
32
+ *
33
+ * @default false
34
+ */
35
+ comma?: boolean;
36
+ /**
37
+ * The index to start parsing from.
38
+ *
39
+ * @default 0
40
+ */
41
+ start?: number;
42
+ }
43
+ /**
44
+ * Parse a `Content-Type` header.
45
+ */
46
+ export declare function parse(header: string, options?: ParseOptions): ContentType;