Skip to content

Commit 69876ac

Browse files
committed
docs: add error-handling section to README and introduce SECURITY.md
1 parent 4454883 commit 69876ac

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Modern secure storage for React Native, powered by Nitro Modules. Version 6 ship
3131
- [⚡️ Quick start](#-quick-start)
3232
- [📚 API reference](#-api-reference)
3333
- [🔐 Access control & metadata](#-access-control--metadata)
34+
- [❗ Error handling](#-error-handling)
3435
- [🧪 Simulators and emulators](#-simulators-and-emulators)
3536
- [📈 Performance benchmarks](#-performance-benchmarks)
3637
- [🎮 Example application](#-example-application)
@@ -219,6 +220,47 @@ function YourComponent() {
219220

220221
For comprehensive examples and advanced patterns, see [`HOOKS.md`](./HOOKS.md).
221222

223+
## ❗ Error handling
224+
225+
Every public hook returns failures as `HookError` instances. Besides `message`, each error carries:
226+
227+
- `operation` – the hook action that failed (for example, `useSecureStorage.saveSecret`).
228+
- `cause` – the original native error for additional diagnostics.
229+
- `hint` – a short suggestion shown in the example app and useful for toast copy.
230+
231+
Biometric or device-credential prompts cancelled by the user now surface as a friendly message (`Authentication prompt canceled by the user.`) and *do not* poison hook state. Imperative calls still reject with the raw error so you can decide how to react.
232+
233+
```tsx
234+
import { Text } from 'react-native'
235+
import { useSecureStorage } from 'react-native-sensitive-info'
236+
237+
function SecretsList() {
238+
const { items, error } = useSecureStorage({ service: 'auth', includeValues: true })
239+
240+
if (error) {
241+
if (error.message.includes('Authentication prompt canceled')) {
242+
return <Text>The user dismissed biometric authentication.</Text>
243+
}
244+
245+
return (
246+
<Text testID="secure-error">
247+
{error.message}
248+
{'\n'}Hint: {error.hint ?? 'Check your secure storage configuration.'}
249+
</Text>
250+
)
251+
}
252+
253+
return items.length === 0 ? (
254+
<Text>No secrets stored yet.</Text>
255+
) : (
256+
<Text>{items.map((item) => item.key).join(', ')}</Text>
257+
)
258+
}
259+
```
260+
261+
> [!TIP]
262+
> When using the imperative API, look for the `[E_AUTH_CANCELED]` marker in the thrown error message to detect cancellations.
263+
222264
## Imperative API
223265

224266
```tsx

SECURITY.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| --- | --- |
7+
| 6.x | ✅ Supported
8+
| 5.6.x | ✅ Supported
9+
| < 5.6.0 | ❌ Not supported
10+
11+
We ship security fixes for the current v6 line and the latest v5 maintenance branch (≥ 5.6.0). Releases prior to 5.6.0 no longer receive patches—upgrade as soon as possible to stay protected.
12+
13+
## Reporting a Vulnerability
14+
15+
1. **Contact**: Email security reports to <mtw.andrade@gmail.com>.
16+
2. **Disclosure Window**: We aim to acknowledge reports within 3 business days and provide a remediation plan within 10 business days.
17+
3. **Coordinated Disclosure**: Please refrain from publicly disclosing the issue until a fix is available or 30 days have passed since acknowledgement.
18+
19+
## Patch Process
20+
21+
- Critical fixes ship in a point release for the supported branches (6.x and ≥ 5.6.0).
22+
- Vulnerability advisories are published on the GitHub release page and npm once patches are available.
23+
- We credit reporters who follow coordinated disclosure and wish to be acknowledged.
24+
25+
## Hardening Recommendations
26+
27+
- Stay on the latest minor release within your major version to receive defense-in-depth updates.
28+
- Review the [Access control & metadata](README.md#-access-control--metadata) section for guidance on choosing the strongest policies.
29+
- Test secure storage flows on physical hardware before shipping; emulators often omit secure elements.
30+
31+
Thank you for helping us keep `react-native-sensitive-info` secure.

0 commit comments

Comments
 (0)