@zuplo/cli 6.70.15 → 6.70.21

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 (203) hide show
  1. package/dist/ca-certificate/create/handler.d.ts +3 -0
  2. package/dist/ca-certificate/create/handler.d.ts.map +1 -0
  3. package/dist/ca-certificate/create/handler.js +46 -0
  4. package/dist/ca-certificate/create/handler.js.map +1 -0
  5. package/dist/ca-certificate/delete/handler.d.ts +3 -0
  6. package/dist/ca-certificate/delete/handler.d.ts.map +1 -0
  7. package/dist/ca-certificate/delete/handler.js +18 -0
  8. package/dist/ca-certificate/delete/handler.js.map +1 -0
  9. package/dist/ca-certificate/describe/handler.d.ts +3 -0
  10. package/dist/ca-certificate/describe/handler.d.ts.map +1 -0
  11. package/dist/ca-certificate/describe/handler.js +32 -0
  12. package/dist/ca-certificate/describe/handler.js.map +1 -0
  13. package/dist/ca-certificate/list/handler.d.ts +3 -0
  14. package/dist/ca-certificate/list/handler.d.ts.map +1 -0
  15. package/dist/ca-certificate/list/handler.js +28 -0
  16. package/dist/ca-certificate/list/handler.js.map +1 -0
  17. package/dist/ca-certificate/models.d.ts +51 -0
  18. package/dist/ca-certificate/models.d.ts.map +1 -0
  19. package/dist/ca-certificate/models.js +2 -0
  20. package/dist/ca-certificate/models.js.map +1 -0
  21. package/dist/ca-certificate/update/handler.d.ts +3 -0
  22. package/dist/ca-certificate/update/handler.d.ts.map +1 -0
  23. package/dist/ca-certificate/update/handler.js +26 -0
  24. package/dist/ca-certificate/update/handler.js.map +1 -0
  25. package/dist/ca-certificate/validation.d.ts +21 -0
  26. package/dist/ca-certificate/validation.d.ts.map +1 -0
  27. package/dist/ca-certificate/validation.js +135 -0
  28. package/dist/ca-certificate/validation.js.map +1 -0
  29. package/dist/ca-certificate/validation.test.d.ts +2 -0
  30. package/dist/ca-certificate/validation.test.d.ts.map +1 -0
  31. package/dist/ca-certificate/validation.test.js +131 -0
  32. package/dist/ca-certificate/validation.test.js.map +1 -0
  33. package/dist/cli.js +2 -6
  34. package/dist/cli.js.map +1 -1
  35. package/dist/cmds/ca-certificate/create.d.ts +9 -0
  36. package/dist/cmds/ca-certificate/create.d.ts.map +1 -0
  37. package/dist/cmds/ca-certificate/create.js +66 -0
  38. package/dist/cmds/ca-certificate/create.js.map +1 -0
  39. package/dist/cmds/ca-certificate/delete.d.ts +9 -0
  40. package/dist/cmds/ca-certificate/delete.d.ts.map +1 -0
  41. package/dist/cmds/ca-certificate/delete.js +56 -0
  42. package/dist/cmds/ca-certificate/delete.js.map +1 -0
  43. package/dist/cmds/ca-certificate/describe.d.ts +9 -0
  44. package/dist/cmds/ca-certificate/describe.d.ts.map +1 -0
  45. package/dist/cmds/ca-certificate/describe.js +56 -0
  46. package/dist/cmds/ca-certificate/describe.js.map +1 -0
  47. package/dist/cmds/ca-certificate/index.d.ts +4 -0
  48. package/dist/cmds/ca-certificate/index.d.ts.map +1 -0
  49. package/dist/cmds/ca-certificate/index.js +18 -0
  50. package/dist/cmds/ca-certificate/index.js.map +1 -0
  51. package/dist/cmds/ca-certificate/list.d.ts +9 -0
  52. package/dist/cmds/ca-certificate/list.d.ts.map +1 -0
  53. package/dist/cmds/ca-certificate/list.js +48 -0
  54. package/dist/cmds/ca-certificate/list.js.map +1 -0
  55. package/dist/cmds/ca-certificate/update.d.ts +9 -0
  56. package/dist/cmds/ca-certificate/update.d.ts.map +1 -0
  57. package/dist/cmds/ca-certificate/update.js +56 -0
  58. package/dist/cmds/ca-certificate/update.js.map +1 -0
  59. package/dist/cmds/mtls-certificates/index.js +1 -1
  60. package/dist/cmds/mtls-certificates/index.js.map +1 -1
  61. package/dist/tsconfig.tsbuildinfo +1 -1
  62. package/node_modules/@cfworker/json-schema/README.md +75 -0
  63. package/node_modules/@cfworker/json-schema/dist/commonjs/deep-compare-strict.d.ts +1 -0
  64. package/node_modules/@cfworker/json-schema/dist/commonjs/deep-compare-strict.js +42 -0
  65. package/node_modules/@cfworker/json-schema/dist/commonjs/dereference.d.ts +7 -0
  66. package/node_modules/@cfworker/json-schema/dist/commonjs/dereference.js +147 -0
  67. package/node_modules/@cfworker/json-schema/dist/commonjs/format.d.ts +1 -0
  68. package/node_modules/@cfworker/json-schema/dist/commonjs/format.js +111 -0
  69. package/node_modules/@cfworker/json-schema/dist/commonjs/index.d.ts +8 -0
  70. package/node_modules/@cfworker/json-schema/dist/commonjs/index.js +24 -0
  71. package/node_modules/@cfworker/json-schema/dist/commonjs/package.json +3 -0
  72. package/node_modules/@cfworker/json-schema/dist/commonjs/pointer.d.ts +2 -0
  73. package/node_modules/@cfworker/json-schema/dist/commonjs/pointer.js +10 -0
  74. package/node_modules/@cfworker/json-schema/dist/commonjs/types.d.ts +72 -0
  75. package/node_modules/@cfworker/json-schema/dist/commonjs/types.js +9 -0
  76. package/node_modules/@cfworker/json-schema/dist/commonjs/ucs2-length.d.ts +1 -0
  77. package/node_modules/@cfworker/json-schema/dist/commonjs/ucs2-length.js +20 -0
  78. package/node_modules/@cfworker/json-schema/dist/commonjs/validate.d.ts +3 -0
  79. package/node_modules/@cfworker/json-schema/dist/commonjs/validate.js +805 -0
  80. package/node_modules/@cfworker/json-schema/dist/commonjs/validator.d.ts +10 -0
  81. package/node_modules/@cfworker/json-schema/dist/commonjs/validator.js +27 -0
  82. package/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.d.ts +1 -0
  83. package/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js +39 -0
  84. package/node_modules/@cfworker/json-schema/dist/esm/dereference.d.ts +7 -0
  85. package/node_modules/@cfworker/json-schema/dist/esm/dereference.js +143 -0
  86. package/node_modules/@cfworker/json-schema/dist/esm/format.d.ts +1 -0
  87. package/node_modules/@cfworker/json-schema/dist/esm/format.js +108 -0
  88. package/node_modules/@cfworker/json-schema/dist/esm/index.d.ts +8 -0
  89. package/node_modules/@cfworker/json-schema/dist/esm/index.js +8 -0
  90. package/node_modules/@cfworker/json-schema/dist/esm/package.json +3 -0
  91. package/node_modules/@cfworker/json-schema/dist/esm/pointer.d.ts +2 -0
  92. package/node_modules/@cfworker/json-schema/dist/esm/pointer.js +6 -0
  93. package/node_modules/@cfworker/json-schema/dist/esm/types.d.ts +72 -0
  94. package/node_modules/@cfworker/json-schema/dist/esm/types.js +6 -0
  95. package/node_modules/@cfworker/json-schema/dist/esm/ucs2-length.d.ts +1 -0
  96. package/node_modules/@cfworker/json-schema/dist/esm/ucs2-length.js +17 -0
  97. package/node_modules/@cfworker/json-schema/dist/esm/validate.d.ts +3 -0
  98. package/node_modules/@cfworker/json-schema/dist/esm/validate.js +802 -0
  99. package/node_modules/@cfworker/json-schema/dist/esm/validator.d.ts +10 -0
  100. package/node_modules/@cfworker/json-schema/dist/esm/validator.js +23 -0
  101. package/node_modules/@cfworker/json-schema/package.json +68 -0
  102. package/node_modules/@cfworker/json-schema/src/deep-compare-strict.d.ts +1 -0
  103. package/node_modules/@cfworker/json-schema/src/deep-compare-strict.ts +39 -0
  104. package/node_modules/@cfworker/json-schema/src/dereference.d.ts +12 -0
  105. package/node_modules/@cfworker/json-schema/src/dereference.ts +188 -0
  106. package/node_modules/@cfworker/json-schema/src/format.d.ts +2 -0
  107. package/node_modules/@cfworker/json-schema/src/format.ts +164 -0
  108. package/node_modules/@cfworker/json-schema/src/index.d.ts +8 -0
  109. package/node_modules/@cfworker/json-schema/src/index.ts +8 -0
  110. package/node_modules/@cfworker/json-schema/src/pointer.d.ts +2 -0
  111. package/node_modules/@cfworker/json-schema/src/pointer.ts +7 -0
  112. package/node_modules/@cfworker/json-schema/src/types.d.ts +79 -0
  113. package/node_modules/@cfworker/json-schema/src/types.ts +92 -0
  114. package/node_modules/@cfworker/json-schema/src/ucs2-length.d.ts +1 -0
  115. package/node_modules/@cfworker/json-schema/src/ucs2-length.ts +24 -0
  116. package/node_modules/@cfworker/json-schema/src/validate.d.ts +13 -0
  117. package/node_modules/@cfworker/json-schema/src/validate.ts +1168 -0
  118. package/node_modules/@cfworker/json-schema/src/validator.d.ts +14 -0
  119. package/node_modules/@cfworker/json-schema/src/validator.ts +32 -0
  120. package/node_modules/@zuplo/core/package.json +1 -1
  121. package/node_modules/@zuplo/graphql/package.json +1 -1
  122. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  123. package/node_modules/@zuplo/otel/package.json +1 -1
  124. package/node_modules/@zuplo/runtime/out/esm/{chunk-YJ3VHQXF.js → chunk-2ZQVIVZ3.js} +2 -2
  125. package/node_modules/@zuplo/runtime/out/esm/{chunk-STBDRSX7.js → chunk-UMZORQLU.js} +67 -66
  126. package/node_modules/@zuplo/runtime/out/esm/chunk-UMZORQLU.js.map +1 -0
  127. package/node_modules/@zuplo/runtime/out/esm/{chunk-KWR5BV7H.js → chunk-YGYFQCBA.js} +6 -6
  128. package/node_modules/@zuplo/runtime/out/esm/chunk-YGYFQCBA.js.map +1 -0
  129. package/node_modules/@zuplo/runtime/out/esm/{chunk-NJNTFB34.js → chunk-ZS34EO4B.js} +2 -2
  130. package/node_modules/@zuplo/runtime/out/esm/{chunk-NJNTFB34.js.map → chunk-ZS34EO4B.js.map} +1 -1
  131. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  132. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  133. package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
  134. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +208 -72
  135. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
  136. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
  137. package/node_modules/@zuplo/runtime/out/types/index.d.ts +61 -12
  138. package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +8 -17
  139. package/node_modules/@zuplo/runtime/out/types/mocks/index.d.ts +3 -12
  140. package/node_modules/@zuplo/runtime/package.json +3 -2
  141. package/node_modules/agent-base/README.md +145 -0
  142. package/node_modules/agent-base/dist/src/index.d.ts +78 -0
  143. package/node_modules/agent-base/dist/src/index.js +203 -0
  144. package/node_modules/agent-base/dist/src/index.js.map +1 -0
  145. package/node_modules/agent-base/dist/src/promisify.d.ts +4 -0
  146. package/node_modules/agent-base/dist/src/promisify.js +18 -0
  147. package/node_modules/agent-base/dist/src/promisify.js.map +1 -0
  148. package/node_modules/agent-base/package.json +64 -0
  149. package/node_modules/agent-base/src/index.ts +345 -0
  150. package/node_modules/agent-base/src/promisify.ts +33 -0
  151. package/node_modules/axios/CHANGELOG.md +71 -0
  152. package/node_modules/axios/README.md +46 -11
  153. package/node_modules/axios/dist/axios.js +81 -53
  154. package/node_modules/axios/dist/axios.js.map +1 -1
  155. package/node_modules/axios/dist/axios.min.js +2 -2
  156. package/node_modules/axios/dist/axios.min.js.map +1 -1
  157. package/node_modules/axios/dist/browser/axios.cjs +96 -64
  158. package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  159. package/node_modules/axios/dist/esm/axios.js +96 -64
  160. package/node_modules/axios/dist/esm/axios.js.map +1 -1
  161. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  162. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  163. package/node_modules/axios/dist/node/axios.cjs +206 -85
  164. package/node_modules/axios/dist/node/axios.cjs.map +1 -1
  165. package/node_modules/axios/index.d.cts +1 -1
  166. package/node_modules/axios/index.d.ts +1 -1
  167. package/node_modules/axios/lib/adapters/fetch.js +6 -2
  168. package/node_modules/axios/lib/adapters/http.js +139 -29
  169. package/node_modules/axios/lib/adapters/xhr.js +2 -1
  170. package/node_modules/axios/lib/core/AxiosHeaders.js +1 -33
  171. package/node_modules/axios/lib/env/data.js +1 -1
  172. package/node_modules/axios/lib/helpers/composeSignals.js +48 -47
  173. package/node_modules/axios/lib/helpers/formDataToJSON.js +1 -1
  174. package/node_modules/axios/lib/helpers/fromDataURI.js +18 -5
  175. package/node_modules/axios/lib/helpers/progressEventReducer.js +3 -0
  176. package/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +60 -0
  177. package/node_modules/axios/lib/utils.js +8 -7
  178. package/node_modules/axios/package.json +3 -1
  179. package/node_modules/https-proxy-agent/README.md +137 -0
  180. package/node_modules/https-proxy-agent/dist/agent.d.ts +30 -0
  181. package/node_modules/https-proxy-agent/dist/agent.js +177 -0
  182. package/node_modules/https-proxy-agent/dist/agent.js.map +1 -0
  183. package/node_modules/https-proxy-agent/dist/index.d.ts +23 -0
  184. package/node_modules/https-proxy-agent/dist/index.js +14 -0
  185. package/node_modules/https-proxy-agent/dist/index.js.map +1 -0
  186. package/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -0
  187. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
  188. package/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
  189. package/node_modules/https-proxy-agent/package.json +56 -0
  190. package/node_modules/type-is/index.js +8 -18
  191. package/node_modules/type-is/node_modules/content-type/LICENSE +22 -0
  192. package/node_modules/type-is/node_modules/content-type/README.md +69 -0
  193. package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +26 -0
  194. package/node_modules/type-is/node_modules/content-type/dist/index.js +170 -0
  195. package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -0
  196. package/node_modules/type-is/node_modules/content-type/package.json +52 -0
  197. package/node_modules/type-is/package.json +9 -5
  198. package/package.json +6 -6
  199. package/node_modules/@zuplo/runtime/out/esm/chunk-KWR5BV7H.js.map +0 -1
  200. package/node_modules/@zuplo/runtime/out/esm/chunk-STBDRSX7.js.map +0 -1
  201. /package/node_modules/@zuplo/runtime/out/esm/{chunk-YJ3VHQXF.js.map → chunk-2ZQVIVZ3.js.map} +0 -0
  202. /package/node_modules/@zuplo/runtime/out/esm/{chunk-STBDRSX7.js.LEGAL.txt → chunk-UMZORQLU.js.LEGAL.txt} +0 -0
  203. /package/node_modules/@zuplo/runtime/out/esm/{chunk-KWR5BV7H.js.LEGAL.txt → chunk-YGYFQCBA.js.LEGAL.txt} +0 -0
@@ -0,0 +1,137 @@
1
+ https-proxy-agent
2
+ ================
3
+ ### An HTTP(s) proxy `http.Agent` implementation for HTTPS
4
+ [![Build Status](https://github.com/TooTallNate/node-https-proxy-agent/workflows/Node%20CI/badge.svg)](https://github.com/TooTallNate/node-https-proxy-agent/actions?workflow=Node+CI)
5
+
6
+ This module provides an `http.Agent` implementation that connects to a specified
7
+ HTTP or HTTPS proxy server, and can be used with the built-in `https` module.
8
+
9
+ Specifically, this `Agent` implementation connects to an intermediary "proxy"
10
+ server and issues the [CONNECT HTTP method][CONNECT], which tells the proxy to
11
+ open a direct TCP connection to the destination server.
12
+
13
+ Since this agent implements the CONNECT HTTP method, it also works with other
14
+ protocols that use this method when connecting over proxies (i.e. WebSockets).
15
+ See the "Examples" section below for more.
16
+
17
+
18
+ Installation
19
+ ------------
20
+
21
+ Install with `npm`:
22
+
23
+ ``` bash
24
+ $ npm install https-proxy-agent
25
+ ```
26
+
27
+
28
+ Examples
29
+ --------
30
+
31
+ #### `https` module example
32
+
33
+ ``` js
34
+ var url = require('url');
35
+ var https = require('https');
36
+ var HttpsProxyAgent = require('https-proxy-agent');
37
+
38
+ // HTTP/HTTPS proxy to connect to
39
+ var proxy = process.env.http_proxy || 'http://168.63.76.32:3128';
40
+ console.log('using proxy server %j', proxy);
41
+
42
+ // HTTPS endpoint for the proxy to connect to
43
+ var endpoint = process.argv[2] || 'https://graph.facebook.com/tootallnate';
44
+ console.log('attempting to GET %j', endpoint);
45
+ var options = url.parse(endpoint);
46
+
47
+ // create an instance of the `HttpsProxyAgent` class with the proxy server information
48
+ var agent = new HttpsProxyAgent(proxy);
49
+ options.agent = agent;
50
+
51
+ https.get(options, function (res) {
52
+ console.log('"response" event!', res.headers);
53
+ res.pipe(process.stdout);
54
+ });
55
+ ```
56
+
57
+ #### `ws` WebSocket connection example
58
+
59
+ ``` js
60
+ var url = require('url');
61
+ var WebSocket = require('ws');
62
+ var HttpsProxyAgent = require('https-proxy-agent');
63
+
64
+ // HTTP/HTTPS proxy to connect to
65
+ var proxy = process.env.http_proxy || 'http://168.63.76.32:3128';
66
+ console.log('using proxy server %j', proxy);
67
+
68
+ // WebSocket endpoint for the proxy to connect to
69
+ var endpoint = process.argv[2] || 'ws://echo.websocket.org';
70
+ var parsed = url.parse(endpoint);
71
+ console.log('attempting to connect to WebSocket %j', endpoint);
72
+
73
+ // create an instance of the `HttpsProxyAgent` class with the proxy server information
74
+ var options = url.parse(proxy);
75
+
76
+ var agent = new HttpsProxyAgent(options);
77
+
78
+ // finally, initiate the WebSocket connection
79
+ var socket = new WebSocket(endpoint, { agent: agent });
80
+
81
+ socket.on('open', function () {
82
+ console.log('"open" event!');
83
+ socket.send('hello world');
84
+ });
85
+
86
+ socket.on('message', function (data, flags) {
87
+ console.log('"message" event! %j %j', data, flags);
88
+ socket.close();
89
+ });
90
+ ```
91
+
92
+ API
93
+ ---
94
+
95
+ ### new HttpsProxyAgent(Object options)
96
+
97
+ The `HttpsProxyAgent` class implements an `http.Agent` subclass that connects
98
+ to the specified "HTTP(s) proxy server" in order to proxy HTTPS and/or WebSocket
99
+ requests. This is achieved by using the [HTTP `CONNECT` method][CONNECT].
100
+
101
+ The `options` argument may either be a string URI of the proxy server to use, or an
102
+ "options" object with more specific properties:
103
+
104
+ * `host` - String - Proxy host to connect to (may use `hostname` as well). Required.
105
+ * `port` - Number - Proxy port to connect to. Required.
106
+ * `protocol` - String - If `https:`, then use TLS to connect to the proxy.
107
+ * `headers` - Object - Additional HTTP headers to be sent on the HTTP CONNECT method.
108
+ * Any other options given are passed to the `net.connect()`/`tls.connect()` functions.
109
+
110
+
111
+ License
112
+ -------
113
+
114
+ (The MIT License)
115
+
116
+ Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
117
+
118
+ Permission is hereby granted, free of charge, to any person obtaining
119
+ a copy of this software and associated documentation files (the
120
+ 'Software'), to deal in the Software without restriction, including
121
+ without limitation the rights to use, copy, modify, merge, publish,
122
+ distribute, sublicense, and/or sell copies of the Software, and to
123
+ permit persons to whom the Software is furnished to do so, subject to
124
+ the following conditions:
125
+
126
+ The above copyright notice and this permission notice shall be
127
+ included in all copies or substantial portions of the Software.
128
+
129
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
130
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
131
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
132
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
133
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
134
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
135
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
136
+
137
+ [CONNECT]: http://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_Tunneling
@@ -0,0 +1,30 @@
1
+ /// <reference types="node" />
2
+ import net from 'net';
3
+ import { Agent, ClientRequest, RequestOptions } from 'agent-base';
4
+ import { HttpsProxyAgentOptions } from '.';
5
+ /**
6
+ * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
7
+ * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
8
+ *
9
+ * Outgoing HTTP requests are first tunneled through the proxy server using the
10
+ * `CONNECT` HTTP request method to establish a connection to the proxy server,
11
+ * and then the proxy server connects to the destination target and issues the
12
+ * HTTP request from the proxy server.
13
+ *
14
+ * `https:` requests have their socket connection upgraded to TLS once
15
+ * the connection to the proxy server has been established.
16
+ *
17
+ * @api public
18
+ */
19
+ export default class HttpsProxyAgent extends Agent {
20
+ private secureProxy;
21
+ private proxy;
22
+ constructor(_opts: string | HttpsProxyAgentOptions);
23
+ /**
24
+ * Called when the node-core HTTP client library is creating a
25
+ * new HTTP request.
26
+ *
27
+ * @api protected
28
+ */
29
+ callback(req: ClientRequest, opts: RequestOptions): Promise<net.Socket>;
30
+ }
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const net_1 = __importDefault(require("net"));
16
+ const tls_1 = __importDefault(require("tls"));
17
+ const url_1 = __importDefault(require("url"));
18
+ const assert_1 = __importDefault(require("assert"));
19
+ const debug_1 = __importDefault(require("debug"));
20
+ const agent_base_1 = require("agent-base");
21
+ const parse_proxy_response_1 = __importDefault(require("./parse-proxy-response"));
22
+ const debug = debug_1.default('https-proxy-agent:agent');
23
+ /**
24
+ * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to
25
+ * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
26
+ *
27
+ * Outgoing HTTP requests are first tunneled through the proxy server using the
28
+ * `CONNECT` HTTP request method to establish a connection to the proxy server,
29
+ * and then the proxy server connects to the destination target and issues the
30
+ * HTTP request from the proxy server.
31
+ *
32
+ * `https:` requests have their socket connection upgraded to TLS once
33
+ * the connection to the proxy server has been established.
34
+ *
35
+ * @api public
36
+ */
37
+ class HttpsProxyAgent extends agent_base_1.Agent {
38
+ constructor(_opts) {
39
+ let opts;
40
+ if (typeof _opts === 'string') {
41
+ opts = url_1.default.parse(_opts);
42
+ }
43
+ else {
44
+ opts = _opts;
45
+ }
46
+ if (!opts) {
47
+ throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
48
+ }
49
+ debug('creating new HttpsProxyAgent instance: %o', opts);
50
+ super(opts);
51
+ const proxy = Object.assign({}, opts);
52
+ // If `true`, then connect to the proxy server over TLS.
53
+ // Defaults to `false`.
54
+ this.secureProxy = opts.secureProxy || isHTTPS(proxy.protocol);
55
+ // Prefer `hostname` over `host`, and set the `port` if needed.
56
+ proxy.host = proxy.hostname || proxy.host;
57
+ if (typeof proxy.port === 'string') {
58
+ proxy.port = parseInt(proxy.port, 10);
59
+ }
60
+ if (!proxy.port && proxy.host) {
61
+ proxy.port = this.secureProxy ? 443 : 80;
62
+ }
63
+ // ALPN is supported by Node.js >= v5.
64
+ // attempt to negotiate http/1.1 for proxy servers that support http/2
65
+ if (this.secureProxy && !('ALPNProtocols' in proxy)) {
66
+ proxy.ALPNProtocols = ['http 1.1'];
67
+ }
68
+ if (proxy.host && proxy.path) {
69
+ // If both a `host` and `path` are specified then it's most likely
70
+ // the result of a `url.parse()` call... we need to remove the
71
+ // `path` portion so that `net.connect()` doesn't attempt to open
72
+ // that as a Unix socket file.
73
+ delete proxy.path;
74
+ delete proxy.pathname;
75
+ }
76
+ this.proxy = proxy;
77
+ }
78
+ /**
79
+ * Called when the node-core HTTP client library is creating a
80
+ * new HTTP request.
81
+ *
82
+ * @api protected
83
+ */
84
+ callback(req, opts) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const { proxy, secureProxy } = this;
87
+ // Create a socket connection to the proxy server.
88
+ let socket;
89
+ if (secureProxy) {
90
+ debug('Creating `tls.Socket`: %o', proxy);
91
+ socket = tls_1.default.connect(proxy);
92
+ }
93
+ else {
94
+ debug('Creating `net.Socket`: %o', proxy);
95
+ socket = net_1.default.connect(proxy);
96
+ }
97
+ const headers = Object.assign({}, proxy.headers);
98
+ const hostname = `${opts.host}:${opts.port}`;
99
+ let payload = `CONNECT ${hostname} HTTP/1.1\r\n`;
100
+ // Inject the `Proxy-Authorization` header if necessary.
101
+ if (proxy.auth) {
102
+ headers['Proxy-Authorization'] = `Basic ${Buffer.from(proxy.auth).toString('base64')}`;
103
+ }
104
+ // The `Host` header should only include the port
105
+ // number when it is not the default port.
106
+ let { host, port, secureEndpoint } = opts;
107
+ if (!isDefaultPort(port, secureEndpoint)) {
108
+ host += `:${port}`;
109
+ }
110
+ headers.Host = host;
111
+ headers.Connection = 'close';
112
+ for (const name of Object.keys(headers)) {
113
+ payload += `${name}: ${headers[name]}\r\n`;
114
+ }
115
+ const proxyResponsePromise = parse_proxy_response_1.default(socket);
116
+ socket.write(`${payload}\r\n`);
117
+ const { statusCode, buffered } = yield proxyResponsePromise;
118
+ if (statusCode === 200) {
119
+ req.once('socket', resume);
120
+ if (opts.secureEndpoint) {
121
+ // The proxy is connecting to a TLS server, so upgrade
122
+ // this socket connection to a TLS connection.
123
+ debug('Upgrading socket connection to TLS');
124
+ const servername = opts.servername || opts.host;
125
+ return tls_1.default.connect(Object.assign(Object.assign({}, omit(opts, 'host', 'hostname', 'path', 'port')), { socket,
126
+ servername }));
127
+ }
128
+ return socket;
129
+ }
130
+ // Some other status code that's not 200... need to re-play the HTTP
131
+ // header "data" events onto the socket once the HTTP machinery is
132
+ // attached so that the node core `http` can parse and handle the
133
+ // error status code.
134
+ // Close the original socket, and a new "fake" socket is returned
135
+ // instead, so that the proxy doesn't get the HTTP request
136
+ // written to it (which may contain `Authorization` headers or other
137
+ // sensitive data).
138
+ //
139
+ // See: https://hackerone.com/reports/541502
140
+ socket.destroy();
141
+ const fakeSocket = new net_1.default.Socket({ writable: false });
142
+ fakeSocket.readable = true;
143
+ // Need to wait for the "socket" event to re-play the "data" events.
144
+ req.once('socket', (s) => {
145
+ debug('replaying proxy buffer for failed request');
146
+ assert_1.default(s.listenerCount('data') > 0);
147
+ // Replay the "buffered" Buffer onto the fake `socket`, since at
148
+ // this point the HTTP module machinery has been hooked up for
149
+ // the user.
150
+ s.push(buffered);
151
+ s.push(null);
152
+ });
153
+ return fakeSocket;
154
+ });
155
+ }
156
+ }
157
+ exports.default = HttpsProxyAgent;
158
+ function resume(socket) {
159
+ socket.resume();
160
+ }
161
+ function isDefaultPort(port, secure) {
162
+ return Boolean((!secure && port === 80) || (secure && port === 443));
163
+ }
164
+ function isHTTPS(protocol) {
165
+ return typeof protocol === 'string' ? /^https:?$/i.test(protocol) : false;
166
+ }
167
+ function omit(obj, ...keys) {
168
+ const ret = {};
169
+ let key;
170
+ for (key in obj) {
171
+ if (!keys.includes(key)) {
172
+ ret[key] = obj[key];
173
+ }
174
+ }
175
+ return ret;
176
+ }
177
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,8CAAsB;AACtB,8CAAsB;AACtB,oDAA4B;AAC5B,kDAAgC;AAEhC,2CAAkE;AAElE,kFAAwD;AAExD,MAAM,KAAK,GAAG,eAAW,CAAC,yBAAyB,CAAC,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAqB,eAAgB,SAAQ,kBAAK;IAIjD,YAAY,KAAsC;QACjD,IAAI,IAA4B,CAAC;QACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC9B,IAAI,GAAG,aAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACxB;aAAM;YACN,IAAI,GAAG,KAAK,CAAC;SACb;QACD,IAAI,CAAC,IAAI,EAAE;YACV,MAAM,IAAI,KAAK,CACd,8DAA8D,CAC9D,CAAC;SACF;QACD,KAAK,CAAC,2CAA2C,EAAE,IAAI,CAAC,CAAC;QACzD,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,MAAM,KAAK,qBAAgC,IAAI,CAAE,CAAC;QAElD,wDAAwD;QACxD,uBAAuB;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE/D,+DAA+D;QAC/D,KA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I,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,OAAO,CAAC,QAAwB;IACxC,OAAO,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC3E,CAAC;AAED,SAAS,IAAI,CACZ,GAAM,EACN,GAAG,IAAO;IAIV,MAAM,GAAG,GAAG,EAEX,CAAC;IACF,IAAI,GAAqB,CAAC;IAC1B,KAAK,GAAG,IAAI,GAAG,EAAE;QAChB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACxB,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;SACpB;KACD;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -0,0 +1,23 @@
1
+ /// <reference types="node" />
2
+ import net from 'net';
3
+ import tls from 'tls';
4
+ import { Url } from 'url';
5
+ import { AgentOptions } from 'agent-base';
6
+ import { OutgoingHttpHeaders } from 'http';
7
+ import _HttpsProxyAgent from './agent';
8
+ declare function createHttpsProxyAgent(opts: string | createHttpsProxyAgent.HttpsProxyAgentOptions): _HttpsProxyAgent;
9
+ declare namespace createHttpsProxyAgent {
10
+ interface BaseHttpsProxyAgentOptions {
11
+ headers?: OutgoingHttpHeaders;
12
+ secureProxy?: boolean;
13
+ host?: string | null;
14
+ path?: string | null;
15
+ port?: string | number | null;
16
+ }
17
+ export interface HttpsProxyAgentOptions extends AgentOptions, BaseHttpsProxyAgentOptions, Partial<Omit<Url & net.NetConnectOpts & tls.ConnectionOptions, keyof BaseHttpsProxyAgentOptions>> {
18
+ }
19
+ export type HttpsProxyAgent = _HttpsProxyAgent;
20
+ export const HttpsProxyAgent: typeof _HttpsProxyAgent;
21
+ export {};
22
+ }
23
+ export = createHttpsProxyAgent;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ const agent_1 = __importDefault(require("./agent"));
6
+ function createHttpsProxyAgent(opts) {
7
+ return new agent_1.default(opts);
8
+ }
9
+ (function (createHttpsProxyAgent) {
10
+ createHttpsProxyAgent.HttpsProxyAgent = agent_1.default;
11
+ createHttpsProxyAgent.prototype = agent_1.default.prototype;
12
+ })(createHttpsProxyAgent || (createHttpsProxyAgent = {}));
13
+ module.exports = createHttpsProxyAgent;
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAKA,oDAAuC;AAEvC,SAAS,qBAAqB,CAC7B,IAA2D;IAE3D,OAAO,IAAI,eAAgB,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,WAAU,qBAAqB;IAoBjB,qCAAe,GAAG,eAAgB,CAAC;IAEhD,qBAAqB,CAAC,SAAS,GAAG,eAAgB,CAAC,SAAS,CAAC;AAC9D,CAAC,EAvBS,qBAAqB,KAArB,qBAAqB,QAuB9B;AAED,iBAAS,qBAAqB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from 'stream';
3
+ export interface ProxyResponse {
4
+ statusCode: number;
5
+ buffered: Buffer;
6
+ }
7
+ export default function parseProxyResponse(socket: Readable): Promise<ProxyResponse>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const debug_1 = __importDefault(require("debug"));
7
+ const debug = debug_1.default('https-proxy-agent:parse-proxy-response');
8
+ function parseProxyResponse(socket) {
9
+ return new Promise((resolve, reject) => {
10
+ // we need to buffer any HTTP traffic that happens with the proxy before we get
11
+ // the CONNECT response, so that if the response is anything other than an "200"
12
+ // response code, then we can re-play the "data" events on the socket once the
13
+ // HTTP parser is hooked up...
14
+ let buffersLength = 0;
15
+ const buffers = [];
16
+ function read() {
17
+ const b = socket.read();
18
+ if (b)
19
+ ondata(b);
20
+ else
21
+ socket.once('readable', read);
22
+ }
23
+ function cleanup() {
24
+ socket.removeListener('end', onend);
25
+ socket.removeListener('error', onerror);
26
+ socket.removeListener('close', onclose);
27
+ socket.removeListener('readable', read);
28
+ }
29
+ function onclose(err) {
30
+ debug('onclose had error %o', err);
31
+ }
32
+ function onend() {
33
+ debug('onend');
34
+ }
35
+ function onerror(err) {
36
+ cleanup();
37
+ debug('onerror %o', err);
38
+ reject(err);
39
+ }
40
+ function ondata(b) {
41
+ buffers.push(b);
42
+ buffersLength += b.length;
43
+ const buffered = Buffer.concat(buffers, buffersLength);
44
+ const endOfHeaders = buffered.indexOf('\r\n\r\n');
45
+ if (endOfHeaders === -1) {
46
+ // keep buffering
47
+ debug('have not received end of HTTP headers yet...');
48
+ read();
49
+ return;
50
+ }
51
+ const firstLine = buffered.toString('ascii', 0, buffered.indexOf('\r\n'));
52
+ const statusCode = +firstLine.split(' ')[1];
53
+ debug('got proxy server response: %o', firstLine);
54
+ resolve({
55
+ statusCode,
56
+ buffered
57
+ });
58
+ }
59
+ socket.on('error', onerror);
60
+ socket.on('close', onclose);
61
+ socket.on('end', onend);
62
+ read();
63
+ });
64
+ }
65
+ exports.default = parseProxyResponse;
66
+ //# sourceMappingURL=parse-proxy-response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-proxy-response.js","sourceRoot":"","sources":["../src/parse-proxy-response.ts"],"names":[],"mappings":";;;;;AAAA,kDAAgC;AAGhC,MAAM,KAAK,GAAG,eAAW,CAAC,wCAAwC,CAAC,CAAC;AAOpE,SAAwB,kBAAkB,CACzC,MAAgB;IAEhB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,+EAA+E;QAC/E,gFAAgF;QAChF,8EAA8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gBACtD,IAAI,EAAE,CAAC;gBACP,OAAO;aACP;YAED,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAClC,OAAO,EACP,CAAC,EACD,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CACxB,CAAC;YACF,MAAM,UAAU,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5C,KAAK,CAAC,+BAA+B,EAAE,SAAS,CAAC,CAAC;YAClD,OAAO,CAAC;gBACP,UAAU;gBACV,QAAQ;aACR,CAAC,CAAC;QACJ,CAAC;QAED,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAExB,IAAI,EAAE,CAAC;IACR,CAAC,CAAC,CAAC;AACJ,CAAC;AAvED,qCAuEC"}
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "https-proxy-agent",
3
+ "version": "5.0.1",
4
+ "description": "An HTTP(s) proxy `http.Agent` implementation for HTTPS",
5
+ "main": "dist/index",
6
+ "types": "dist/index",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "prebuild": "rimraf dist",
12
+ "build": "tsc",
13
+ "test": "mocha --reporter spec",
14
+ "test-lint": "eslint src --ext .js,.ts",
15
+ "prepublishOnly": "npm run build"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git://github.com/TooTallNate/node-https-proxy-agent.git"
20
+ },
21
+ "keywords": [
22
+ "https",
23
+ "proxy",
24
+ "endpoint",
25
+ "agent"
26
+ ],
27
+ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/TooTallNate/node-https-proxy-agent/issues"
31
+ },
32
+ "dependencies": {
33
+ "agent-base": "6",
34
+ "debug": "4"
35
+ },
36
+ "devDependencies": {
37
+ "@types/debug": "4",
38
+ "@types/node": "^12.12.11",
39
+ "@typescript-eslint/eslint-plugin": "1.6.0",
40
+ "@typescript-eslint/parser": "1.1.0",
41
+ "eslint": "5.16.0",
42
+ "eslint-config-airbnb": "17.1.0",
43
+ "eslint-config-prettier": "4.1.0",
44
+ "eslint-import-resolver-typescript": "1.1.1",
45
+ "eslint-plugin-import": "2.16.0",
46
+ "eslint-plugin-jsx-a11y": "6.2.1",
47
+ "eslint-plugin-react": "7.12.4",
48
+ "mocha": "^6.2.2",
49
+ "proxy": "1",
50
+ "rimraf": "^3.0.0",
51
+ "typescript": "^3.5.3"
52
+ },
53
+ "engines": {
54
+ "node": ">= 6"
55
+ }
56
+ }
@@ -42,11 +42,16 @@ module.exports.match = mimeMatch
42
42
  */
43
43
 
44
44
  function typeis (value, types_) {
45
+ // Backward compatibility. TODO: Remove.
46
+ if (value && typeof value === 'object') {
47
+ value = value.headers['content-type']
48
+ }
49
+
45
50
  var i
46
51
  var types = types_
47
52
 
48
53
  // remove parameters and normalize
49
- var val = tryNormalizeType(value)
54
+ var val = normalizeType(value)
50
55
 
51
56
  // no type or invalid
52
57
  if (!val) {
@@ -228,23 +233,8 @@ function mimeMatch (expected, actual) {
228
233
  * @private
229
234
  */
230
235
  function normalizeType (value) {
231
- // Parse the type
232
- var type = contentType.parse(value).type
236
+ if (!value) return null
237
+ var type = contentType.parse(value, { parameters: false }).type
233
238
 
234
239
  return typer.test(type) ? type : null
235
240
  }
236
-
237
- /**
238
- * Try to normalize a type and remove parameters.
239
- *
240
- * @param {string} value
241
- * @return {(string|null)}
242
- * @private
243
- */
244
- function tryNormalizeType (value) {
245
- try {
246
- return value ? normalizeType(value) : null
247
- } catch (err) {
248
- return null
249
- }
250
- }
@@ -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,69 @@
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
+
40
+ ### contentType.format(obj)
41
+
42
+ ```js
43
+ const str = contentType.format({
44
+ type: "image/svg+xml",
45
+ parameters: { charset: "utf-8" },
46
+ });
47
+ ```
48
+
49
+ 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'`):
50
+
51
+ - `type`: The media type. Example: `'image/svg+xml'`.
52
+ - `parameters`: An optional object of the parameters in the media type. Example: `{charset: 'utf-8'}`.
53
+
54
+ Throws a `TypeError` if the object contains an invalid type or parameter names.
55
+
56
+ ## License
57
+
58
+ [MIT](LICENSE)
59
+
60
+ [npm-image]: https://img.shields.io/npm/v/content-type
61
+ [npm-url]: https://npmjs.org/package/content-type
62
+ [downloads-image]: https://img.shields.io/npm/dm/content-type
63
+ [downloads-url]: https://npmjs.org/package/content-type
64
+ [build-image]: https://img.shields.io/github/actions/workflow/status/jshttp/content-type/ci.yml?branch=master
65
+ [build-url]: https://github.com/jshttp/content-type/actions/workflows/ci.yml?query=branch%3Amaster
66
+ [coverage-image]: https://img.shields.io/codecov/c/gh/jshttp/content-type
67
+ [coverage-url]: https://codecov.io/gh/jshttp/content-type
68
+ [license-image]: http://img.shields.io/npm/l/content-type.svg?style=flat
69
+ [license-url]: LICENSE