Clean up as per review comments

Signed-off-by: Andy Caruso <macaruso@gmail.com>
This commit is contained in:
Andy Caruso
2022-03-29 10:08:10 -07:00
committed by blam
parent cbe119efa6
commit d253d46ba9
5 changed files with 47 additions and 20 deletions
@@ -24,7 +24,10 @@ const logger = getVoidLogger();
function jwtKid(jwt: string): string {
const header = decodeProtectedHeader(jwt);
return header.kid ?? '';
if (!header.kid) {
throw new Error('JWT Header did not contain a key ID (kid)');
}
return header.kid;
}
const entityRef = stringifyEntityRef({
@@ -44,11 +44,6 @@ type Options = {
resolverContext: AuthResolverContext;
};
export const getJWTHeaders = (input: string): AwsAlbHeaders => {
const encoded = input.split('.')[0];
return JSON.parse(Buffer.from(encoded, 'base64').toString('utf8'));
};
export type AwsAlbHeaders = {
alg: string;
kid: string;