// The gateway's shared-secret auth contract accepts either `token` or // `password` as the Bearer credential on authenticated control-UI routes. // Passing the password through the Authorization header is the intended // server-side contract for `gateway.auth.mode="password"`. Callers that need // resilience to stale credentials should use `resolveControlUiAuthCandidates` // below to retry with the alternate credential on 401. function sanitizeHeaderToken(value: string | null): string | null { if (!value) { returnnull;
} // Reject tokens that would smuggle CR/LF into the HTTP header. return /[\r\n]/.test(value) ? null : value;
}
// Ordered list of non-empty, header-safe shared-secret candidates. Used by // call sites that can retry a single request against an alternate credential // when the first returns 401 — for example, recovering from a stale // `settings.token` when the live session is authenticated via `password`.
export function resolveControlUiAuthCandidates(source: ControlUiAuthSource): string[] { const seen = new Set<string>(); const out: string[] = []; for (const raw of [
normalizeOptionalString(source.hello?.auth?.deviceToken),
normalizeOptionalString(source.settings?.token),
normalizeOptionalString(source.password),
]) { const sanitized = sanitizeHeaderToken(raw ?? null); if (sanitized && !seen.has(sanitized)) {
seen.add(sanitized);
out.push(sanitized);
}
} return out;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.19 Sekunden
(vorverarbeitet am 2026-06-07)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.