This commit is contained in:
Kismet Hasanaj
2026-05-02 20:07:02 +02:00
parent ce8672e283
commit 34dc9aec52
9428 changed files with 1733330 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
export declare const ipcForbiddenHeaders: string[];
export declare const actionsForbiddenHeaders: string[];
export declare const filterReqHeaders: (headers: Record<string, undefined | string | number | string[]>, forbiddenHeaders: string[]) => Record<string, undefined | string | string[]>;
export declare const filterInternalHeaders: (headers: Record<string, undefined | string | string[]>) => void;
+81
View File
@@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
actionsForbiddenHeaders: null,
filterInternalHeaders: null,
filterReqHeaders: null,
ipcForbiddenHeaders: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
actionsForbiddenHeaders: function() {
return actionsForbiddenHeaders;
},
filterInternalHeaders: function() {
return filterInternalHeaders;
},
filterReqHeaders: function() {
return filterReqHeaders;
},
ipcForbiddenHeaders: function() {
return ipcForbiddenHeaders;
}
});
const ipcForbiddenHeaders = [
'accept-encoding',
'keepalive',
'keep-alive',
'content-encoding',
'transfer-encoding',
// https://github.com/nodejs/undici/issues/1470
'connection',
// marked as unsupported by undici: https://github.com/nodejs/undici/blob/c83b084879fa0bb8e0469d31ec61428ac68160d5/lib/core/request.js#L354
'expect'
];
const actionsForbiddenHeaders = [
...ipcForbiddenHeaders,
'content-length',
'set-cookie'
];
const filterReqHeaders = (headers, forbiddenHeaders)=>{
// Some browsers are not matching spec and sending Content-Length: 0. This causes issues in undici
// https://github.com/nodejs/undici/issues/2046
if (headers['content-length'] && headers['content-length'] === '0') {
delete headers['content-length'];
}
for (const [key, value] of Object.entries(headers)){
if (forbiddenHeaders.includes(key) || !(Array.isArray(value) || typeof value === 'string')) {
delete headers[key];
}
}
return headers;
};
// These are headers that are only used internally and should
// not be honored from the external request
const INTERNAL_HEADERS = [
'x-middleware-rewrite',
'x-middleware-redirect',
'x-middleware-set-cookie',
'x-middleware-skip',
'x-middleware-override-headers',
'x-middleware-next',
'x-now-route-matches',
'x-matched-path',
'x-next-resume-state-length'
];
const filterInternalHeaders = (headers)=>{
for(const header in headers){
if (INTERNAL_HEADERS.includes(header)) {
delete headers[header];
}
}
};
//# sourceMappingURL=utils.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/lib/server-ipc/utils.ts"],"sourcesContent":["export const ipcForbiddenHeaders = [\n 'accept-encoding',\n 'keepalive',\n 'keep-alive',\n 'content-encoding',\n 'transfer-encoding',\n // https://github.com/nodejs/undici/issues/1470\n 'connection',\n // marked as unsupported by undici: https://github.com/nodejs/undici/blob/c83b084879fa0bb8e0469d31ec61428ac68160d5/lib/core/request.js#L354\n 'expect',\n]\n\nexport const actionsForbiddenHeaders = [\n ...ipcForbiddenHeaders,\n 'content-length',\n 'set-cookie',\n]\n\nexport const filterReqHeaders = (\n headers: Record<string, undefined | string | number | string[]>,\n forbiddenHeaders: string[]\n) => {\n // Some browsers are not matching spec and sending Content-Length: 0. This causes issues in undici\n // https://github.com/nodejs/undici/issues/2046\n if (headers['content-length'] && headers['content-length'] === '0') {\n delete headers['content-length']\n }\n\n for (const [key, value] of Object.entries(headers)) {\n if (\n forbiddenHeaders.includes(key) ||\n !(Array.isArray(value) || typeof value === 'string')\n ) {\n delete headers[key]\n }\n }\n return headers as Record<string, undefined | string | string[]>\n}\n\n// These are headers that are only used internally and should\n// not be honored from the external request\nconst INTERNAL_HEADERS = [\n 'x-middleware-rewrite',\n 'x-middleware-redirect',\n 'x-middleware-set-cookie',\n 'x-middleware-skip',\n 'x-middleware-override-headers',\n 'x-middleware-next',\n 'x-now-route-matches',\n 'x-matched-path',\n 'x-next-resume-state-length',\n]\n\nexport const filterInternalHeaders = (\n headers: Record<string, undefined | string | string[]>\n) => {\n for (const header in headers) {\n if (INTERNAL_HEADERS.includes(header)) {\n delete headers[header]\n }\n }\n}\n"],"names":["actionsForbiddenHeaders","filterInternalHeaders","filterReqHeaders","ipcForbiddenHeaders","headers","forbiddenHeaders","key","value","Object","entries","includes","Array","isArray","INTERNAL_HEADERS","header"],"mappings":";;;;;;;;;;;;;;;;;IAYaA,uBAAuB;eAAvBA;;IAyCAC,qBAAqB;eAArBA;;IAnCAC,gBAAgB;eAAhBA;;IAlBAC,mBAAmB;eAAnBA;;;AAAN,MAAMA,sBAAsB;IACjC;IACA;IACA;IACA;IACA;IACA,+CAA+C;IAC/C;IACA,2IAA2I;IAC3I;CACD;AAEM,MAAMH,0BAA0B;OAClCG;IACH;IACA;CACD;AAEM,MAAMD,mBAAmB,CAC9BE,SACAC;IAEA,kGAAkG;IAClG,+CAA+C;IAC/C,IAAID,OAAO,CAAC,iBAAiB,IAAIA,OAAO,CAAC,iBAAiB,KAAK,KAAK;QAClE,OAAOA,OAAO,CAAC,iBAAiB;IAClC;IAEA,KAAK,MAAM,CAACE,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACL,SAAU;QAClD,IACEC,iBAAiBK,QAAQ,CAACJ,QAC1B,CAAEK,CAAAA,MAAMC,OAAO,CAACL,UAAU,OAAOA,UAAU,QAAO,GAClD;YACA,OAAOH,OAAO,CAACE,IAAI;QACrB;IACF;IACA,OAAOF;AACT;AAEA,6DAA6D;AAC7D,2CAA2C;AAC3C,MAAMS,mBAAmB;IACvB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAEM,MAAMZ,wBAAwB,CACnCG;IAEA,IAAK,MAAMU,UAAUV,QAAS;QAC5B,IAAIS,iBAAiBH,QAAQ,CAACI,SAAS;YACrC,OAAOV,OAAO,CAACU,OAAO;QACxB;IACF;AACF","ignoreList":[0]}