miniflare
Advanced tools
Comparing version 0.0.0-5244faae5 to 0.0.0-5251052ff
@@ -869,3 +869,3 @@ // ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs | ||
var encoder = new TextEncoder(); | ||
function getUserRequest(request, env) { | ||
function getUserRequest(request, env, clientIp) { | ||
let originalUrl = request.headers.get(CoreHeaders.ORIGINAL_URL), url = new URL(originalUrl ?? request.url), rewriteHeadersFromOriginalUrl = !1, proxySharedSecret = request.headers.get( | ||
@@ -889,12 +889,7 @@ CoreHeaders.PROXY_SHARED_SECRET | ||
} | ||
if (request = new Request(url, request), request.cf === void 0) { | ||
let cf = { | ||
...env[CoreBindings.JSON_CF_BLOB], | ||
// Defaulting to empty string to preserve undefined `Accept-Encoding` | ||
// through Wrangler's proxy worker. | ||
clientAcceptEncoding: request.headers.get("Accept-Encoding") ?? "" | ||
}; | ||
request = new Request(request, { cf }); | ||
if (request = new Request(url, request), request.headers.set("Accept-Encoding", "br, gzip"), rewriteHeadersFromOriginalUrl && request.headers.set("Host", url.host), clientIp && !request.headers.get("CF-Connecting-IP")) { | ||
let ipv4Regex = /(?<ip>.*?):\d+/, ipv6Regex = /\[(?<ip>.*?)\]:\d+/, ip = clientIp.match(ipv6Regex)?.groups?.ip ?? clientIp.match(ipv4Regex)?.groups?.ip; | ||
ip && request.headers.set("CF-Connecting-IP", ip); | ||
} | ||
return request.headers.set("Accept-Encoding", "br, gzip"), rewriteHeadersFromOriginalUrl && request.headers.set("Host", url.host), request.headers.delete(CoreHeaders.PROXY_SHARED_SECRET), request.headers.delete(CoreHeaders.ORIGINAL_URL), request.headers.delete(CoreHeaders.DISABLE_PRETTY_ERROR), request; | ||
return request.headers.delete(CoreHeaders.PROXY_SHARED_SECRET), request.headers.delete(CoreHeaders.ORIGINAL_URL), request.headers.delete(CoreHeaders.DISABLE_PRETTY_ERROR), request; | ||
} | ||
@@ -1014,8 +1009,13 @@ function getTargetService(request, url, env) { | ||
async fetch(request, env, ctx) { | ||
let startTime = Date.now(); | ||
if (request.headers.get(CoreHeaders.OP) !== null) | ||
let startTime = Date.now(), clientIp = request.cf?.clientIp, clientCfBlobHeader = request.headers.get(CoreHeaders.CF_BLOB), cf = clientCfBlobHeader ? JSON.parse(clientCfBlobHeader) : { | ||
...env[CoreBindings.JSON_CF_BLOB], | ||
// Defaulting to empty string to preserve undefined `Accept-Encoding` | ||
// through Wrangler's proxy worker. | ||
clientAcceptEncoding: request.headers.get("Accept-Encoding") ?? "" | ||
}; | ||
if (request = new Request(request, { cf }), request.headers.get(CoreHeaders.OP) !== null) | ||
return handleProxy(request, env); | ||
let disablePrettyErrorPage = request.headers.get(CoreHeaders.DISABLE_PRETTY_ERROR) !== null, clientAcceptEncoding = request.headers.get("Accept-Encoding"); | ||
try { | ||
request = getUserRequest(request, env); | ||
request = getUserRequest(request, env, clientIp); | ||
} catch (e) { | ||
@@ -1022,0 +1022,0 @@ if (e instanceof HttpError) |
@@ -53,3 +53,3 @@ var __defProp = Object.defineProperty; | ||
let colType = columns[i].type, cellType = typeof cell; | ||
return cell === null ? "NULL" : colType === "INTEGER" || cellType === "number" ? cell : colType === "TEXT" || cellType === "string" ? outputQuotedEscapedString(cell) : cell instanceof ArrayBuffer ? `X'${Array.prototype.map.call(new Uint8Array(cell), (b) => b.toString(16)).join("")}'` : (console.log({ colType, cellType, cell, column: columns[i] }), "ERROR"); | ||
return cell === null ? "NULL" : colType === "INTEGER" || cellType === "number" ? cell : colType === "TEXT" || cellType === "string" ? outputQuotedEscapedString(cell) : cell instanceof ArrayBuffer ? `X'${Array.prototype.map.call(new Uint8Array(cell), (b) => b.toString(16).padStart(2, "0")).join("")}'` : (console.log({ colType, cellType, cell, column: columns[i] }), "ERROR"); | ||
}); | ||
@@ -56,0 +56,0 @@ yield `INSERT INTO ${sqliteQuote(table)} VALUES(${formattedCells.join(",")});`; |
@@ -8,3 +8,6 @@ // src/workers/shared/blob.worker.ts | ||
function viewToBuffer(view) { | ||
return view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength); | ||
return view.buffer.slice( | ||
view.byteOffset, | ||
view.byteOffset + view.byteLength | ||
); | ||
} | ||
@@ -11,0 +14,0 @@ function base64Encode(value) { |
{ | ||
"name": "miniflare", | ||
"version": "0.0.0-5244faae5", | ||
"version": "0.0.0-5251052ff", | ||
"description": "Fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -36,3 +36,2 @@ "keywords": [ | ||
"acorn-walk": "^8.2.0", | ||
"capnp-ts": "^0.7.0", | ||
"exit-hook": "^2.2.1", | ||
@@ -42,3 +41,3 @@ "glob-to-regexp": "^0.4.1", | ||
"undici": "^5.28.4", | ||
"workerd": "1.20241106.1", | ||
"workerd": "1.20250124.0", | ||
"ws": "^8.18.0", | ||
@@ -50,4 +49,4 @@ "youch": "^3.2.2", | ||
"@ava/typescript": "^4.1.0", | ||
"@cloudflare/workers-types": "^4.20241106.0", | ||
"@microsoft/api-extractor": "^7.47.0", | ||
"@cloudflare/workers-types": "^4.20250121.0", | ||
"@microsoft/api-extractor": "7.49.1", | ||
"@types/debug": "^4.1.7", | ||
@@ -58,4 +57,3 @@ "@types/estree": "^1.0.0", | ||
"@types/mime": "^3.0.4", | ||
"@types/node": "^18.19.59", | ||
"@types/rimraf": "^4.0.5", | ||
"@types/node": "^18.19.71", | ||
"@types/stoppable": "^1.1.1", | ||
@@ -67,3 +65,3 @@ "@types/which": "^2.0.1", | ||
"ava": "^6.0.1", | ||
"capnpc-ts": "^0.7.0", | ||
"capnp-es": "^0.0.7", | ||
"concurrently": "^8.2.2", | ||
@@ -84,8 +82,9 @@ "devalue": "^4.3.0", | ||
"pretty-bytes": "^6.0.0", | ||
"rimraf": "^5.0.1", | ||
"rimraf": "^5.0.10", | ||
"source-map": "^0.6.1", | ||
"typescript": "^5.7.2", | ||
"which": "^2.0.2", | ||
"@cloudflare/workers-shared": "0.0.0-5244faae5", | ||
"@cloudflare/kv-asset-handler": "0.3.4", | ||
"@cloudflare/workflows-shared": "0.2.0" | ||
"@cloudflare/workflows-shared": "0.2.2", | ||
"@cloudflare/workers-shared": "0.0.0-5251052ff" | ||
}, | ||
@@ -106,3 +105,3 @@ "engines": { | ||
"build": "node scripts/build.mjs && pnpm run types:build", | ||
"capnp:workerd": "capnpc -o ts src/runtime/config/workerd.capnp", | ||
"capnp:workerd": "node scripts/build-capnp.mjs", | ||
"check:lint": "eslint --max-warnings=0 \"{src,test}/**/*.ts\" \"scripts/**/*.{js,mjs}\" \"types/**/*.ts\"", | ||
@@ -109,0 +108,0 @@ "check:type": "tsc", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2896651
11
46735
+ Added@cloudflare/workerd-darwin-64@1.20250124.0(transitive)
+ Added@cloudflare/workerd-darwin-arm64@1.20250124.0(transitive)
+ Added@cloudflare/workerd-linux-64@1.20250124.0(transitive)
+ Added@cloudflare/workerd-linux-arm64@1.20250124.0(transitive)
+ Added@cloudflare/workerd-windows-64@1.20250124.0(transitive)
+ Addedworkerd@1.20250124.0(transitive)
- Removedcapnp-ts@^0.7.0
- Removed@cloudflare/workerd-darwin-64@1.20241106.1(transitive)
- Removed@cloudflare/workerd-darwin-arm64@1.20241106.1(transitive)
- Removed@cloudflare/workerd-linux-64@1.20241106.1(transitive)
- Removed@cloudflare/workerd-linux-arm64@1.20241106.1(transitive)
- Removed@cloudflare/workerd-windows-64@1.20241106.1(transitive)
- Removedcapnp-ts@0.7.0(transitive)
- Removeddebug@4.4.0(transitive)
- Removedms@2.1.3(transitive)
- Removedtslib@2.8.1(transitive)
- Removedworkerd@1.20241106.1(transitive)
Updatedworkerd@1.20250124.0