@a2a-exposed/control-core 0.8.32 → 0.8.34

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.
Files changed (2) hide show
  1. package/dist/index.js +81 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3192,8 +3192,12 @@ var BASIC_RE = /(basic\s+)(\S+)/gi;
3192
3192
  var PEM_RE = /-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----[\s\S]*?(?:-----END (?:[A-Z0-9]+ )?PRIVATE KEY-----|$)/g;
3193
3193
  var API_KEY_RE = /(?:(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|\bAKIA[0-9A-Z]{16}\b|\bsk_(?:live|test)_[A-Za-z0-9]{10,}|\brk_(?:live|test)_[A-Za-z0-9]{10,}|\bsk-(?:proj-)?[A-Za-z0-9_-]{20,}|\bxox[baprs]-[A-Za-z0-9-]{10,}|\bAIza[0-9A-Za-z_-]{35}\b)/g;
3194
3194
  var JWT_RE = /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g;
3195
- var AUTH_RE = /\b((?:proxy-)?authorization)(\s*[:=]\s*)([^\n]+)/gi;
3195
+ var AUTH_RE = /\b((?:proxy-)?authorization)(\s*[:=]\s*)([^\r\n]+)/gi;
3196
3196
  var QUERY_RE = /(^|[?&#\s])([^?&#\s="'<>]+)(\s*=\s*)("(?:\\.|[^"\\])*(?:"|$)|'(?:\\.|[^'\\])*(?:'|$)|(?:\\(?!["'])|[^&#\s"'<>\\])*)/g;
3197
+ var HEADER_RE = /\b([A-Za-z][A-Za-z0-9_-]*)([ \t]*:[ \t]*)/g;
3198
+ var CONFIG_LINE_RE = /^([ \t]*)([A-Z_][A-Z0-9_]*)([ \t]*=[ \t]*)([^\r\n]*)/gm;
3199
+ var URL_PATH_RE = /(\bhttps?:\/\/[^/?#\s"'<>]+)([^?#\s"'<>]*)/gi;
3200
+ var QUERY_SECRET = /* @__PURE__ */ new Set(["key", "sig", "code", "codeverifier"]);
3197
3201
  var ASSIGN_RE = /\b([A-Za-z_][A-Za-z0-9_]*)(\s*=\s*)/g;
3198
3202
  var SECRET_EXACT = /* @__PURE__ */ new Set([
3199
3203
  "authorization",
@@ -3203,6 +3207,8 @@ var SECRET_EXACT = /* @__PURE__ */ new Set([
3203
3207
  "password",
3204
3208
  "passwd",
3205
3209
  "secret",
3210
+ "secrets",
3211
+ "signature",
3206
3212
  "token",
3207
3213
  "apikey",
3208
3214
  "accesstoken",
@@ -3216,9 +3222,12 @@ var SECRET_EXACT = /* @__PURE__ */ new Set([
3216
3222
  "bearer",
3217
3223
  "webhookkey",
3218
3224
  "accessclientid",
3219
- "accessclientsecret"
3225
+ "accessclientsecret",
3226
+ "xhubsignature256"
3220
3227
  ]);
3221
3228
  var SECRET_SUFFIX = [
3229
+ "secrets",
3230
+ "signature",
3222
3231
  "authorization",
3223
3232
  "token",
3224
3233
  "secret",
@@ -3273,6 +3282,38 @@ function unquotedValueEnd(text, start) {
3273
3282
  while (i < text.length && !/\s/.test(text[i])) i += 1;
3274
3283
  return i;
3275
3284
  }
3285
+ function jsonStringSpans(text) {
3286
+ const strings = [];
3287
+ for (let i = 0; i < text.length; i += 1) {
3288
+ if (text[i] !== '"') continue;
3289
+ const end = quotedValueEnd(text, i);
3290
+ try {
3291
+ JSON.parse(text.slice(i, end));
3292
+ strings.push([i, end]);
3293
+ } catch {
3294
+ }
3295
+ i = end - 1;
3296
+ }
3297
+ return strings;
3298
+ }
3299
+ function redactHeaderLines(text) {
3300
+ const strings = jsonStringSpans(text);
3301
+ const pattern = new RegExp(HEADER_RE.source, "g");
3302
+ let out = "";
3303
+ let last = 0;
3304
+ let match;
3305
+ while ((match = pattern.exec(text)) !== null) {
3306
+ if (!secretName(match[1]) || strings.some(([start2, end2]) => match.index >= start2 && match.index < end2)) continue;
3307
+ const start = pattern.lastIndex;
3308
+ let end = start;
3309
+ while (end < text.length && !/[\r\n]/.test(text[end])) end += 1;
3310
+ if (end === start) continue;
3311
+ out += text.slice(last, start) + REDACTED;
3312
+ last = end;
3313
+ pattern.lastIndex = end;
3314
+ }
3315
+ return out + text.slice(last);
3316
+ }
3276
3317
  function redactAssignments(text) {
3277
3318
  const pattern = new RegExp(ASSIGN_RE.source, "g");
3278
3319
  const parameters = Array.from(text.matchAll(new RegExp(QUERY_RE.source, "g")));
@@ -3377,19 +3418,43 @@ function redactNested(value, depth, cache = /* @__PURE__ */ new Map()) {
3377
3418
  return REDACTED;
3378
3419
  }
3379
3420
  }
3421
+ function redactEnvironmentLines(text) {
3422
+ const pattern = new RegExp(CONFIG_LINE_RE.source, "gm");
3423
+ let out = "";
3424
+ let last = 0;
3425
+ let match;
3426
+ while ((match = pattern.exec(text)) !== null) {
3427
+ const [, indent, name, sep, item] = match;
3428
+ const structured = item.startsWith("{") || item.startsWith("[");
3429
+ const parameterList = /^[^\s<>]*[&#][^?&#\s="'<>]+[ \t]*=/.test(item) && !structured;
3430
+ if (!secretName(name) || !item || /^["']/.test(item) || parameterList || /\b[A-Za-z_][A-Za-z0-9_]*\s*=\s*$/.test(item)) continue;
3431
+ const start = match.index + indent.length + name.length + sep.length;
3432
+ const end = structured ? jsonValueEnd(text, start) : pattern.lastIndex;
3433
+ out += text.slice(last, start) + REDACTED;
3434
+ last = end;
3435
+ pattern.lastIndex = end;
3436
+ }
3437
+ return out + text.slice(last);
3438
+ }
3380
3439
  function redactText(value, depth, cache) {
3381
3440
  let text = redactJsonFields(value, depth, cache);
3382
3441
  text = replaceAll(text, PEM_RE, REDACTED);
3442
+ text = redactEnvironmentLines(text);
3383
3443
  text = replaceAll(text, JWT_RE, REDACTED);
3384
3444
  text = replaceAll(text, API_KEY_RE, REDACTED);
3385
3445
  text = replaceAll(text, TOKEN_RE, REDACTED);
3386
3446
  text = replaceAll(text, BEARER_RE, `$1${REDACTED}`);
3387
3447
  text = replaceAll(text, BASIC_RE, `$1${REDACTED}`);
3388
- text = replaceAll(text, AUTH_RE, (_all, name, sep, rest) => {
3448
+ text = redactHeaderLines(text);
3449
+ const authStrings = jsonStringSpans(text);
3450
+ text = text.replace(AUTH_RE, (all, name, sep, rest, offset) => {
3451
+ if (authStrings.some(([start, end]) => offset >= start && offset < end)) return all;
3389
3452
  if (rest.trim().length < 8 && !/bearer|basic/i.test(rest)) return `${name}${sep}${rest}`;
3390
3453
  return `${name}${sep}${REDACTED}`;
3391
3454
  });
3392
3455
  text = replaceAll(text, USERINFO_RE, `$1${REDACTED}@`);
3456
+ text = text.replace(/(\/webhooks\/)\d+\/[^/?#\s"'<>]+/gi, `$1${REDACTED}/${REDACTED}`).replace(/(\/(?:hooks|webhooks)\/)[^/?#\s"'<>]+/gi, `$1${REDACTED}`).replace(/\/bot[0-9]+:[^/?#\s"'<>]+/gi, `/bot${REDACTED}`);
3457
+ text = replaceAll(text, URL_PATH_RE, (_all, origin, path) => origin + path.replace(/\/[^/]{16,}/g, `/${REDACTED}`));
3393
3458
  const cleanParameter = (all, sep, name, assignment, item) => {
3394
3459
  let decoded = name;
3395
3460
  while (true) {
@@ -3408,7 +3473,7 @@ function redactText(value, depth, cache) {
3408
3473
  setup = /^[A-Za-z0-9_-]{16,}/.test(candidate);
3409
3474
  }
3410
3475
  if (!item) return all;
3411
- if (!secretName(decoded) && !setup) {
3476
+ if (!secretName(decoded) && !QUERY_SECRET.has(compactName(decoded)) && !setup) {
3412
3477
  const quote = item[0];
3413
3478
  const wrapped = (quote === '"' || quote === "'") && item.endsWith(quote) && item.length > 1;
3414
3479
  const cleaned = wrapped ? quote + redactNested(item.slice(1, -1), depth + 1, cache) + quote : redactNested(item, depth + 1, cache);
@@ -3416,17 +3481,7 @@ function redactText(value, depth, cache) {
3416
3481
  }
3417
3482
  return `${sep}${name}${assignment}${REDACTED}`;
3418
3483
  };
3419
- const strings = [];
3420
- for (let i = 0; i < text.length; i += 1) {
3421
- if (text[i] !== '"') continue;
3422
- const end = quotedValueEnd(text, i);
3423
- try {
3424
- JSON.parse(text.slice(i, end));
3425
- strings.push([i, end]);
3426
- } catch {
3427
- }
3428
- i = end - 1;
3429
- }
3484
+ const strings = jsonStringSpans(text);
3430
3485
  const parameters = new RegExp(QUERY_RE.source, "g");
3431
3486
  let out = "";
3432
3487
  let last = 0;
@@ -3478,6 +3533,17 @@ function walk(value, seen) {
3478
3533
  return value.map((item) => walk(item, seen));
3479
3534
  }
3480
3535
  const proto = Object.getPrototypeOf(value);
3536
+ if (value instanceof Error) {
3537
+ const out2 = new Error();
3538
+ Object.setPrototypeOf(out2, proto);
3539
+ delete out2.stack;
3540
+ for (const key of Reflect.ownKeys(value)) {
3541
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
3542
+ const item = "value" in descriptor && !(typeof key === "string" && secretName(key)) ? walk(descriptor.value, seen) : REDACTED;
3543
+ Object.defineProperty(out2, key, { value: item, enumerable: descriptor.enumerable, configurable: true, writable: true });
3544
+ }
3545
+ return out2;
3546
+ }
3481
3547
  if (proto !== Object.prototype && proto !== null) return value;
3482
3548
  const record = value;
3483
3549
  const hidden = /* @__PURE__ */ new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2a-exposed/control-core",
3
- "version": "0.8.32",
3
+ "version": "0.8.34",
4
4
  "description": "A2A endpoint provisioning, routing, and D1 migrations for a2a-exposed.",
5
5
  "type": "module",
6
6
  "scripts": {