mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
0f06e635df
* feat(platform/azure): support bearer token auth (auto-detect token type) * refactor(platform/azure): use isPlainObject for JWT header check Replace manual typeof/null check with isPlainObject() from @sindresorhus/is in isProbablyJwt(). Remove unused _GlobalConfig import from test file. * refactor(platform/azure): use parseJsonc to parse JWT header * test(platform/azure): use a real JWT in the set bearer token/endpoint test * feat(platform/azure): log detected token type * refactor(platform/azure): guard token before JWT check; remove outdated todo comment * docs(platform/azure): restore TODO note about possibly-undefined token (#22198) * refactor(platform/azure): move isProbablyJwt() and tests to new files lib/util/http/jwt.ts and lib/util/http/jwt.spec.ts * refactor(platform/azure): use Json.safeParse() instead of parseJsonc() in isProbablyJwt() * refactor(platform/azure): accept undefined token in isProbablyJwt and add guard to drop non-null assertions * test(platform/azure): extract shared buildTestJwt helper and dedupe * docs(platform/azure): reword the Entra ID token instructions * chore(platform/azure): remove irrelevant lines from docstring * refactor(platform/azure): export buildTestJwt() from new test/jwt-util.ts * docs(platform/azure): use 1 for numbered lists * refactor(test): extract arrow function from buildTestJwt --------- Co-authored-by: Bastian Wenske <bastianwenske@outlook.de>
14 lines
362 B
TypeScript
14 lines
362 B
TypeScript
type StrObjNull = string | object | null;
|
|
|
|
function encodeJwtPart(segment: StrObjNull): string {
|
|
return Buffer.from(JSON.stringify(segment)).toString('base64url');
|
|
}
|
|
|
|
export function buildTestJwt(
|
|
header: StrObjNull,
|
|
payload: StrObjNull,
|
|
sig: StrObjNull,
|
|
): string {
|
|
return `${encodeJwtPart(header)}.${encodeJwtPart(payload)}.${encodeJwtPart(sig)}`;
|
|
}
|