clean up some deprecations
Signed-off-by: Maximilian Vorbrodt <maximilian.vorbrodt@hotmail.com>
This commit is contained in:
+13
-11
@@ -48,7 +48,7 @@ describe('ProxiedSignInIdentity', () => {
|
||||
|
||||
it('handles a token that has no exp', async () => {
|
||||
const [a, _b, c] = validBackstageToken.split('.');
|
||||
const botched = `${a}.${btoa(JSON.stringify({}))}.${c}`;
|
||||
const botched = `${a}.${window.btoa(JSON.stringify({}))}.${c}`;
|
||||
expect(tokenToExpiry(botched)).toEqual(
|
||||
new Date(new Date(Date.now() + DEFAULTS.defaultTokenExpiryMillis)),
|
||||
);
|
||||
@@ -81,16 +81,18 @@ describe('ProxiedSignInIdentity', () => {
|
||||
backstageIdentity: {
|
||||
token: [
|
||||
'eyJhbGciOiJFUzI1NiIsImtpZCI6ImMxNTMzNDRiLWZjYzktNGIwOS1iN2ZhLTU3ZmM5MDhjMjBiNiJ9',
|
||||
btoa(
|
||||
JSON.stringify({
|
||||
iss: 'http://localhost:7007/api/auth',
|
||||
sub: 'user:default/freben',
|
||||
aud: 'backstage',
|
||||
iat,
|
||||
exp,
|
||||
ent: ['group:default/my-team'],
|
||||
}),
|
||||
).replace(/=/g, ''),
|
||||
window
|
||||
.btoa(
|
||||
JSON.stringify({
|
||||
iss: 'http://localhost:7007/api/auth',
|
||||
sub: 'user:default/freben',
|
||||
aud: 'backstage',
|
||||
iat,
|
||||
exp,
|
||||
ent: ['group:default/my-team'],
|
||||
}),
|
||||
)
|
||||
.replace(/=/g, ''),
|
||||
'4nOTmPHPwhzaKTzikgUsHcszfcP-JamcojMnRfyfsKhyHCCEywe6uLFlvvmK5NbaX5Z7IIji-kg7bxKU58kwoQ',
|
||||
].join('.'),
|
||||
identity: {
|
||||
|
||||
@@ -40,7 +40,7 @@ export function tokenToExpiry(jwtToken: string | undefined): Date {
|
||||
}
|
||||
|
||||
const [_header, rawPayload, _signature] = jwtToken.split('.');
|
||||
const payload = JSON.parse(atob(rawPayload));
|
||||
const payload = JSON.parse(window.atob(rawPayload));
|
||||
if (typeof payload.exp !== 'number') {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
|
||||
function parseJwtPayload(token: string) {
|
||||
const [_header, payload, _signature] = token.split('.');
|
||||
return JSON.parse(atob(payload));
|
||||
return JSON.parse(window.atob(payload));
|
||||
}
|
||||
|
||||
type LegacySignInResult = {
|
||||
|
||||
Reference in New Issue
Block a user