Skip to content

Commit

Permalink
[SDK-3596] Remove references to IE11 and Safari 10 (auth0#955)
Browse files Browse the repository at this point in the history
Remove references to IE11 and Safari 10
  • Loading branch information
frederikprijck authored Aug 16, 2022
1 parent b8f931f commit 034278b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15,098 deletions.
43 changes: 0 additions & 43 deletions __tests__/Auth0Client/getTokenSilently.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,12 +948,6 @@ describe('Auth0Client', () => {

describe('Worker browser support', () => {
[
{
name: 'IE11',
userAgent:
'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko',
supported: false
},
{
name: 'Chrome',
userAgent:
Expand Down Expand Up @@ -1332,43 +1326,6 @@ describe('Auth0Client', () => {
expect(utils.runIframe).not.toHaveBeenCalled();
});

it('falls back to iframe when missing refresh token in ie11 and useRefreshTokensFallback is set to true', async () => {
const originalUserAgent = window.navigator.userAgent;
Object.defineProperty(window.navigator, 'userAgent', {
value:
'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko',
configurable: true
});
const auth0 = setup({
useRefreshTokens: true,
useRefreshTokensFallback: true
});
expect((<any>auth0).worker).toBeUndefined();
await loginWithRedirect(auth0, undefined, {
token: {
response: { refresh_token: '' }
}
});
jest.spyOn(<any>utils, 'runIframe').mockResolvedValue({
access_token: TEST_ACCESS_TOKEN,
state: TEST_STATE
});
mockFetch.mockResolvedValueOnce(
fetchResponse(true, {
id_token: TEST_ID_TOKEN,
refresh_token: TEST_REFRESH_TOKEN,
access_token: TEST_ACCESS_TOKEN,
expires_in: 86400
})
);
const access_token = await auth0.getTokenSilently({ cacheMode: 'off' });
expect(access_token).toEqual(TEST_ACCESS_TOKEN);
expect(utils.runIframe).toHaveBeenCalled();
Object.defineProperty(window.navigator, 'userAgent', {
value: originalUserAgent
});
});

it('uses the cache for subsequent requests that occur before the response', async () => {
let singlePromiseSpy = jest
.spyOn(promiseUtils, 'singlePromise')
Expand Down
102 changes: 2 additions & 100 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
runIframe,
urlDecodeB64,
getCrypto,
getCryptoSubtle,
validateCrypto
} from '../src/utils';

Expand Down Expand Up @@ -152,77 +151,8 @@ describe('utils', () => {
const result = await sha256('test');
expect(result).toBe(true);
});
it('handles ie11 digest.result scenario', () => {
(<any>global).msCrypto = {};

const digestResult = {
oncomplete: null
};

(<any>global).crypto = {
subtle: {
digest: jest.fn(() => {
return digestResult;
})
}
};

const sha = sha256('test').then(r => {
expect(r).toBe(true);
});

digestResult.oncomplete({ target: { result: true } });

return sha;
});
it('handles ie11 digest.result error scenario', () => {
(<any>global).msCrypto = {};

const digestResult = {
onerror: null
};

(<any>global).crypto = {
subtle: {
digest: jest.fn(() => {
return digestResult;
})
}
};

const sha = sha256('test').catch(e => {
expect(e).toBe('An error occurred');
});

digestResult.onerror({ error: 'An error occurred' });

return sha;
});

it('handles ie11 digest.result abort scenario', () => {
(<any>global).msCrypto = {};

const digestResult = {
onabort: null
};

(<any>global).crypto = {
subtle: {
digest: jest.fn(() => {
return digestResult;
})
}
};

const sha = sha256('test').catch(e => {
expect(e).toBe('The digest operation was aborted');
});

digestResult.onabort();

return sha;
});
});

describe('bufferToBase64UrlEncoded ', () => {
it('generates correct base64 encoded value from a buffer', async () => {
const result = bufferToBase64UrlEncoded([116, 101, 115, 116]);
Expand Down Expand Up @@ -526,42 +456,14 @@ describe('utils', () => {
});
});
describe('getCrypto', () => {
it('should use msCrypto when window.crypto is unavailable', () => {
(<any>global).crypto = undefined;
(<any>global).msCrypto = 'ms';

const theCrypto = getCrypto();
expect(theCrypto).toBe('ms');
});
it('should use window.crypto when available', () => {
it('should use window.crypto', () => {
(<any>global).crypto = 'window';
(<any>global).msCrypto = 'ms';

const theCrypto = getCrypto();
expect(theCrypto).toBe('window');
});
});
describe('getCryptoSubtle', () => {
it('should use crypto.webkitSubtle when available', () => {
(<any>global).crypto = { subtle: undefined, webkitSubtle: 'webkit' };

const theSubtle = getCryptoSubtle();
expect(theSubtle).toBe('webkit');
});
it('should use crypto.subtle when available', () => {
(<any>global).crypto = { subtle: 'window', webkitSubtle: 'webkit' };

const theSubtle = getCryptoSubtle();
expect(theSubtle).toBe('window');
});
it('should use msCrypto.subtle when available', () => {
(<any>global).crypto = undefined;
(<any>global).msCrypto = { subtle: 'ms' };

const cryptoSubtle = getCryptoSubtle();
expect(cryptoSubtle).toBe('ms');
});
});
describe('validateCrypto', () => {
it('should throw error if crypto is unavailable', () => {
(<any>global).crypto = undefined;
Expand Down
Loading

0 comments on commit 034278b

Please sign in to comment.