@psnext/slingcli 3.5.20261019-1 → 3.5.20261026-1
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/node_modules/@aws-sdk/core/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-env/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-http/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +11 -11
- package/node_modules/@aws-sdk/credential-provider-login/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-node/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-process/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +5 -5
- package/node_modules/@aws-sdk/eventstream-handler-node/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-eventstream/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-websocket/package.json +4 -4
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/CognitoIdentityClient.d.ts +2 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/SigninClient.d.ts +2 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/SSOClient.d.ts +2 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/SSOOIDCClient.d.ts +2 -1
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/STSClient.d.ts +2 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +5 -5
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +2 -2
- package/node_modules/@aws-sdk/types/dist-types/feature-ids.d.ts +3 -0
- package/node_modules/@aws-sdk/types/dist-types/ts3.4/feature-ids.d.ts +3 -0
- package/node_modules/@aws-sdk/types/package.json +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js +10 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/transport.d.ts +8 -8
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/transport.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +10 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.d.ts +8 -8
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/package.json +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +15 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +10 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +10 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +5 -5
- package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/command.js +16 -2
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js +10 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js +5 -5
- package/node_modules/@smithy/core/package.json +1 -1
- package/node_modules/body-parser/README.md +17 -13
- package/node_modules/body-parser/lib/read.js +74 -57
- package/node_modules/body-parser/lib/types/json.js +11 -11
- package/node_modules/body-parser/lib/types/urlencoded.js +5 -5
- package/node_modules/body-parser/lib/utils.js +0 -15
- package/node_modules/body-parser/package.json +7 -12
- package/node_modules/hono/README.md +2 -3
- package/node_modules/hono/dist/cjs/helper/css/common.js +8 -3
- package/node_modules/hono/dist/cjs/helper/css/index.js +1 -1
- package/node_modules/hono/dist/cjs/helper/route/index.js +3 -1
- package/node_modules/hono/dist/cjs/jsx/base.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +8 -0
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +3 -1
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +2 -2
- package/node_modules/hono/dist/cjs/utils/url.js +11 -6
- package/node_modules/hono/dist/helper/css/common.js +8 -3
- package/node_modules/hono/dist/helper/css/index.js +1 -1
- package/node_modules/hono/dist/helper/route/index.js +3 -1
- package/node_modules/hono/dist/jsx/base.js +1 -1
- package/node_modules/hono/dist/middleware/bearer-auth/index.js +8 -0
- package/node_modules/hono/dist/middleware/serve-static/index.js +3 -1
- package/node_modules/hono/dist/router/trie-router/node.js +2 -2
- package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +1 -1
- package/node_modules/hono/dist/types/helper/testing/index.d.ts +2 -1
- package/node_modules/hono/dist/types/hono-base.d.ts +21 -9
- package/node_modules/hono/dist/types/index.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/context.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/css.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/streaming.d.ts +4 -3
- package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +2 -1
- package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +3 -3
- package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +3 -3
- package/node_modules/hono/dist/types/utils/ipaddr.d.ts +1 -1
- package/node_modules/hono/dist/utils/url.js +11 -6
- package/node_modules/hono/package.json +1 -1
- package/node_modules/ip-address/dist/common.js +2 -2
- package/node_modules/ip-address/dist/common.js.map +1 -1
- package/node_modules/ip-address/package.json +2 -2
- package/node_modules/on-finished/index.js +14 -2
- package/node_modules/on-finished/package.json +11 -7
- package/package.json +2 -2
- package/sling-default-packages.json +3 -2
- package/slingshot/index.js +1 -1
- package/node_modules/on-finished/HISTORY.md +0 -98
|
@@ -61,6 +61,9 @@ class HeaderMarshaller {
|
|
|
61
61
|
if (!hasOwn(headers, headerName))
|
|
62
62
|
continue;
|
|
63
63
|
const bytes = this.fromUtf8(headerName);
|
|
64
|
+
if (bytes.byteLength > 255) {
|
|
65
|
+
throw new Error(`@smithy/core/event-streams - header name exceeds 255 bytes: ${bytes.byteLength}`);
|
|
66
|
+
}
|
|
64
67
|
chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
|
|
65
68
|
}
|
|
66
69
|
const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
|
|
@@ -93,6 +96,9 @@ class HeaderMarshaller {
|
|
|
93
96
|
longBytes.set(header.value.bytes, 1);
|
|
94
97
|
return longBytes;
|
|
95
98
|
case "binary":
|
|
99
|
+
if (header.value.byteLength > MAX_HEADER_VALUE_BYTES) {
|
|
100
|
+
throw new Error(`@smithy/core/event-streams - header value (binary) exceeds ${MAX_HEADER_VALUE_BYTES} bytes: ${header.value.byteLength}`);
|
|
101
|
+
}
|
|
96
102
|
const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
|
|
97
103
|
binView.setUint8(0, 6);
|
|
98
104
|
binView.setUint16(1, header.value.byteLength, false);
|
|
@@ -101,6 +107,9 @@ class HeaderMarshaller {
|
|
|
101
107
|
return binBytes;
|
|
102
108
|
case "string":
|
|
103
109
|
const utf8Bytes = this.fromUtf8(header.value);
|
|
110
|
+
if (utf8Bytes.byteLength > MAX_HEADER_VALUE_BYTES) {
|
|
111
|
+
throw new Error(`@smithy/core/event-streams - header value (string) exceeds ${MAX_HEADER_VALUE_BYTES} bytes: ${utf8Bytes.byteLength}`);
|
|
112
|
+
}
|
|
104
113
|
const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
|
|
105
114
|
strView.setUint8(0, 7);
|
|
106
115
|
strView.setUint16(1, utf8Bytes.byteLength, false);
|
|
@@ -232,6 +241,7 @@ const STRING_TAG = "string";
|
|
|
232
241
|
const TIMESTAMP_TAG = "timestamp";
|
|
233
242
|
const UUID_TAG = "uuid";
|
|
234
243
|
const UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
244
|
+
const MAX_HEADER_VALUE_BYTES = 32767;
|
|
235
245
|
|
|
236
246
|
const PRELUDE_MEMBER_LENGTH = 4;
|
|
237
247
|
const PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
|
|
@@ -1812,9 +1812,9 @@ class JsonShapeSerializer2 extends SerdeContextConfig {
|
|
|
1812
1812
|
this.i = i;
|
|
1813
1813
|
}
|
|
1814
1814
|
writeJsonString(s) {
|
|
1815
|
-
this.ensure(s.length * 3 + 2);
|
|
1816
|
-
this.json[this.i++] = QUOTE;
|
|
1817
1815
|
const z = s.length;
|
|
1816
|
+
this.ensure(z * 3 + 2);
|
|
1817
|
+
this.json[this.i++] = QUOTE;
|
|
1818
1818
|
for (let j = 0; j < z; ++j) {
|
|
1819
1819
|
const c = s.charCodeAt(j);
|
|
1820
1820
|
if (c > 0x22 && c < 0x5c) {
|
|
@@ -1823,7 +1823,7 @@ class JsonShapeSerializer2 extends SerdeContextConfig {
|
|
|
1823
1823
|
else if (c < 0x80) {
|
|
1824
1824
|
const esc = ESCAPE_TABLE[c];
|
|
1825
1825
|
if (esc !== null) {
|
|
1826
|
-
this.ensure(esc.length + 1);
|
|
1826
|
+
this.ensure(esc.length + 1 + (z - j - 1) * 3 + 1);
|
|
1827
1827
|
this.json[this.i++] = BACKSLASH;
|
|
1828
1828
|
for (let k = 0; k < esc.length; k++) {
|
|
1829
1829
|
this.json[this.i++] = esc.charCodeAt(k);
|
|
@@ -1842,12 +1842,12 @@ class JsonShapeSerializer2 extends SerdeContextConfig {
|
|
|
1842
1842
|
++j;
|
|
1843
1843
|
}
|
|
1844
1844
|
else {
|
|
1845
|
-
this.ensure(6);
|
|
1845
|
+
this.ensure(6 + (z - j - 1) * 3 + 1);
|
|
1846
1846
|
this.writeUnicodeEscape(c);
|
|
1847
1847
|
}
|
|
1848
1848
|
}
|
|
1849
1849
|
else if (c >= 0xdc00 && c <= 0xdfff) {
|
|
1850
|
-
this.ensure(6);
|
|
1850
|
+
this.ensure(6 + (z - j - 1) * 3 + 1);
|
|
1851
1851
|
this.writeUnicodeEscape(c);
|
|
1852
1852
|
}
|
|
1853
1853
|
else {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SMITHY_CONTEXT_KEY, } from "@smithy/types";
|
|
2
2
|
import { constructStack } from "../middleware-stack/MiddlewareStack";
|
|
3
3
|
import { schemaLogFilter } from "./schemaLogFilter";
|
|
4
|
+
import { NormalizedSchema } from "@smithy/core/schema";
|
|
5
|
+
const operationEventStreamMarker = Symbol.for("@smithy/op-event-stream");
|
|
4
6
|
export class Command {
|
|
5
7
|
middlewareStack = constructStack();
|
|
6
8
|
schema;
|
|
@@ -34,9 +36,21 @@ export class Command {
|
|
|
34
36
|
requestOptions = { ...requestOptions };
|
|
35
37
|
delete requestOptions.metricsRecorder;
|
|
36
38
|
}
|
|
37
|
-
|
|
39
|
+
let isEventStream;
|
|
40
|
+
const schema = this.schema;
|
|
41
|
+
const marker = schema?.[operationEventStreamMarker];
|
|
42
|
+
if (marker !== undefined) {
|
|
43
|
+
isEventStream = marker;
|
|
44
|
+
}
|
|
45
|
+
else if (schema) {
|
|
46
|
+
if (Array.isArray(schema) && schema[0] === 9) {
|
|
47
|
+
const [, , , , input$, output$] = schema;
|
|
48
|
+
isEventStream = schema[operationEventStreamMarker] = Boolean(NormalizedSchema.of(input$).getEventStreamMember() || NormalizedSchema.of(output$).getEventStreamMember());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (isEventStream) {
|
|
38
52
|
requestOptions = {
|
|
39
|
-
isEventStream
|
|
53
|
+
isEventStream,
|
|
40
54
|
...requestOptions,
|
|
41
55
|
};
|
|
42
56
|
}
|
|
@@ -14,6 +14,9 @@ export class HeaderMarshaller {
|
|
|
14
14
|
if (!hasOwn(headers, headerName))
|
|
15
15
|
continue;
|
|
16
16
|
const bytes = this.fromUtf8(headerName);
|
|
17
|
+
if (bytes.byteLength > 255) {
|
|
18
|
+
throw new Error(`@smithy/core/event-streams - header name exceeds 255 bytes: ${bytes.byteLength}`);
|
|
19
|
+
}
|
|
17
20
|
chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
|
|
18
21
|
}
|
|
19
22
|
const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
|
|
@@ -46,6 +49,9 @@ export class HeaderMarshaller {
|
|
|
46
49
|
longBytes.set(header.value.bytes, 1);
|
|
47
50
|
return longBytes;
|
|
48
51
|
case "binary":
|
|
52
|
+
if (header.value.byteLength > MAX_HEADER_VALUE_BYTES) {
|
|
53
|
+
throw new Error(`@smithy/core/event-streams - header value (binary) exceeds ${MAX_HEADER_VALUE_BYTES} bytes: ${header.value.byteLength}`);
|
|
54
|
+
}
|
|
49
55
|
const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
|
|
50
56
|
binView.setUint8(0, 6);
|
|
51
57
|
binView.setUint16(1, header.value.byteLength, false);
|
|
@@ -54,6 +60,9 @@ export class HeaderMarshaller {
|
|
|
54
60
|
return binBytes;
|
|
55
61
|
case "string":
|
|
56
62
|
const utf8Bytes = this.fromUtf8(header.value);
|
|
63
|
+
if (utf8Bytes.byteLength > MAX_HEADER_VALUE_BYTES) {
|
|
64
|
+
throw new Error(`@smithy/core/event-streams - header value (string) exceeds ${MAX_HEADER_VALUE_BYTES} bytes: ${utf8Bytes.byteLength}`);
|
|
65
|
+
}
|
|
57
66
|
const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
|
|
58
67
|
strView.setUint8(0, 7);
|
|
59
68
|
strView.setUint16(1, utf8Bytes.byteLength, false);
|
|
@@ -185,3 +194,4 @@ const STRING_TAG = "string";
|
|
|
185
194
|
const TIMESTAMP_TAG = "timestamp";
|
|
186
195
|
const UUID_TAG = "uuid";
|
|
187
196
|
const UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
197
|
+
const MAX_HEADER_VALUE_BYTES = 32767;
|
package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js
CHANGED
|
@@ -118,9 +118,9 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
|
|
|
118
118
|
this.i = i;
|
|
119
119
|
}
|
|
120
120
|
writeJsonString(s) {
|
|
121
|
-
this.ensure(s.length * 3 + 2);
|
|
122
|
-
this.json[this.i++] = QUOTE;
|
|
123
121
|
const z = s.length;
|
|
122
|
+
this.ensure(z * 3 + 2);
|
|
123
|
+
this.json[this.i++] = QUOTE;
|
|
124
124
|
for (let j = 0; j < z; ++j) {
|
|
125
125
|
const c = s.charCodeAt(j);
|
|
126
126
|
if (c > 0x22 && c < 0x5c) {
|
|
@@ -129,7 +129,7 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
|
|
|
129
129
|
else if (c < 0x80) {
|
|
130
130
|
const esc = ESCAPE_TABLE[c];
|
|
131
131
|
if (esc !== null) {
|
|
132
|
-
this.ensure(esc.length + 1);
|
|
132
|
+
this.ensure(esc.length + 1 + (z - j - 1) * 3 + 1);
|
|
133
133
|
this.json[this.i++] = BACKSLASH;
|
|
134
134
|
for (let k = 0; k < esc.length; k++) {
|
|
135
135
|
this.json[this.i++] = esc.charCodeAt(k);
|
|
@@ -148,12 +148,12 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
|
|
|
148
148
|
++j;
|
|
149
149
|
}
|
|
150
150
|
else {
|
|
151
|
-
this.ensure(6);
|
|
151
|
+
this.ensure(6 + (z - j - 1) * 3 + 1);
|
|
152
152
|
this.writeUnicodeEscape(c);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
else if (c >= 0xdc00 && c <= 0xdfff) {
|
|
156
|
-
this.ensure(6);
|
|
156
|
+
this.ensure(6 + (z - j - 1) * 3 + 1);
|
|
157
157
|
this.writeUnicodeEscape(c);
|
|
158
158
|
}
|
|
159
159
|
else {
|
|
@@ -37,6 +37,10 @@ This module provides the following parsers:
|
|
|
37
37
|
* [Text body parser](#bodyparsertextoptions)
|
|
38
38
|
* [URL-encoded form body parser](#bodyparserurlencodedoptions)
|
|
39
39
|
|
|
40
|
+
All parsers support automatic inflation of `gzip`, `br` (brotli), `deflate`
|
|
41
|
+
and `zstd` encodings. `zstd` is available in Node.js `^22.15.0` and
|
|
42
|
+
`>=23.8.0`.
|
|
43
|
+
|
|
40
44
|
Other body parsers you might be interested in:
|
|
41
45
|
|
|
42
46
|
- [body](https://www.npmjs.com/package/body#readme)
|
|
@@ -65,6 +69,12 @@ The `bodyParser` object exposes various factories to create middlewares. All
|
|
|
65
69
|
middlewares will populate the `req.body` property with the parsed body when
|
|
66
70
|
the `Content-Type` request header matches the `type` option.
|
|
67
71
|
|
|
72
|
+
**Note** As of v2, `req.body` is left `undefined` when no body is parsed (for
|
|
73
|
+
example when the request has neither `Content-Length` nor `Transfer-Encoding`,
|
|
74
|
+
or when `Content-Type` does not match). In v1, `req.body` was always initialized
|
|
75
|
+
to `{}`. Code that assumes `req.body` is always an object should use optional
|
|
76
|
+
chaining (for example `req.body?.username`) or set a default.
|
|
77
|
+
|
|
68
78
|
The various errors returned by this module are described in the
|
|
69
79
|
[errors section](#errors).
|
|
70
80
|
|
|
@@ -72,8 +82,7 @@ The various errors returned by this module are described in the
|
|
|
72
82
|
|
|
73
83
|
Returns middleware that only parses `json` and only looks at requests where
|
|
74
84
|
the `Content-Type` header matches the `type` option. This parser accepts any
|
|
75
|
-
Unicode encoding of the body
|
|
76
|
-
`br` (brotli) and `deflate` encodings.
|
|
85
|
+
Unicode encoding of the body.
|
|
77
86
|
|
|
78
87
|
A new `body` object containing the parsed data is populated on the `request`
|
|
79
88
|
object after the middleware (i.e. `req.body`).
|
|
@@ -110,7 +119,7 @@ argument. You can find more information on this argument
|
|
|
110
119
|
|
|
111
120
|
##### strict
|
|
112
121
|
|
|
113
|
-
When set to `true`, will only accept arrays and objects; when `false
|
|
122
|
+
When set to `true`, it will only accept arrays and objects; when `false`, it will
|
|
114
123
|
accept anything `JSON.parse` accepts. Defaults to `true`.
|
|
115
124
|
|
|
116
125
|
##### type
|
|
@@ -133,9 +142,7 @@ encoding of the request. The parsing can be aborted by throwing an error.
|
|
|
133
142
|
### bodyParser.raw([options])
|
|
134
143
|
|
|
135
144
|
Returns middleware that parses all bodies as a `Buffer` and only looks at
|
|
136
|
-
requests where the `Content-Type` header matches the `type` option.
|
|
137
|
-
parser supports automatic inflation of `gzip`, `br` (brotli) and `deflate`
|
|
138
|
-
encodings.
|
|
145
|
+
requests where the `Content-Type` header matches the `type` option.
|
|
139
146
|
|
|
140
147
|
A new `body` object containing the parsed data is populated on the `request`
|
|
141
148
|
object after the middleware (i.e. `req.body`). This will be a `Buffer` object
|
|
@@ -181,9 +188,7 @@ encoding of the request. The parsing can be aborted by throwing an error.
|
|
|
181
188
|
### bodyParser.text([options])
|
|
182
189
|
|
|
183
190
|
Returns middleware that parses all bodies as a string and only looks at
|
|
184
|
-
requests where the `Content-Type` header matches the `type` option.
|
|
185
|
-
parser supports automatic inflation of `gzip`, `br` (brotli) and `deflate`
|
|
186
|
-
encodings.
|
|
191
|
+
requests where the `Content-Type` header matches the `type` option.
|
|
187
192
|
|
|
188
193
|
A new `body` string containing the parsed data is populated on the `request`
|
|
189
194
|
object after the middleware (i.e. `req.body`). This will be a string of the
|
|
@@ -234,8 +239,7 @@ encoding of the request. The parsing can be aborted by throwing an error.
|
|
|
234
239
|
|
|
235
240
|
Returns middleware that only parses `urlencoded` bodies and only looks at
|
|
236
241
|
requests where the `Content-Type` header matches the `type` option. This
|
|
237
|
-
parser accepts only UTF-8 and ISO-8859-1 encodings of the body
|
|
238
|
-
automatic inflation of `gzip`, `br` (brotli) and `deflate` encodings.
|
|
242
|
+
parser accepts only UTF-8 and ISO-8859-1 encodings of the body.
|
|
239
243
|
|
|
240
244
|
A new `body` object containing the parsed data is populated on the `request`
|
|
241
245
|
object after the middleware (i.e. `req.body`). This object will contain
|
|
@@ -346,7 +350,7 @@ the entity value that failed parsing.
|
|
|
346
350
|
### entity verify failed
|
|
347
351
|
|
|
348
352
|
This error will occur when the request contained an entity that could not be
|
|
349
|
-
|
|
353
|
+
verified by the defined `verify` option. The `status` property is
|
|
350
354
|
set to `403`, the `type` property is set to `'entity.verify.failed'`, and the
|
|
351
355
|
`body` property is set to the entity value that failed verification.
|
|
352
356
|
|
|
@@ -413,7 +417,7 @@ property is set to the encoding that is unsupported.
|
|
|
413
417
|
|
|
414
418
|
### The input exceeded the depth
|
|
415
419
|
|
|
416
|
-
This error occurs when using `bodyParser.urlencoded` with the `extended` property set to `true` and the input exceeds the configured `depth` option. The `status` property is set to `400`. It is recommended to review the `depth` option and evaluate if it requires a higher value.
|
|
420
|
+
This error occurs when using `bodyParser.urlencoded` with the `extended` property set to `true` and the input exceeds the configured `depth` option. The `status` property is set to `400`. It is recommended to review the `depth` option and evaluate if it requires a higher value. With the default `depth` of `32`, an input with 33 or more levels of nesting gets this error.
|
|
417
421
|
|
|
418
422
|
## Examples
|
|
419
423
|
|
|
@@ -17,7 +17,7 @@ const iconv = require('iconv-lite')
|
|
|
17
17
|
const onFinished = require('on-finished')
|
|
18
18
|
const zlib = require('node:zlib')
|
|
19
19
|
const hasBody = require('type-is').hasBody
|
|
20
|
-
const
|
|
20
|
+
const contentType = require('content-type')
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Module exports.
|
|
@@ -25,6 +25,12 @@ const { getCharset } = require('./utils')
|
|
|
25
25
|
|
|
26
26
|
module.exports = read
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* @const
|
|
30
|
+
* whether current node version has zstandard support
|
|
31
|
+
*/
|
|
32
|
+
const hasZstandardSupport = 'createZstdDecompress' in zlib
|
|
33
|
+
|
|
28
34
|
/**
|
|
29
35
|
* Read a request into a buffer and parse.
|
|
30
36
|
*
|
|
@@ -79,38 +85,53 @@ function read (req, res, next, parse, debug, options) {
|
|
|
79
85
|
}
|
|
80
86
|
|
|
81
87
|
let length
|
|
82
|
-
const opts = options
|
|
83
88
|
let stream
|
|
84
89
|
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
const verify = options.verify
|
|
91
|
+
|
|
92
|
+
// assert charset is supported before creating the decompression stream, so an
|
|
93
|
+
// unsupported charset cannot leave a decoder piped with no error listener
|
|
94
|
+
if (verify && encoding !== null && !iconv.encodingExists(encoding)) {
|
|
95
|
+
return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
|
|
96
|
+
charset: encoding.toLowerCase(),
|
|
97
|
+
type: 'charset.unsupported'
|
|
98
|
+
}))
|
|
99
|
+
}
|
|
87
100
|
|
|
88
101
|
try {
|
|
102
|
+
const contentEncoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
|
|
103
|
+
|
|
104
|
+
debug('content-encoding "%s"', contentEncoding)
|
|
105
|
+
|
|
106
|
+
if (options.inflate === false && contentEncoding !== 'identity') {
|
|
107
|
+
throw createError(415, 'content encoding unsupported', {
|
|
108
|
+
encoding: contentEncoding,
|
|
109
|
+
type: 'encoding.unsupported'
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
89
113
|
// get the content stream
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
114
|
+
if (contentEncoding === 'identity') {
|
|
115
|
+
length = req.headers['content-length']
|
|
116
|
+
stream = req
|
|
117
|
+
} else {
|
|
118
|
+
stream = createDecompressionStream(contentEncoding, debug)
|
|
119
|
+
req.pipe(stream)
|
|
120
|
+
}
|
|
93
121
|
} catch (err) {
|
|
94
122
|
return next(err)
|
|
95
123
|
}
|
|
96
124
|
|
|
97
125
|
// set raw-body options
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
? null
|
|
101
|
-
:
|
|
102
|
-
|
|
103
|
-
// assert charset is supported
|
|
104
|
-
if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
|
|
105
|
-
return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
|
|
106
|
-
charset: encoding.toLowerCase(),
|
|
107
|
-
type: 'charset.unsupported'
|
|
108
|
-
}))
|
|
126
|
+
const rawBodyOptions = {
|
|
127
|
+
length,
|
|
128
|
+
encoding: verify ? null : encoding,
|
|
129
|
+
limit: options.limit
|
|
109
130
|
}
|
|
110
131
|
|
|
111
132
|
// read body
|
|
112
133
|
debug('read body')
|
|
113
|
-
getBody(stream,
|
|
134
|
+
getBody(stream, rawBodyOptions, function (error, body) {
|
|
114
135
|
if (error) {
|
|
115
136
|
let _error
|
|
116
137
|
|
|
@@ -138,6 +159,17 @@ function read (req, res, next, parse, debug, options) {
|
|
|
138
159
|
return
|
|
139
160
|
}
|
|
140
161
|
|
|
162
|
+
// detach and destroy the decompression stream to
|
|
163
|
+
// avoid decompression errors on the finished stream
|
|
164
|
+
if (stream !== req) {
|
|
165
|
+
req.unpipe(stream)
|
|
166
|
+
stream.on('error', () => {})
|
|
167
|
+
stream.destroy()
|
|
168
|
+
|
|
169
|
+
// consume any remaining bytes so the HTTP request can finish
|
|
170
|
+
req.resume()
|
|
171
|
+
}
|
|
172
|
+
|
|
141
173
|
// verify
|
|
142
174
|
if (verify) {
|
|
143
175
|
try {
|
|
@@ -145,7 +177,7 @@ function read (req, res, next, parse, debug, options) {
|
|
|
145
177
|
verify(req, res, body, encoding)
|
|
146
178
|
} catch (err) {
|
|
147
179
|
next(createError(403, err, {
|
|
148
|
-
body
|
|
180
|
+
body,
|
|
149
181
|
type: err.type || 'entity.verify.failed'
|
|
150
182
|
}))
|
|
151
183
|
return
|
|
@@ -172,38 +204,6 @@ function read (req, res, next, parse, debug, options) {
|
|
|
172
204
|
})
|
|
173
205
|
}
|
|
174
206
|
|
|
175
|
-
/**
|
|
176
|
-
* Get the content stream of the request.
|
|
177
|
-
*
|
|
178
|
-
* @param {Object} req
|
|
179
|
-
* @param {Function} debug
|
|
180
|
-
* @param {boolean} inflate
|
|
181
|
-
* @returns {Object}
|
|
182
|
-
* @private
|
|
183
|
-
*/
|
|
184
|
-
function contentstream (req, debug, inflate) {
|
|
185
|
-
const encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
|
|
186
|
-
const length = req.headers['content-length']
|
|
187
|
-
|
|
188
|
-
debug('content-encoding "%s"', encoding)
|
|
189
|
-
|
|
190
|
-
if (inflate === false && encoding !== 'identity') {
|
|
191
|
-
throw createError(415, 'content encoding unsupported', {
|
|
192
|
-
encoding: encoding,
|
|
193
|
-
type: 'encoding.unsupported'
|
|
194
|
-
})
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (encoding === 'identity') {
|
|
198
|
-
req.length = length
|
|
199
|
-
return req
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const stream = createDecompressionStream(encoding, debug)
|
|
203
|
-
req.pipe(stream)
|
|
204
|
-
return stream
|
|
205
|
-
}
|
|
206
|
-
|
|
207
207
|
/**
|
|
208
208
|
* Create a decompression stream for the given encoding.
|
|
209
209
|
* @param {string} encoding
|
|
@@ -222,12 +222,16 @@ function createDecompressionStream (encoding, debug) {
|
|
|
222
222
|
case 'br':
|
|
223
223
|
debug('brotli decompress body')
|
|
224
224
|
return zlib.createBrotliDecompress()
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
225
|
+
case 'zstd':
|
|
226
|
+
if (hasZstandardSupport) {
|
|
227
|
+
debug('zstd decompress body')
|
|
228
|
+
return zlib.createZstdDecompress()
|
|
229
|
+
}
|
|
230
230
|
}
|
|
231
|
+
throw createError(415, 'unsupported content encoding "' + encoding + '"', {
|
|
232
|
+
encoding,
|
|
233
|
+
type: 'encoding.unsupported'
|
|
234
|
+
})
|
|
231
235
|
}
|
|
232
236
|
|
|
233
237
|
/**
|
|
@@ -245,3 +249,16 @@ function dump (req, callback) {
|
|
|
245
249
|
req.resume()
|
|
246
250
|
}
|
|
247
251
|
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Get the charset of a request.
|
|
255
|
+
*
|
|
256
|
+
* @param {Object} req
|
|
257
|
+
* @returns {string | undefined}
|
|
258
|
+
* @private
|
|
259
|
+
*/
|
|
260
|
+
function getCharset (req) {
|
|
261
|
+
const header = req.headers['content-type']
|
|
262
|
+
if (!header) return undefined
|
|
263
|
+
return contentType.parse(header).parameters.charset?.toLowerCase()
|
|
264
|
+
}
|
|
@@ -23,7 +23,7 @@ const { normalizeOptions } = require('../utils')
|
|
|
23
23
|
module.exports = json
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* RegExp to match the first non-
|
|
26
|
+
* RegExp to match the first non-whitespace character in a string.
|
|
27
27
|
*
|
|
28
28
|
* Allowed whitespace is defined in RFC 7159:
|
|
29
29
|
*
|
|
@@ -33,7 +33,7 @@ module.exports = json
|
|
|
33
33
|
* %x0A / ; Line feed or New line
|
|
34
34
|
* %x0D ) ; Carriage return
|
|
35
35
|
*/
|
|
36
|
-
const
|
|
36
|
+
const FIRST_NON_WHITESPACE_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d]|$)/ // eslint-disable-line no-control-regex
|
|
37
37
|
|
|
38
38
|
const JSON_SYNTAX_CHAR = '#'
|
|
39
39
|
const JSON_SYNTAX_REGEXP = /#+/g
|
|
@@ -80,10 +80,12 @@ function createJsonParser (options) {
|
|
|
80
80
|
return {}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
if (body[0] !== '{' && body[0] !== '[') {
|
|
84
|
+
const first = firstNonWhitespaceChar(body)
|
|
85
|
+
if (first !== '{' && first !== '[') {
|
|
86
|
+
debug('strict violation')
|
|
87
|
+
throw createStrictSyntaxError(body, first)
|
|
88
|
+
}
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
try {
|
|
@@ -152,12 +154,10 @@ function createStrictSyntaxError (str, char) {
|
|
|
152
154
|
* @returns {string|undefined}
|
|
153
155
|
* @private
|
|
154
156
|
*/
|
|
155
|
-
function
|
|
156
|
-
const match =
|
|
157
|
+
function firstNonWhitespaceChar (str) {
|
|
158
|
+
const match = FIRST_NON_WHITESPACE_REGEXP.exec(str)
|
|
157
159
|
|
|
158
|
-
return match
|
|
159
|
-
? match[1]
|
|
160
|
-
: undefined
|
|
160
|
+
return match && match[1] ? match[1] : undefined
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
@@ -98,12 +98,12 @@ function createQueryParser (options) {
|
|
|
98
98
|
try {
|
|
99
99
|
return qs.parse(body, {
|
|
100
100
|
allowPrototypes: true,
|
|
101
|
-
arrayLimit
|
|
102
|
-
depth
|
|
103
|
-
charsetSentinel
|
|
104
|
-
interpretNumericEntities
|
|
101
|
+
arrayLimit,
|
|
102
|
+
depth,
|
|
103
|
+
charsetSentinel,
|
|
104
|
+
interpretNumericEntities,
|
|
105
105
|
charset: encoding,
|
|
106
|
-
parameterLimit
|
|
106
|
+
parameterLimit,
|
|
107
107
|
strictDepth: true
|
|
108
108
|
})
|
|
109
109
|
} catch (err) {
|
|
@@ -5,31 +5,16 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const bytes = require('bytes')
|
|
8
|
-
const contentType = require('content-type')
|
|
9
8
|
const typeis = require('type-is')
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Module exports.
|
|
13
12
|
*/
|
|
14
13
|
module.exports = {
|
|
15
|
-
getCharset,
|
|
16
14
|
normalizeOptions,
|
|
17
15
|
passthrough
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
/**
|
|
21
|
-
* Get the charset of a request.
|
|
22
|
-
*
|
|
23
|
-
* @param {Object} req
|
|
24
|
-
* @returns {string | undefined}
|
|
25
|
-
* @private
|
|
26
|
-
*/
|
|
27
|
-
function getCharset (req) {
|
|
28
|
-
const header = req.headers['content-type']
|
|
29
|
-
if (!header) return undefined
|
|
30
|
-
return contentType.parse(header).parameters.charset?.toLowerCase()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
18
|
/**
|
|
34
19
|
* Get the simple type checker.
|
|
35
20
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "body-parser",
|
|
3
3
|
"description": "Node.js body parsing middleware",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
|
7
7
|
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
|
@@ -27,26 +27,21 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"bytes": "^3.1.2",
|
|
30
|
-
"content-type": "^2.
|
|
30
|
+
"content-type": "^2.1.0",
|
|
31
31
|
"debug": "^4.4.3",
|
|
32
32
|
"http-errors": "^2.0.1",
|
|
33
|
-
"iconv-lite": "^0.7.
|
|
33
|
+
"iconv-lite": "^0.7.3",
|
|
34
34
|
"on-finished": "^2.4.1",
|
|
35
|
-
"qs": "^6.
|
|
35
|
+
"qs": "^6.16.1",
|
|
36
36
|
"raw-body": "^3.0.2",
|
|
37
37
|
"type-is": "^2.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"eslint": "^
|
|
41
|
-
"eslint-config-standard": "^14.1.1",
|
|
42
|
-
"eslint-plugin-import": "^2.32.0",
|
|
43
|
-
"eslint-plugin-markdown": "^3.0.1",
|
|
44
|
-
"eslint-plugin-node": "^11.1.0",
|
|
45
|
-
"eslint-plugin-promise": "^6.6.0",
|
|
46
|
-
"eslint-plugin-standard": "^4.1.0",
|
|
40
|
+
"eslint": "^9.39.5",
|
|
47
41
|
"mocha": "^11.7.6",
|
|
42
|
+
"neostandard": "^0.13.0",
|
|
48
43
|
"nyc": "^17.1.0",
|
|
49
|
-
"supertest": "
|
|
44
|
+
"supertest": "7.3.0"
|
|
50
45
|
},
|
|
51
46
|
"files": [
|
|
52
47
|
"lib/",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
[](https://github.com/honojs/hono/commits/main)
|
|
18
18
|
[](https://codecov.io/github/honojs/hono)
|
|
19
19
|
[](https://discord.gg/KMh2eNSdxV)
|
|
20
|
-
[](https://deepwiki.com/honojs/hono)
|
|
21
20
|
|
|
22
21
|
Hono - _**means flame🔥 in Japanese**_ - is a small, simple, and ultrafast web framework built on Web Standards. It works on any JavaScript runtime: Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, AWS Lambda, Lambda@Edge, and Node.js.
|
|
23
22
|
|
|
@@ -63,9 +62,9 @@ The migration guide is available on [docs/MIGRATION.md](docs/MIGRATION.md).
|
|
|
63
62
|
Contributions Welcome! You can contribute in the following ways.
|
|
64
63
|
|
|
65
64
|
- Create an Issue - Propose a new feature. Report a bug.
|
|
66
|
-
-
|
|
67
|
-
- Create third-party middleware - See [Third-party middleware](docs/CONTRIBUTING.md#third-party-middleware).
|
|
65
|
+
- Build middleware and libraries - Grow the Hono ecosystem.
|
|
68
66
|
- Share - Share your thoughts on the Blog, X, and others.
|
|
67
|
+
- Sponsor - Support the maintainers through GitHub Sponsors: [@yusukebe](https://github.com/sponsors/yusukebe) and [@usualoma](https://github.com/sponsors/usualoma).
|
|
69
68
|
- Make your application - Please try to use Hono.
|
|
70
69
|
|
|
71
70
|
For more details, see [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md).
|
|
@@ -46,7 +46,11 @@ const isValidKeyframeName = (name) => isValidClassName(name) && !RESERVED_KEYFRA
|
|
|
46
46
|
const defaultOnInvalidSlug = (slug) => {
|
|
47
47
|
console.warn(`Invalid slug: ${slug}`);
|
|
48
48
|
};
|
|
49
|
-
const cssStringReStr = [
|
|
49
|
+
const cssStringReStr = [
|
|
50
|
+
"\"(?:(?:\\\\[\\s\\S]|[^\"\\\\])*)\"",
|
|
51
|
+
"'(?:(?:\\\\[\\s\\S]|[^'\\\\])*)'",
|
|
52
|
+
"url\\(\\s*[^)\"'\\s]*\\s*\\)"
|
|
53
|
+
].join("|");
|
|
50
54
|
const minifyCssRe = new RegExp([
|
|
51
55
|
"(" + cssStringReStr + ")",
|
|
52
56
|
"(?:" + [
|
|
@@ -56,11 +60,12 @@ const minifyCssRe = new RegExp([
|
|
|
56
60
|
"\\s+$"
|
|
57
61
|
].join("|") + ")",
|
|
58
62
|
"\\s*;\\s*(}|$)\\s*",
|
|
59
|
-
"\\s*([{}
|
|
63
|
+
"\\s*([{};,])\\s*",
|
|
64
|
+
"(:)\\s*",
|
|
60
65
|
"(\\s)\\s+"
|
|
61
66
|
].join("|"), "g");
|
|
62
67
|
const minify = (css) => {
|
|
63
|
-
return css.replace(minifyCssRe, (_, $1, $2, $3, $4) => $1 || $2 || $3 || $4 || "");
|
|
68
|
+
return css.replace(minifyCssRe, (_, $1, $2, $3, $4, $5) => $1 || $2 || $3 || $4 || $5 || "");
|
|
64
69
|
};
|
|
65
70
|
const buildStyleString = (strings, values) => {
|
|
66
71
|
const selectors = [];
|