-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix safari10 initialization error #232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should only use webkitSubtle
when subtle
is not available. Not prefer webkitSubtle
over subtle
. Guidance from https://webkit.org/blog/7790/update-on-web-cryptography/
@damieng updated 🎉 thanks for the reference |
src/index.ts
Outdated
@@ -20,10 +21,14 @@ export default async function createAuth0Client(options: Auth0ClientOptions) { | |||
'For security reasons, `window.crypto` is required to run `auth0-spa-js`.' | |||
); | |||
} | |||
// safari 10 compat | |||
if (!window.crypto.subtle && (<any>window.crypto).webkitSubtle) { | |||
(<any>window.crypto).subtle = (<any>window.crypto).webkitSubtle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No non-Auth0 code can be running in the Window while we're doing this right?
Trying to decide if replacing a global is safe in this context or whether we should be creating our own variable to use instead to avoid non-Auth0 code getting confused.
Description
Safari 10 uses
crypto.webkitSubtle
instead ofcrypto.subtle
. This PR normalizes this behavior.References
ESD-2220
Testing