185 lines
5.1 KiB
JavaScript
185 lines
5.1 KiB
JavaScript
// Module ID: 883
|
|
// Function ID: 9765
|
|
// Name: winterCGHeadersToDict
|
|
// Dependencies: []
|
|
// Exports: httpHeadersToSpanAttributes, httpRequestToRequestData, winterCGRequestToRequestData
|
|
|
|
// Module 883 (winterCGHeadersToDict)
|
|
function winterCGHeadersToDict(arr) {
|
|
let closure_0 = {};
|
|
const item = arr.forEach((arg0, arg1) => {
|
|
if ("string" === typeof arg0) {
|
|
obj[arg1] = arg0;
|
|
}
|
|
});
|
|
}
|
|
function headersToDict(arg0) {
|
|
let closure_0 = Object.create(null);
|
|
const entries = Object.entries(arg0);
|
|
const item = entries.forEach((arg0) => {
|
|
const tmp3 = obj(arg0, 2)[1];
|
|
if ("string" === typeof tmp3) {
|
|
obj[tmp2] = tmp3;
|
|
}
|
|
});
|
|
}
|
|
function normalizeAttributeKey(str) {
|
|
return str.replace(/-/g, "_");
|
|
}
|
|
function addSpanAttribute(arg0, arg1, arg2, arr) {
|
|
const tmp2 = normalizeAttributeKey(arg1);
|
|
if (arg2) {
|
|
const _HermesInternal2 = HermesInternal;
|
|
let combined = "http.request.header." + tmp2 + "." + normalizeAttributeKey(arg2);
|
|
} else {
|
|
const _HermesInternal = HermesInternal;
|
|
combined = "http.request.header." + tmp2;
|
|
}
|
|
let tmp4 = arg2;
|
|
if (!arg2) {
|
|
tmp4 = arg1;
|
|
}
|
|
const tmp5 = function handleHttpHeader(arg0, arr, arg2) {
|
|
if (arg2) {
|
|
let someResult = closure_1.some((arg0) => arg0.includes(arg0));
|
|
} else {
|
|
const items = [];
|
|
const combined = items.concat(closure_2, closure_1);
|
|
someResult = combined.some((arg0) => arg0.includes(arg0));
|
|
}
|
|
if (someResult) {
|
|
return "[Filtered]";
|
|
} else {
|
|
const _Array = Array;
|
|
if (Array.isArray(arr)) {
|
|
const mapped = arr.map((arg0) => {
|
|
let StringResult = arg0;
|
|
if (null != arg0) {
|
|
const _String = String;
|
|
StringResult = String(arg0);
|
|
}
|
|
return StringResult;
|
|
});
|
|
return mapped.join(";");
|
|
} else {
|
|
return "string" === typeof arr ? arr : undefined;
|
|
}
|
|
}
|
|
}(tmp4, arr, arg4);
|
|
if (undefined !== tmp5) {
|
|
arg0[combined] = tmp5;
|
|
}
|
|
}
|
|
function extractQueryParamsFromUrl(arg0) {
|
|
if (arg0) {
|
|
const _URL = URL;
|
|
const uRL = new URL(tmp, "http://s.io");
|
|
const search = uRL.search;
|
|
const substr = search.slice(1);
|
|
let tmp9;
|
|
if (substr.length) {
|
|
tmp9 = substr;
|
|
}
|
|
return tmp9;
|
|
}
|
|
}
|
|
let closure_0 = require(dependencyMap[0]);
|
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
let closure_1 = [];
|
|
let closure_2 = [];
|
|
|
|
export { extractQueryParamsFromUrl };
|
|
export { headersToDict };
|
|
export const httpHeadersToSpanAttributes = function httpHeadersToSpanAttributes(arg0) {
|
|
const tmp = arguments.length > 1 && undefined !== arguments[1];
|
|
let tmp2 = tmp;
|
|
if (tmp) {
|
|
tmp2 = arguments[1];
|
|
}
|
|
let closure_0 = tmp2;
|
|
let closure_1 = {};
|
|
const entries = Object.entries(arg0);
|
|
const item = entries.forEach((arg0) => {
|
|
const tmp = tmp2(arg0, 2);
|
|
if (null != tmp[1]) {
|
|
const formatted = str.toLowerCase();
|
|
if ("cookie" === formatted) {
|
|
if ("string" === typeof arr) {
|
|
if ("" !== arr) {
|
|
const index = arr.indexOf(";");
|
|
let num = arr;
|
|
if ("set-cookie" === tmp16) {
|
|
num = arr;
|
|
if (-1 !== index) {
|
|
num = arr.substring(0, index);
|
|
}
|
|
}
|
|
if ("set-cookie" === tmp16) {
|
|
const items = [num];
|
|
let parts = items;
|
|
} else {
|
|
parts = num.split("; ");
|
|
}
|
|
parts[Symbol.iterator]();
|
|
num = -1;
|
|
}
|
|
}
|
|
}
|
|
callback(obj, formatted, "", arr, tmp2);
|
|
}
|
|
});
|
|
};
|
|
export const httpRequestToRequestData = function httpRequestToRequestData(headers) {
|
|
let host;
|
|
let protocol;
|
|
let url;
|
|
const tmp = headers.headers || {};
|
|
let prop;
|
|
if ("string" === typeof tmp.x-forwarded-host) {
|
|
prop = tmp.x-forwarded-host;
|
|
}
|
|
if (!prop) {
|
|
host = undefined;
|
|
if ("string" === typeof tmp.host) {
|
|
host = tmp.host;
|
|
}
|
|
prop = host;
|
|
}
|
|
let prop1;
|
|
if ("string" === typeof tmp.x-forwarded-proto) {
|
|
prop1 = tmp.x-forwarded-proto;
|
|
}
|
|
if (!prop1) {
|
|
prop1 = headers.protocol;
|
|
}
|
|
if (!prop1) {
|
|
const socket = headers.socket;
|
|
let str2 = "http";
|
|
if (null != socket) {
|
|
str2 = "http";
|
|
if (socket.encrypted) {
|
|
str2 = "https";
|
|
}
|
|
}
|
|
prop1 = str2;
|
|
}
|
|
let obj = { url: tmp6, host: prop, protocol: prop1 };
|
|
({ url, protocol, host } = obj);
|
|
if (null == url) {
|
|
if (url) {
|
|
if (host) {
|
|
const _HermesInternal = HermesInternal;
|
|
let combined = "" + protocol + "://" + host + url;
|
|
}
|
|
}
|
|
} else {
|
|
combined = url;
|
|
}
|
|
obj = { url: combined, method: headers.method, query_string: extractQueryParamsFromUrl(headers.url || ""), headers: headersToDict(tmp), cookies: headers.cookies, data: headers.body || undefined };
|
|
return obj;
|
|
};
|
|
export { winterCGHeadersToDict };
|
|
export const winterCGRequestToRequestData = function winterCGRequestToRequestData(method) {
|
|
const obj = { method: method.method, url: method.url, query_string: extractQueryParamsFromUrl(method.url), headers: winterCGHeadersToDict(method.headers) };
|
|
return obj;
|
|
};
|