diff --git a/src/frontier-coverage/evidence-capture.ts b/src/frontier-coverage/evidence-capture.ts index e798915c..58c7c852 100644 --- a/src/frontier-coverage/evidence-capture.ts +++ b/src/frontier-coverage/evidence-capture.ts @@ -135,6 +135,8 @@ const EMAIL_PATTERN = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi; const LONG_TOKEN_PATTERN = /\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+|\b[A-Za-z0-9_-]{24,}\b/g; const UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi; const PRIVATE_NAME_PATTERN = /\b[A-Z][a-z]+ [A-Z][a-z]+\b/g; +const KEPT_HEADERS = new Set(["accept", "content-type", "x-substack-version"]); + const PRIVATE_NAME_KEYS = new Set(["first_name", "last_name", "full_name", "display_name", "name"]); const BODY_PREVIEW_LIMIT = 2_000; const REDACTED = "[REDACTED]"; @@ -461,7 +463,7 @@ function minimizeHeaders( const kept: Record = {}; for (const [key, value] of Object.entries(headers)) { const normalized = key.toLowerCase(); - if (["accept", "content-type", "x-substack-version"].includes(normalized)) { + if (KEPT_HEADERS.has(normalized)) { kept[normalized] = redactValueForKey(normalized, value); } else if (SENSITIVE_KEY_PATTERN.test(key)) { kept[normalized] = REDACTED; diff --git a/src/substack-api/schedule-reconcile.ts b/src/substack-api/schedule-reconcile.ts index 8c565556..d1188160 100644 --- a/src/substack-api/schedule-reconcile.ts +++ b/src/substack-api/schedule-reconcile.ts @@ -1,3 +1,9 @@ +const SCHEDULED_QUEUE_STATUSES = new Set(["scheduled", "queue", "queued"]); +const PUBLISHED_QUEUE_STATUSES = new Set(["published", "publish", "live", "sent"]); +const SCHEDULED_EXPECTED_STATUSES = new Set(["scheduled", "schedule", "queued", "queue"]); +const PUBLISHED_EXPECTED_STATUSES = new Set(["published", "publish", "published_at", "live"]); +const DRAFT_EXPECTED_STATUSES = new Set(["draft", "unscheduled", "drafted"]); + export type ScheduleReconcileKey = "title" | "time" | "draft-id"; type ReconciledQueueStatus = "scheduled" | "published" | "draft" | "other"; @@ -365,8 +371,8 @@ function normalizeQueueStatus(status: string | undefined): ReconciledQueueStatus if (!status) return "other"; const normalized = status.trim().toLowerCase(); - if (["scheduled", "queue", "queued"].includes(normalized)) return "scheduled"; - if (["published", "publish", "live", "sent"].includes(normalized)) return "published"; + if (SCHEDULED_QUEUE_STATUSES.has(normalized)) return "scheduled"; + if (PUBLISHED_QUEUE_STATUSES.has(normalized)) return "published"; if (normalized.includes("draft")) return "draft"; return "other"; } @@ -383,9 +389,9 @@ function parseExpectedStatus(item: Record, index: number, sourc function normalizeExpectedStatus(raw: string): "scheduled" | "published" | "draft" | undefined { const normalized = raw.trim().toLowerCase(); - if (["scheduled", "schedule", "queued", "queue"].includes(normalized)) return "scheduled"; - if (["published", "publish", "published_at", "live"].includes(normalized)) return "published"; - if (["draft", "unscheduled", "drafted"].includes(normalized)) return "draft"; + if (SCHEDULED_EXPECTED_STATUSES.has(normalized)) return "scheduled"; + if (PUBLISHED_EXPECTED_STATUSES.has(normalized)) return "published"; + if (DRAFT_EXPECTED_STATUSES.has(normalized)) return "draft"; return undefined; }