@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
|
@@ -21,7 +21,7 @@ const createCssContext = ({ id, classNameSlug, onInvalidSlug }) => {
|
|
|
21
21
|
const [cssJsxDomObject, StyleRenderToDom] = require_jsx_dom_css.createCssJsxDomObjects({ id });
|
|
22
22
|
const contextMap = /* @__PURE__ */ new WeakMap();
|
|
23
23
|
const nonceMap = /* @__PURE__ */ new WeakMap();
|
|
24
|
-
const replaceStyleRe = new RegExp(`(<style id="${id}"(?: nonce="[^"]*")?>.*?)(</style>)
|
|
24
|
+
const replaceStyleRe = new RegExp(`(<style id="${id}"(?: nonce="[^"]*")?>.*?)(</style>)`, "s");
|
|
25
25
|
const newCssClassNameObject = (cssClassName) => {
|
|
26
26
|
const appendStyle = ({ buffer, context }) => {
|
|
27
27
|
const [toAdd, added] = contextMap.get(context);
|
|
@@ -111,7 +111,9 @@ const basePath = (c, index) => {
|
|
|
111
111
|
const pattern = require_utils_url.getPattern(paths[i], paths[i + 1]);
|
|
112
112
|
if (pattern) {
|
|
113
113
|
const re = pattern[2] === true || pattern === "*" ? /[^\/]+/ : pattern[2];
|
|
114
|
-
|
|
114
|
+
const restPath = reqPath.substring(basePathLength + 1);
|
|
115
|
+
const segment = restPath.split("/", 1)[0];
|
|
116
|
+
basePathLength += (restPath.match(re)?.[0] ?? (re.test(segment) ? segment : "")).length;
|
|
115
117
|
} else basePathLength += paths[i].length;
|
|
116
118
|
basePathLength += 1;
|
|
117
119
|
}
|
|
@@ -240,7 +240,7 @@ const cloneElement = (element, props, ...children) => {
|
|
|
240
240
|
if (children.length > 0) childrenToClone = children;
|
|
241
241
|
else {
|
|
242
242
|
const c = element.props.children;
|
|
243
|
-
childrenToClone = Array.isArray(c) ? c : [c];
|
|
243
|
+
childrenToClone = c !== void 0 ? Array.isArray(c) ? c : [c] : [];
|
|
244
244
|
}
|
|
245
245
|
return jsx(element.tag, {
|
|
246
246
|
...element.props,
|
|
@@ -53,6 +53,14 @@ const bearerAuth = (options) => {
|
|
|
53
53
|
const wwwAuthenticateHeaderValue = typeof wwwAuthenticateHeader === "function" ? await wwwAuthenticateHeader(c) : wwwAuthenticateHeader;
|
|
54
54
|
const headers = { "WWW-Authenticate": typeof wwwAuthenticateHeaderValue === "string" ? wwwAuthenticateHeaderValue : `${wwwAuthenticatePrefix}${Object.entries(wwwAuthenticateHeaderValue).map(([key, value]) => `${key}="${value}"`).join(",")}` };
|
|
55
55
|
const responseMessage = typeof messageOption === "function" ? await messageOption(c) : messageOption;
|
|
56
|
+
if (responseMessage instanceof Response) {
|
|
57
|
+
const resHeaders = new Headers(responseMessage.headers);
|
|
58
|
+
if (!resHeaders.has("WWW-Authenticate")) resHeaders.set("WWW-Authenticate", headers["WWW-Authenticate"]);
|
|
59
|
+
throw new require_http_exception.HTTPException(responseMessage.status, { res: new Response(responseMessage.body, {
|
|
60
|
+
status: responseMessage.status,
|
|
61
|
+
headers: resHeaders
|
|
62
|
+
}) });
|
|
63
|
+
}
|
|
56
64
|
const res = typeof responseMessage === "string" ? new Response(responseMessage, {
|
|
57
65
|
status,
|
|
58
66
|
headers
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils_url = require("../../utils/url.js");
|
|
3
|
+
const require_utils_accept = require("../../utils/accept.js");
|
|
3
4
|
const require_utils_compress = require("../../utils/compress.js");
|
|
4
5
|
const require_utils_mime = require("../../utils/mime.js");
|
|
5
6
|
const require_middleware_serve_static_path = require("./path.js");
|
|
@@ -20,6 +21,7 @@ const serveStatic = (options) => {
|
|
|
20
21
|
const join = options.join ?? require_middleware_serve_static_path.defaultJoin;
|
|
21
22
|
return async (c, next) => {
|
|
22
23
|
if (c.finalized) return next();
|
|
24
|
+
if (c.req.method !== "GET" && c.req.method !== "HEAD") return next();
|
|
23
25
|
let filename;
|
|
24
26
|
if (options.path) filename = options.path;
|
|
25
27
|
else try {
|
|
@@ -39,7 +41,7 @@ const serveStatic = (options) => {
|
|
|
39
41
|
const mimeType = options.mimes && require_utils_mime.getMimeType(path, options.mimes) || require_utils_mime.getMimeType(path);
|
|
40
42
|
c.header("Content-Type", mimeType || "application/octet-stream");
|
|
41
43
|
if (options.precompressed && (!mimeType || require_utils_compress.COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
|
|
42
|
-
const acceptEncodingSet = new Set(c.req.header("Accept-Encoding")
|
|
44
|
+
const acceptEncodingSet = new Set(require_utils_accept.parseAccept(c.req.header("Accept-Encoding") ?? "").filter((encoding) => encoding.q > 0).map((encoding) => encoding.type));
|
|
43
45
|
for (const encoding of ENCODINGS_ORDERED_KEYS) {
|
|
44
46
|
if (!acceptEncodingSet.has(encoding)) continue;
|
|
45
47
|
const compressedContent = await getContent(path + ENCODINGS[encoding], c);
|
|
@@ -98,7 +98,7 @@ var Node = class Node {
|
|
|
98
98
|
const restPathString = path.slice(partOffsets[i]);
|
|
99
99
|
const m = matcher.exec(restPathString);
|
|
100
100
|
if (m) {
|
|
101
|
-
params[name] = m[0];
|
|
101
|
+
if (!Object.hasOwn(params, name)) params[name] = m[0];
|
|
102
102
|
this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
|
|
103
103
|
if (m[0].length === restPathString.length && child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, node.#params, params);
|
|
104
104
|
for (const _ in child.#children) {
|
|
@@ -111,7 +111,7 @@ var Node = class Node {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
if (matcher === true || matcher.test(part)) {
|
|
114
|
-
params[name] = part;
|
|
114
|
+
if (!Object.hasOwn(params, name)) params[name] = part;
|
|
115
115
|
if (isLast) {
|
|
116
116
|
this.#pushHandlerSets(handlerSets, child, method, params, node.#params);
|
|
117
117
|
if (child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, params, node.#params);
|
|
@@ -154,16 +154,21 @@ const _getQueryParam = (url, key, multiple) => {
|
|
|
154
154
|
if (hashIndex !== -1) url = url.slice(0, hashIndex);
|
|
155
155
|
let encoded;
|
|
156
156
|
if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
|
|
157
|
-
|
|
157
|
+
const queryIndex = url.indexOf("?", 8);
|
|
158
|
+
let keyIndex = queryIndex;
|
|
158
159
|
if (keyIndex === -1) return;
|
|
159
160
|
if (!url.startsWith(key, keyIndex + 1)) keyIndex = url.indexOf(`&${key}`, keyIndex + 1);
|
|
160
161
|
while (keyIndex !== -1) {
|
|
161
162
|
const trailingKeyCode = url.charCodeAt(keyIndex + key.length + 1);
|
|
162
|
-
if (trailingKeyCode === 61) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
if (trailingKeyCode === 61 || trailingKeyCode === 38 || isNaN(trailingKeyCode)) {
|
|
164
|
+
if (keyIndex > queryIndex && /(?:^|&)[^=&]*[%+]/.test(url.slice(queryIndex + 1, keyIndex))) break;
|
|
165
|
+
if (trailingKeyCode === 61) {
|
|
166
|
+
const valueIndex = keyIndex + key.length + 2;
|
|
167
|
+
const endIndex = url.indexOf("&", valueIndex);
|
|
168
|
+
return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
|
|
169
|
+
}
|
|
170
|
+
return "";
|
|
171
|
+
}
|
|
167
172
|
keyIndex = url.indexOf(`&${key}`, keyIndex + 1);
|
|
168
173
|
}
|
|
169
174
|
encoded = /[%+]/.test(url);
|
|
@@ -45,7 +45,11 @@ const isValidKeyframeName = (name) => isValidClassName(name) && !RESERVED_KEYFRA
|
|
|
45
45
|
const defaultOnInvalidSlug = (slug) => {
|
|
46
46
|
console.warn(`Invalid slug: ${slug}`);
|
|
47
47
|
};
|
|
48
|
-
const cssStringReStr = [
|
|
48
|
+
const cssStringReStr = [
|
|
49
|
+
"\"(?:(?:\\\\[\\s\\S]|[^\"\\\\])*)\"",
|
|
50
|
+
"'(?:(?:\\\\[\\s\\S]|[^'\\\\])*)'",
|
|
51
|
+
"url\\(\\s*[^)\"'\\s]*\\s*\\)"
|
|
52
|
+
].join("|");
|
|
49
53
|
const minifyCssRe = new RegExp([
|
|
50
54
|
"(" + cssStringReStr + ")",
|
|
51
55
|
"(?:" + [
|
|
@@ -55,11 +59,12 @@ const minifyCssRe = new RegExp([
|
|
|
55
59
|
"\\s+$"
|
|
56
60
|
].join("|") + ")",
|
|
57
61
|
"\\s*;\\s*(}|$)\\s*",
|
|
58
|
-
"\\s*([{}
|
|
62
|
+
"\\s*([{};,])\\s*",
|
|
63
|
+
"(:)\\s*",
|
|
59
64
|
"(\\s)\\s+"
|
|
60
65
|
].join("|"), "g");
|
|
61
66
|
const minify = (css) => {
|
|
62
|
-
return css.replace(minifyCssRe, (_, $1, $2, $3, $4) => $1 || $2 || $3 || $4 || "");
|
|
67
|
+
return css.replace(minifyCssRe, (_, $1, $2, $3, $4, $5) => $1 || $2 || $3 || $4 || $5 || "");
|
|
63
68
|
};
|
|
64
69
|
const buildStyleString = (strings, values) => {
|
|
65
70
|
const selectors = [];
|
|
@@ -20,7 +20,7 @@ const createCssContext = ({ id, classNameSlug, onInvalidSlug }) => {
|
|
|
20
20
|
const [cssJsxDomObject, StyleRenderToDom] = createCssJsxDomObjects({ id });
|
|
21
21
|
const contextMap = /* @__PURE__ */ new WeakMap();
|
|
22
22
|
const nonceMap = /* @__PURE__ */ new WeakMap();
|
|
23
|
-
const replaceStyleRe = new RegExp(`(<style id="${id}"(?: nonce="[^"]*")?>.*?)(</style>)
|
|
23
|
+
const replaceStyleRe = new RegExp(`(<style id="${id}"(?: nonce="[^"]*")?>.*?)(</style>)`, "s");
|
|
24
24
|
const newCssClassNameObject = (cssClassName) => {
|
|
25
25
|
const appendStyle = ({ buffer, context }) => {
|
|
26
26
|
const [toAdd, added] = contextMap.get(context);
|
|
@@ -110,7 +110,9 @@ const basePath = (c, index) => {
|
|
|
110
110
|
const pattern = getPattern(paths[i], paths[i + 1]);
|
|
111
111
|
if (pattern) {
|
|
112
112
|
const re = pattern[2] === true || pattern === "*" ? /[^\/]+/ : pattern[2];
|
|
113
|
-
|
|
113
|
+
const restPath = reqPath.substring(basePathLength + 1);
|
|
114
|
+
const segment = restPath.split("/", 1)[0];
|
|
115
|
+
basePathLength += (restPath.match(re)?.[0] ?? (re.test(segment) ? segment : "")).length;
|
|
114
116
|
} else basePathLength += paths[i].length;
|
|
115
117
|
basePathLength += 1;
|
|
116
118
|
}
|
|
@@ -239,7 +239,7 @@ const cloneElement = (element, props, ...children) => {
|
|
|
239
239
|
if (children.length > 0) childrenToClone = children;
|
|
240
240
|
else {
|
|
241
241
|
const c = element.props.children;
|
|
242
|
-
childrenToClone = Array.isArray(c) ? c : [c];
|
|
242
|
+
childrenToClone = c !== void 0 ? Array.isArray(c) ? c : [c] : [];
|
|
243
243
|
}
|
|
244
244
|
return jsx(element.tag, {
|
|
245
245
|
...element.props,
|
|
@@ -52,6 +52,14 @@ const bearerAuth = (options) => {
|
|
|
52
52
|
const wwwAuthenticateHeaderValue = typeof wwwAuthenticateHeader === "function" ? await wwwAuthenticateHeader(c) : wwwAuthenticateHeader;
|
|
53
53
|
const headers = { "WWW-Authenticate": typeof wwwAuthenticateHeaderValue === "string" ? wwwAuthenticateHeaderValue : `${wwwAuthenticatePrefix}${Object.entries(wwwAuthenticateHeaderValue).map(([key, value]) => `${key}="${value}"`).join(",")}` };
|
|
54
54
|
const responseMessage = typeof messageOption === "function" ? await messageOption(c) : messageOption;
|
|
55
|
+
if (responseMessage instanceof Response) {
|
|
56
|
+
const resHeaders = new Headers(responseMessage.headers);
|
|
57
|
+
if (!resHeaders.has("WWW-Authenticate")) resHeaders.set("WWW-Authenticate", headers["WWW-Authenticate"]);
|
|
58
|
+
throw new HTTPException(responseMessage.status, { res: new Response(responseMessage.body, {
|
|
59
|
+
status: responseMessage.status,
|
|
60
|
+
headers: resHeaders
|
|
61
|
+
}) });
|
|
62
|
+
}
|
|
55
63
|
const res = typeof responseMessage === "string" ? new Response(responseMessage, {
|
|
56
64
|
status,
|
|
57
65
|
headers
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { tryDecodeURI } from "../../utils/url.js";
|
|
2
|
+
import { parseAccept } from "../../utils/accept.js";
|
|
2
3
|
import { COMPRESSIBLE_CONTENT_TYPE_REGEX } from "../../utils/compress.js";
|
|
3
4
|
import { getMimeType } from "../../utils/mime.js";
|
|
4
5
|
import { defaultJoin } from "./path.js";
|
|
@@ -19,6 +20,7 @@ const serveStatic = (options) => {
|
|
|
19
20
|
const join = options.join ?? defaultJoin;
|
|
20
21
|
return async (c, next) => {
|
|
21
22
|
if (c.finalized) return next();
|
|
23
|
+
if (c.req.method !== "GET" && c.req.method !== "HEAD") return next();
|
|
22
24
|
let filename;
|
|
23
25
|
if (options.path) filename = options.path;
|
|
24
26
|
else try {
|
|
@@ -38,7 +40,7 @@ const serveStatic = (options) => {
|
|
|
38
40
|
const mimeType = options.mimes && getMimeType(path, options.mimes) || getMimeType(path);
|
|
39
41
|
c.header("Content-Type", mimeType || "application/octet-stream");
|
|
40
42
|
if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
|
|
41
|
-
const acceptEncodingSet = new Set(c.req.header("Accept-Encoding")
|
|
43
|
+
const acceptEncodingSet = new Set(parseAccept(c.req.header("Accept-Encoding") ?? "").filter((encoding) => encoding.q > 0).map((encoding) => encoding.type));
|
|
42
44
|
for (const encoding of ENCODINGS_ORDERED_KEYS) {
|
|
43
45
|
if (!acceptEncodingSet.has(encoding)) continue;
|
|
44
46
|
const compressedContent = await getContent(path + ENCODINGS[encoding], c);
|
|
@@ -97,7 +97,7 @@ var Node = class Node {
|
|
|
97
97
|
const restPathString = path.slice(partOffsets[i]);
|
|
98
98
|
const m = matcher.exec(restPathString);
|
|
99
99
|
if (m) {
|
|
100
|
-
params[name] = m[0];
|
|
100
|
+
if (!Object.hasOwn(params, name)) params[name] = m[0];
|
|
101
101
|
this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
|
|
102
102
|
if (m[0].length === restPathString.length && child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, node.#params, params);
|
|
103
103
|
for (const _ in child.#children) {
|
|
@@ -110,7 +110,7 @@ var Node = class Node {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
if (matcher === true || matcher.test(part)) {
|
|
113
|
-
params[name] = part;
|
|
113
|
+
if (!Object.hasOwn(params, name)) params[name] = part;
|
|
114
114
|
if (isLast) {
|
|
115
115
|
this.#pushHandlerSets(handlerSets, child, method, params, node.#params);
|
|
116
116
|
if (child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, params, node.#params);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetConnInfo } from "../../helper/conninfo/
|
|
1
|
+
import { GetConnInfo } from "../../helper/conninfo/index.js";
|
|
2
2
|
//#region src/adapter/cloudflare-workers/conninfo.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated `hono/cloudflare-workers` will be removed in v5. Install `@hono/cloudflare-workers` and import from there instead.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetConnInfo } from "../../helper/conninfo/
|
|
1
|
+
import { GetConnInfo } from "../../helper/conninfo/index.js";
|
|
2
2
|
//#region src/adapter/lambda-edge/conninfo.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated `hono/lambda-edge` will be removed in v5. Install `@hono/lambda-edge` and import from there instead.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetConnInfo } from "../../helper/conninfo/
|
|
1
|
+
import { GetConnInfo } from "../../helper/conninfo/index.js";
|
|
2
2
|
//#region src/adapter/vercel/conninfo.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated `hono/vercel` will be removed in v5. Install `@hono/vercel` and import from there instead.
|
|
@@ -2,7 +2,8 @@ import { UnionToIntersection } from "../../utils/types.js";
|
|
|
2
2
|
import { Schema } from "../../types.js";
|
|
3
3
|
import { ExecutionContext } from "../../context.js";
|
|
4
4
|
import { Hono } from "../../hono.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ClientRequestOptions } from "../../client/index.js";
|
|
6
|
+
import { Client } from "../../client/types.js";
|
|
6
7
|
//#region src/helper/testing/index.d.ts
|
|
7
8
|
type ExtractEnv<T> = T extends Hono<infer E, Schema, string> ? E : never;
|
|
8
9
|
export declare const testClient: <T extends Hono<any, Schema, string>>(app: T, Env?: ExtractEnv<T>["Bindings"] | {}, executionCtx?: ExecutionContext, options?: Omit<ClientRequestOptions, "fetch">) => UnionToIntersection<Client<T, "http://localhost">>;
|
|
@@ -6,14 +6,6 @@ type GetPath<E extends Env> = (request: Request, options?: {
|
|
|
6
6
|
env?: E['Bindings'];
|
|
7
7
|
}) => string;
|
|
8
8
|
export type HonoOptions<E extends Env> = {
|
|
9
|
-
/**
|
|
10
|
-
* `strict` option specifies whether to distinguish whether the last path is a directory or not.
|
|
11
|
-
*
|
|
12
|
-
* @see {@link https://hono.dev/docs/api/hono#strict-mode}
|
|
13
|
-
*
|
|
14
|
-
* @default true
|
|
15
|
-
*/
|
|
16
|
-
strict?: boolean;
|
|
17
9
|
/**
|
|
18
10
|
* `router` option specifies which router to use.
|
|
19
11
|
*
|
|
@@ -25,6 +17,15 @@ export type HonoOptions<E extends Env> = {
|
|
|
25
17
|
* ```
|
|
26
18
|
*/
|
|
27
19
|
router?: Router<[H, RouterRoute]>;
|
|
20
|
+
} & ({
|
|
21
|
+
/**
|
|
22
|
+
* `strict` option specifies whether to distinguish whether the last path is a directory or not.
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://hono.dev/docs/api/hono#strict-mode}
|
|
25
|
+
*
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
strict?: true;
|
|
28
29
|
/**
|
|
29
30
|
* `getPath` can handle the host header value.
|
|
30
31
|
*
|
|
@@ -46,7 +47,18 @@ export type HonoOptions<E extends Env> = {
|
|
|
46
47
|
* ```
|
|
47
48
|
*/
|
|
48
49
|
getPath?: GetPath<E>;
|
|
49
|
-
}
|
|
50
|
+
} | {
|
|
51
|
+
/**
|
|
52
|
+
* `strict` option specifies whether to distinguish whether the last path is a directory or not.
|
|
53
|
+
* When `strict` is `false`, `getPath` is not used.
|
|
54
|
+
*
|
|
55
|
+
* @see {@link https://hono.dev/docs/api/hono#strict-mode}
|
|
56
|
+
*
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
strict: false;
|
|
60
|
+
getPath?: never;
|
|
61
|
+
});
|
|
50
62
|
type MountOptionHandler = (c: Context) => unknown;
|
|
51
63
|
type MountReplaceRequest = (originalRequest: Request) => Request;
|
|
52
64
|
type MountOptions = MountOptionHandler | {
|
|
@@ -2,5 +2,5 @@ import { Env, ErrorHandler, Handler, Input, MiddlewareHandler, Next, NotFoundHan
|
|
|
2
2
|
import { HonoRequest } from "./request.js";
|
|
3
3
|
import { Context, ContextRenderer, ContextVariableMap, ExecutionContext } from "./context.js";
|
|
4
4
|
import { Hono } from "./hono.js";
|
|
5
|
-
import { ClientRequestOptions, InferRequestType, InferResponseType } from "./client/
|
|
5
|
+
import { ClientRequestOptions, InferRequestType, InferResponseType } from "./client/index.js";
|
|
6
6
|
export { type ClientRequestOptions, Context, type ContextRenderer, type ContextVariableMap, type Env, type ErrorHandler, type ExecutionContext, type Handler, Hono, type HonoRequest, type InferRequestType, type InferResponseType, type Input, type MiddlewareHandler, type Next, type NotFoundHandler, type NotFoundResponse, type Schema, type ToSchema, type TypedResponse, type ValidationTargets };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HtmlEscapedString } from "../utils/html.js";
|
|
2
|
-
import { PropsWithChildren } from "./
|
|
3
|
-
import { Child, FC } from "./
|
|
2
|
+
import { PropsWithChildren } from "./index.js";
|
|
3
|
+
import { Child, FC } from "./index.js";
|
|
4
4
|
//#region src/jsx/components.d.ts
|
|
5
5
|
export declare const childrenToString: (children: Child[]) => Promise<HtmlEscapedString[]>;
|
|
6
6
|
export type ErrorHandler = (error: Error) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PropsWithChildren } from "./
|
|
2
|
-
import { FC } from "./
|
|
1
|
+
import { PropsWithChildren } from "./index.js";
|
|
2
|
+
import { FC } from "./index.js";
|
|
3
3
|
//#region src/jsx/context.d.ts
|
|
4
4
|
export interface Context<T> extends FC<PropsWithChildren<{
|
|
5
5
|
value: T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ErrorHandler, FallbackRender } from "../components.js";
|
|
2
|
-
import { PropsWithChildren } from "../
|
|
3
|
-
import { Child, FC } from "../
|
|
2
|
+
import { PropsWithChildren } from "../index.js";
|
|
3
|
+
import { Child, FC } from "../index.js";
|
|
4
4
|
//#region src/jsx/dom/components.d.ts
|
|
5
5
|
export declare const ErrorBoundary: FC<PropsWithChildren<{
|
|
6
6
|
fallback?: Child;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClassNameSlug, CssClassName, CssVariableType, OnInvalidSlug, rawCssString } from "../../helper/css/common.js";
|
|
2
|
-
import { PropsWithChildren } from "../
|
|
3
|
-
import { FC } from "../
|
|
2
|
+
import { PropsWithChildren } from "../index.js";
|
|
3
|
+
import { FC } from "../index.js";
|
|
4
4
|
//#region src/jsx/dom/css.d.ts
|
|
5
5
|
interface CreateCssJsxDomObjectsType {
|
|
6
6
|
(args: {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { HtmlEscapedString } from "../utils/html.js";
|
|
2
|
-
import { PropsWithChildren } from "./
|
|
3
|
-
import { Context } from "./
|
|
4
|
-
import { FC
|
|
2
|
+
import { PropsWithChildren } from "./index.js";
|
|
3
|
+
import { Context } from "./index.js";
|
|
4
|
+
import { FC } from "./index.js";
|
|
5
|
+
import { JSXNode } from "./base.js";
|
|
5
6
|
//#region src/jsx/streaming.d.ts
|
|
6
7
|
/**
|
|
7
8
|
* Used to specify nonce for scripts generated by `Suspense` and `ErrorBoundary`.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Env, MiddlewareHandler } from "../../types.js";
|
|
2
2
|
import { Context } from "../../context.js";
|
|
3
3
|
//#region src/middleware/bearer-auth/index.d.ts
|
|
4
|
-
type
|
|
4
|
+
type MessageValue = string | object | Response;
|
|
5
|
+
type MessageFunction = (c: Context) => MessageValue | Promise<MessageValue>;
|
|
5
6
|
type CustomizedErrorResponseOptions = {
|
|
6
7
|
wwwAuthenticateHeader?: string | object | MessageFunction;
|
|
7
8
|
message?: string | object | MessageFunction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MiddlewareHandler } from "../../
|
|
2
|
-
import { Context } from "../../
|
|
3
|
-
import { AddressType, GetConnInfo } from "../../helper/conninfo/
|
|
1
|
+
import { MiddlewareHandler } from "../../index.js";
|
|
2
|
+
import { Context } from "../../index.js";
|
|
3
|
+
import { AddressType, GetConnInfo } from "../../helper/conninfo/index.js";
|
|
4
4
|
//#region src/middleware/ip-restriction/index.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Function to get IP Address
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Env, Input, MiddlewareHandler } from "../../types.js";
|
|
2
2
|
import { Context, PropsForRenderer } from "../../context.js";
|
|
3
|
-
import { PropsWithChildren } from "../../jsx/
|
|
4
|
-
import { Context as Context$1 } from "../../jsx/
|
|
5
|
-
import { FC } from "../../jsx/
|
|
3
|
+
import { PropsWithChildren } from "../../jsx/index.js";
|
|
4
|
+
import { Context as Context$1 } from "../../jsx/index.js";
|
|
5
|
+
import { FC } from "../../jsx/index.js";
|
|
6
6
|
//#region src/middleware/jsx-renderer/index.d.ts
|
|
7
7
|
export declare const RequestContext: Context$1<Context<any, any, {}> | null>;
|
|
8
8
|
type RendererOptions = {
|
|
@@ -153,16 +153,21 @@ const _getQueryParam = (url, key, multiple) => {
|
|
|
153
153
|
if (hashIndex !== -1) url = url.slice(0, hashIndex);
|
|
154
154
|
let encoded;
|
|
155
155
|
if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
|
|
156
|
-
|
|
156
|
+
const queryIndex = url.indexOf("?", 8);
|
|
157
|
+
let keyIndex = queryIndex;
|
|
157
158
|
if (keyIndex === -1) return;
|
|
158
159
|
if (!url.startsWith(key, keyIndex + 1)) keyIndex = url.indexOf(`&${key}`, keyIndex + 1);
|
|
159
160
|
while (keyIndex !== -1) {
|
|
160
161
|
const trailingKeyCode = url.charCodeAt(keyIndex + key.length + 1);
|
|
161
|
-
if (trailingKeyCode === 61) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
if (trailingKeyCode === 61 || trailingKeyCode === 38 || isNaN(trailingKeyCode)) {
|
|
163
|
+
if (keyIndex > queryIndex && /(?:^|&)[^=&]*[%+]/.test(url.slice(queryIndex + 1, keyIndex))) break;
|
|
164
|
+
if (trailingKeyCode === 61) {
|
|
165
|
+
const valueIndex = keyIndex + key.length + 2;
|
|
166
|
+
const endIndex = url.indexOf("&", valueIndex);
|
|
167
|
+
return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
|
|
168
|
+
}
|
|
169
|
+
return "";
|
|
170
|
+
}
|
|
166
171
|
keyIndex = url.indexOf(`&${key}`, keyIndex + 1);
|
|
167
172
|
}
|
|
168
173
|
encoded = /[%+]/.test(url);
|
|
@@ -145,10 +145,10 @@ function stringToPaddedHex(numberString) {
|
|
|
145
145
|
*/
|
|
146
146
|
function testBit(binaryValue, position) {
|
|
147
147
|
const { length } = binaryValue;
|
|
148
|
-
if (position
|
|
148
|
+
if (position >= length) {
|
|
149
149
|
return false;
|
|
150
150
|
}
|
|
151
|
-
const positionInString = length - position;
|
|
151
|
+
const positionInString = length - position - 1;
|
|
152
152
|
return binaryValue.substring(positionInString, positionInString + 1) === '1';
|
|
153
153
|
}
|
|
154
154
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";;AAkBA,gCAMC;AAmBD,wCAUC;AAiBD,kDAmBC;AAMD,oCAqBC;AAED,8BAYC;AAOD,oDAkBC;AAOD,0CAeC;AAED,8CAEC;AAED,8CAEC;AAMD,0BASC;AAtMD,mDAA+C;AAM/C;;;;;;;;;GASG;AACH,SAAgB,UAAU,CAA4B,OAA4B;IAChF,IAAI,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACzC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,c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GAAG,WAAW,CAAC;IAE/B,IAAI,QAAQ,GAAG,MAAM,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC3C,OAAO,WAAW,CAAC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;AAC/E,CAAC","sourcesContent":["import { Address4 } from './ipv4';\nimport { Address6 } from './ipv6';\nimport { AddressError } from './address-error';\n\nexport interface ReverseFormOptions {\n omitSuffix?: boolean;\n}\n\n/**\n * Returns whether this address's *network* is contained within `address`,\n * i.e. whether every address this one can represent also falls inside\n * `address`. A network wider than `address` is not contained in it, so\n * `10.0.0.0/8` is not in `10.0.0.0/16`.\n *\n * To ask whether the address itself falls inside a range, ignoring any CIDR\n * suffix it was written with, use {@link isHostInSubnet} instead. That is the\n * question the special-use classifiers ask.\n */\nexport function isInSubnet(this: Address4 | Address6, address: Address4 | Address6) {\n if (this.subnetMask < address.subnetMask) {\n return false;\n }\n\n return isHostInSubnet.call(this, address);\n}\n\n/**\n * Returns whether this address's host bits fall inside `address`, ignoring\n * this address's own subnet mask.\n *\n * This is the primitive the special-use classifiers (`isLoopback`,\n * `isPrivate`, `isLinkLocal`, `getType`, …) are built on: they answer a\n * question about the address, so the answer must not change with the CIDR\n * suffix the caller happened to write. Use this rather than\n * {@link isInSubnet} when classifying a single address — notably when the\n * address came from untrusted input and the result backs a trust-boundary\n * decision such as an SSRF allow/deny filter.\n *\n * An address of one family is never inside a network of the other, so an\n * `Address4` against an `Address6` (or the reverse) is `false`. To compare\n * across families, convert first: `Address6.fromAddress4()`, `to4()`, or\n * `toAddress4Nat64()`.\n */\nexport function isHostInSubnet(this: Address4 | Address6, address: Address4 | Address6) {\n // mask() is a bit string of the family's width, and the leading bits of a\n // 32-bit string can coincide with those of a 128-bit one (a00::1 and\n // 10.0.0.0/8 both mask to 00001010), so the widths must agree before the\n // strings are compared.\n if (this.binaryZeroPad().length !== address.binaryZeroPad().length) {\n return false;\n }\n\n return this.mask(address.subnetMask) === address.mask();\n}\n\n/**\n * One parsed row of an IANA special-purpose address registry: the block, and\n * whether the registry marks it globally reachable (`null` when the column is\n * blank, in which case the containing block answers).\n */\nexport interface SpecialPurposeEntry<A extends Address4 | Address6> {\n subnet: A;\n reachable: boolean | null;\n}\n\n/**\n * Returns whether the registry marks this address globally reachable: the\n * answer of the most specific entry containing it that has one, or `true`\n * when no entry contains it.\n */\nexport function isGloballyReachable<A extends Address4 | Address6>(\n this: A,\n entries: ReadonlyArray<SpecialPurposeEntry<A>>,\n): boolean {\n let best: SpecialPurposeEntry<A> | null = null;\n\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n\n if (\n entry.reachable !== null &&\n isHostInSubnet.call(this, entry.subnet) &&\n (best === null || entry.subnet.subnetMask > best.subnet.subnetMask)\n ) {\n best = entry;\n }\n }\n\n return best === null ? true : (best.reachable as boolean);\n}\n\n/**\n * Adds `n` to `value` and returns the result, throwing `AddressError` unless\n * `n` is an integer and the result stays within `[0, 2**bits - 1]`.\n */\nexport function offsetBigInt(\n value: bigint,\n n: number | bigint,\n bits: number,\n family: string,\n): bigint {\n if (typeof n === 'number' && !Number.isSafeInteger(n)) {\n throw new AddressError(`${family} offset must be an integer`);\n }\n\n if (typeof n !== 'number' && typeof n !== 'bigint') {\n throw new AddressError(`${family} offset must be an integer`);\n }\n\n const result = value + BigInt(n);\n\n if (result < BigInt(0) || result > (BigInt(1) << BigInt(bits)) - BigInt(1)) {\n throw new AddressError(`${family} offset leaves the address space`);\n }\n\n return result;\n}\n\nexport function isCorrect(defaultBits: number) {\n return function isCorrectForm(this: Address4 | Address6) {\n if (this.addressMinusSuffix !== this.correctForm()) {\n return false;\n }\n\n if (this.subnetMask === defaultBits && !this.parsedSubnet) {\n return true;\n }\n\n return this.parsedSubnet === String(this.subnetMask);\n };\n}\n\n/**\n * Returns the prefix length (number of leading 1 bits) of a contiguous\n * subnet mask. Throws `AddressError` if the mask is non-contiguous (e.g.\n * `255.0.255.0`).\n */\nexport function prefixLengthFromMask(value: bigint, totalBits: number): number {\n const binary = value.toString(2).padStart(totalBits, '0');\n\n if (binary.length > totalBits) {\n throw new AddressError('Invalid subnet mask.');\n }\n\n const firstZero = binary.indexOf('0');\n\n if (firstZero === -1) {\n return totalBits;\n }\n\n if (binary.slice(firstZero).includes('1')) {\n throw new AddressError('Invalid subnet mask.');\n }\n\n return firstZero;\n}\n\n/**\n * Throws `AddressError` unless `bytes` holds exactly `byteCount` integers,\n * each from `minimum` to 255. Pass a `minimum` of `-128` where signed bytes\n * are accepted and folded to unsigned, and `0` where they are not.\n */\nexport function assertByteArray(\n bytes: number[],\n byteCount: number,\n family: 'IPv4' | 'IPv6',\n minimum: number,\n): void {\n if (bytes.length !== byteCount) {\n throw new AddressError(`${family} addresses require exactly ${byteCount} bytes`);\n }\n\n for (let i = 0; i < bytes.length; i++) {\n if (!Number.isInteger(bytes[i]) || bytes[i] < minimum || bytes[i] > 255) {\n throw new AddressError(`All bytes must be integers between ${minimum} and 255`);\n }\n }\n}\n\nexport function numberToPaddedHex(number: number) {\n return number.toString(16).padStart(2, '0');\n}\n\nexport function stringToPaddedHex(numberString: string) {\n return numberToPaddedHex(parseInt(numberString, 10));\n}\n\n/**\n * @param binaryValue Binary representation of a value (e.g. `10`)\n * @param position Byte position, where 0 is the least significant bit\n */\nexport function testBit(binaryValue: string, position: number): boolean {\n const { length } = binaryValue;\n\n if (position > length) {\n return false;\n }\n\n const positionInString = length - position;\n return binaryValue.substring(positionInString, positionInString + 1) === '1';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";;AAkBA,gCAMC;AAmBD,wCAUC;AAiBD,kDAmBC;AAMD,oCAqBC;AAED,8BAYC;AAOD,oDAkBC;AAOD,0CAeC;AAED,8CAEC;AAED,8CAEC;AAMD,0BASC;AAtMD,mDAA+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CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,SAAgB,iBAAiB,CAAC,YAAoB;IACpD,OAAO,iBAAiB,CAAC,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,WAAmB,EAAE,QAAgB;IAC3D,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC;IAE/B,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,CAAC,CAAC;IAC/C,OAAO,WAAW,CAAC,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;AAC/E,CAAC","sourcesContent":["import { Address4 } from './ipv4';\nimport { Address6 } from './ipv6';\nimport { AddressError } from './address-error';\n\nexport interface ReverseFormOptions {\n omitSuffix?: boolean;\n}\n\n/**\n * Returns whether this address's *network* is contained within `address`,\n * i.e. whether every address this one can represent also falls inside\n * `address`. A network wider than `address` is not contained in it, so\n * `10.0.0.0/8` is not in `10.0.0.0/16`.\n *\n * To ask whether the address itself falls inside a range, ignoring any CIDR\n * suffix it was written with, use {@link isHostInSubnet} instead. That is the\n * question the special-use classifiers ask.\n */\nexport function isInSubnet(this: Address4 | Address6, address: Address4 | Address6) {\n if (this.subnetMask < address.subnetMask) {\n return false;\n }\n\n return isHostInSubnet.call(this, address);\n}\n\n/**\n * Returns whether this address's host bits fall inside `address`, ignoring\n * this address's own subnet mask.\n *\n * This is the primitive the special-use classifiers (`isLoopback`,\n * `isPrivate`, `isLinkLocal`, `getType`, …) are built on: they answer a\n * question about the address, so the answer must not change with the CIDR\n * suffix the caller happened to write. Use this rather than\n * {@link isInSubnet} when classifying a single address — notably when the\n * address came from untrusted input and the result backs a trust-boundary\n * decision such as an SSRF allow/deny filter.\n *\n * An address of one family is never inside a network of the other, so an\n * `Address4` against an `Address6` (or the reverse) is `false`. To compare\n * across families, convert first: `Address6.fromAddress4()`, `to4()`, or\n * `toAddress4Nat64()`.\n */\nexport function isHostInSubnet(this: Address4 | Address6, address: Address4 | Address6) {\n // mask() is a bit string of the family's width, and the leading bits of a\n // 32-bit string can coincide with those of a 128-bit one (a00::1 and\n // 10.0.0.0/8 both mask to 00001010), so the widths must agree before the\n // strings are compared.\n if (this.binaryZeroPad().length !== address.binaryZeroPad().length) {\n return false;\n }\n\n return this.mask(address.subnetMask) === address.mask();\n}\n\n/**\n * One parsed row of an IANA special-purpose address registry: the block, and\n * whether the registry marks it globally reachable (`null` when the column is\n * blank, in which case the containing block answers).\n */\nexport interface SpecialPurposeEntry<A extends Address4 | Address6> {\n subnet: A;\n reachable: boolean | null;\n}\n\n/**\n * Returns whether the registry marks this address globally reachable: the\n * answer of the most specific entry containing it that has one, or `true`\n * when no entry contains it.\n */\nexport function isGloballyReachable<A extends Address4 | Address6>(\n this: A,\n entries: ReadonlyArray<SpecialPurposeEntry<A>>,\n): boolean {\n let best: SpecialPurposeEntry<A> | null = null;\n\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n\n if (\n entry.reachable !== null &&\n isHostInSubnet.call(this, entry.subnet) &&\n (best === null || entry.subnet.subnetMask > best.subnet.subnetMask)\n ) {\n best = entry;\n }\n }\n\n return best === null ? true : (best.reachable as boolean);\n}\n\n/**\n * Adds `n` to `value` and returns the result, throwing `AddressError` unless\n * `n` is an integer and the result stays within `[0, 2**bits - 1]`.\n */\nexport function offsetBigInt(\n value: bigint,\n n: number | bigint,\n bits: number,\n family: string,\n): bigint {\n if (typeof n === 'number' && !Number.isSafeInteger(n)) {\n throw new AddressError(`${family} offset must be an integer`);\n }\n\n if (typeof n !== 'number' && typeof n !== 'bigint') {\n throw new AddressError(`${family} offset must be an integer`);\n }\n\n const result = value + BigInt(n);\n\n if (result < BigInt(0) || result > (BigInt(1) << BigInt(bits)) - BigInt(1)) {\n throw new AddressError(`${family} offset leaves the address space`);\n }\n\n return result;\n}\n\nexport function isCorrect(defaultBits: number) {\n return function isCorrectForm(this: Address4 | Address6) {\n if (this.addressMinusSuffix !== this.correctForm()) {\n return false;\n }\n\n if (this.subnetMask === defaultBits && !this.parsedSubnet) {\n return true;\n }\n\n return this.parsedSubnet === String(this.subnetMask);\n };\n}\n\n/**\n * Returns the prefix length (number of leading 1 bits) of a contiguous\n * subnet mask. Throws `AddressError` if the mask is non-contiguous (e.g.\n * `255.0.255.0`).\n */\nexport function prefixLengthFromMask(value: bigint, totalBits: number): number {\n const binary = value.toString(2).padStart(totalBits, '0');\n\n if (binary.length > totalBits) {\n throw new AddressError('Invalid subnet mask.');\n }\n\n const firstZero = binary.indexOf('0');\n\n if (firstZero === -1) {\n return totalBits;\n }\n\n if (binary.slice(firstZero).includes('1')) {\n throw new AddressError('Invalid subnet mask.');\n }\n\n return firstZero;\n}\n\n/**\n * Throws `AddressError` unless `bytes` holds exactly `byteCount` integers,\n * each from `minimum` to 255. Pass a `minimum` of `-128` where signed bytes\n * are accepted and folded to unsigned, and `0` where they are not.\n */\nexport function assertByteArray(\n bytes: number[],\n byteCount: number,\n family: 'IPv4' | 'IPv6',\n minimum: number,\n): void {\n if (bytes.length !== byteCount) {\n throw new AddressError(`${family} addresses require exactly ${byteCount} bytes`);\n }\n\n for (let i = 0; i < bytes.length; i++) {\n if (!Number.isInteger(bytes[i]) || bytes[i] < minimum || bytes[i] > 255) {\n throw new AddressError(`All bytes must be integers between ${minimum} and 255`);\n }\n }\n}\n\nexport function numberToPaddedHex(number: number) {\n return number.toString(16).padStart(2, '0');\n}\n\nexport function stringToPaddedHex(numberString: string) {\n return numberToPaddedHex(parseInt(numberString, 10));\n}\n\n/**\n * @param binaryValue Binary representation of a value (e.g. `10`)\n * @param position Byte position, where 0 is the least significant bit\n */\nexport function testBit(binaryValue: string, position: number): boolean {\n const { length } = binaryValue;\n\n if (position >= length) {\n return false;\n }\n\n const positionInString = length - position - 1;\n return binaryValue.substring(positionInString, positionInString + 1) === '1';\n}\n"]}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"bigint",
|
|
17
17
|
"browser"
|
|
18
18
|
],
|
|
19
|
-
"version": "10.7.
|
|
19
|
+
"version": "10.7.5",
|
|
20
20
|
"author": "Beau Gunderson <beau@beaugunderson.com> (https://beaugunderson.com/)",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"main": "dist/ip-address.js",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"eslint-plugin-import": "^2.32.0",
|
|
81
81
|
"eslint-plugin-prettier": "^5.5.5",
|
|
82
82
|
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
|
|
83
|
-
"mocha": "^
|
|
83
|
+
"mocha": "^12.0.3",
|
|
84
84
|
"monocart-coverage-reports": "^2.12.11",
|
|
85
85
|
"prettier": "^3.8.3",
|
|
86
86
|
"source-map-support": "^0.5.21",
|