@psnext/slingcli 3.0.20260811-3 → 3.0.20260820-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/dist-types/submodules/client/util-endpoints/lib/aws/partitions.d.ts +54 -54
- package/node_modules/@aws-sdk/core/dist-types/submodules/client/util-user-agent-browser/defaultUserAgent.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/client/util-user-agent-browser/defaultUserAgent.native.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/submodules/client/util-user-agent-node/defaultUserAgent.d.ts +1 -1
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partitions.d.ts +54 -54
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.d.ts +1 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.native.d.ts +1 -4
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/util-user-agent-node/defaultUserAgent.d.ts +1 -4
- package/node_modules/@aws-sdk/core/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-env/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-cjs/index.js +9 -2
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +9 -2
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +1 -1
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-handler.d.ts +1 -1
- package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/package.json +5 -13
- 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/runtimeConfig.browser.d.ts +42 -42
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.d.ts +42 -42
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.native.d.ts +41 -41
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.shared.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.browser.d.ts +43 -43
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.d.ts +43 -43
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.native.d.ts +42 -42
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.shared.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.browser.d.ts +42 -42
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.d.ts +42 -42
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.native.d.ts +41 -41
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.shared.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.browser.d.ts +42 -42
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.d.ts +42 -42
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.native.d.ts +41 -41
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.shared.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.browser.d.ts +44 -44
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.d.ts +35 -35
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.native.d.ts +43 -43
- package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.shared.d.ts +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.browser.d.ts +64 -66
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.d.ts +65 -65
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.native.d.ts +68 -70
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.shared.d.ts +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.browser.d.ts +67 -69
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.d.ts +66 -66
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.native.d.ts +71 -73
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.shared.d.ts +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.browser.d.ts +64 -66
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.d.ts +65 -65
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.native.d.ts +68 -70
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.shared.d.ts +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.browser.d.ts +64 -66
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.d.ts +65 -65
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.native.d.ts +68 -70
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.shared.d.ts +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.browser.d.ts +68 -70
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.d.ts +68 -68
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.native.d.ts +72 -74
- package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.shared.d.ts +3 -3
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-cjs/index.js +9 -2
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +9 -2
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-handler.d.ts +1 -1
- package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/package.json +5 -13
- package/node_modules/@aws-sdk/nested-clients/package.json +5 -5
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +3 -3
- package/node_modules/@aws-sdk/types/package.json +2 -2
- package/node_modules/@aws-sdk/util-locate-window/package.json +27 -27
- package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +4 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@hono/node-server/dist/index.cjs +151 -9
- package/node_modules/@hono/node-server/dist/index.mjs +151 -9
- package/node_modules/@hono/node-server/package.json +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +1 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +23 -23
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +23 -23
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +17 -13
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +0 -10
- package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +1 -2
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +4 -4
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js +19 -19
- package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +3 -4
- package/node_modules/@smithy/core/dist-es/submodules/protocols/middleware-content-length/contentLengthMiddleware.js +6 -4
- package/node_modules/@smithy/core/dist-es/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.js +8 -5
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js +0 -2
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js +0 -2
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/OperationSchema.js +0 -2
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +0 -2
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js +0 -2
- package/node_modules/@smithy/core/dist-types/submodules/client/smithy-client/extensions/defaultExtensionConfiguration.d.ts +1 -7
- package/node_modules/@smithy/core/dist-types/submodules/config/config-resolver/regionConfig/checkRegion.d.ts +2 -1
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/evaluateCondition.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/evaluateConditions.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/evaluateExpression.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/evaluateRules.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/getEndpointProperties.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/submodules/endpoints/util-endpoints/utils/getReferenceValue.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/submodules/event-streams/EventStreamSerde.d.ts +14 -2
- package/node_modules/@smithy/core/dist-types/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +7 -2
- package/node_modules/@smithy/core/dist-types/submodules/retry/util-retry/retries-2026-config.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/submodules/schema/TypeRegistry.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/serde/parse-utils.d.ts +5 -5
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/client/smithy-client/extensions/defaultExtensionConfiguration.d.ts +1 -7
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/config/config-resolver/regionConfig/checkRegion.d.ts +2 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/evaluateCondition.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/evaluateConditions.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/evaluateExpression.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/evaluateRules.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/getEndpointProperties.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/util-endpoints/utils/getReferenceValue.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/event-streams/EventStreamSerde.d.ts +14 -2
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +7 -2
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/retry/util-retry/retries-2026-config.d.ts +2 -2
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/TypeRegistry.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/serde/parse-utils.d.ts +5 -5
- package/node_modules/@smithy/core/package.json +3 -11
- package/node_modules/@smithy/credential-provider-imds/package.json +4 -12
- package/node_modules/@smithy/fetch-http-handler/package.json +5 -13
- package/node_modules/@smithy/signature-v4/dist-cjs/index.js +9 -9
- package/node_modules/@smithy/signature-v4/dist-es/HeaderFormatter.js +9 -9
- package/node_modules/@smithy/signature-v4/package.json +4 -12
- package/node_modules/@smithy/types/dist-types/schema/sentinels.d.ts +14 -14
- package/node_modules/@smithy/types/package.json +29 -39
- package/node_modules/body-parser/node_modules/content-type/README.md +2 -0
- package/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/body-parser/node_modules/content-type/package.json +1 -1
- package/node_modules/gaxios/build/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/node_modules/gaxios/build/esm/tsconfig.tsbuildinfo +1 -1
- package/node_modules/gaxios/package.json +3 -3
- package/node_modules/hono/dist/cjs/client/client.js +3 -3
- package/node_modules/hono/dist/cjs/client/utils.js +1 -1
- package/node_modules/hono/dist/cjs/context.js +4 -0
- package/node_modules/hono/dist/cjs/jsx/intrinsic-element/components.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +16 -13
- package/node_modules/hono/dist/cjs/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/etag/digest.js +47 -1
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/cjs/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/cjs/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +43 -67
- package/node_modules/hono/dist/cjs/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/cjs/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/cjs/utils/url.js +2 -2
- package/node_modules/hono/dist/client/client.js +3 -3
- package/node_modules/hono/dist/client/utils.js +1 -1
- package/node_modules/hono/dist/context.js +4 -0
- package/node_modules/hono/dist/jsx/intrinsic-element/components.js +1 -1
- package/node_modules/hono/dist/middleware/cors/index.js +16 -13
- package/node_modules/hono/dist/middleware/csrf/index.js +1 -1
- package/node_modules/hono/dist/middleware/etag/digest.js +47 -1
- package/node_modules/hono/dist/middleware/etag/index.js +2 -2
- package/node_modules/hono/dist/middleware/pretty-json/index.js +3 -1
- package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
- package/node_modules/hono/dist/router/linear-router/router.js +7 -2
- package/node_modules/hono/dist/router/pattern-router/router.js +3 -9
- package/node_modules/hono/dist/router/trie-router/node.js +43 -67
- package/node_modules/hono/dist/router/trie-router/router.js +3 -11
- package/node_modules/hono/dist/types/context.d.ts +4 -0
- package/node_modules/hono/dist/types/middleware/secure-headers/permissions-policy.d.ts +3 -3
- package/node_modules/hono/dist/types/router/trie-router/node.d.ts +1 -2
- package/node_modules/hono/dist/types/router/trie-router/router.d.ts +0 -1
- package/node_modules/hono/dist/utils/ipaddr.js +5 -3
- package/node_modules/hono/dist/utils/url.js +2 -2
- package/node_modules/hono/package.json +1 -1
- package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -3
- package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +4 -3
- package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +4 -3
- package/node_modules/jose/dist/types/jwt/encrypt.d.ts +4 -3
- package/node_modules/jose/dist/types/types.d.ts +4 -2
- package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +7 -3
- package/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +6 -2
- package/node_modules/jose/package.json +1 -1
- package/node_modules/type-is/node_modules/content-type/README.md +2 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
- package/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
- package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
- package/node_modules/type-is/node_modules/content-type/package.json +1 -1
- package/package.json +2 -2
- package/slingshot/index.js +295 -279
|
@@ -20,12 +20,14 @@ __export(pretty_json_exports, {
|
|
|
20
20
|
prettyJSON: () => prettyJSON
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(pretty_json_exports);
|
|
23
|
+
const jsonContentTypeRegex = /^application\/(?:[a-z0-9._-]+\+)?json(?=$|[;\s])/i;
|
|
23
24
|
const prettyJSON = (options) => {
|
|
24
25
|
const targetQuery = options?.query ?? "pretty";
|
|
25
26
|
return async function prettyJSON2(c, next) {
|
|
26
27
|
const pretty = options?.force || c.req.query(targetQuery) || c.req.query(targetQuery) === "";
|
|
27
28
|
await next();
|
|
28
|
-
|
|
29
|
+
const contentType = c.res.headers.get("Content-Type");
|
|
30
|
+
if (pretty && contentType && jsonContentTypeRegex.test(contentType)) {
|
|
29
31
|
const obj = await c.res.json();
|
|
30
32
|
c.res = new Response(JSON.stringify(obj, null, options?.space ?? 2), c.res);
|
|
31
33
|
}
|
|
@@ -159,14 +159,17 @@ function getPermissionsPolicyDirectives(policy) {
|
|
|
159
159
|
return Object.entries(policy).map(([directive, value]) => {
|
|
160
160
|
const kebabDirective = camelToKebab(directive);
|
|
161
161
|
if (typeof value === "boolean") {
|
|
162
|
-
return `${kebabDirective}=${value ? "*" : "
|
|
162
|
+
return `${kebabDirective}=${value ? "*" : "()"}`;
|
|
163
163
|
}
|
|
164
164
|
if (Array.isArray(value)) {
|
|
165
165
|
if (value.length === 0) {
|
|
166
166
|
return `${kebabDirective}=()`;
|
|
167
167
|
}
|
|
168
|
-
if (value.length === 1 &&
|
|
169
|
-
return `${kebabDirective}
|
|
168
|
+
if (value.length === 1 && value[0] === "*") {
|
|
169
|
+
return `${kebabDirective}=*`;
|
|
170
|
+
}
|
|
171
|
+
if (value.length === 1 && value[0] === "none") {
|
|
172
|
+
return `${kebabDirective}=()`;
|
|
170
173
|
}
|
|
171
174
|
const allowlist = value.map((item) => ["self", "src"].includes(item) ? item : `"${item}"`);
|
|
172
175
|
return `${kebabDirective}=(${allowlist.join(" ")})`;
|
|
@@ -50,7 +50,8 @@ class LinearRouter {
|
|
|
50
50
|
}
|
|
51
51
|
} else if (hasStar && !hasLabel) {
|
|
52
52
|
const endsWithStar = routePath.charCodeAt(routePath.length - 1) === 42;
|
|
53
|
-
const
|
|
53
|
+
const endsWithSlashStar = routePath.endsWith("/*");
|
|
54
|
+
const parts = (endsWithStar ? routePath.slice(0, endsWithSlashStar ? -2 : -1) : routePath).split(splitByStarRe);
|
|
54
55
|
const lastIndex = parts.length - 1;
|
|
55
56
|
for (let j = 0, pos = 0, len2 = parts.length; j < len2; j++) {
|
|
56
57
|
const part = parts[j];
|
|
@@ -60,7 +61,11 @@ class LinearRouter {
|
|
|
60
61
|
}
|
|
61
62
|
pos += part.length;
|
|
62
63
|
if (j === lastIndex) {
|
|
63
|
-
if (
|
|
64
|
+
if (endsWithSlashStar) {
|
|
65
|
+
if (pos !== path.length && path.charCodeAt(pos) !== 47) {
|
|
66
|
+
continue ROUTES_LOOP;
|
|
67
|
+
}
|
|
68
|
+
} else if (!endsWithStar && pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) {
|
|
64
69
|
continue ROUTES_LOOP;
|
|
65
70
|
}
|
|
66
71
|
} else {
|
|
@@ -26,10 +26,8 @@ class PatternRouter {
|
|
|
26
26
|
name = "PatternRouter";
|
|
27
27
|
#routes = [];
|
|
28
28
|
add(method, path, handler) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
path = path.slice(0, -2);
|
|
32
|
-
}
|
|
29
|
+
const suffix = path.endsWith("/*") ? "(?:$|/)" : path.endsWith("*") ? "" : "/?$";
|
|
30
|
+
path = path.replace(/\*$/, "");
|
|
33
31
|
if (path.at(-1) === "?") {
|
|
34
32
|
path = path.slice(0, -1);
|
|
35
33
|
this.add(method, path.replace(/\/[^/]+$/, ""), handler);
|
|
@@ -41,11 +39,7 @@ class PatternRouter {
|
|
|
41
39
|
}
|
|
42
40
|
);
|
|
43
41
|
try {
|
|
44
|
-
this.#routes.push([
|
|
45
|
-
new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`),
|
|
46
|
-
method,
|
|
47
|
-
handler
|
|
48
|
-
]);
|
|
42
|
+
this.#routes.push([new RegExp(`^${parts.join("")}${suffix}`), method, handler]);
|
|
49
43
|
} catch {
|
|
50
44
|
throw new import_router.UnsupportedPathError();
|
|
51
45
|
}
|
|
@@ -23,76 +23,51 @@ module.exports = __toCommonJS(node_exports);
|
|
|
23
23
|
var import_router = require("../../router");
|
|
24
24
|
var import_url = require("../../utils/url");
|
|
25
25
|
const emptyParams = /* @__PURE__ */ Object.create(null);
|
|
26
|
-
|
|
27
|
-
for (const _ in children) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
};
|
|
26
|
+
let order = 0;
|
|
32
27
|
class Node {
|
|
33
|
-
#methods;
|
|
34
|
-
#children;
|
|
35
|
-
#patterns;
|
|
36
|
-
#
|
|
28
|
+
#methods = [];
|
|
29
|
+
#children = /* @__PURE__ */ Object.create(null);
|
|
30
|
+
#patterns = [];
|
|
31
|
+
#pattern;
|
|
37
32
|
#params = emptyParams;
|
|
38
|
-
constructor(method, handler, children) {
|
|
39
|
-
this.#children = children || /* @__PURE__ */ Object.create(null);
|
|
40
|
-
this.#methods = [];
|
|
41
|
-
if (method && handler) {
|
|
42
|
-
const m = /* @__PURE__ */ Object.create(null);
|
|
43
|
-
m[method] = { handler, possibleKeys: [], score: 0 };
|
|
44
|
-
this.#methods = [m];
|
|
45
|
-
}
|
|
46
|
-
this.#patterns = [];
|
|
47
|
-
}
|
|
48
33
|
insert(method, path, handler) {
|
|
49
|
-
this.#order = ++this.#order;
|
|
50
34
|
let curNode = this;
|
|
51
35
|
const parts = (0, import_url.splitRoutingPath)(path);
|
|
52
|
-
const possibleKeys =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const nextP = parts[i
|
|
56
|
-
const pattern = (0, import_url.getPattern)(p, nextP);
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
continue;
|
|
36
|
+
const possibleKeys = /* @__PURE__ */ new Set();
|
|
37
|
+
let i = 0;
|
|
38
|
+
for (const p of parts) {
|
|
39
|
+
const nextP = parts[++i];
|
|
40
|
+
const pattern = (0, import_url.getPattern)(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
|
|
41
|
+
const isParam = Array.isArray(pattern);
|
|
42
|
+
const key = isParam ? pattern[0] : pattern || p;
|
|
43
|
+
const child = curNode.#children[key] ||= new Node();
|
|
44
|
+
if (pattern && !child.#pattern) {
|
|
45
|
+
child.#pattern = pattern;
|
|
46
|
+
curNode.#patterns.push(child);
|
|
64
47
|
}
|
|
65
|
-
curNode
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
possibleKeys.push(pattern[1]);
|
|
48
|
+
curNode = child;
|
|
49
|
+
if (isParam) {
|
|
50
|
+
possibleKeys.add(pattern[1]);
|
|
69
51
|
}
|
|
70
|
-
curNode = curNode.#children[key];
|
|
71
52
|
}
|
|
72
53
|
curNode.#methods.push({
|
|
73
54
|
[method]: {
|
|
74
55
|
handler,
|
|
75
|
-
possibleKeys: possibleKeys
|
|
76
|
-
score:
|
|
56
|
+
possibleKeys: [...possibleKeys],
|
|
57
|
+
score: ++order
|
|
77
58
|
}
|
|
78
59
|
});
|
|
79
|
-
return curNode;
|
|
80
60
|
}
|
|
81
61
|
#pushHandlerSets(handlerSets, node, method, nodeParams, params) {
|
|
82
62
|
for (let i = 0, len = node.#methods.length; i < len; i++) {
|
|
83
63
|
const m = node.#methods[i];
|
|
84
64
|
const handlerSet = m[method] || m[import_router.METHOD_NAME_ALL];
|
|
85
|
-
|
|
86
|
-
if (handlerSet !== void 0) {
|
|
65
|
+
if (handlerSet) {
|
|
87
66
|
handlerSet.params = /* @__PURE__ */ Object.create(null);
|
|
88
67
|
handlerSets.push(handlerSet);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const processed = processedSet[handlerSet.score];
|
|
93
|
-
handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key];
|
|
94
|
-
processedSet[handlerSet.score] = true;
|
|
95
|
-
}
|
|
68
|
+
for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
|
|
69
|
+
const key = handlerSet.possibleKeys[i2];
|
|
70
|
+
handlerSet.params[key] = params?.[key] && !i2 ? params[key] : nodeParams[key] ?? params?.[key];
|
|
96
71
|
}
|
|
97
72
|
}
|
|
98
73
|
}
|
|
@@ -124,33 +99,33 @@ class Node {
|
|
|
124
99
|
tempNodes.push(nextNode);
|
|
125
100
|
}
|
|
126
101
|
}
|
|
127
|
-
for (
|
|
128
|
-
const pattern =
|
|
102
|
+
for (const child of node.#patterns) {
|
|
103
|
+
const pattern = child.#pattern;
|
|
129
104
|
const params = node.#params === emptyParams ? {} : { ...node.#params };
|
|
130
|
-
if (pattern === "
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
105
|
+
if (typeof pattern === "string") {
|
|
106
|
+
if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
|
|
107
|
+
this.#pushHandlerSets(handlerSets, child, method, node.#params);
|
|
108
|
+
if (pattern === "*") {
|
|
109
|
+
child.#params = params;
|
|
110
|
+
tempNodes.push(child);
|
|
111
|
+
}
|
|
136
112
|
}
|
|
137
113
|
continue;
|
|
138
114
|
}
|
|
139
|
-
const [
|
|
140
|
-
if (!part &&
|
|
115
|
+
const [, name, matcher] = pattern;
|
|
116
|
+
if (!part && matcher === true) {
|
|
141
117
|
continue;
|
|
142
118
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
partOffsets = new Array(len);
|
|
119
|
+
if (matcher !== true) {
|
|
120
|
+
if (!partOffsets) {
|
|
121
|
+
partOffsets = [];
|
|
147
122
|
let offset = path[0] === "/" ? 1 : 0;
|
|
148
123
|
for (let p = 0; p < len; p++) {
|
|
149
124
|
partOffsets[p] = offset;
|
|
150
125
|
offset += parts[p].length + 1;
|
|
151
126
|
}
|
|
152
127
|
}
|
|
153
|
-
const restPathString = path.
|
|
128
|
+
const restPathString = path.slice(partOffsets[i]);
|
|
154
129
|
const m = matcher.exec(restPathString);
|
|
155
130
|
if (m) {
|
|
156
131
|
params[name] = m[0];
|
|
@@ -164,11 +139,12 @@ class Node {
|
|
|
164
139
|
params
|
|
165
140
|
);
|
|
166
141
|
}
|
|
167
|
-
|
|
142
|
+
for (const _ in child.#children) {
|
|
168
143
|
child.#params = params;
|
|
169
144
|
const componentCount = m[0].match(/\//g)?.length ?? 0;
|
|
170
145
|
const targetCurNodes = curNodesQueue[componentCount] ||= [];
|
|
171
146
|
targetCurNodes.push(child);
|
|
147
|
+
break;
|
|
172
148
|
}
|
|
173
149
|
continue;
|
|
174
150
|
}
|
|
@@ -196,7 +172,7 @@ class Node {
|
|
|
196
172
|
const shifted = curNodesQueue.shift();
|
|
197
173
|
curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
|
|
198
174
|
}
|
|
199
|
-
if (handlerSets
|
|
175
|
+
if (handlerSets[1]) {
|
|
200
176
|
handlerSets.sort((a, b) => {
|
|
201
177
|
return a.score - b.score;
|
|
202
178
|
});
|
|
@@ -24,19 +24,11 @@ var import_url = require("../../utils/url");
|
|
|
24
24
|
var import_node = require("./node");
|
|
25
25
|
class TrieRouter {
|
|
26
26
|
name = "TrieRouter";
|
|
27
|
-
#node;
|
|
28
|
-
constructor() {
|
|
29
|
-
this.#node = new import_node.Node();
|
|
30
|
-
}
|
|
27
|
+
#node = new import_node.Node();
|
|
31
28
|
add(method, path, handler) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
for (let i = 0, len = results.length; i < len; i++) {
|
|
35
|
-
this.#node.insert(method, results[i], handler);
|
|
36
|
-
}
|
|
37
|
-
return;
|
|
29
|
+
for (const result of (0, import_url.checkOptionalParameter)(path) || [path]) {
|
|
30
|
+
this.#node.insert(method, result, handler);
|
|
38
31
|
}
|
|
39
|
-
this.#node.insert(method, path, handler);
|
|
40
32
|
}
|
|
41
33
|
match(method, path) {
|
|
42
34
|
return this.#node.search(method, path);
|
|
@@ -30,12 +30,14 @@ __export(ipaddr_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(ipaddr_exports);
|
|
31
31
|
const expandIPv6 = (ipV6) => {
|
|
32
32
|
const sections = ipV6.split(":");
|
|
33
|
-
|
|
33
|
+
const lastSection = sections.at(-1);
|
|
34
|
+
if (IPV4_REGEX.test(lastSection)) {
|
|
35
|
+
const octets = lastSection.split(".").map(Number);
|
|
34
36
|
sections.splice(
|
|
35
37
|
-1,
|
|
36
38
|
1,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
(octets[0] << 8 | octets[1]).toString(16),
|
|
40
|
+
(octets[2] << 8 | octets[3]).toString(16)
|
|
39
41
|
);
|
|
40
42
|
}
|
|
41
43
|
for (let i = 0; i < sections.length; i++) {
|
|
@@ -142,13 +142,13 @@ const checkOptionalParameter = (path) => {
|
|
|
142
142
|
if (segment !== "" && !/\:/.test(segment)) {
|
|
143
143
|
basePath += "/" + segment;
|
|
144
144
|
} else if (/\:/.test(segment)) {
|
|
145
|
-
if (
|
|
145
|
+
if (segment.charCodeAt(segment.length - 1) === 63) {
|
|
146
146
|
if (results.length === 0 && basePath === "") {
|
|
147
147
|
results.push("/");
|
|
148
148
|
} else {
|
|
149
149
|
results.push(basePath);
|
|
150
150
|
}
|
|
151
|
-
const optionalSegment = segment.
|
|
151
|
+
const optionalSegment = segment.slice(0, -1);
|
|
152
152
|
basePath += "/" + optionalSegment;
|
|
153
153
|
results.push(basePath);
|
|
154
154
|
} else {
|
|
@@ -60,7 +60,7 @@ var ClientRequestImpl = class {
|
|
|
60
60
|
}
|
|
61
61
|
this.rBody = form;
|
|
62
62
|
}
|
|
63
|
-
if (args.json) {
|
|
63
|
+
if (args.json !== void 0) {
|
|
64
64
|
this.rBody = JSON.stringify(args.json);
|
|
65
65
|
this.cType = "application/json";
|
|
66
66
|
}
|
|
@@ -76,9 +76,9 @@ var ClientRequestImpl = class {
|
|
|
76
76
|
if (args?.cookie) {
|
|
77
77
|
const cookies = [];
|
|
78
78
|
for (const [key, value] of Object.entries(args.cookie)) {
|
|
79
|
-
cookies.push(serialize(key, value
|
|
79
|
+
cookies.push(serialize(key, value));
|
|
80
80
|
}
|
|
81
|
-
headerValues["Cookie"] = cookies.join("
|
|
81
|
+
headerValues["Cookie"] = cookies.join("; ");
|
|
82
82
|
}
|
|
83
83
|
if (this.cType) {
|
|
84
84
|
headerValues["Content-Type"] = this.cType;
|
|
@@ -9,7 +9,7 @@ var mergePath = (base, path) => {
|
|
|
9
9
|
var replaceUrlParam = (urlString, params) => {
|
|
10
10
|
for (const [k, v] of Object.entries(params)) {
|
|
11
11
|
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
|
|
12
|
-
urlString = urlString.replace(reg, v ? `/${v}` : "");
|
|
12
|
+
urlString = urlString.replace(reg, () => v ? `/${v}` : "");
|
|
13
13
|
}
|
|
14
14
|
return urlString;
|
|
15
15
|
};
|
|
@@ -202,6 +202,10 @@ var Context = class {
|
|
|
202
202
|
* c.header('X-Message', 'Hello!')
|
|
203
203
|
* c.header('Content-Type', 'text/plain')
|
|
204
204
|
*
|
|
205
|
+
* // Append multiple headers using the append option (e.g. Vary)
|
|
206
|
+
* c.header('Vary', 'Accept-Encoding', { append: true })
|
|
207
|
+
* c.header('Vary', 'User-Agent', { append: true })
|
|
208
|
+
*
|
|
205
209
|
* return c.body('Thank you for coming')
|
|
206
210
|
* })
|
|
207
211
|
* ```
|
|
@@ -78,7 +78,7 @@ var documentMetadataTag = (tag, children, props, sort) => {
|
|
|
78
78
|
const string = new JSXNode(tag, restProps, toArray(children || [])).toString();
|
|
79
79
|
if (string instanceof Promise) {
|
|
80
80
|
return string.then(
|
|
81
|
-
(resString) => raw(
|
|
81
|
+
(resString) => raw(resString, [
|
|
82
82
|
...resString.callbacks || [],
|
|
83
83
|
insertIntoHead(tag, resString, restProps, precedence)
|
|
84
84
|
])
|
|
@@ -7,6 +7,8 @@ var cors = (options) => {
|
|
|
7
7
|
exposeHeaders: [],
|
|
8
8
|
...options
|
|
9
9
|
};
|
|
10
|
+
const exposeHeadersStr = opts.exposeHeaders?.length ? opts.exposeHeaders.join(",") : void 0;
|
|
11
|
+
const allowHeadersStr = opts.allowHeaders?.length ? opts.allowHeaders.join(",") : void 0;
|
|
10
12
|
const findAllowOrigin = ((optsOrigin) => {
|
|
11
13
|
if (typeof optsOrigin === "string") {
|
|
12
14
|
if (optsOrigin === "*") {
|
|
@@ -22,11 +24,12 @@ var cors = (options) => {
|
|
|
22
24
|
})(opts.origin);
|
|
23
25
|
const findAllowMethods = ((optsAllowMethods) => {
|
|
24
26
|
if (typeof optsAllowMethods === "function") {
|
|
25
|
-
return optsAllowMethods;
|
|
27
|
+
return async (origin, c) => (await optsAllowMethods(origin, c)).join(",");
|
|
26
28
|
} else if (Array.isArray(optsAllowMethods)) {
|
|
27
|
-
|
|
29
|
+
const methodsStr = optsAllowMethods.join(",");
|
|
30
|
+
return () => methodsStr;
|
|
28
31
|
} else {
|
|
29
|
-
return () =>
|
|
32
|
+
return () => "";
|
|
30
33
|
}
|
|
31
34
|
})(opts.allowMethods);
|
|
32
35
|
return async function cors2(c, next) {
|
|
@@ -40,29 +43,29 @@ var cors = (options) => {
|
|
|
40
43
|
if (opts.credentials) {
|
|
41
44
|
set("Access-Control-Allow-Credentials", "true");
|
|
42
45
|
}
|
|
43
|
-
if (
|
|
44
|
-
set("Access-Control-Expose-Headers",
|
|
46
|
+
if (exposeHeadersStr) {
|
|
47
|
+
set("Access-Control-Expose-Headers", exposeHeadersStr);
|
|
45
48
|
}
|
|
46
49
|
if (c.req.method === "OPTIONS") {
|
|
47
50
|
if (opts.origin !== "*") {
|
|
48
|
-
|
|
51
|
+
c.res.headers.append("Vary", "Origin");
|
|
49
52
|
}
|
|
50
53
|
if (opts.maxAge != null) {
|
|
51
54
|
set("Access-Control-Max-Age", opts.maxAge.toString());
|
|
52
55
|
}
|
|
53
56
|
const allowMethods = await findAllowMethods(c.req.header("origin") || "", c);
|
|
54
|
-
if (allowMethods
|
|
55
|
-
set("Access-Control-Allow-Methods", allowMethods
|
|
57
|
+
if (allowMethods) {
|
|
58
|
+
set("Access-Control-Allow-Methods", allowMethods);
|
|
56
59
|
}
|
|
57
|
-
let
|
|
58
|
-
if (!
|
|
60
|
+
let headersStr = allowHeadersStr;
|
|
61
|
+
if (!headersStr) {
|
|
59
62
|
const requestHeaders = c.req.header("Access-Control-Request-Headers");
|
|
60
63
|
if (requestHeaders) {
|
|
61
|
-
|
|
64
|
+
headersStr = requestHeaders.split(",").map((h) => h.trim()).join(",");
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
|
-
if (
|
|
65
|
-
set("Access-Control-Allow-Headers",
|
|
67
|
+
if (headersStr) {
|
|
68
|
+
set("Access-Control-Allow-Headers", headersStr);
|
|
66
69
|
c.res.headers.append("Vary", "Access-Control-Request-Headers");
|
|
67
70
|
}
|
|
68
71
|
c.res.headers.delete("Content-Length");
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { HTTPException } from "../../http-exception.js";
|
|
3
3
|
var secFetchSiteValues = ["same-origin", "same-site", "none", "cross-site"];
|
|
4
4
|
var isSecFetchSite = (value) => secFetchSiteValues.includes(value);
|
|
5
|
-
var isSafeMethodRe = /^(GET|HEAD)$/;
|
|
5
|
+
var isSafeMethodRe = /^(GET|HEAD|OPTIONS)$/;
|
|
6
6
|
var isRequestedByFormElementRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b/i;
|
|
7
7
|
var csrf = (options) => {
|
|
8
8
|
const originHandler = ((optsOrigin) => {
|
|
@@ -10,18 +10,64 @@ var mergeBuffers = (buffer1, buffer2) => {
|
|
|
10
10
|
merged.set(buffer2, buffer1.byteLength);
|
|
11
11
|
return merged;
|
|
12
12
|
};
|
|
13
|
+
var CHUNK_SIZE = 256 * 1024;
|
|
13
14
|
var generateDigest = async (stream, generator) => {
|
|
14
15
|
if (!stream) {
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
18
|
let result = void 0;
|
|
19
|
+
let chunk;
|
|
20
|
+
let chunkLength = 0;
|
|
21
|
+
const digest = async (body) => {
|
|
22
|
+
result = await generator(mergeBuffers(result, body));
|
|
23
|
+
};
|
|
18
24
|
const reader = stream.getReader();
|
|
19
25
|
for (; ; ) {
|
|
20
26
|
const { value, done } = await reader.read();
|
|
21
27
|
if (done) {
|
|
22
28
|
break;
|
|
23
29
|
}
|
|
24
|
-
|
|
30
|
+
let offset = 0;
|
|
31
|
+
while (offset < value.byteLength) {
|
|
32
|
+
const remaining = value.byteLength - offset;
|
|
33
|
+
if (chunkLength === 0 && remaining >= CHUNK_SIZE) {
|
|
34
|
+
await digest(value.subarray(offset, offset + CHUNK_SIZE));
|
|
35
|
+
offset += CHUNK_SIZE;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const requiredLength = chunkLength + remaining;
|
|
39
|
+
if (requiredLength < CHUNK_SIZE) {
|
|
40
|
+
if (!chunk) {
|
|
41
|
+
chunk = value.slice(offset);
|
|
42
|
+
} else {
|
|
43
|
+
if (chunk.byteLength < requiredLength) {
|
|
44
|
+
const nextChunk = new Uint8Array(
|
|
45
|
+
new ArrayBuffer(Math.min(CHUNK_SIZE, Math.max(requiredLength, chunk.byteLength * 2)))
|
|
46
|
+
);
|
|
47
|
+
nextChunk.set(chunk.subarray(0, chunkLength));
|
|
48
|
+
chunk = nextChunk;
|
|
49
|
+
}
|
|
50
|
+
chunk.set(value.subarray(offset), chunkLength);
|
|
51
|
+
}
|
|
52
|
+
chunkLength = requiredLength;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
const length = CHUNK_SIZE - chunkLength;
|
|
56
|
+
if (chunk?.byteLength !== CHUNK_SIZE) {
|
|
57
|
+
const nextChunk = new Uint8Array(new ArrayBuffer(CHUNK_SIZE));
|
|
58
|
+
if (chunk) {
|
|
59
|
+
nextChunk.set(chunk.subarray(0, chunkLength));
|
|
60
|
+
}
|
|
61
|
+
chunk = nextChunk;
|
|
62
|
+
}
|
|
63
|
+
chunk.set(value.subarray(offset, offset + length), chunkLength);
|
|
64
|
+
await digest(chunk);
|
|
65
|
+
chunkLength = 0;
|
|
66
|
+
offset += length;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (chunk && chunkLength > 0) {
|
|
70
|
+
await digest(chunk.subarray(0, chunkLength));
|
|
25
71
|
}
|
|
26
72
|
if (!result) {
|
|
27
73
|
return null;
|
|
@@ -60,11 +60,11 @@ var etag = (options) => {
|
|
|
60
60
|
ETag: etag3
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
c.res.headers.
|
|
63
|
+
for (const key of Array.from(c.res.headers.keys())) {
|
|
64
64
|
if (retainedHeaders.indexOf(key.toLowerCase()) === -1) {
|
|
65
65
|
c.res.headers.delete(key);
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|
|
68
68
|
} else {
|
|
69
69
|
c.res.headers.set("ETag", etag3);
|
|
70
70
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// src/middleware/pretty-json/index.ts
|
|
2
|
+
var jsonContentTypeRegex = /^application\/(?:[a-z0-9._-]+\+)?json(?=$|[;\s])/i;
|
|
2
3
|
var prettyJSON = (options) => {
|
|
3
4
|
const targetQuery = options?.query ?? "pretty";
|
|
4
5
|
return async function prettyJSON2(c, next) {
|
|
5
6
|
const pretty = options?.force || c.req.query(targetQuery) || c.req.query(targetQuery) === "";
|
|
6
7
|
await next();
|
|
7
|
-
|
|
8
|
+
const contentType = c.res.headers.get("Content-Type");
|
|
9
|
+
if (pretty && contentType && jsonContentTypeRegex.test(contentType)) {
|
|
8
10
|
const obj = await c.res.json();
|
|
9
11
|
c.res = new Response(JSON.stringify(obj, null, options?.space ?? 2), c.res);
|
|
10
12
|
}
|
|
@@ -137,14 +137,17 @@ function getPermissionsPolicyDirectives(policy) {
|
|
|
137
137
|
return Object.entries(policy).map(([directive, value]) => {
|
|
138
138
|
const kebabDirective = camelToKebab(directive);
|
|
139
139
|
if (typeof value === "boolean") {
|
|
140
|
-
return `${kebabDirective}=${value ? "*" : "
|
|
140
|
+
return `${kebabDirective}=${value ? "*" : "()"}`;
|
|
141
141
|
}
|
|
142
142
|
if (Array.isArray(value)) {
|
|
143
143
|
if (value.length === 0) {
|
|
144
144
|
return `${kebabDirective}=()`;
|
|
145
145
|
}
|
|
146
|
-
if (value.length === 1 &&
|
|
147
|
-
return `${kebabDirective}
|
|
146
|
+
if (value.length === 1 && value[0] === "*") {
|
|
147
|
+
return `${kebabDirective}=*`;
|
|
148
|
+
}
|
|
149
|
+
if (value.length === 1 && value[0] === "none") {
|
|
150
|
+
return `${kebabDirective}=()`;
|
|
148
151
|
}
|
|
149
152
|
const allowlist = value.map((item) => ["self", "src"].includes(item) ? item : `"${item}"`);
|
|
150
153
|
return `${kebabDirective}=(${allowlist.join(" ")})`;
|
|
@@ -29,7 +29,8 @@ var LinearRouter = class {
|
|
|
29
29
|
}
|
|
30
30
|
} else if (hasStar && !hasLabel) {
|
|
31
31
|
const endsWithStar = routePath.charCodeAt(routePath.length - 1) === 42;
|
|
32
|
-
const
|
|
32
|
+
const endsWithSlashStar = routePath.endsWith("/*");
|
|
33
|
+
const parts = (endsWithStar ? routePath.slice(0, endsWithSlashStar ? -2 : -1) : routePath).split(splitByStarRe);
|
|
33
34
|
const lastIndex = parts.length - 1;
|
|
34
35
|
for (let j = 0, pos = 0, len2 = parts.length; j < len2; j++) {
|
|
35
36
|
const part = parts[j];
|
|
@@ -39,7 +40,11 @@ var LinearRouter = class {
|
|
|
39
40
|
}
|
|
40
41
|
pos += part.length;
|
|
41
42
|
if (j === lastIndex) {
|
|
42
|
-
if (
|
|
43
|
+
if (endsWithSlashStar) {
|
|
44
|
+
if (pos !== path.length && path.charCodeAt(pos) !== 47) {
|
|
45
|
+
continue ROUTES_LOOP;
|
|
46
|
+
}
|
|
47
|
+
} else if (!endsWithStar && pos !== path.length && !(pos === path.length - 1 && path.charCodeAt(pos) === 47)) {
|
|
43
48
|
continue ROUTES_LOOP;
|
|
44
49
|
}
|
|
45
50
|
} else {
|
|
@@ -5,10 +5,8 @@ var PatternRouter = class {
|
|
|
5
5
|
name = "PatternRouter";
|
|
6
6
|
#routes = [];
|
|
7
7
|
add(method, path, handler) {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
path = path.slice(0, -2);
|
|
11
|
-
}
|
|
8
|
+
const suffix = path.endsWith("/*") ? "(?:$|/)" : path.endsWith("*") ? "" : "/?$";
|
|
9
|
+
path = path.replace(/\*$/, "");
|
|
12
10
|
if (path.at(-1) === "?") {
|
|
13
11
|
path = path.slice(0, -1);
|
|
14
12
|
this.add(method, path.replace(/\/[^/]+$/, ""), handler);
|
|
@@ -20,11 +18,7 @@ var PatternRouter = class {
|
|
|
20
18
|
}
|
|
21
19
|
);
|
|
22
20
|
try {
|
|
23
|
-
this.#routes.push([
|
|
24
|
-
new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`),
|
|
25
|
-
method,
|
|
26
|
-
handler
|
|
27
|
-
]);
|
|
21
|
+
this.#routes.push([new RegExp(`^${parts.join("")}${suffix}`), method, handler]);
|
|
28
22
|
} catch {
|
|
29
23
|
throw new UnsupportedPathError();
|
|
30
24
|
}
|