@deadair/plugin-sdk 0.25.0 → 0.25.1
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/index.js
CHANGED
|
@@ -1092,13 +1092,28 @@ var snippet = /* @__PURE__ */ __name((body) => {
|
|
|
1092
1092
|
if (trimmed2.length === 0) return "<empty body>";
|
|
1093
1093
|
return trimmed2.length <= BODY_SNIPPET_LENGTH ? trimmed2 : `${trimmed2.slice(0, BODY_SNIPPET_LENGTH)}\u2026`;
|
|
1094
1094
|
}, "snippet");
|
|
1095
|
+
var CREDENTIAL_PARAM = /key|token|secret|sig|pass|auth/i;
|
|
1096
|
+
var redactedUrl = /* @__PURE__ */ __name((raw) => {
|
|
1097
|
+
let url;
|
|
1098
|
+
try {
|
|
1099
|
+
url = new URL(raw);
|
|
1100
|
+
} catch {
|
|
1101
|
+
return raw;
|
|
1102
|
+
}
|
|
1103
|
+
for (const name of [
|
|
1104
|
+
...url.searchParams.keys()
|
|
1105
|
+
]) {
|
|
1106
|
+
if (CREDENTIAL_PARAM.test(name)) url.searchParams.set(name, "REDACTED");
|
|
1107
|
+
}
|
|
1108
|
+
return url.toString();
|
|
1109
|
+
}, "redactedUrl");
|
|
1095
1110
|
async function jsonBody(response) {
|
|
1096
1111
|
const text2 = await response.text();
|
|
1097
1112
|
try {
|
|
1098
1113
|
return JSON.parse(text2);
|
|
1099
1114
|
} catch (error) {
|
|
1100
1115
|
const reason = error instanceof Error ? error.message : String(error);
|
|
1101
|
-
throw new Error(`expected JSON from ${response.url} (HTTP ${response.status}) but got ${snippet(text2)}: ${reason}`, {
|
|
1116
|
+
throw new Error(`expected JSON from ${redactedUrl(response.url)} (HTTP ${response.status}) but got ${snippet(text2)}: ${reason}`, {
|
|
1102
1117
|
cause: error
|
|
1103
1118
|
});
|
|
1104
1119
|
}
|