firebase / firebase/firebase-js-sdk
Auth persistence fails in Safari
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### [REQUIRED] Describe your environment
* Operating System version: macOS Monterey 12.2.1
* Browser version: Safari 15.3
* Firebase SDK version: 9.6.8
* Firebase Product: auth
### [REQUIRED] Describe the problem
The problem arises in Safari auth sessions lasting 1 hour or more.
* Calling `getIdToken()` or `reload()`, passing in the result of `getAuth().currentUser`, throws an error `undefined is not an object (evaluating t._canInitEmulator=!1)`.
* On calling a Firebase HTTPS Callable function, the auth token also fails to validate. `context.auth` evaluates falsy.
* When inspecting `firebaseLocalStorage` contents in Indexed DB, `value.stsTokenManager.expirationTime` is not updated.
Note that `getAuth().currentUser` returns a `User`.
(We do not explicitly specify authentication state persistence, so assume it is the default 'local'.)
#### Steps to reproduce:
1. Sign in
2. Leave session open for 1 hour +
3. Call getIdToken() or reload(), or call HTTPS Callable function
#### Relevant Code:
```javascript
// TODO(you): code here to reproduce the problem
```
Contributor guide
Assessment
This issue has not been assessed yet.