mirror of
https://github.com/graphql-hive/console
synced 2026-05-23 09:08:34 +00:00
fix: gracefully handle base64 decoding error in case of invalid access token (#1302)
This commit is contained in:
parent
efae22e7b6
commit
f01c25efce
1 changed files with 8 additions and 1 deletions
|
|
@ -38,7 +38,14 @@ export function decodeCdnAccessTokenSafe(token: string) {
|
|||
|
||||
token = token.slice(keyPrefix.length);
|
||||
|
||||
const str = globalThis.atob(token);
|
||||
let str: string;
|
||||
|
||||
try {
|
||||
str = globalThis.atob(token);
|
||||
} catch (error) {
|
||||
return decodeError;
|
||||
}
|
||||
|
||||
const [keyId, privateKey] = str.split(':');
|
||||
if (keyId && privateKey) {
|
||||
return { type: 'success', token: { keyId, privateKey } } as const;
|
||||
|
|
|
|||
Loading…
Reference in a new issue