Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pretty-parks-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-expo': minor
---

Default token cache `SecureStore` implementation `keychainAccessible` to `AFTER_FIRST_UNLOCK` - The data in the keychain item cannot be accessed after a restart until the device has been unlocked once by the user. This may be useful if you need to access the item when the device is locked.
16 changes: 13 additions & 3 deletions packages/expo/src/token-cache/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,28 @@ import { isNative } from '../utils';
* Create a token cache using Expo's SecureStore
*/
const createTokenCache = (): TokenCache => {
const secureStoreOpts: SecureStore.SecureStoreOptions = {
/**
* The data in the keychain item cannot be accessed after a restart until the
* device has been unlocked once by the user.
*
* This may be useful if you need to access the item when the phone is locked.
*/
keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK,
};

return {
getToken: async (key: string) => {
try {
const item = await SecureStore.getItemAsync(key);
const item = await SecureStore.getItemAsync(key, secureStoreOpts);
return item;
} catch {
await SecureStore.deleteItemAsync(key);
await SecureStore.deleteItemAsync(key, secureStoreOpts);
return null;
}
},
saveToken: (key: string, token: string) => {
return SecureStore.setItemAsync(key, token);
return SecureStore.setItemAsync(key, token, secureStoreOpts);
},
};
};
Expand Down
Loading