Function
isCachedTokenValid
({
user,
accessTokenExpiresIn,
}: Partial<BootCacheData>)
Source from the content-addressed store, hash-verified
| 126 | const CACHED_TOKEN_EXPIRY_MARGIN = FIVE_MINUTES; |
| 127 | |
| 128 | const isCachedTokenValid = ({ |
| 129 | user, |
| 130 | accessTokenExpiresIn, |
| 131 | }: Partial<BootCacheData>): boolean => { |
| 132 | const logged = user as LoggedUser; |
| 133 | |
| 134 | return ( |
| 135 | !!logged?.providers && |
| 136 | !!logged?.id && |
| 137 | !!accessTokenExpiresIn && |
| 138 | new Date(accessTokenExpiresIn).getTime() - Date.now() > |
| 139 | CACHED_TOKEN_EXPIRY_MARGIN |
| 140 | ); |
| 141 | }; |
| 142 | |
| 143 | export const BootDataProvider = ({ |
| 144 | children, |
Tested by
no test coverage detected