acrylblends 1.0.4 → 1.0.5
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/docs/framework/agents/index.md +6 -4
- package/lib/accept-CNNHu4Cf.js +193 -0
- package/lib/{accepts-XBuZPVRI.js → accepts-Btq83xPd.js} +1 -1
- package/lib/accepts.js +1 -1
- package/lib/acryl-base.js +1 -331
- package/lib/adapter-CaZ6FZUU.js +37 -0
- package/lib/adapter.js +1 -36
- package/lib/{app-BM0rTCp7.js → app-CQcGWjrk.js} +4 -4
- package/lib/app-base-CpRMZL4v.js +332 -0
- package/lib/{base-NSN_SNv-.js → base-D_6kfOr-.js} +1 -1
- package/lib/basic-auth-C0HTRpXh.js +20 -0
- package/lib/basic-auth-DFLflXNe.js +95 -0
- package/lib/basic-auth.js +1 -94
- package/lib/bearer-auth-Cwxt-vgS.js +94 -0
- package/lib/bearer-auth.js +1 -93
- package/lib/body-D7f4e7w_.js +94 -0
- package/lib/body-limit-WmIjWRLt.js +66 -0
- package/lib/body-limit.js +1 -65
- package/lib/buffer-CkEOJCcY.js +51 -0
- package/lib/bun.js +3 -3
- package/lib/cache-B0bHH7s5.js +169 -0
- package/lib/cache.js +1 -168
- package/lib/{client-DDLXwhBo.js → client-BrMFnMEd.js} +1 -1
- package/lib/{client-modules-CLvWOjbd.js → client-modules-drj4mjhj.js} +4 -4
- package/lib/client.js +1 -1
- package/lib/color-COa3DplO.js +37 -0
- package/lib/combine-TWuGdcbC.js +137 -0
- package/lib/combine.js +1 -136
- package/lib/{components-cEW3ovK0.js → components-B2ka9Ax1.js} +4 -4
- package/lib/{components-JXVm45kK.js → components-PVXwaOaC.js} +2 -2
- package/lib/compress-BzWqsHF1.js +79 -0
- package/lib/compress-C-9vK4B2.d.ts +11 -0
- package/lib/compress-DCyrrQ5D.js +11 -0
- package/lib/compress.d.ts +1 -1
- package/lib/compress.js +2 -78
- package/lib/concurrent-DrF3d2c-.js +30 -0
- package/lib/conninfo-BCROmdnf.d.ts +11 -0
- package/lib/conninfo-CWJwieh4.js +19 -0
- package/lib/constants-CBSEudrb.js +7 -0
- package/lib/{context-DDO0cfuP.js → context-CkOh7Ygv.js} +2 -2
- package/lib/context-storage-iuPoI_CR.js +52 -0
- package/lib/context-storage.js +1 -51
- package/lib/cookie-B1LlkzOe.js +125 -0
- package/lib/cookie-BHIduy2T.js +82 -0
- package/lib/cookie.js +1 -81
- package/lib/cordis/db-sqlite.d.ts +1 -1
- package/lib/cordis/door.d.ts +9 -1
- package/lib/cordis/door.js +39 -8
- package/lib/cordis/inspect.js +4 -4
- package/lib/cordis/kv-db.d.ts +1 -1
- package/lib/cordis/kv-db.js +1 -1
- package/lib/cordis/kv-json.d.ts +1 -1
- package/lib/cordis/kv-json.js +1 -1
- package/lib/cordis/node-server.d.ts +1 -1
- package/lib/cordis/node-server.js +3 -116
- package/lib/cordis/router-http.js +2 -2
- package/lib/cordis/router.js +4 -4
- package/lib/cordis/state.js +7 -7
- package/lib/{core-CaY8XDZ6.js → core-BOu1jYua.js} +1 -1
- package/lib/cors-CbAQ-8qU.js +106 -0
- package/lib/cors.js +1 -105
- package/lib/crypto-iVP-N-tS.js +34 -0
- package/lib/csrf-DqqOZtgy.js +101 -0
- package/lib/csrf.js +1 -100
- package/lib/css-C5CPVMvM.js +134 -0
- package/lib/css.js +2 -133
- package/lib/db/sqlite.d.ts +1 -25
- package/lib/dev-CLgu-JRe.js +50 -0
- package/lib/dev.js +1 -49
- package/lib/dom-YjND9Jt3.js +74 -0
- package/lib/door/host.js +1 -1
- package/lib/door/page.js +1 -1
- package/lib/door/protocol.js +1 -212
- package/lib/encode-BhbNLrjp.js +33 -0
- package/lib/factory-CLdSf-xS.js +30 -0
- package/lib/factory.js +1 -29
- package/lib/handler-C0wZ0KwO.js +12 -0
- package/lib/helpers-BEjcdbgw.js +5 -0
- package/lib/{hooks-w72iLeFR.js → hooks-CfC07ri0.js} +1 -1
- package/lib/html-CgNa89xw.js +31 -0
- package/lib/html-DGExBFNg.js +103 -0
- package/lib/html.d.ts +2 -5
- package/lib/html.js +2 -30
- package/lib/http-exception-MjWkT89V.js +54 -0
- package/lib/http-exception.js +1 -53
- package/lib/index-dAzQsJG9.d.ts +6 -0
- package/lib/index.js +3 -3
- package/lib/ip-restriction-jKtKCRM_.js +166 -0
- package/lib/ip-restriction.js +1 -165
- package/lib/ipaddr-DCoIo528.js +238 -0
- package/lib/jsx/dom/client.js +1 -1
- package/lib/jsx/dom/jsx-dev-runtime.js +1 -1
- package/lib/jsx/dom/jsx-runtime.js +2 -1
- package/lib/jsx/dom/server.js +3 -3
- package/lib/jsx/dom.js +5 -73
- package/lib/jsx/jsx-dev-runtime.d.ts +2 -5
- package/lib/jsx/jsx-dev-runtime.js +2 -13
- package/lib/jsx/jsx-runtime.d.ts +2 -2
- package/lib/jsx/jsx-runtime.js +4 -4
- package/lib/jsx/streaming.js +1 -1
- package/lib/jsx-CUQgttxU.js +47 -0
- package/lib/jsx-dev-runtime-B4WTyq8r.js +14 -0
- package/lib/{jsx-dev-runtime-CWLRA2F3.js → jsx-dev-runtime-BLfA-EhI.js} +2 -2
- package/lib/jsx-dev-runtime-CGt4kNYr.d.ts +6 -0
- package/lib/jsx-renderer-CfifM4hT.js +99 -0
- package/lib/jsx-renderer.js +1 -98
- package/lib/jsx-runtime-COCRWBJ9.js +2 -0
- package/lib/jsx.js +5 -46
- package/lib/{jwk-LkzeoaU8.js → jwk-CDPpYQpD.js} +3 -3
- package/lib/jwk.js +1 -1
- package/lib/{jwt-BGJBw5AF.js → jwt-BXoIA2fQ.js} +2 -2
- package/lib/{jwt-CskdhEW9.js → jwt-lyS4Q3mT.js} +3 -3
- package/lib/jwt.js +2 -2
- package/lib/kv/db.d.ts +1 -10
- package/lib/kv/db.js +1 -56
- package/lib/kv/json.d.ts +1 -9
- package/lib/kv/json.js +1 -223
- package/lib/{language-D9a4zqvn.js → language-DeGRtLJt.js} +2 -2
- package/lib/language.js +1 -1
- package/lib/{linear-router-C3FPib6h.js → linear-router-CmZn_JLV.js} +2 -2
- package/lib/logger-Ckxu8diz.js +54 -0
- package/lib/logger.js +1 -53
- package/lib/loopback-only-BbasoF7R.js +90 -0
- package/lib/loopback-only.js +1 -89
- package/lib/method-not-allowed-TO2_hnfl.js +82 -0
- package/lib/method-not-allowed.js +1 -81
- package/lib/method-override-DnZKfJbV.js +103 -0
- package/lib/method-override.js +1 -102
- package/lib/middleware-BfG_fp8P.js +12 -0
- package/lib/mime-BnScXkQn.js +77 -0
- package/lib/mount-QkK_3NtJ.js +67 -0
- package/lib/mount.js +1 -66
- package/lib/node-server/conninfo.d.ts +1 -10
- package/lib/node-server/conninfo.js +1 -18
- package/lib/node-server/register.js +25 -2
- package/lib/node-server/serve-static.d.ts +1 -17
- package/lib/node-server/serve-static.js +1 -1
- package/lib/node-server.d.ts +2 -2
- package/lib/node-server.js +4 -4
- package/lib/open-BqK4D2Wn.d.ts +11 -0
- package/lib/open-But9E2rL.js +57 -0
- package/lib/open-CULVJgOc.d.ts +12 -0
- package/lib/open-Dp4sxspc.js +224 -0
- package/lib/open-T7kgbO2O.d.ts +27 -0
- package/lib/{pattern-router-HZxjDGEQ.js → pattern-router-CJBecJBd.js} +1 -1
- package/lib/powered-by-CXQNjNIX.js +24 -0
- package/lib/powered-by.js +1 -23
- package/lib/pretty-json-CeC1yvYt.js +39 -0
- package/lib/pretty-json.js +1 -38
- package/lib/protocol-Dt0AZBOz.js +213 -0
- package/lib/proxy-C2w_mH7k.js +121 -0
- package/lib/proxy.js +1 -120
- package/lib/quick.js +4 -4
- package/lib/{reg-exp-router-DC1R3qoY.js → reg-exp-router-C_WV84eV.js} +2 -2
- package/lib/request-DvMgGtlW.js +323 -0
- package/lib/request.js +1 -322
- package/lib/route-D8m-a2I1.js +126 -0
- package/lib/route.js +1 -125
- package/lib/router/linear-router.js +1 -1
- package/lib/router/pattern-router.js +1 -1
- package/lib/router/reg-exp-router.js +1 -1
- package/lib/router/smart-router.js +1 -1
- package/lib/router/trie-router.js +1 -1
- package/lib/router-Be_o6nFu.js +35 -0
- package/lib/router.js +1 -34
- package/lib/schema-validator-EK3cUUCt.js +22 -0
- package/lib/schema-validator.js +1 -21
- package/lib/{secure-headers-mP3j6Hm6.js → secure-headers-C5ZOcXqk.js} +1 -1
- package/lib/secure-headers.js +1 -1
- package/lib/serve-static-B7sqnftW.d.ts +18 -0
- package/lib/{serve-static-3uo_9rjF.js → serve-static-C1Nkj_xB.js} +2 -2
- package/lib/{serve-static-Cp5adzGo.js → serve-static-EiJf1zkO.js} +4 -4
- package/lib/serve-static.js +1 -1
- package/lib/{smart-router-C5CZ5XSM.js → smart-router-BjxkDQCE.js} +1 -1
- package/lib/{snapshot-text-BLz8nlSc.js → snapshot-text-Bbx43mN0.js} +9 -9
- package/lib/{src-dy3Fk9tA.js → src-BTBm4OPD.js} +6 -6
- package/lib/src-LX0E4ec4.js +117 -0
- package/lib/{ssg-BwjcA-Ge.js → ssg-BEl7MHqg.js} +5 -5
- package/lib/ssg.js +1 -1
- package/lib/stream-CzM_SHkq.js +88 -0
- package/lib/{streaming-DHST3Scg.js → streaming-BlDaph8U.js} +3 -3
- package/lib/streaming.js +1 -1
- package/lib/{test-websocket-D8WWqE5G.js → test-websocket-BLeEvybj.js} +2 -2
- package/lib/testing-BQx5T_UX.js +17 -0
- package/lib/testing.js +1 -16
- package/lib/timeout-FeqZ9A-0.js +42 -0
- package/lib/timeout.js +1 -41
- package/lib/tiny.js +2 -2
- package/lib/trailing-slash-DwTx-1sk.js +85 -0
- package/lib/trailing-slash.js +1 -84
- package/lib/{trie-router-CfFbapzL.js → trie-router-JydLKUa2.js} +2 -2
- package/lib/url-BPh4d6j-.js +197 -0
- package/lib/utils/accept.js +1 -192
- package/lib/utils/basic-auth.js +1 -19
- package/lib/utils/body.js +1 -93
- package/lib/utils/buffer.js +1 -50
- package/lib/utils/color.js +1 -36
- package/lib/utils/compress.d.ts +1 -10
- package/lib/utils/compress.js +1 -10
- package/lib/utils/concurrent.js +1 -29
- package/lib/utils/constants.js +1 -6
- package/lib/utils/cookie.js +1 -124
- package/lib/utils/crypto.js +1 -33
- package/lib/utils/encode.js +1 -32
- package/lib/utils/handler.js +1 -11
- package/lib/utils/html.js +1 -102
- package/lib/utils/ipaddr.js +1 -237
- package/lib/utils/jwt.js +1 -1
- package/lib/utils/mime.js +1 -76
- package/lib/utils/stream.js +1 -87
- package/lib/utils/url.js +1 -196
- package/lib/{validator-D84mq-dO.js → validator-Btiyt5VJ.js} +3 -3
- package/lib/validator.js +1 -1
- package/lib/websocket-DsyBIKVA.js +56 -0
- package/lib/ws.js +1 -55
- package/package.json +1 -1
- package/plugins/acryl-door/src/host/chat-tools.ts +2 -0
- package/plugins/acryl-door/src/host/door.ts +19 -2
- package/plugins/acryl-door/src/index.ts +15 -2
- package/plugins/acryl-node-server/src/register.ts +29 -2
- package/plugins/agent/model.ts +6 -1
- package/plugins/agent/tools.ts +12 -2
- package/plugins/agent-panel/client/describe.ts +44 -0
- package/plugins/agent-panel/client/main.ts +4 -1
- package/plugins/agent-panel/index.ts +22 -10
- package/plugins/desktop/attach.ts +72 -0
- package/plugins/desktop/main.ts +17 -4
- package/plugins/extensions/index.ts +3 -4
- package/plugins/extensions/stage.ts +33 -5
- package/plugins/openai/index.ts +1 -1
- package/templates/agent/AGENTS.md +2 -0
- package/templates/agent/blend.yaml +4 -1
- package/templates/agent/src/app.ts +2 -0
- package/templates/agent/src/routes.ts +1 -1
- package/templates/agent/template.json +1 -0
- package/templates/agent/test/builder.test.ts +26 -21
- package/lib/helpers-CvTauQT5.js +0 -5
- package/lib/middleware-CPQ8himN.js +0 -12
package/lib/utils/compress.d.ts
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @module
|
|
4
|
-
* Constants for compression.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Match for compressible content type.
|
|
8
|
-
*/
|
|
9
|
-
declare const COMPRESSIBLE_CONTENT_TYPE_REGEX: RegExp;
|
|
10
|
-
//#endregion
|
|
1
|
+
import { t as COMPRESSIBLE_CONTENT_TYPE_REGEX } from "../compress-C-9vK4B2.js";
|
|
11
2
|
export { COMPRESSIBLE_CONTENT_TYPE_REGEX };
|
package/lib/utils/compress.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @module
|
|
4
|
-
* Constants for compression.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Match for compressible content type.
|
|
8
|
-
*/
|
|
9
|
-
const COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|msgpack|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|vnd\.msgpack|wasm|x-httpd-php|x-javascript|x-msgpack|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml|msgpack))(?:[;\s]|$)/i;
|
|
10
|
-
//#endregion
|
|
1
|
+
import { t as COMPRESSIBLE_CONTENT_TYPE_REGEX } from "../compress-DCyrrQ5D.js";
|
|
11
2
|
export { COMPRESSIBLE_CONTENT_TYPE_REGEX };
|
package/lib/utils/concurrent.js
CHANGED
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @module
|
|
4
|
-
* Concurrent utility.
|
|
5
|
-
*/
|
|
6
|
-
const DEFAULT_CONCURRENCY = 1024;
|
|
7
|
-
const createPool = ({ concurrency, interval } = {}) => {
|
|
8
|
-
concurrency ||= DEFAULT_CONCURRENCY;
|
|
9
|
-
if (concurrency === Infinity) return { run: async (fn) => fn() };
|
|
10
|
-
const pool = /* @__PURE__ */ new Set();
|
|
11
|
-
const run = async (fn, promise, resolve) => {
|
|
12
|
-
if (pool.size >= concurrency) {
|
|
13
|
-
promise ||= new Promise((r) => resolve = r);
|
|
14
|
-
setTimeout(() => run(fn, promise, resolve));
|
|
15
|
-
return promise;
|
|
16
|
-
}
|
|
17
|
-
const marker = {};
|
|
18
|
-
pool.add(marker);
|
|
19
|
-
const result = await fn();
|
|
20
|
-
if (interval) setTimeout(() => pool.delete(marker), interval);
|
|
21
|
-
else pool.delete(marker);
|
|
22
|
-
if (resolve) {
|
|
23
|
-
resolve(result);
|
|
24
|
-
return promise;
|
|
25
|
-
} else return result;
|
|
26
|
-
};
|
|
27
|
-
return { run };
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
1
|
+
import { t as createPool } from "../concurrent-DrF3d2c-.js";
|
|
30
2
|
export { createPool };
|
package/lib/utils/constants.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Constant used to mark a composed handler.
|
|
4
|
-
*/
|
|
5
|
-
const COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
6
|
-
//#endregion
|
|
1
|
+
import { t as COMPOSED_HANDLER } from "../constants-CBSEudrb.js";
|
|
7
2
|
export { COMPOSED_HANDLER };
|
package/lib/utils/cookie.js
CHANGED
|
@@ -1,125 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ../../plugins/acryl-router/src/core/utils/cookie.ts
|
|
3
|
-
/**
|
|
4
|
-
* @module
|
|
5
|
-
* Cookie utility.
|
|
6
|
-
*/
|
|
7
|
-
const algorithm = {
|
|
8
|
-
name: "HMAC",
|
|
9
|
-
hash: "SHA-256"
|
|
10
|
-
};
|
|
11
|
-
const getCryptoKey = async (secret) => {
|
|
12
|
-
const secretBuf = typeof secret === "string" ? new TextEncoder().encode(secret) : secret;
|
|
13
|
-
return await crypto.subtle.importKey("raw", secretBuf, algorithm, false, ["sign", "verify"]);
|
|
14
|
-
};
|
|
15
|
-
const makeSignature = async (value, secret) => {
|
|
16
|
-
const key = await getCryptoKey(secret);
|
|
17
|
-
const signature = await crypto.subtle.sign(algorithm.name, key, new TextEncoder().encode(value));
|
|
18
|
-
return btoa(String.fromCharCode(...new Uint8Array(signature)));
|
|
19
|
-
};
|
|
20
|
-
const verifySignature = async (base64Signature, value, secret) => {
|
|
21
|
-
try {
|
|
22
|
-
const signatureBinStr = atob(base64Signature);
|
|
23
|
-
const signature = new Uint8Array(signatureBinStr.length);
|
|
24
|
-
for (let i = 0, len = signatureBinStr.length; i < len; i++) signature[i] = signatureBinStr.charCodeAt(i);
|
|
25
|
-
return await crypto.subtle.verify(algorithm, secret, signature, new TextEncoder().encode(value));
|
|
26
|
-
} catch {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
|
|
31
|
-
const relaxedCookieNameRegEx = /^[!#-:<>-[\]-~]+$/;
|
|
32
|
-
const validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
|
|
33
|
-
const trimCookieWhitespace = (value) => {
|
|
34
|
-
let start = 0;
|
|
35
|
-
let end = value.length;
|
|
36
|
-
while (start < end) {
|
|
37
|
-
const charCode = value.charCodeAt(start);
|
|
38
|
-
if (charCode !== 32 && charCode !== 9) break;
|
|
39
|
-
start++;
|
|
40
|
-
}
|
|
41
|
-
while (end > start) {
|
|
42
|
-
const charCode = value.charCodeAt(end - 1);
|
|
43
|
-
if (charCode !== 32 && charCode !== 9) break;
|
|
44
|
-
end--;
|
|
45
|
-
}
|
|
46
|
-
return start === 0 && end === value.length ? value : value.slice(start, end);
|
|
47
|
-
};
|
|
48
|
-
const parse = (cookie, name) => {
|
|
49
|
-
if (name && cookie.indexOf(name) === -1) return {};
|
|
50
|
-
const pairs = cookie.split(";");
|
|
51
|
-
const parsedCookie = Object.create(null);
|
|
52
|
-
for (const pairStr of pairs) {
|
|
53
|
-
const valueStartPos = pairStr.indexOf("=");
|
|
54
|
-
if (valueStartPos === -1) continue;
|
|
55
|
-
const cookieName = trimCookieWhitespace(pairStr.substring(0, valueStartPos));
|
|
56
|
-
if (name && name !== cookieName || !relaxedCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) continue;
|
|
57
|
-
let cookieValue = trimCookieWhitespace(pairStr.substring(valueStartPos + 1));
|
|
58
|
-
if (cookieValue.startsWith("\"") && cookieValue.endsWith("\"")) cookieValue = cookieValue.slice(1, -1);
|
|
59
|
-
if (validCookieValueRegEx.test(cookieValue)) {
|
|
60
|
-
parsedCookie[cookieName] = tryDecodeURIComponent(cookieValue);
|
|
61
|
-
if (name) break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return parsedCookie;
|
|
65
|
-
};
|
|
66
|
-
const parseSigned = async (cookie, secret, name) => {
|
|
67
|
-
const parsedCookie = Object.create(null);
|
|
68
|
-
const secretKey = await getCryptoKey(secret);
|
|
69
|
-
for (const [key, value] of Object.entries(parse(cookie, name))) {
|
|
70
|
-
const signatureStartPos = value.lastIndexOf(".");
|
|
71
|
-
if (signatureStartPos < 0) continue;
|
|
72
|
-
const signedValue = value.substring(0, signatureStartPos);
|
|
73
|
-
const signature = value.substring(signatureStartPos + 1);
|
|
74
|
-
if (signature.length !== 44 || !signature.endsWith("=")) continue;
|
|
75
|
-
parsedCookie[key] = await verifySignature(signature, signedValue, secretKey) ? signedValue : false;
|
|
76
|
-
}
|
|
77
|
-
return parsedCookie;
|
|
78
|
-
};
|
|
79
|
-
const _serialize = (name, value, opt = {}) => {
|
|
80
|
-
if (!validCookieNameRegEx.test(name)) throw new Error("Invalid cookie name");
|
|
81
|
-
let cookie = `${name}=${value}`;
|
|
82
|
-
if (name.startsWith("__Secure-") && !opt.secure) throw new Error("__Secure- Cookie must have Secure attributes");
|
|
83
|
-
if (name.startsWith("__Host-")) {
|
|
84
|
-
if (!opt.secure) throw new Error("__Host- Cookie must have Secure attributes");
|
|
85
|
-
if (opt.path !== "/") throw new Error("__Host- Cookie must have Path attributes with \"/\"");
|
|
86
|
-
if (opt.domain) throw new Error("__Host- Cookie must not have Domain attributes");
|
|
87
|
-
}
|
|
88
|
-
for (const key of [
|
|
89
|
-
"domain",
|
|
90
|
-
"path",
|
|
91
|
-
"sameSite",
|
|
92
|
-
"priority"
|
|
93
|
-
]) if (opt[key] && /[;\r\n]/.test(opt[key])) throw new Error(`${key} must not contain ";", "\\r", or "\\n"`);
|
|
94
|
-
if (opt && typeof opt.maxAge === "number" && opt.maxAge >= 0) {
|
|
95
|
-
if (opt.maxAge > 3456e4) throw new Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");
|
|
96
|
-
cookie += `; Max-Age=${opt.maxAge | 0}`;
|
|
97
|
-
}
|
|
98
|
-
if (opt.domain && opt.prefix !== "host") cookie += `; Domain=${opt.domain}`;
|
|
99
|
-
if (opt.path) cookie += `; Path=${opt.path}`;
|
|
100
|
-
if (opt.expires) {
|
|
101
|
-
if (opt.expires.getTime() - Date.now() > 3456e7) throw new Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");
|
|
102
|
-
cookie += `; Expires=${opt.expires.toUTCString()}`;
|
|
103
|
-
}
|
|
104
|
-
if (opt.httpOnly) cookie += "; HttpOnly";
|
|
105
|
-
if (opt.secure) cookie += "; Secure";
|
|
106
|
-
if (opt.sameSite) cookie += `; SameSite=${opt.sameSite.charAt(0).toUpperCase() + opt.sameSite.slice(1)}`;
|
|
107
|
-
if (opt.priority) cookie += `; Priority=${opt.priority.charAt(0).toUpperCase() + opt.priority.slice(1)}`;
|
|
108
|
-
if (opt.partitioned) {
|
|
109
|
-
if (!opt.secure) throw new Error("Partitioned Cookie must have Secure attributes");
|
|
110
|
-
cookie += "; Partitioned";
|
|
111
|
-
}
|
|
112
|
-
return cookie;
|
|
113
|
-
};
|
|
114
|
-
const serialize = (name, value, opt) => {
|
|
115
|
-
value = encodeURIComponent(value);
|
|
116
|
-
return _serialize(name, value, opt);
|
|
117
|
-
};
|
|
118
|
-
const serializeSigned = async (name, value, secret, opt = {}) => {
|
|
119
|
-
const signature = await makeSignature(value, secret);
|
|
120
|
-
value = `${value}.${signature}`;
|
|
121
|
-
value = encodeURIComponent(value);
|
|
122
|
-
return _serialize(name, value, opt);
|
|
123
|
-
};
|
|
124
|
-
//#endregion
|
|
1
|
+
import { i as serializeSigned, n as parseSigned, r as serialize, t as parse } from "../cookie-B1LlkzOe.js";
|
|
125
2
|
export { parse, parseSigned, serialize, serializeSigned };
|
package/lib/utils/crypto.js
CHANGED
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
const sha256 = async (data) => {
|
|
3
|
-
return await createHash(data, {
|
|
4
|
-
name: "SHA-256",
|
|
5
|
-
alias: "sha256"
|
|
6
|
-
});
|
|
7
|
-
};
|
|
8
|
-
const sha1 = async (data) => {
|
|
9
|
-
return await createHash(data, {
|
|
10
|
-
name: "SHA-1",
|
|
11
|
-
alias: "sha1"
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
const md5 = async (data) => {
|
|
15
|
-
return await createHash(data, {
|
|
16
|
-
name: "MD5",
|
|
17
|
-
alias: "md5"
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
const createHash = async (data, algorithm) => {
|
|
21
|
-
let sourceBuffer;
|
|
22
|
-
if (ArrayBuffer.isView(data) || data instanceof ArrayBuffer) sourceBuffer = data;
|
|
23
|
-
else {
|
|
24
|
-
if (typeof data === "object") data = JSON.stringify(data);
|
|
25
|
-
sourceBuffer = new TextEncoder().encode(String(data));
|
|
26
|
-
}
|
|
27
|
-
if (crypto && crypto.subtle) {
|
|
28
|
-
const buffer = await crypto.subtle.digest({ name: algorithm.name }, sourceBuffer);
|
|
29
|
-
return Array.prototype.map.call(new Uint8Array(buffer), (x) => ("00" + x.toString(16)).slice(-2)).join("");
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
};
|
|
33
|
-
//#endregion
|
|
1
|
+
import { i as sha256, n as md5, r as sha1, t as createHash } from "../crypto-iVP-N-tS.js";
|
|
34
2
|
export { createHash, md5, sha1, sha256 };
|
package/lib/utils/encode.js
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @module
|
|
4
|
-
* Encode utility.
|
|
5
|
-
*/
|
|
6
|
-
const decodeBase64Url = (str) => {
|
|
7
|
-
return decodeBase64(str.replace(/_|-/g, (m) => ({
|
|
8
|
-
_: "/",
|
|
9
|
-
"-": "+"
|
|
10
|
-
})[m] ?? m));
|
|
11
|
-
};
|
|
12
|
-
const encodeBase64Url = (buf) => encodeBase64(buf).replace(/\/|\+/g, (m) => ({
|
|
13
|
-
"/": "_",
|
|
14
|
-
"+": "-"
|
|
15
|
-
})[m] ?? m);
|
|
16
|
-
const encodeBase64 = (buf) => {
|
|
17
|
-
let binary = "";
|
|
18
|
-
const bytes = new Uint8Array(buf);
|
|
19
|
-
for (let i = 0, len = bytes.length; i < len; i++) binary += String.fromCharCode(bytes[i]);
|
|
20
|
-
return btoa(binary);
|
|
21
|
-
};
|
|
22
|
-
const decodeBase64 = (str) => {
|
|
23
|
-
const binary = atob(str);
|
|
24
|
-
const bytes = new Uint8Array(new ArrayBuffer(binary.length));
|
|
25
|
-
const half = binary.length / 2;
|
|
26
|
-
for (let i = 0, j = binary.length - 1; i <= half; i++, j--) {
|
|
27
|
-
bytes[i] = binary.charCodeAt(i);
|
|
28
|
-
bytes[j] = binary.charCodeAt(j);
|
|
29
|
-
}
|
|
30
|
-
return bytes;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
1
|
+
import { i as encodeBase64Url, n as decodeBase64Url, r as encodeBase64, t as decodeBase64 } from "../encode-BhbNLrjp.js";
|
|
33
2
|
export { decodeBase64, decodeBase64Url, encodeBase64, encodeBase64Url };
|
package/lib/utils/handler.js
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ../../plugins/acryl-router/src/core/utils/handler.ts
|
|
3
|
-
/**
|
|
4
|
-
* @module
|
|
5
|
-
* Handler utility.
|
|
6
|
-
*/
|
|
7
|
-
const isMiddleware = (handler) => handler.length > 1;
|
|
8
|
-
const findTargetHandler = (handler) => {
|
|
9
|
-
return handler["__COMPOSED_HANDLER"] ? findTargetHandler(handler[COMPOSED_HANDLER]) : handler;
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
1
|
+
import { n as isMiddleware, t as findTargetHandler } from "../handler-C0wZ0KwO.js";
|
|
12
2
|
export { findTargetHandler, isMiddleware };
|
package/lib/utils/html.js
CHANGED
|
@@ -1,103 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @module
|
|
4
|
-
* HTML utility.
|
|
5
|
-
*/
|
|
6
|
-
const HtmlEscapedCallbackPhase = {
|
|
7
|
-
Stringify: 1,
|
|
8
|
-
BeforeStream: 2,
|
|
9
|
-
Stream: 3
|
|
10
|
-
};
|
|
11
|
-
const raw = (value, callbacks) => {
|
|
12
|
-
const escapedString = new String(value);
|
|
13
|
-
escapedString.isEscaped = true;
|
|
14
|
-
escapedString.callbacks = callbacks;
|
|
15
|
-
return escapedString;
|
|
16
|
-
};
|
|
17
|
-
const escapeRe = /[&<>'"]/;
|
|
18
|
-
const stringBufferToString = async (buffer, callbacks) => {
|
|
19
|
-
let str = "";
|
|
20
|
-
callbacks ||= [];
|
|
21
|
-
const resolvedBuffer = await Promise.all(buffer);
|
|
22
|
-
for (let i = resolvedBuffer.length - 1;; i--) {
|
|
23
|
-
str += resolvedBuffer[i];
|
|
24
|
-
i--;
|
|
25
|
-
if (i < 0) break;
|
|
26
|
-
let r = resolvedBuffer[i];
|
|
27
|
-
if (typeof r === "object") callbacks.push(...r.callbacks || []);
|
|
28
|
-
const isEscaped = r.isEscaped;
|
|
29
|
-
r = await (typeof r === "object" ? r.toString() : r);
|
|
30
|
-
if (typeof r === "object") callbacks.push(...r.callbacks || []);
|
|
31
|
-
if (r.isEscaped ?? isEscaped) str += r;
|
|
32
|
-
else {
|
|
33
|
-
const buf = [str];
|
|
34
|
-
escapeToBuffer(r, buf);
|
|
35
|
-
str = buf[0];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return raw(str, callbacks);
|
|
39
|
-
};
|
|
40
|
-
const escapeToBuffer = (str, buffer) => {
|
|
41
|
-
const match = str.search(escapeRe);
|
|
42
|
-
if (match === -1) {
|
|
43
|
-
buffer[0] += str;
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
let escape;
|
|
47
|
-
let index;
|
|
48
|
-
let lastIndex = 0;
|
|
49
|
-
for (index = match; index < str.length; index++) {
|
|
50
|
-
switch (str.charCodeAt(index)) {
|
|
51
|
-
case 34:
|
|
52
|
-
escape = """;
|
|
53
|
-
break;
|
|
54
|
-
case 39:
|
|
55
|
-
escape = "'";
|
|
56
|
-
break;
|
|
57
|
-
case 38:
|
|
58
|
-
escape = "&";
|
|
59
|
-
break;
|
|
60
|
-
case 60:
|
|
61
|
-
escape = "<";
|
|
62
|
-
break;
|
|
63
|
-
case 62:
|
|
64
|
-
escape = ">";
|
|
65
|
-
break;
|
|
66
|
-
default: continue;
|
|
67
|
-
}
|
|
68
|
-
buffer[0] += str.substring(lastIndex, index) + escape;
|
|
69
|
-
lastIndex = index + 1;
|
|
70
|
-
}
|
|
71
|
-
buffer[0] += str.substring(lastIndex, index);
|
|
72
|
-
};
|
|
73
|
-
const resolveCallbackSync = (str) => {
|
|
74
|
-
const callbacks = str.callbacks;
|
|
75
|
-
if (!callbacks?.length) return str;
|
|
76
|
-
const buffer = [str];
|
|
77
|
-
const context = {};
|
|
78
|
-
callbacks.forEach((c) => c({
|
|
79
|
-
phase: HtmlEscapedCallbackPhase.Stringify,
|
|
80
|
-
buffer,
|
|
81
|
-
context
|
|
82
|
-
}));
|
|
83
|
-
return buffer[0];
|
|
84
|
-
};
|
|
85
|
-
const resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
|
|
86
|
-
if (typeof str === "object" && !(str instanceof String)) {
|
|
87
|
-
if (!(str instanceof Promise)) str = str.toString();
|
|
88
|
-
if (str instanceof Promise) str = await str;
|
|
89
|
-
}
|
|
90
|
-
const callbacks = str.callbacks;
|
|
91
|
-
if (!callbacks?.length) return Promise.resolve(str);
|
|
92
|
-
if (buffer) buffer[0] += str;
|
|
93
|
-
else buffer = [str];
|
|
94
|
-
const resStr = Promise.all(callbacks.map((c) => c({
|
|
95
|
-
phase,
|
|
96
|
-
buffer,
|
|
97
|
-
context
|
|
98
|
-
}))).then((res) => Promise.all(res.filter(Boolean).map((str) => resolveCallback(str, phase, false, context, buffer))).then(() => buffer[0]));
|
|
99
|
-
if (preserveCallbacks) return raw(await resStr, callbacks);
|
|
100
|
-
else return resStr;
|
|
101
|
-
};
|
|
102
|
-
//#endregion
|
|
1
|
+
import { a as resolveCallbackSync, i as resolveCallback, n as escapeToBuffer, o as stringBufferToString, r as raw, t as HtmlEscapedCallbackPhase } from "../html-DGExBFNg.js";
|
|
103
2
|
export { HtmlEscapedCallbackPhase, escapeToBuffer, raw, resolveCallback, resolveCallbackSync, stringBufferToString };
|
package/lib/utils/ipaddr.js
CHANGED
|
@@ -1,238 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Expand IPv6 Address
|
|
4
|
-
* @param ipV6 Shorten IPv6 Address
|
|
5
|
-
* @return expanded IPv6 Address
|
|
6
|
-
*/
|
|
7
|
-
const expandIPv6 = (ipV6) => {
|
|
8
|
-
const sections = ipV6.split(":");
|
|
9
|
-
const lastSection = sections.at(-1);
|
|
10
|
-
if (IPV4_REGEX.test(lastSection)) {
|
|
11
|
-
const octets = lastSection.split(".").map(Number);
|
|
12
|
-
sections.splice(-1, 1, (octets[0] << 8 | octets[1]).toString(16), (octets[2] << 8 | octets[3]).toString(16));
|
|
13
|
-
}
|
|
14
|
-
for (let i = 0; i < sections.length; i++) {
|
|
15
|
-
const node = sections[i];
|
|
16
|
-
if (node !== "") sections[i] = node.padStart(4, "0");
|
|
17
|
-
else {
|
|
18
|
-
while (sections[i + 1] === "") sections.splice(i + 1, 1);
|
|
19
|
-
sections[i] = new Array(8 - sections.length + 1).fill("0000").join(":");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return sections.join(":");
|
|
23
|
-
};
|
|
24
|
-
const IPV4_OCTET_PART = "(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])";
|
|
25
|
-
const IPV4_REGEX = new RegExp(`^(?:${IPV4_OCTET_PART}\\.){3}${IPV4_OCTET_PART}$`);
|
|
26
|
-
const INVALID_IP_ADDRESS_ERROR_CODE = "ERR_INVALID_IP_ADDRESS";
|
|
27
|
-
const CHAR_CODE_0 = 48;
|
|
28
|
-
const CHAR_CODE_9 = 57;
|
|
29
|
-
const CHAR_CODE_A = 65;
|
|
30
|
-
const CHAR_CODE_F = 70;
|
|
31
|
-
const CHAR_CODE_a = 97;
|
|
32
|
-
const CHAR_CODE_f = 102;
|
|
33
|
-
const CHAR_CODE_DOT = 46;
|
|
34
|
-
const CHAR_CODE_COLON = 58;
|
|
35
|
-
const CHAR_CODE_PERCENT = 37;
|
|
36
|
-
/**
|
|
37
|
-
* Distinct Remote Addr
|
|
38
|
-
* @param remoteAddr Remote Addr
|
|
39
|
-
*/
|
|
40
|
-
const distinctRemoteAddr = (remoteAddr) => {
|
|
41
|
-
if (IPV4_REGEX.test(remoteAddr)) return "IPv4";
|
|
42
|
-
if (remoteAddr.includes(":")) return "IPv6";
|
|
43
|
-
};
|
|
44
|
-
const createInvalidIPAddressError = (message) => {
|
|
45
|
-
const error = new TypeError(message);
|
|
46
|
-
error.code = INVALID_IP_ADDRESS_ERROR_CODE;
|
|
47
|
-
return error;
|
|
48
|
-
};
|
|
49
|
-
const throwInvalidIPv4Address = (ipv4) => {
|
|
50
|
-
throw createInvalidIPAddressError(`Invalid IPv4 address: ${ipv4}`);
|
|
51
|
-
};
|
|
52
|
-
const throwInvalidIPv6Address = (ipv6) => {
|
|
53
|
-
throw createInvalidIPAddressError(`Invalid IPv6 address: ${ipv6}`);
|
|
54
|
-
};
|
|
55
|
-
const parseIPv4ToBinary = (ipv4, start, end, onInvalid) => {
|
|
56
|
-
let result = 0n;
|
|
57
|
-
let octets = 0;
|
|
58
|
-
let octet = 0;
|
|
59
|
-
let digits = 0;
|
|
60
|
-
let firstDigit = 0;
|
|
61
|
-
for (let i = start; i <= end; i++) {
|
|
62
|
-
const code = i < end ? ipv4.charCodeAt(i) : CHAR_CODE_DOT;
|
|
63
|
-
if (code >= CHAR_CODE_0 && code <= CHAR_CODE_9) {
|
|
64
|
-
if (digits === 0) firstDigit = code;
|
|
65
|
-
else if (firstDigit === CHAR_CODE_0) onInvalid();
|
|
66
|
-
octet = octet * 10 + code - CHAR_CODE_0;
|
|
67
|
-
if (octet > 255) onInvalid();
|
|
68
|
-
digits++;
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (code !== CHAR_CODE_DOT || digits === 0 || octets === 4) onInvalid();
|
|
72
|
-
result = (result << 8n) + BigInt(octet);
|
|
73
|
-
octets++;
|
|
74
|
-
octet = 0;
|
|
75
|
-
digits = 0;
|
|
76
|
-
}
|
|
77
|
-
if (octets !== 4) onInvalid();
|
|
78
|
-
return result;
|
|
79
|
-
};
|
|
80
|
-
const parseIPv6HexCode = (code) => {
|
|
81
|
-
if (code >= CHAR_CODE_0 && code <= CHAR_CODE_9) return code - CHAR_CODE_0;
|
|
82
|
-
if (code >= CHAR_CODE_A && code <= CHAR_CODE_F) return code - CHAR_CODE_A + 10;
|
|
83
|
-
if (code >= CHAR_CODE_a && code <= CHAR_CODE_f) return code - CHAR_CODE_a + 10;
|
|
84
|
-
return -1;
|
|
85
|
-
};
|
|
86
|
-
const isIPv6LinkLocal = (ipv6binary) => ipv6binary >> 118n === 1018n;
|
|
87
|
-
/**
|
|
88
|
-
* Convert IPv4 to Uint8Array
|
|
89
|
-
* @param ipv4 IPv4 Address
|
|
90
|
-
* @returns BigInt
|
|
91
|
-
*/
|
|
92
|
-
const convertIPv4ToBinary = (ipv4) => {
|
|
93
|
-
return parseIPv4ToBinary(ipv4, 0, ipv4.length, () => throwInvalidIPv4Address(ipv4));
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Convert IPv6 to Uint8Array
|
|
97
|
-
* @param ipv6 IPv6 Address
|
|
98
|
-
* @returns BigInt
|
|
99
|
-
*/
|
|
100
|
-
const convertIPv6ToBinary = (ipv6) => {
|
|
101
|
-
const length = ipv6.length;
|
|
102
|
-
const sections = [];
|
|
103
|
-
let hasZoneId = false;
|
|
104
|
-
let compressAt = -1;
|
|
105
|
-
let index = 0;
|
|
106
|
-
if (length === 0) throwInvalidIPv6Address(ipv6);
|
|
107
|
-
while (index < length) {
|
|
108
|
-
if (sections.length > 8) throwInvalidIPv6Address(ipv6);
|
|
109
|
-
let code = ipv6.charCodeAt(index);
|
|
110
|
-
if (code === CHAR_CODE_PERCENT) {
|
|
111
|
-
if (index + 1 === length) throwInvalidIPv6Address(ipv6);
|
|
112
|
-
hasZoneId = true;
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
if (code === CHAR_CODE_COLON) {
|
|
116
|
-
if (index + 1 < length && ipv6.charCodeAt(index + 1) === CHAR_CODE_COLON) {
|
|
117
|
-
if (compressAt !== -1) throwInvalidIPv6Address(ipv6);
|
|
118
|
-
compressAt = sections.length;
|
|
119
|
-
index += 2;
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
throwInvalidIPv6Address(ipv6);
|
|
123
|
-
}
|
|
124
|
-
let value = 0;
|
|
125
|
-
let digits = 0;
|
|
126
|
-
const sectionStart = index;
|
|
127
|
-
while (index < length) {
|
|
128
|
-
code = ipv6.charCodeAt(index);
|
|
129
|
-
const hex = parseIPv6HexCode(code);
|
|
130
|
-
if (hex === -1) break;
|
|
131
|
-
if (digits === 4) throwInvalidIPv6Address(ipv6);
|
|
132
|
-
value = value << 4 | hex;
|
|
133
|
-
digits++;
|
|
134
|
-
index++;
|
|
135
|
-
}
|
|
136
|
-
if (index < length && ipv6.charCodeAt(index) === CHAR_CODE_DOT) {
|
|
137
|
-
let ipv4End = length;
|
|
138
|
-
for (let i = index; i < length; i++) if (ipv6.charCodeAt(i) === CHAR_CODE_PERCENT) {
|
|
139
|
-
if (i + 1 === length) throwInvalidIPv6Address(ipv6);
|
|
140
|
-
hasZoneId = true;
|
|
141
|
-
ipv4End = i;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
const ipv4 = parseIPv4ToBinary(ipv6, sectionStart, ipv4End, () => throwInvalidIPv6Address(ipv6));
|
|
145
|
-
sections.push(Number(ipv4 >> 16n & 65535n), Number(ipv4 & 65535n));
|
|
146
|
-
index = length;
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
if (digits === 0) throwInvalidIPv6Address(ipv6);
|
|
150
|
-
sections.push(value);
|
|
151
|
-
if (index === length) break;
|
|
152
|
-
code = ipv6.charCodeAt(index);
|
|
153
|
-
if (code === CHAR_CODE_PERCENT) {
|
|
154
|
-
if (index + 1 === length) throwInvalidIPv6Address(ipv6);
|
|
155
|
-
hasZoneId = true;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
if (code !== CHAR_CODE_COLON) throwInvalidIPv6Address(ipv6);
|
|
159
|
-
if (index + 1 < length && ipv6.charCodeAt(index + 1) === CHAR_CODE_COLON) {
|
|
160
|
-
if (compressAt !== -1) throwInvalidIPv6Address(ipv6);
|
|
161
|
-
compressAt = sections.length;
|
|
162
|
-
index += 2;
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
index++;
|
|
166
|
-
if (index === length) throwInvalidIPv6Address(ipv6);
|
|
167
|
-
}
|
|
168
|
-
if (compressAt === -1 ? sections.length !== 8 : sections.length >= 8) throwInvalidIPv6Address(ipv6);
|
|
169
|
-
let result = 0n;
|
|
170
|
-
const zeros = compressAt === -1 ? 0 : 8 - sections.length;
|
|
171
|
-
const firstSectionEnd = compressAt === -1 ? sections.length : compressAt;
|
|
172
|
-
for (let i = 0; i < firstSectionEnd; i++) {
|
|
173
|
-
result <<= 16n;
|
|
174
|
-
result += BigInt(sections[i]);
|
|
175
|
-
}
|
|
176
|
-
for (let i = 0; i < zeros; i++) result <<= 16n;
|
|
177
|
-
for (let i = firstSectionEnd; i < sections.length; i++) {
|
|
178
|
-
result <<= 16n;
|
|
179
|
-
result += BigInt(sections[i]);
|
|
180
|
-
}
|
|
181
|
-
if (hasZoneId && !isIPv6LinkLocal(result)) throwInvalidIPv6Address(ipv6);
|
|
182
|
-
return result;
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Convert a binary representation of an IPv4 address to a string.
|
|
186
|
-
* @param ipV4 binary IPv4 Address
|
|
187
|
-
* @return IPv4 Address in string
|
|
188
|
-
*/
|
|
189
|
-
const convertIPv4BinaryToString = (ipV4) => {
|
|
190
|
-
const sections = [];
|
|
191
|
-
for (let i = 0; i < 4; i++) sections.push(ipV4 >> BigInt(8 * (3 - i)) & 255n);
|
|
192
|
-
return sections.join(".");
|
|
193
|
-
};
|
|
194
|
-
/**
|
|
195
|
-
* Check if a binary IPv6 address is an IPv4-mapped IPv6 address (::ffff:x.x.x.x)
|
|
196
|
-
* @param ipv6binary binary IPv6 Address
|
|
197
|
-
* @return true if the address is an IPv4-mapped IPv6 address
|
|
198
|
-
*/
|
|
199
|
-
const isIPv4MappedIPv6 = (ipv6binary) => ipv6binary >> 32n === 65535n;
|
|
200
|
-
/**
|
|
201
|
-
* Extract the IPv4 portion from an IPv4-mapped IPv6 address
|
|
202
|
-
* @param ipv6binary binary IPv4-mapped IPv6 Address
|
|
203
|
-
* @return binary IPv4 Address
|
|
204
|
-
*/
|
|
205
|
-
const convertIPv4MappedIPv6ToIPv4 = (ipv6binary) => ipv6binary & 4294967295n;
|
|
206
|
-
/**
|
|
207
|
-
* Convert a binary representation of an IPv6 address to a string.
|
|
208
|
-
* @param ipV6 binary IPv6 Address
|
|
209
|
-
* @return normalized IPv6 Address in string
|
|
210
|
-
*/
|
|
211
|
-
const convertIPv6BinaryToString = (ipV6) => {
|
|
212
|
-
if (ipV6 === 0n) return "::";
|
|
213
|
-
if (isIPv4MappedIPv6(ipV6)) return `::ffff:${convertIPv4BinaryToString(convertIPv4MappedIPv6ToIPv4(ipV6))}`;
|
|
214
|
-
const sections = [];
|
|
215
|
-
for (let i = 0; i < 8; i++) sections.push((ipV6 >> BigInt(16 * (7 - i)) & 65535n).toString(16));
|
|
216
|
-
let currentZeroStart = -1;
|
|
217
|
-
let maxZeroStart = -1;
|
|
218
|
-
let maxZeroEnd = -1;
|
|
219
|
-
for (let i = 0; i < 8; i++) if (sections[i] === "0") {
|
|
220
|
-
if (currentZeroStart === -1) currentZeroStart = i;
|
|
221
|
-
} else if (currentZeroStart > -1) {
|
|
222
|
-
if (i - currentZeroStart > maxZeroEnd - maxZeroStart) {
|
|
223
|
-
maxZeroStart = currentZeroStart;
|
|
224
|
-
maxZeroEnd = i;
|
|
225
|
-
}
|
|
226
|
-
currentZeroStart = -1;
|
|
227
|
-
}
|
|
228
|
-
if (currentZeroStart > -1) {
|
|
229
|
-
if (8 - currentZeroStart > maxZeroEnd - maxZeroStart) {
|
|
230
|
-
maxZeroStart = currentZeroStart;
|
|
231
|
-
maxZeroEnd = 8;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (maxZeroStart !== -1 && maxZeroEnd - maxZeroStart > 1) sections.splice(maxZeroStart, maxZeroEnd - maxZeroStart, ":");
|
|
235
|
-
return sections.join(":").replace(/:{2,}/g, "::");
|
|
236
|
-
};
|
|
237
|
-
//#endregion
|
|
1
|
+
import { a as convertIPv6BinaryToString, c as expandIPv6, i as convertIPv4ToBinary, l as isIPv4MappedIPv6, n as convertIPv4BinaryToString, o as convertIPv6ToBinary, r as convertIPv4MappedIPv6ToIPv4, s as distinctRemoteAddr, t as INVALID_IP_ADDRESS_ERROR_CODE } from "../ipaddr-DCoIo528.js";
|
|
238
2
|
export { INVALID_IP_ADDRESS_ERROR_CODE, convertIPv4BinaryToString, convertIPv4MappedIPv6ToIPv4, convertIPv4ToBinary, convertIPv6BinaryToString, convertIPv6ToBinary, distinctRemoteAddr, expandIPv6, isIPv4MappedIPv6 };
|
package/lib/utils/jwt.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Jwt } from "../jwt-
|
|
1
|
+
import { t as Jwt } from "../jwt-BXoIA2fQ.js";
|
|
2
2
|
export { Jwt };
|