specli 0.0.29 → 0.0.30
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/runtime/request.js +21 -1
- package/package.json +1 -1
|
@@ -264,7 +264,8 @@ export async function buildRequest(input) {
|
|
|
264
264
|
function buildCurl(req, body) {
|
|
265
265
|
const parts = ["curl", "-sS", "-X", req.method];
|
|
266
266
|
for (const [k, v] of req.headers.entries()) {
|
|
267
|
-
|
|
267
|
+
const value = k.toLowerCase() === "authorization" ? maskAuthHeader(v) : v;
|
|
268
|
+
parts.push("-H", shellQuote(`${k}: ${value}`));
|
|
268
269
|
}
|
|
269
270
|
if (typeof body === "string") {
|
|
270
271
|
parts.push("--data", shellQuote(body));
|
|
@@ -272,6 +273,25 @@ function buildCurl(req, body) {
|
|
|
272
273
|
parts.push(shellQuote(req.url));
|
|
273
274
|
return parts.join(" ");
|
|
274
275
|
}
|
|
276
|
+
function maskAuthHeader(value) {
|
|
277
|
+
// Mask token in authorization header, preserving scheme (e.g., "Bearer")
|
|
278
|
+
// "Bearer abc123xyz" -> "Bearer abc...xyz"
|
|
279
|
+
const parts = value.split(" ");
|
|
280
|
+
if (parts.length === 2) {
|
|
281
|
+
const [scheme, token] = parts;
|
|
282
|
+
return `${scheme} ${maskToken(token)}`;
|
|
283
|
+
}
|
|
284
|
+
// No scheme, just mask the whole value
|
|
285
|
+
return maskToken(value);
|
|
286
|
+
}
|
|
287
|
+
function maskToken(token) {
|
|
288
|
+
if (token.length <= 6) {
|
|
289
|
+
return "***";
|
|
290
|
+
}
|
|
291
|
+
const prefix = token.slice(0, 3);
|
|
292
|
+
const suffix = token.slice(-3);
|
|
293
|
+
return `${prefix}...${suffix}`;
|
|
294
|
+
}
|
|
275
295
|
function shellQuote(value) {
|
|
276
296
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
277
297
|
}
|