@base44-preview/cli 0.1.32-pr.662.66693f8 → 0.1.32-pr.662.e04bb64
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/dist/cli/index.js +33 -16
- package/dist/cli/index.js.map +3 -3
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -253287,13 +253287,15 @@ var MAX_EDGE_ERRORS = 5;
|
|
|
253287
253287
|
var MAX_INSPECTED_BODY_BYTES = 8192;
|
|
253288
253288
|
var BODY_READ_TIMEOUT_MS = 500;
|
|
253289
253289
|
var PLAIN_TEXT_EDGE_ERROR = /^error code: (\\d{3,4})\\s*$/;
|
|
253290
|
+
var UNBRANDED_5XX_PAGE = /<center>cloudflare<\\/center>/i;
|
|
253290
253291
|
var SAFE_VALUE = /^[\\x20-\\x7e]{1,253}$/;
|
|
253291
253292
|
function safe(value) {
|
|
253292
253293
|
return typeof value === "string" && SAFE_VALUE.test(value) ? value : void 0;
|
|
253293
253294
|
}
|
|
253294
|
-
function parseEdgeErrorBody(body) {
|
|
253295
|
+
function parseEdgeErrorBody(body, status) {
|
|
253295
253296
|
const plain = PLAIN_TEXT_EDGE_ERROR.exec(body);
|
|
253296
253297
|
if (plain) return { code: Number(plain[1]) };
|
|
253298
|
+
if (status >= 500 && UNBRANDED_5XX_PAGE.test(body)) return { code: status };
|
|
253297
253299
|
try {
|
|
253298
253300
|
const json = JSON.parse(body);
|
|
253299
253301
|
if (json === null || typeof json !== "object") return null;
|
|
@@ -253309,24 +253311,39 @@ function parseEdgeErrorBody(body) {
|
|
|
253309
253311
|
return null;
|
|
253310
253312
|
}
|
|
253311
253313
|
}
|
|
253312
|
-
async function
|
|
253313
|
-
if (response.
|
|
253314
|
-
const
|
|
253315
|
-
if (!
|
|
253316
|
-
|
|
253317
|
-
}
|
|
253318
|
-
|
|
253314
|
+
async function readBodyPrefix(response) {
|
|
253315
|
+
if (Number(response.headers.get("content-length")) > MAX_INSPECTED_BODY_BYTES) return null;
|
|
253316
|
+
const reader = response.clone().body?.getReader();
|
|
253317
|
+
if (!reader) return "";
|
|
253318
|
+
const timer = setTimeout(() => reader.cancel().catch(() => {
|
|
253319
|
+
}), BODY_READ_TIMEOUT_MS);
|
|
253320
|
+
const decoder = new TextDecoder();
|
|
253321
|
+
let text = "";
|
|
253322
|
+
let size = 0;
|
|
253319
253323
|
try {
|
|
253320
|
-
|
|
253321
|
-
|
|
253322
|
-
|
|
253323
|
-
|
|
253324
|
-
|
|
253325
|
-
|
|
253326
|
-
|
|
253324
|
+
for (; ; ) {
|
|
253325
|
+
const { done, value } = await reader.read();
|
|
253326
|
+
if (done) break;
|
|
253327
|
+
size += value.byteLength;
|
|
253328
|
+
if (size > MAX_INSPECTED_BODY_BYTES) return null;
|
|
253329
|
+
text += decoder.decode(value, { stream: true });
|
|
253330
|
+
}
|
|
253331
|
+
} catch {
|
|
253332
|
+
return null;
|
|
253327
253333
|
} finally {
|
|
253328
253334
|
clearTimeout(timer);
|
|
253335
|
+
reader.cancel().catch(() => {
|
|
253336
|
+
});
|
|
253337
|
+
}
|
|
253338
|
+
return text + decoder.decode();
|
|
253339
|
+
}
|
|
253340
|
+
async function readEdgeError(response) {
|
|
253341
|
+
if (response.status < 400 || !response.headers.get("cf-ray")) return null;
|
|
253342
|
+
if (response.headers.get("cf-mitigated") === "challenge") {
|
|
253343
|
+
return { code: response.status, name: "challenge" };
|
|
253329
253344
|
}
|
|
253345
|
+
const body = await readBodyPrefix(response);
|
|
253346
|
+
return body === null ? null : parseEdgeErrorBody(body, response.status);
|
|
253330
253347
|
}
|
|
253331
253348
|
function targetOrigin(input) {
|
|
253332
253349
|
try {
|
|
@@ -271518,4 +271535,4 @@ export {
|
|
|
271518
271535
|
runCLI
|
|
271519
271536
|
};
|
|
271520
271537
|
|
|
271521
|
-
//# debugId=
|
|
271538
|
+
//# debugId=45318CD4F94D8EF364756E2164756E21
|