auth0 / auth0-spa-js

Auth0 authentication for Single Page Applications (SPA) with PKCE
MIT License
903 stars 357 forks source link

window.crypto.subtle does not exist #218

Closed markmarijnissen closed 4 years ago

markmarijnissen commented 4 years ago

Following instructions, when I call loginWithRedirect() the promise throws an error.

https://github.com/auth0/auth0-spa-js/blob/master/src/utils.ts#L112

See https://www.dropbox.com/s/7l3g8yqpozvhfpb/Screenshot%202019-09-18%2012.36.46.png?dl=0

index.ts:23 Uncaught (in promise) TypeError: Cannot read property 'digest' of undefined TypeError: Cannot read property 'digest' of undefined
    at F (utils.ts:92)
    at e.<anonymous> (Auth0Client.ts:199)
    at tslib.es6.js:99
    at Object.next (tslib.es6.js:80)
    at tslib.es6.js:73
    at new Promise (<anonymous>)
    at n (tslib.es6.js:69)
    at e.loginWithRedirect (Auth0Client.ts:194)
    at <anonymous>:1:35
    at <anonymous>:2:3
F @ utils.ts:92
(anonymous) @ Auth0Client.ts:199
(anonymous) @ tslib.es6.js:99
(anonymous) @ tslib.es6.js:80
(anonymous) @ tslib.es6.js:73
n @ tslib.es6.js:69
e.loginWithRedirect @ Auth0Client.ts:194
(anonymous) @ VM1019:1
(anonymous) @ VM1019:2
utils.ts:92 Uncaught (in promise) TypeError: Cannot read property 'digest' of undefined
    at F (utils.ts:92)
    at e.<anonymous> (Auth0Client.ts:199)
    at tslib.es6.js:99
    at Object.next (tslib.es6.js:80)
    at tslib.es6.js:73
    at new Promise (<anonymous>)
    at n (tslib.es6.js:69)
    at e.loginWithRedirect (Auth0Client.ts:194)
    at <anonymous>:1:35
    at <anonymous>:2:3
stevehobbsdev commented 4 years ago

@markmarijnissen We usually see that error when your app is not running on a secure origin (localhost or using HTTPS). Although, we added some handling to throw a proper error when this occurs - are you using an older version of the library?

See Why do I get auth0-spa-js must run on a secure origin?

markmarijnissen commented 4 years ago

Yes, I was running it from an insecure origin.

First, I used the version in the documents. (The vanilla Javascript Quickstart, as documented when you create a new Application in the Auth0 dashboard).

Then, I figured the library might be outdated so I found this Github repo. I followed instructions, there, which pointed to also to an outdated version.

Finally, with your suggestion, I found the latest 1.2.3 (using unpkg.com) for a quick prototype. Indeed, I now see the secure origin error.

stevehobbsdev commented 4 years ago

Thanks @markmarijnissen. Glad you got it sorted and will begin opening PRs for the incorrect documentation that you found. Thanks for letting us know!