/** * Returns `` from `authorization: Bearer `. * @param headers may or may not contain the Authorization header. * @returns `` or undefined if headers did not contain the expected header and value. */ export function getAuthorizationTokenFromHeaders(headers: Headers): string | undefined { const [, token] = headers.get('authorization')?.trim().split(' ', 2) ?? []; return token; }