Challenge - 5 Problems
SecureStore Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What happens when you try to retrieve a non-existent key from SecureStore?
Consider this React Native code snippet using SecureStore to get a value for a key that was never saved. What will be the output?
React Native
import * as SecureStore from 'expo-secure-store'; async function getValue() { const result = await SecureStore.getItemAsync('missingKey'); console.log(result); } getValue();
Attempts:
2 left
💡 Hint
Think about what SecureStore returns when the key does not exist.
✗ Incorrect
SecureStore.getItemAsync returns null if the key is not found. It does not throw an error or return undefined or empty string.
❓ lifecycle
intermediate2:00remaining
When should you clear sensitive data from SecureStore in a React Native app?
You store a user's authentication token in SecureStore. When is the best time to remove this token to keep the app secure?
Attempts:
2 left
💡 Hint
Think about user control and security best practices.
✗ Incorrect
Sensitive data like auth tokens should be removed when the user logs out to prevent unauthorized access. Closing or backgrounding the app does not guarantee security.
📝 Syntax
advanced2:00remaining
Which code snippet correctly saves and retrieves a password securely using SecureStore?
Choose the option that correctly saves a password and then retrieves it asynchronously using SecureStore in React Native.
Attempts:
2 left
💡 Hint
Remember the exact method names and that these are async functions.
✗ Incorrect
The correct methods are setItemAsync and getItemAsync, both returning promises that must be awaited. Option A uses these correctly. Option A uses wrong method names and no await. Option A uses non-existent methods. Option A misses await on calls.
🔧 Debug
advanced2:00remaining
Why does this SecureStore code fail to save data?
Identify the reason this code does not save the data as expected.
React Native
import * as SecureStore from 'expo-secure-store'; function saveData() { SecureStore.setItemAsync('token', 'abc123'); } saveData();
Attempts:
2 left
💡 Hint
Check how async functions should be handled.
✗ Incorrect
SecureStore.setItemAsync returns a promise. Without await or then, the function may not complete before the app continues, causing unexpected behavior. The method name is correct, no callbacks needed, and keys are not reserved.
🧠 Conceptual
expert2:00remaining
What is the main security advantage of using SecureStore over AsyncStorage for sensitive data?
Choose the best explanation for why SecureStore is preferred for storing sensitive information like passwords or tokens.
Attempts:
2 left
💡 Hint
Think about data protection and encryption.
✗ Incorrect
SecureStore uses the device's secure enclave or keystore to encrypt and protect data, making it much safer for sensitive info. AsyncStorage stores data as plain text files, which can be accessed if the device is compromised.