From 47b530c435e010cf83ae029c08140cf32be2a39f Mon Sep 17 00:00:00 2001 From: Jason Caldwell Date: Sat, 24 Feb 2024 13:56:41 -0500 Subject: [PATCH] Project update. [p][robotic] --- .browserslistrc | 2 +- .dockerignore | 2 +- .env.vault | 8 ++-- .gitattributes | 2 +- .gitignore | 2 +- .npmignore | 2 +- .prettierignore | 2 +- .vscode/settings.json | 2 +- .vscodeignore | 2 +- package-lock.json | 106 +++++++++++++++++++++--------------------- package.json | 6 +-- src/cfw.ts | 18 +------ src/proxy.ts | 44 +++++++++++------- tsconfig.json | 2 +- wrangler.toml | 2 +- 15 files changed, 99 insertions(+), 103 deletions(-) diff --git a/.browserslistrc b/.browserslistrc index c678458..5ab31e5 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -17,7 +17,7 @@ # Generated data. # -# Last generated Feb 24, 2024 2:55 PM UTC. +# Last generated Feb 24, 2024 6:56 PM UTC. [production] node >= 20.9.0 diff --git a/.dockerignore b/.dockerignore index ff6dd8c..90a7dbf 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,7 +17,7 @@ # Generated data. # -# Last generated Feb 24, 2024 2:55 PM UTC. +# Last generated Feb 24, 2024 6:56 PM UTC. # Locals diff --git a/.env.vault b/.env.vault index b7152a3..2d5fa9b 100644 --- a/.env.vault +++ b/.env.vault @@ -8,12 +8,12 @@ DOTENV_VAULT_MAIN="3rfi+ClkONvfHPiU9FTBcC1+Um/L8QeM9dRw1jFzEqzZXw==" DOTENV_VAULT_MAIN_VERSION=1 # dev -DOTENV_VAULT_DEV="0aHFqQZv8yCGRbEI8aS4M8P8NZFPO3np612NaLiVUUwHBEtjP31Iu/lhM2/Vz1x7oxm/uWT9+3dOBOoBCWu3rYzEjBZiUgAYHzRUPbVLb7BeJmiojEOZa3XOUvpTnaXsKeXvH7S2F/VgxgILOFzDIz5kp7lBB3B01Y584g4CwFAhF9gbo54UBwOtQzkXTFgTWelHz2YGqinH34vsuw/pm1WnRpOCF7zUXHV41dNHxS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6BtsXvR/CHzzydAqKBpNwQX4JtEXW0fLiHYbX1gEpxCIJvsWz7UpJJOgln9mPyo8DMh333EAcb9oll11vWen5y4hpAJAnCwwzNFPWbkjtwjfAc8Z3DFxY/NcQKdeNSobXlWnzs0Zog9xQQAms5pR0vzqaf+5ERVVAXx/1evdFgfxMG1zeo9ft+82AzFzIsqwjU+BH+rYtCwE8z565+LkklR6P8cqYVKXsWyO9R2" +DOTENV_VAULT_CI_VERSION=199 # stage DOTENV_VAULT_STAGE="bfqZYD8oVLWMZ0JR5LICV+sB/btaXavszxZLxTfwSH8U5fg=" diff --git a/.gitattributes b/.gitattributes index 40a42c2..310f0ca 100644 --- a/.gitattributes +++ b/.gitattributes @@ -17,7 +17,7 @@ # Generated data. # -# Last generated Feb 24, 2024 2:55 PM UTC. +# Last generated Feb 24, 2024 6:56 PM UTC. # Default diff --git a/.gitignore b/.gitignore index 14a8f72..eebe4a3 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ # Generated data. # -# Last generated Feb 24, 2024 2:55 PM UTC. +# Last generated Feb 24, 2024 6:56 PM UTC. # Locals diff --git a/.npmignore b/.npmignore index 4bb1e70..06cf4bc 100644 --- a/.npmignore +++ b/.npmignore @@ -25,7 +25,7 @@ # Generated data. # -# Last generated Feb 24, 2024 2:55 PM UTC. +# Last generated Feb 24, 2024 6:56 PM UTC. # Locals diff --git a/.prettierignore b/.prettierignore index c95e1d9..506391c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -17,7 +17,7 @@ # Generated data. # -# Last generated Feb 24, 2024 2:55 PM UTC. +# Last generated Feb 24, 2024 6:56 PM UTC. # Packages diff --git a/.vscode/settings.json b/.vscode/settings.json index a97f69c..9237904 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,7 +7,7 @@ * @note This entire file will be updated automatically. * @note Instead of editing here, please review `./settings.mjs`. * - * Last generated using `./settings.mjs` Feb 24, 2024 2:55 PM UTC. + * Last generated using `./settings.mjs` Feb 24, 2024 6:56 PM UTC. */ { "editor.formatOnType": false, diff --git a/.vscodeignore b/.vscodeignore index 2d38d41..58ea318 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -17,7 +17,7 @@ # Generated data. # -# Last generated Feb 24, 2024 2:55 PM UTC. +# Last generated Feb 24, 2024 6:56 PM UTC. # Locals diff --git a/package-lock.json b/package-lock.json index d944858..b821ba7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@clevercanyon/utilities.cfw", - "version": "1.0.251", + "version": "1.0.252", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@clevercanyon/utilities.cfw", - "version": "1.0.251", + "version": "1.0.252", "cpu": [ "x64", "arm64" @@ -17,7 +17,7 @@ "linux" ], "devDependencies": { - "@clevercanyon/dev-deps": "^1.0.358" + "@clevercanyon/dev-deps": "^1.0.359" }, "engines": { "node": "^20.5.0 || ^20.9.0", @@ -27,7 +27,7 @@ "url": "https://github.com/sponsors/clevercanyon" }, "peerDependencies": { - "@clevercanyon/utilities": "^1.0.851", + "@clevercanyon/utilities": "^1.0.853", "@upstash/ratelimit": "1.0.0", "@upstash/redis": "1.28.0" } @@ -837,9 +837,9 @@ "dev": true }, "node_modules/@clevercanyon/dev-deps": { - "version": "1.0.358", - "resolved": "https://registry.npmjs.org/@clevercanyon/dev-deps/-/dev-deps-1.0.358.tgz", - "integrity": "sha512-LpRjRMxeiktT2oaeWkmrVOeDV1To+GzZmFdN+M5SWAApz3mdJkUsWwFJ0oKSQwPfSDGt2+ZHzj25mZFKIZLdYA==", + "version": "1.0.359", + "resolved": "https://registry.npmjs.org/@clevercanyon/dev-deps/-/dev-deps-1.0.359.tgz", + "integrity": "sha512-54hdMU/DYyjENvGYaqhB7g9G+cSmkw54uglmYHithZorcU+v7E8JNB5aS0Q+nYuJfEK4tFd1h94NPnM+HEvwXw==", "cpu": [ "x64", "arm64" @@ -850,11 +850,11 @@ "linux" ], "dependencies": { - "@clevercanyon/madrun": "^1.0.178", - "@clevercanyon/utilities": "^1.0.832", - "@clevercanyon/utilities.bash": "^1.0.192", - "@clevercanyon/utilities.cfp": "^1.0.211", - "@clevercanyon/utilities.node": "^1.0.187", + "@clevercanyon/madrun": "^1.0.179", + "@clevercanyon/utilities": "^1.0.853", + "@clevercanyon/utilities.bash": "^1.0.193", + "@clevercanyon/utilities.cfp": "^1.0.214", + "@clevercanyon/utilities.node": "^1.0.188", "@cloudflare/workers-types": "4.20240208.0", "@eslint/js": "8.48.0", "@iarna/toml": "2.2.5", @@ -966,9 +966,9 @@ } }, "node_modules/@clevercanyon/madrun": { - "version": "1.0.179", - "resolved": "https://registry.npmjs.org/@clevercanyon/madrun/-/madrun-1.0.179.tgz", - "integrity": "sha512-NGoW6up6qEjLvrvmaiQAK1rtm03I9OERJXWOg2q9Ey9pHHHMl2c9+xAODLgH7RDkxD9k3isEt1suTwK/phBuZg==", + "version": "1.0.180", + "resolved": "https://registry.npmjs.org/@clevercanyon/madrun/-/madrun-1.0.180.tgz", + "integrity": "sha512-MNLE7S0MeMiZrJPrJ74Mc5wExmIoLVGYkRUzvOIThqKgEbr+r6IoiMHMfvpc2McsEbk8dBOwFa/BB1Dj0flwPw==", "cpu": [ "x64", "arm64" @@ -979,8 +979,8 @@ "linux" ], "dependencies": { - "@clevercanyon/utilities": "^1.0.832", - "@clevercanyon/utilities.node": "^1.0.187" + "@clevercanyon/utilities": "^1.0.853", + "@clevercanyon/utilities.node": "^1.0.188" }, "bin": { "madrun": "dist/bin/cli.js" @@ -994,9 +994,9 @@ } }, "node_modules/@clevercanyon/split-cmd.fork": { - "version": "1.0.128", - "resolved": "https://registry.npmjs.org/@clevercanyon/split-cmd.fork/-/split-cmd.fork-1.0.128.tgz", - "integrity": "sha512-+UyFdrUfUvr6u4iYoZQyo4nTYUaS75GMCjhxGW+KVN1yQpnnW2Y9bj4eKYwKxZotmZe+A5HIE04x1pZTgx5JsQ==", + "version": "1.0.129", + "resolved": "https://registry.npmjs.org/@clevercanyon/split-cmd.fork/-/split-cmd.fork-1.0.129.tgz", + "integrity": "sha512-Kd0INjCtmuC7LZPMOMWCStW2UalDrwsqzEqE50GVG+/UPNgod3Gw9kThYLomivAlmsZwLu8HUjkTv3ozMEr5xQ==", "cpu": [ "x64", "arm64" @@ -1016,9 +1016,9 @@ } }, "node_modules/@clevercanyon/utilities": { - "version": "1.0.851", - "resolved": "https://registry.npmjs.org/@clevercanyon/utilities/-/utilities-1.0.851.tgz", - "integrity": "sha512-Rwu/AE0t76fr+KidcPKPrdNQtqzTovoBYMlRgxEK6EaK8pywkP5NzcDgtFv1F2Z0sZt8wVm4+Wx5JLHnYuEI9g==", + "version": "1.0.853", + "resolved": "https://registry.npmjs.org/@clevercanyon/utilities/-/utilities-1.0.853.tgz", + "integrity": "sha512-D+2qdQaD9bfpmD90c/axuuBwtlopl+PAwhGt2IgpeKrmFjanG7ZzVYRq43DLFEQkAhxx/cp0tp+jZAPLRsnQBA==", "cpu": [ "x64", "arm64" @@ -1102,9 +1102,9 @@ } }, "node_modules/@clevercanyon/utilities.cfw": { - "version": "1.0.251", - "resolved": "https://registry.npmjs.org/@clevercanyon/utilities.cfw/-/utilities.cfw-1.0.251.tgz", - "integrity": "sha512-ntKybbytXhRwUtee5Qx/sKpklpdKP2w7DnlSnK0JR8A/LpEwhBS8yPKuNtHo/A9W19eEDKzbMQLBDwHyvsjEPQ==", + "version": "1.0.252", + "resolved": "https://registry.npmjs.org/@clevercanyon/utilities.cfw/-/utilities.cfw-1.0.252.tgz", + "integrity": "sha512-SGwgrvP/nvg1k4CCeTGI+xuMsgYO5UBTI6Kvvzc4knZhdA0n9dutiQphkxo9OfqMSdxRdkCzviLWKwGaJ+8B+g==", "cpu": [ "x64", "arm64" @@ -1129,9 +1129,9 @@ } }, "node_modules/@clevercanyon/utilities.node": { - "version": "1.0.188", - "resolved": "https://registry.npmjs.org/@clevercanyon/utilities.node/-/utilities.node-1.0.188.tgz", - "integrity": "sha512-19Xjd+B3yb4VmjYgMUYbko4Dx7XDaQ3YPXahUUAH4XtFqhGuKGUl6jlicRd+hN9fpxxo9zmV92FcIfzfEdwYKg==", + "version": "1.0.189", + "resolved": "https://registry.npmjs.org/@clevercanyon/utilities.node/-/utilities.node-1.0.189.tgz", + "integrity": "sha512-2oRAuyZeRaBU2THEJzH8tjhqbsgwcf2r14lgF9ZaRarT6rlW9x63sktV95u81DHEE4RGhgmNjJ05ZIcqEVVsSQ==", "cpu": [ "x64", "arm64" @@ -1149,8 +1149,8 @@ "url": "https://github.com/sponsors/clevercanyon" }, "peerDependencies": { - "@clevercanyon/split-cmd.fork": "^1.0.128", - "@clevercanyon/utilities": "^1.0.833", + "@clevercanyon/split-cmd.fork": "^1.0.129", + "@clevercanyon/utilities": "^1.0.853", "@upstash/ratelimit": "1.0.0", "@upstash/redis": "1.28.0", "archiver": "6.0.1", @@ -1163,7 +1163,7 @@ "globby": "14.0.0", "prettier": "3.1.0", "shescape": "2.0.2", - "spawn-please": "npm:@clevercanyon/spawn-please.fork@^2.0.122", + "spawn-please": "npm:@clevercanyon/spawn-please.fork@^2.0.123", "term-img": "6.0.0", "yargs": "17.7.2", "yargs-parser": "21.1.1" @@ -7845,9 +7845,9 @@ }, "node_modules/braces": { "name": "@clevercanyon/braces.fork", - "version": "3.0.126", - "resolved": "https://registry.npmjs.org/@clevercanyon/braces.fork/-/braces.fork-3.0.126.tgz", - "integrity": "sha512-xQdmxSkjmAx9LvuIGEnWmrcOxLFq3t50os5uosUsP3DXAiefFeg2nz/hQ5qvS0ezfOPcNr3zwxGvYm9Jt8YAPQ==", + "version": "3.0.127", + "resolved": "https://registry.npmjs.org/@clevercanyon/braces.fork/-/braces.fork-3.0.127.tgz", + "integrity": "sha512-dnbkzSbM2DVerHqDxIaZuATBzmJji4YywU9Z3rvou3DpUFdTeVQlX1q2vYllIQr8SaHxB9FsKY06SCVKhov1JQ==", "cpu": [ "x64", "arm64" @@ -7857,7 +7857,7 @@ "linux" ], "dependencies": { - "fill-range": "npm:@clevercanyon/fill-range.fork@^7.0.125" + "fill-range": "npm:@clevercanyon/fill-range.fork@^7.0.126" }, "engines": { "node": "^20.5.0 || ^20.9.0", @@ -12626,9 +12626,9 @@ }, "node_modules/fill-range": { "name": "@clevercanyon/fill-range.fork", - "version": "7.0.125", - "resolved": "https://registry.npmjs.org/@clevercanyon/fill-range.fork/-/fill-range.fork-7.0.125.tgz", - "integrity": "sha512-091261vOEQIxtIBDTg6bHxbM+PGFQ/CT1Fd5qukWzZtTemp0+c6nb+U8xDzjJ5mk24Wh7P9M84WbbRdqMLSckw==", + "version": "7.0.126", + "resolved": "https://registry.npmjs.org/@clevercanyon/fill-range.fork/-/fill-range.fork-7.0.126.tgz", + "integrity": "sha512-FHAEc5eaCFdDUOSy+q0qfdH+1xtvuMSH5wf13xzAE7ByAhdBLepF45tfzL1qrNRdf5xVbDD7ipFiXx2fqK/znw==", "cpu": [ "x64", "arm64" @@ -12638,7 +12638,7 @@ "linux" ], "dependencies": { - "to-regex-range": "npm:@clevercanyon/to-regex-range.fork@^5.0.125" + "to-regex-range": "npm:@clevercanyon/to-regex-range.fork@^5.0.126" }, "engines": { "node": "^20.5.0 || ^20.9.0", @@ -14203,9 +14203,9 @@ }, "node_modules/is-number": { "name": "@clevercanyon/is-number.fork", - "version": "7.0.128", - "resolved": "https://registry.npmjs.org/@clevercanyon/is-number.fork/-/is-number.fork-7.0.128.tgz", - "integrity": "sha512-tvaZwNzaFmnyWlA1DfUwCMeyKJHKGuAjL4R1xn1EQB94HX182uTYYXKw0LqRxRmLUeCY2wI9utIHY42oHR3QlQ==", + "version": "7.0.129", + "resolved": "https://registry.npmjs.org/@clevercanyon/is-number.fork/-/is-number.fork-7.0.129.tgz", + "integrity": "sha512-4TpIFixhOWAL+bm3nof1kw0FA2FZxDjwZrYXoTK9OhZPaBSuYs9RmrsxZkhWfV+hYjIpXqJ/5/ciCZiPJvivGg==", "cpu": [ "x64", "arm64" @@ -19961,9 +19961,9 @@ }, "node_modules/micromatch/node_modules/picomatch": { "name": "@clevercanyon/picomatch.fork", - "version": "2.3.125", - "resolved": "https://registry.npmjs.org/@clevercanyon/picomatch.fork/-/picomatch.fork-2.3.125.tgz", - "integrity": "sha512-x+UThs2CiBNHQndRPiNBSmR9wNYcM+rEooUcj+75hmiQ+dpDZuu2sEPphJu2snZwAI35NY3hVhtRMSvbH46EGA==", + "version": "2.3.126", + "resolved": "https://registry.npmjs.org/@clevercanyon/picomatch.fork/-/picomatch.fork-2.3.126.tgz", + "integrity": "sha512-CRvSshv4swmHJfuI3UA8gDnGQ17aZwtWX9L3IDjm+8oNgZazwnzxkzUVp7URmI+ojTg7ZrcIYoTdg/zROIlfYw==", "cpu": [ "x64", "arm64" @@ -27186,9 +27186,9 @@ }, "node_modules/spawn-please": { "name": "@clevercanyon/spawn-please.fork", - "version": "2.0.122", - "resolved": "https://registry.npmjs.org/@clevercanyon/spawn-please.fork/-/spawn-please.fork-2.0.122.tgz", - "integrity": "sha512-OBQOgZHb0jYt6e2XxZ1F7mJHUOs+k8HGwaHN0QZJC/11gLwXUF9N6ugzg2bkRbiZcf367xtLYkKb549ZvQjk3A==", + "version": "2.0.123", + "resolved": "https://registry.npmjs.org/@clevercanyon/spawn-please.fork/-/spawn-please.fork-2.0.123.tgz", + "integrity": "sha512-FQfqBz3lpKtWi5vreUDJL+koy8isywqLXKhk/w2iYfiDwtR2v/WzwVIN+8zPhi8j/vv2SGXnyC297/mOh2Lg8w==", "cpu": [ "x64", "arm64" @@ -28504,9 +28504,9 @@ }, "node_modules/to-regex-range": { "name": "@clevercanyon/to-regex-range.fork", - "version": "5.0.125", - "resolved": "https://registry.npmjs.org/@clevercanyon/to-regex-range.fork/-/to-regex-range.fork-5.0.125.tgz", - "integrity": "sha512-K5z4jxIp+yVAZ7fUuEUpgtWU/5FiifKxaNp+4aXxA6UBGrcRbhvrBMygDQHBoV2lNoUOzYgcM1HMszkZehwCfQ==", + "version": "5.0.126", + "resolved": "https://registry.npmjs.org/@clevercanyon/to-regex-range.fork/-/to-regex-range.fork-5.0.126.tgz", + "integrity": "sha512-3c2M87j5JS+8enOj+NPMH+xDJMySM0CUw+LCHFukPE/3UhzgI+SErq2ylaHPdrT5qFfxK55Hi9Gby4ZlbZxB6Q==", "cpu": [ "x64", "arm64" @@ -28516,7 +28516,7 @@ "linux" ], "dependencies": { - "is-number": "npm:@clevercanyon/is-number.fork@^7.0.128" + "is-number": "npm:@clevercanyon/is-number.fork@^7.0.129" }, "engines": { "node": "^20.5.0 || ^20.9.0", diff --git a/package.json b/package.json index 1fe357c..4be74a8 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "1.0.252", + "version": "1.0.253", "license": "GPL-3.0-or-later", "name": "@clevercanyon/utilities.cfw", "description": "Utilities for JavaScript apps running in a Cloudflare Worker environment.", @@ -59,7 +59,7 @@ }, "dependencies": {}, "peerDependencies": { - "@clevercanyon/utilities": "^1.0.851", + "@clevercanyon/utilities": "^1.0.853", "@upstash/ratelimit": "1.0.0", "@upstash/redis": "1.28.0" }, @@ -67,7 +67,7 @@ "optionalDependencies": {}, "bundleDependencies": [], "devDependencies": { - "@clevercanyon/dev-deps": "^1.0.358" + "@clevercanyon/dev-deps": "^1.0.359" }, "overrides": {}, "cpu": ["x64", "arm64"], diff --git a/src/cfw.ts b/src/cfw.ts index 3a2d1eb..c4eac16 100644 --- a/src/cfw.ts +++ b/src/cfw.ts @@ -4,7 +4,7 @@ import '#@initialize.ts'; -import { $app, $class, $crypto, $env, $error, $fsize, $http, $is, $mm, $obj, $str, $url, $user, type $type } from '@clevercanyon/utilities'; +import { $app, $class, $crypto, $env, $error, $fsize, $http, $is, $mm, $obj, $url, $user, type $type } from '@clevercanyon/utilities'; /** * Defines types. @@ -46,6 +46,7 @@ export type StdExecutionContext = Readonly< >; export type StdEnvironment = Readonly<{ UT: $type.cfw.Fetcher; + UT_KV: $type.cfw.KVNamespace; D1: $type.cfw.D1Database; R2: $type.cfw.R2Bucket; KV: $type.cfw.KVNamespace; @@ -177,21 +178,6 @@ export const handleFetchEvent = async (ircData: InitialRequestContextData): Prom // --- // Misc exports. -/** - * Detects if current worker is a specific route. - * - * @param rcData Request context data; {@see StdRequestContextData}. - * @param workerRoute Worker route to consider; e.g., `/utilities`. - * - * @returns True if current worker is a specific route. - * - * @review Can we get rid of this hardcoded hostname? - * @review Should there be a call to `$env.isCFW()` here? - */ -export const is = (rcData: StdRequestContextData, workerRoute: string): boolean => { - return rcData.url.toString().startsWith('https://workers.hop.gdn/' + $str.trim(workerRoute, '/') + '/'); -}; - /** * Creates a scheduled event request. * diff --git a/src/proxy.ts b/src/proxy.ts index e9078fd..d589f7a 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -5,7 +5,7 @@ import '#@initialize.ts'; import { $cfw, cfw } from '#index.ts'; -import { $arr, $crypto, $env, $http, $is, $mime, $obj, $str, $time, $to, $url, type $type } from '@clevercanyon/utilities'; +import { $app, $arr, $crypto, $env, $http, $is, $mime, $obj, $str, $time, $to, $url, type $type } from '@clevercanyon/utilities'; /** * Defines types. @@ -247,7 +247,13 @@ const fetchꓺviaSocket = async (rcData: $cfw.StdRequestContextData, url: $type. * @returns Promise of fake UA headers. */ const fetchꓺfakeUAHeaders = async (rcData: $cfw.StdRequestContextData): Promise => { - const { env: { UT: ut }, auditLogger } = rcData, // prettier-ignore + const { fetch } = cfw, + { url, env, auditLogger } = rcData, + // + uaHeadersAPIRoute = $url.addQueryVars( + { randomIndex: String($crypto.randomNumber(1, 100)) }, // + 'https://workers.hop.gdn/utilities/api/fake-ua-headers/v1', + ), defaultUAHeaders = { 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36', @@ -261,10 +267,9 @@ const fetchꓺfakeUAHeaders = async (rcData: $cfw.StdRequestContextData): Promis 'accept-encoding': 'gzip, deflate', 'accept-language': 'en-US,en;q=0.9', }; - if ($cfw.is(rcData, '/utilities')) { - const { env: { KV: kv } } = rcData, // prettier-ignore - kvKey = 'fakeUAHeaders:' + String($crypto.randomNumber(1, 100)), - uaHeaders = (await kv.get(kvKey, { type: 'json' })) as FakeUAHeaders; + if (env.UT_KV || ('@clevercanyon/workers.hop.gdn-utilities' === $app.pkgName() && env.KV)) { + const kvKey = 'fakeUAHeaders:' + String($crypto.randomNumber(1, 100)), + uaHeaders = (await (env.UT_KV || env.KV).get(kvKey, { type: 'json' })) as FakeUAHeaders; if (!$is.plainObject(uaHeaders)) { void auditLogger.warn('Fake UA headers failure.', { uaHeaders, error: Error('q9UTub4N') }); @@ -272,17 +277,8 @@ const fetchꓺfakeUAHeaders = async (rcData: $cfw.StdRequestContextData): Promis } return uaHeaders; } - if (ut /* Utilities worker service binding exists? */) { - const payload = await ut - .fetch( - await $cfw.serviceBindingRequest( - rcData, - $url.addQueryVars( - { randomIndex: String($crypto.randomNumber(1, 100)) }, // - 'https://workers.hop.gdn/utilities/api/fake-ua-headers/v1', - ), - ), - ) + if (env.UT /* Utilities worker service binding exists? */) { + const payload = await env.UT.fetch(await $cfw.serviceBindingRequest(rcData, uaHeadersAPIRoute)) .then(async (response): Promise => { return $to.plainObject(await response.json()) as FakeUAHeadersResponsePayload; }) @@ -295,5 +291,19 @@ const fetchꓺfakeUAHeaders = async (rcData: $cfw.StdRequestContextData): Promis } return payload.data; } + if ('workers.hop.gdn' !== url.hostname /* Worker-to-worker possible? */) { + const payload = await fetch(uaHeadersAPIRoute) + .then(async (response): Promise => { + return $to.plainObject(await response.json()) as FakeUAHeadersResponsePayload; + }) + .catch((thrown: unknown): void => { + void auditLogger.warn('Fake UA headers error thrown.', { thrown }); + }); + if (!payload?.ok || !$is.plainObject(payload.data)) { + void auditLogger.warn('Fake UA headers failure.', { payload, error: Error('hMG9q7P5') }); + return defaultUAHeaders; + } + return payload.data; + } return defaultUAHeaders; }; diff --git a/tsconfig.json b/tsconfig.json index 5450729..1fbcded 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ * @note This entire file will be updated automatically. * @note Instead of editing here, please review `./tsconfig.mjs`. * - * Last generated using `./tsconfig.mjs` Feb 24, 2024 2:55 PM UTC. + * Last generated using `./tsconfig.mjs` Feb 24, 2024 6:56 PM UTC. */ { "include": ["./src/**/*", "./dev-types.d.ts"], diff --git a/wrangler.toml b/wrangler.toml index 33c94f3..4777861 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -7,7 +7,7 @@ # @note This entire file will be updated automatically. # @note Instead of editing here, please review `./wrangler.mjs`. # -# Last generated using `./wrangler.mjs` Feb 24, 2024 2:55 PM UTC. +# Last generated using `./wrangler.mjs` Feb 24, 2024 6:56 PM UTC. ## send_metrics = false