react-native-nitro-storage 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -29
- package/README.md +81 -24
- package/android/src/main/cpp/AndroidStorageAdapterCpp.cpp +5 -2
- package/android/src/main/java/com/nitrostorage/AndroidStorageAdapter.kt +240 -34
- package/cpp/bindings/HybridStorage.cpp +106 -283
- package/cpp/bindings/HybridStorage.hpp +16 -9
- package/docs/api-reference.md +75 -19
- package/docs/benchmarks.md +6 -1
- package/docs/keychain-lifecycle-testing.md +36 -0
- package/docs/recipes.md +1 -2
- package/docs/secure-storage.md +45 -9
- package/ios/IOSStorageAdapterCpp.mm +391 -175
- package/lib/commonjs/capabilities.js +3 -1
- package/lib/commonjs/capabilities.js.map +1 -1
- package/lib/commonjs/core/durability.js +110 -43
- package/lib/commonjs/core/durability.js.map +1 -1
- package/lib/commonjs/index.js +15 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +219 -97
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/internal.js +3 -11
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/shared.js +62 -2
- package/lib/commonjs/shared.js.map +1 -1
- package/lib/commonjs/storage-core.js +852 -141
- package/lib/commonjs/storage-core.js.map +1 -1
- package/lib/commonjs/storage-runtime.js +5 -1
- package/lib/commonjs/storage-runtime.js.map +1 -1
- package/lib/commonjs/testing.js +13 -0
- package/lib/commonjs/testing.js.map +1 -1
- package/lib/module/capabilities.js +2 -1
- package/lib/module/capabilities.js.map +1 -1
- package/lib/module/core/durability.js +110 -43
- package/lib/module/core/durability.js.map +1 -1
- package/lib/module/index.js +12 -8
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +215 -99
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/internal.js +2 -9
- package/lib/module/internal.js.map +1 -1
- package/lib/module/shared.js +60 -2
- package/lib/module/shared.js.map +1 -1
- package/lib/module/storage-core.js +853 -142
- package/lib/module/storage-core.js.map +1 -1
- package/lib/module/storage-runtime.js +4 -1
- package/lib/module/storage-runtime.js.map +1 -1
- package/lib/module/testing.js +8 -1
- package/lib/module/testing.js.map +1 -1
- package/lib/typescript/capabilities.d.ts +2 -1
- package/lib/typescript/capabilities.d.ts.map +1 -1
- package/lib/typescript/core/durability.d.ts +7 -2
- package/lib/typescript/core/durability.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/index.web.d.ts +3 -29
- package/lib/typescript/index.web.d.ts.map +1 -1
- package/lib/typescript/internal.d.ts +0 -2
- package/lib/typescript/internal.d.ts.map +1 -1
- package/lib/typescript/shared.d.ts +19 -0
- package/lib/typescript/shared.d.ts.map +1 -1
- package/lib/typescript/storage-core.d.ts +15 -6
- package/lib/typescript/storage-core.d.ts.map +1 -1
- package/lib/typescript/storage-runtime.d.ts +2 -1
- package/lib/typescript/storage-runtime.d.ts.map +1 -1
- package/lib/typescript/testing.d.ts +1 -1
- package/lib/typescript/testing.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/capabilities.ts +3 -1
- package/src/core/durability.ts +139 -39
- package/src/index.ts +20 -10
- package/src/index.web.ts +328 -166
- package/src/internal.ts +0 -14
- package/src/shared.ts +85 -0
- package/src/storage-core.ts +1165 -202
- package/src/storage-runtime.ts +6 -0
- package/src/testing.ts +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
-
The format
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
Breaking changes are always listed first in each release section.
|
|
6
8
|
|
|
7
|
-
## 0.
|
|
9
|
+
## [0.10.0] - 2026-08-25
|
|
10
|
+
|
|
11
|
+
### Breaking changes
|
|
12
|
+
|
|
13
|
+
- None when upgrading from `0.9.x`. Direct upgrades from `0.8.x` or earlier
|
|
14
|
+
still require Nitro Modules `0.37.x` and a native rebuild as described in
|
|
15
|
+
the `0.9.0` entry. This release restores the previous set-item type and
|
|
16
|
+
secure-write defaults for existing consumers.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Added `isStorageError(error, code)` to select recovery behavior from an exact
|
|
21
|
+
stable storage error code on native and web.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Restored `SetStorageItem.get()` and its `item` property to the original
|
|
26
|
+
`Record<string, true>` compatibility shape. Added `getTyped()` for new code
|
|
27
|
+
that wants `Partial<Record<TMember, true>>` without forcing a type migration.
|
|
28
|
+
- Restored synchronous Android Secure writes by default. Asynchronous
|
|
29
|
+
`apply()` writes remain available through the explicit
|
|
30
|
+
`storage.setSecureWritesAsync(true)` opt-in and can be drained with
|
|
31
|
+
`storage.flushSecureWrites()`.
|
|
32
|
+
- Enabled raw read-cache lookups now reuse cached missing values in single and
|
|
33
|
+
batch reads without per-item fallback calls.
|
|
34
|
+
|
|
35
|
+
### Deprecated
|
|
36
|
+
|
|
37
|
+
- Deprecated `isKeychainLockedError()`. It remains backward compatible but
|
|
38
|
+
groups `keychain_locked`, `authentication_required`, and `key_invalidated`;
|
|
39
|
+
use `isStorageError()` when deciding whether to retry, authenticate, or
|
|
40
|
+
rebuild a credential.
|
|
41
|
+
|
|
42
|
+
### Documentation
|
|
43
|
+
|
|
44
|
+
- Documented secure-storage recovery semantics and warned against cached
|
|
45
|
+
fallback for authentication tokens unless stale credentials are an explicit
|
|
46
|
+
application policy.
|
|
47
|
+
- Clarified isolated web benchmark limits and corrected capability/API examples.
|
|
48
|
+
|
|
49
|
+
## [0.9.0] - 2026-08-20
|
|
8
50
|
|
|
9
51
|
### Breaking changes
|
|
10
52
|
|
|
@@ -14,6 +56,10 @@ The format follows Keep a Changelog and the project adheres to SemVer.
|
|
|
14
56
|
- `SetStorageItem.get()` now returns `Partial<Record<TMember, true>>`. Use
|
|
15
57
|
`has()` for membership checks or handle an indexed value as `true | undefined`
|
|
16
58
|
instead of assuming every member exists.
|
|
59
|
+
- Android Secure writes now default to asynchronous `apply()`. Call
|
|
60
|
+
`storage.setSecureWritesAsync(false)` when existing code depends on
|
|
61
|
+
synchronous `commit()` durability, or call `storage.flushSecureWrites()` at
|
|
62
|
+
deterministic persistence boundaries.
|
|
17
63
|
|
|
18
64
|
### Changed
|
|
19
65
|
|
|
@@ -22,11 +68,25 @@ The format follows Keep a Changelog and the project adheres to SemVer.
|
|
|
22
68
|
- Native batch reads now preserve missing entries as `undefined`, matching the
|
|
23
69
|
TypeScript contract and allowing stored values that match the old internal
|
|
24
70
|
sentinel string.
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
71
|
+
- Secure write flushes now retain failed and unattempted last-write-wins entries
|
|
72
|
+
for retry instead of silently dropping them.
|
|
73
|
+
- iOS legacy Disk migration is conservative and retryable. A valid registry is
|
|
74
|
+
copied into the suite domain and each `standardUserDefaults` source is
|
|
75
|
+
removed only after target persistence is verified; malformed registries,
|
|
76
|
+
fallback or same-domain stores, conflicts, and failed persistence leave the
|
|
77
|
+
source and registry available for recovery.
|
|
78
|
+
|
|
79
|
+
### Fixed
|
|
80
|
+
|
|
81
|
+
- `storage.clearBiometric()` flushes pending Secure writes, clears the JS raw
|
|
82
|
+
cache before listener notification, uses a durable Android biometric clear,
|
|
83
|
+
surfaces failures, and emits the same Secure-scope `clear` event as a Secure
|
|
84
|
+
clear after success.
|
|
85
|
+
- Android biometric corruption is checked and recovered at preference-store
|
|
86
|
+
initialization instead of probing the full encrypted store on each
|
|
87
|
+
existence or deletion hot path.
|
|
28
88
|
|
|
29
|
-
## 0.8.0 - 2026-08-12
|
|
89
|
+
## [0.8.0] - 2026-08-12
|
|
30
90
|
|
|
31
91
|
### Breaking changes
|
|
32
92
|
|
|
@@ -58,7 +118,7 @@ The format follows Keep a Changelog and the project adheres to SemVer.
|
|
|
58
118
|
- The IndexedDB backend reports affected keys when `flush()` fails and starts a best-effort flush on `pagehide` and hidden visibility changes.
|
|
59
119
|
- `setIfVersion()` is documented as optimistic (no backend-level atomicity); CAS guarantees are covered by race tests.
|
|
60
120
|
|
|
61
|
-
## 0.7.0 - 2026-07-30
|
|
121
|
+
## [0.7.0] - 2026-07-30
|
|
62
122
|
|
|
63
123
|
### Changes
|
|
64
124
|
|
|
@@ -69,7 +129,7 @@ The format follows Keep a Changelog and the project adheres to SemVer.
|
|
|
69
129
|
- Enforce Android biometric policy levels with distinct Keystore keys, propagate locked or invalidated biometric failures, and keep secure preference files excluded from backup.
|
|
70
130
|
- Preflight biometric store access before aggregate secure mutations and surface native commit or corruption-recovery failures.
|
|
71
131
|
|
|
72
|
-
## 0.6.0 - 2026-06-15
|
|
132
|
+
## [0.6.0] - 2026-06-15
|
|
73
133
|
|
|
74
134
|
### Added
|
|
75
135
|
|
|
@@ -97,7 +157,7 @@ type changes can affect advanced consumers:
|
|
|
97
157
|
- `StorageChangeOperation` gained the `"expire"` and `"clearGroup"` members. Exhaustive `switch` statements over a change event's `operation` need cases for the new members.
|
|
98
158
|
- `useStorage()` now returns a three-element tuple `[value, setter, actions]` (was two). Array destructuring such as `const [value, setStore] = useStorage(item)` is unaffected; only code that annotated the result with an explicit two-element tuple type needs to widen the annotation.
|
|
99
159
|
|
|
100
|
-
## 0.5.9 - 2026-06-11
|
|
160
|
+
## [0.5.9] - 2026-06-11
|
|
101
161
|
|
|
102
162
|
### Fixed
|
|
103
163
|
|
|
@@ -108,7 +168,7 @@ type changes can affect advanced consumers:
|
|
|
108
168
|
|
|
109
169
|
- Included `CHANGELOG.md` in the packed package docs.
|
|
110
170
|
|
|
111
|
-
## 0.5.8 - 2026-06-11
|
|
171
|
+
## [0.5.8] - 2026-06-11
|
|
112
172
|
|
|
113
173
|
### Changed
|
|
114
174
|
|
|
@@ -119,7 +179,7 @@ type changes can affect advanced consumers:
|
|
|
119
179
|
|
|
120
180
|
- Regenerate Nitrogen output and package build artifacts before pack-content audits so clean release and CI environments validate the actual published tarball.
|
|
121
181
|
|
|
122
|
-
## 0.5.7 - 2026-06-10
|
|
182
|
+
## [0.5.7] - 2026-06-10
|
|
123
183
|
|
|
124
184
|
### Added
|
|
125
185
|
|
|
@@ -137,7 +197,7 @@ type changes can affect advanced consumers:
|
|
|
137
197
|
- Keep native and web public TypeScript entrypoints aligned so IDEs infer storage setters and batch tuple results consistently across React Native and web imports.
|
|
138
198
|
- Keep the README, issue template, package metadata, and release notes aligned with the current `0.5.7` package surface.
|
|
139
199
|
|
|
140
|
-
## 0.5.6 - 2026-05-22
|
|
200
|
+
## [0.5.6] - 2026-05-22
|
|
141
201
|
|
|
142
202
|
### Added
|
|
143
203
|
|
|
@@ -159,7 +219,7 @@ type changes can affect advanced consumers:
|
|
|
159
219
|
- Remove package-owned Android native log spam for expected unavailable biometric storage paths.
|
|
160
220
|
- Modernize Android Gradle assignment syntax to avoid package-owned Gradle warnings.
|
|
161
221
|
|
|
162
|
-
## 0.5.4 - 2026-05-13
|
|
222
|
+
## [0.5.4] - 2026-05-13
|
|
163
223
|
|
|
164
224
|
### Fixed
|
|
165
225
|
|
|
@@ -170,7 +230,7 @@ type changes can affect advanced consumers:
|
|
|
170
230
|
- Publish GitHub Releases to npm through a Trusted Publishing/OIDC workflow.
|
|
171
231
|
- Resolve the package build's TypeScript binary lookup warning during release checks.
|
|
172
232
|
|
|
173
|
-
## 0.5.2 - 2026-04-27
|
|
233
|
+
## [0.5.2] - 2026-04-27
|
|
174
234
|
|
|
175
235
|
### Fixed
|
|
176
236
|
|
|
@@ -178,7 +238,7 @@ type changes can affect advanced consumers:
|
|
|
178
238
|
- Stabilize the release benchmark gate by sampling each benchmark three times while keeping the same regression thresholds.
|
|
179
239
|
- Correct package content check commands in the release documentation for current Bun.
|
|
180
240
|
|
|
181
|
-
## 0.5.1 - 2026-04-24
|
|
241
|
+
## [0.5.1] - 2026-04-24
|
|
182
242
|
|
|
183
243
|
### Added
|
|
184
244
|
|
|
@@ -196,7 +256,7 @@ type changes can affect advanced consumers:
|
|
|
196
256
|
- Document raw import/export workflows and warn that Secure exports expose secret values.
|
|
197
257
|
- Refactor the publish script to validate release docs, report check timings, support coverage gates, and avoid redundant pack dry-runs.
|
|
198
258
|
|
|
199
|
-
## 0.5.0 - 2026-04-18
|
|
259
|
+
## [0.5.0] - 2026-04-18
|
|
200
260
|
|
|
201
261
|
### Added
|
|
202
262
|
|
|
@@ -213,7 +273,7 @@ type changes can affect advanced consumers:
|
|
|
213
273
|
- Expand npm package description and keywords around React Native secure storage, biometric storage, Keychain, Android Keystore, Nitro Modules, MMKV migration, Expo SecureStore, Zustand/Jotai, and IndexedDB.
|
|
214
274
|
- Harden publish dry-runs, package docs syncing, and npm pack content validation.
|
|
215
275
|
|
|
216
|
-
## 0.4.5 - 2026-04-14
|
|
276
|
+
## [0.4.5] - 2026-04-14
|
|
217
277
|
|
|
218
278
|
### Added
|
|
219
279
|
|
|
@@ -258,7 +318,7 @@ type changes can affect advanced consumers:
|
|
|
258
318
|
- Fix web `import()` for Secure scope skipping `flushSecureWrites()` and `setSecureAccessControl()` before writing.
|
|
259
319
|
- Expand ProGuard/R8 keep rules with explicit method-signature patterns so JNI-callable methods survive aggressive R8 shrinking in release builds.
|
|
260
320
|
|
|
261
|
-
## 0.4.1 - 2026-03-04
|
|
321
|
+
## [0.4.1] - 2026-03-04
|
|
262
322
|
|
|
263
323
|
### Added
|
|
264
324
|
|
|
@@ -277,7 +337,7 @@ type changes can affect advanced consumers:
|
|
|
277
337
|
- Bump to **React 19.2.0** and **React Native 0.83.2** across workspace and example.
|
|
278
338
|
- Add `--provenance` flag to `npm publish` for npm supply-chain attestation.
|
|
279
339
|
|
|
280
|
-
## 0.4.0 - 2026-02-25
|
|
340
|
+
## [0.4.0] - 2026-02-25
|
|
281
341
|
|
|
282
342
|
### Added
|
|
283
343
|
|
|
@@ -297,7 +357,7 @@ type changes can affect advanced consumers:
|
|
|
297
357
|
- Keep iOS secure keychain cache/index behavior aligned with new prefix query and biometric-level paths.
|
|
298
358
|
- Expand README/API docs to cover the new public API surface with concrete TypeScript use-case snippets.
|
|
299
359
|
|
|
300
|
-
## 0.3.2 - 2026-02-22
|
|
360
|
+
## [0.3.2] - 2026-02-22
|
|
301
361
|
|
|
302
362
|
### Added
|
|
303
363
|
|
|
@@ -320,7 +380,7 @@ type changes can affect advanced consumers:
|
|
|
320
380
|
- Expand benchmark coverage to include Disk and Secure scope throughput checks and tighten regression thresholds.
|
|
321
381
|
- Expand README coverage so every public feature has a concrete TypeScript use-case example, including secure write flush, biometric/access-control usage, batch bootstrap, and storage utility workflows.
|
|
322
382
|
|
|
323
|
-
## 0.3.1 - 2026-02-16
|
|
383
|
+
## [0.3.1] - 2026-02-16
|
|
324
384
|
|
|
325
385
|
### Changed
|
|
326
386
|
|
|
@@ -337,7 +397,7 @@ type changes can affect advanced consumers:
|
|
|
337
397
|
- Fix global `storage.setAccessControl(...)` handling so non-item raw secure writes keep the configured level instead of being forced back to default.
|
|
338
398
|
- Fix Android secure key enumeration to return deduplicated key sets when secure and biometric stores share key names.
|
|
339
399
|
|
|
340
|
-
## 0.3.0 - 2026-02-15
|
|
400
|
+
## [0.3.0] - 2026-02-15
|
|
341
401
|
|
|
342
402
|
### Added
|
|
343
403
|
|
|
@@ -354,7 +414,7 @@ type changes can affect advanced consumers:
|
|
|
354
414
|
- Route native batch calls through true adapter-level batch APIs (HybridStorage + iOS/Android adapters) instead of per-key loops.
|
|
355
415
|
- Add read-through cache invalidation on scoped/key change events and native/web clear paths.
|
|
356
416
|
|
|
357
|
-
## 0.2.1 - 2026-02-15
|
|
417
|
+
## [0.2.1] - 2026-02-15
|
|
358
418
|
|
|
359
419
|
### Added
|
|
360
420
|
|
|
@@ -375,7 +435,7 @@ type changes can affect advanced consumers:
|
|
|
375
435
|
|
|
376
436
|
- Raise `react` peer dependency floor to `>=18.2.0`.
|
|
377
437
|
|
|
378
|
-
## 0.2.0 - 2026-02-15
|
|
438
|
+
## [0.2.0] - 2026-02-15
|
|
379
439
|
|
|
380
440
|
### Added
|
|
381
441
|
|
|
@@ -398,7 +458,7 @@ type changes can affect advanced consumers:
|
|
|
398
458
|
- Expand README with complete API behavior/throws documentation.
|
|
399
459
|
- Strengthen native and web test coverage for validation, TTL, migrations, and transactions.
|
|
400
460
|
|
|
401
|
-
## 0.1.4 - 2026-02-09
|
|
461
|
+
## [0.1.4] - 2026-02-09
|
|
402
462
|
|
|
403
463
|
### Added
|
|
404
464
|
|
|
@@ -412,13 +472,13 @@ type changes can affect advanced consumers:
|
|
|
412
472
|
|
|
413
473
|
- Bump react-native-nitro-modules to the latest version and raise the peer dependency floor.
|
|
414
474
|
|
|
415
|
-
## 0.1.3 - 2026-01-22
|
|
475
|
+
## [0.1.3] - 2026-01-22
|
|
416
476
|
|
|
417
477
|
### Fixed
|
|
418
478
|
|
|
419
479
|
- Prevent ProGuard from stripping the JNI class in release builds.
|
|
420
480
|
|
|
421
|
-
## 0.1.2 - 2026-01-07
|
|
481
|
+
## [0.1.2] - 2026-01-07
|
|
422
482
|
|
|
423
483
|
### Added
|
|
424
484
|
|
|
@@ -429,7 +489,7 @@ type changes can affect advanced consumers:
|
|
|
429
489
|
|
|
430
490
|
- Point types to the correct path and simplify bob targets.
|
|
431
491
|
|
|
432
|
-
## 0.1.1 - 2025-12-15
|
|
492
|
+
## [0.1.1] - 2025-12-15
|
|
433
493
|
|
|
434
494
|
### Added
|
|
435
495
|
|
|
@@ -442,7 +502,7 @@ type changes can affect advanced consumers:
|
|
|
442
502
|
- Update README screenshots.
|
|
443
503
|
- Add tests for memory item deletion and MMKV migration, and simplify the README.
|
|
444
504
|
|
|
445
|
-
## 0.1.0 - 2025-12-15
|
|
505
|
+
## [0.1.0] - 2025-12-15
|
|
446
506
|
|
|
447
507
|
### Added
|
|
448
508
|
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/react-native-nitro-storage)
|
|
5
5
|
[](https://github.com/JoaoPauloCMarra/react-native-nitro-storage/actions/workflows/ci.yml)
|
|
6
6
|
[](https://github.com/JoaoPauloCMarra/react-native-nitro-storage/blob/main/LICENSE)
|
|
7
|
-
[](https://reactnative.dev/docs/0.86/getting-started-without-a-framework)
|
|
8
8
|
[](https://docs.expo.dev/versions/v57.0.0/)
|
|
9
9
|
[](https://nitro.margelo.com/)
|
|
10
10
|
[](https://www.typescriptlang.org/)
|
|
@@ -24,6 +24,7 @@ pagination, conflict resolution, or remote synchronization.
|
|
|
24
24
|
## Contents
|
|
25
25
|
|
|
26
26
|
- [Install](#install)
|
|
27
|
+
- [Requirements and compatibility](#requirements-and-compatibility)
|
|
27
28
|
- [Expo Config](#expo-config)
|
|
28
29
|
- [Quick Start](#quick-start)
|
|
29
30
|
- [Auth Tokens](#auth-tokens)
|
|
@@ -52,6 +53,8 @@ pagination, conflict resolution, or remote synchronization.
|
|
|
52
53
|
bun add react-native-nitro-storage react-native-nitro-modules
|
|
53
54
|
```
|
|
54
55
|
|
|
56
|
+
## Requirements and compatibility
|
|
57
|
+
|
|
55
58
|
Peer dependencies:
|
|
56
59
|
|
|
57
60
|
| Package | Version |
|
|
@@ -62,24 +65,26 @@ Peer dependencies:
|
|
|
62
65
|
|
|
63
66
|
Nitro peer requirement: `react-native-nitro-modules >=0.37.0 <0.38.0`.
|
|
64
67
|
|
|
65
|
-
The
|
|
66
|
-
|
|
68
|
+
The package gate uses React Native `0.86.2` and the Strict TypeScript API.
|
|
69
|
+
`check:ci` also compiles the public source against React Native `0.87.0`'s
|
|
70
|
+
Strict TypeScript API; this does not change the runtime baseline. The Expo
|
|
71
|
+
example uses Expo SDK `57.0.16`, React Native
|
|
67
72
|
`0.86.2`, React `19.2.3`, and Nitro Modules `0.37.0`, which is the React Native
|
|
68
73
|
version supported by that Expo SDK. Do not override Expo's React Native version.
|
|
69
74
|
|
|
70
|
-
When upgrading from 0.8.x, upgrade Nitro Modules to the 0.37.x range
|
|
71
|
-
installing this package, then rebuild the native app so the generated
|
|
72
|
-
bindings and native runtime use the same major-minor version:
|
|
75
|
+
When upgrading from 0.8.x or 0.9.x, upgrade Nitro Modules to the 0.37.x range
|
|
76
|
+
before installing this package, then rebuild the native app so the generated
|
|
77
|
+
Nitro bindings and native runtime use the same major-minor version:
|
|
73
78
|
|
|
74
79
|
```sh
|
|
75
|
-
bun add react-native-nitro-modules@0.37.0 react-native-nitro-storage@0.
|
|
80
|
+
bun add react-native-nitro-modules@0.37.0 react-native-nitro-storage@0.10.0
|
|
76
81
|
bunx expo prebuild
|
|
77
82
|
```
|
|
78
83
|
|
|
79
|
-
`SetStorageItem.get()`
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
`Record<
|
|
84
|
+
`SetStorageItem.get()` retains its original `Record<string, true>` compatibility
|
|
85
|
+
shape. At runtime, absent members are still absent, so use `set.has(member)` for
|
|
86
|
+
membership checks. New code that wants a precise member union can use
|
|
87
|
+
`set.getTyped()`, which returns `Partial<Record<TMember, true>>`.
|
|
83
88
|
|
|
84
89
|
Nitro Storage requires an Expo development build or a bare React Native app;
|
|
85
90
|
Expo Go and native Windows, macOS, and tvOS targets are not supported.
|
|
@@ -171,7 +176,7 @@ const auth = createSecureAuthStorage(
|
|
|
171
176
|
accessToken: { renameFrom: "authToken" },
|
|
172
177
|
refreshToken: { renameFrom: "refreshToken" },
|
|
173
178
|
},
|
|
174
|
-
{ namespace: "auth"
|
|
179
|
+
{ namespace: "auth" },
|
|
175
180
|
);
|
|
176
181
|
|
|
177
182
|
auth.accessToken.set("access-token");
|
|
@@ -183,6 +188,11 @@ Keep `getString` facades only when the app owns a storage architecture
|
|
|
183
188
|
boundary. `createSecureAuthStorage` already namespaces keys, notifies
|
|
184
189
|
subscribers, and migrates legacy keys.
|
|
185
190
|
|
|
191
|
+
Do not enable `fallbackToCacheOnReadError` for access or refresh tokens unless
|
|
192
|
+
the application explicitly accepts stale or revoked credentials. Handle
|
|
193
|
+
temporary secure-storage errors and retry from application lifecycle state
|
|
194
|
+
instead.
|
|
195
|
+
|
|
186
196
|
## Typed Storage Items
|
|
187
197
|
|
|
188
198
|
`createStorageItem<T>()` is the recommended API for application code. It keeps
|
|
@@ -248,9 +258,11 @@ loginMethod.setOrDelete(maybeMethod); // null/undefined deletes, value sets
|
|
|
248
258
|
## Set Items
|
|
249
259
|
|
|
250
260
|
`createSetItem()` models set-membership state (seen ids, dismissed prompts)
|
|
251
|
-
without hand-rolling membership helpers. Its `get()` result is a
|
|
252
|
-
|
|
253
|
-
|
|
261
|
+
without hand-rolling membership helpers. Its compatibility `get()` result is a
|
|
262
|
+
`Record<string, true>`; absent members are still not stored at runtime. Use
|
|
263
|
+
`getTyped()` when a precise `Partial<Record<TMember, true>>` result is useful.
|
|
264
|
+
Adding an existing member or deleting an absent one is a no-op, so subscribers
|
|
265
|
+
do not re-render.
|
|
254
266
|
|
|
255
267
|
```ts
|
|
256
268
|
import { createSetItem, StorageScope } from "react-native-nitro-storage";
|
|
@@ -386,7 +398,7 @@ import {
|
|
|
386
398
|
StorageScope,
|
|
387
399
|
createSecureAuthStorage,
|
|
388
400
|
createStorageItem,
|
|
389
|
-
|
|
401
|
+
isStorageError,
|
|
390
402
|
storage,
|
|
391
403
|
} from "react-native-nitro-storage";
|
|
392
404
|
|
|
@@ -417,7 +429,7 @@ const auth = createSecureAuthStorage({
|
|
|
417
429
|
try {
|
|
418
430
|
recoveryCode.get();
|
|
419
431
|
} catch (error) {
|
|
420
|
-
if (
|
|
432
|
+
if (isStorageError(error, "keychain_locked")) {
|
|
421
433
|
storage.getSecurityCapabilities();
|
|
422
434
|
}
|
|
423
435
|
}
|
|
@@ -429,6 +441,15 @@ exporting secure values unless you are intentionally doing a short-lived
|
|
|
429
441
|
in-memory migration. `storage.export(StorageScope.Secure)` throws unless you
|
|
430
442
|
explicitly opt into `{ includeSecureValues: true }`.
|
|
431
443
|
|
|
444
|
+
Android secure writes default to synchronous `commit()` durability. Call
|
|
445
|
+
`storage.setSecureWritesAsync(true)` only when asynchronous `apply()` writes are
|
|
446
|
+
acceptable. After opting into async writes, call `storage.flushSecureWrites()`
|
|
447
|
+
before a deterministic persistence boundary. A failed secure flush throws and
|
|
448
|
+
keeps failed or unattempted queued writes available for retry.
|
|
449
|
+
`storage.clearBiometric()`
|
|
450
|
+
flushes pending Secure writes before clearing biometric entries and surfaces
|
|
451
|
+
native clear failures.
|
|
452
|
+
|
|
432
453
|
On Android 11 and newer, `BiometricLevel.BiometryOnly` and
|
|
433
454
|
`BiometricLevel.BiometryOrPasscode` use separate Keystore policies. Android 10
|
|
434
455
|
and older support `BiometryOrPasscode`; `BiometryOnly` throws
|
|
@@ -436,9 +457,11 @@ and older support `BiometryOrPasscode`; `BiometryOnly` throws
|
|
|
436
457
|
biometric-only distinction. Promoting a value to biometric storage removes the
|
|
437
458
|
plain secure copy on every platform, so plain reads cannot return a stale
|
|
438
459
|
value. Secure existence, discovery, and cleanup operations
|
|
439
|
-
can also throw when a protected store is locked or its key is invalidated.
|
|
440
|
-
|
|
441
|
-
|
|
460
|
+
can also throw when a protected store is locked or its key is invalidated. Use
|
|
461
|
+
`isStorageError()` to choose the correct recovery path: retry
|
|
462
|
+
`keychain_locked` after unlock, request user interaction for
|
|
463
|
+
`authentication_required`, and rebuild the affected credential for
|
|
464
|
+
`key_invalidated`.
|
|
442
465
|
|
|
443
466
|
## Batch Operations
|
|
444
467
|
|
|
@@ -446,7 +469,9 @@ behavior is appropriate.
|
|
|
446
469
|
matching item. `setBatch()` validates every item/value pair independently,
|
|
447
470
|
including heterogeneous batches.
|
|
448
471
|
Missing keys use each item's `defaultValue`; the native bridge preserves missing
|
|
449
|
-
entries as `undefined` while reading the batch.
|
|
472
|
+
entries as `undefined` while reading the batch. With `readCache: true`, item and
|
|
473
|
+
batch reads reuse raw cache entries, including cached missing values, until a
|
|
474
|
+
write, delete, clear, or external change invalidates the entry.
|
|
450
475
|
|
|
451
476
|
```ts
|
|
452
477
|
import { getBatch, removeBatch, setBatch } from "react-native-nitro-storage";
|
|
@@ -569,6 +594,11 @@ setWebDiskStorageBackend(backend);
|
|
|
569
594
|
setWebSecureStorageBackend(backend);
|
|
570
595
|
```
|
|
571
596
|
|
|
597
|
+
Web reads and mutations stay synchronous against the backend's in-memory
|
|
598
|
+
contract; use `flushWebStorageBackends()` for asynchronous persistence
|
|
599
|
+
boundaries. The native entry keeps the web backend setters, getters, and flush
|
|
600
|
+
function as typed no-ops for cross-platform code.
|
|
601
|
+
|
|
572
602
|
Browser storage cannot provide iOS Keychain or Android Keystore guarantees. Web
|
|
573
603
|
Secure scope is only as strong as the backend you configure.
|
|
574
604
|
|
|
@@ -597,6 +627,28 @@ beforeEach(() => {
|
|
|
597
627
|
const { storage, memoryItem } = createNitroStorageMock();
|
|
598
628
|
```
|
|
599
629
|
|
|
630
|
+
## API
|
|
631
|
+
|
|
632
|
+
The package exposes named `storage`, `createStorageItem`, the scoped item
|
|
633
|
+
factories, `createSetItem`, batch operations, migration and transaction helpers,
|
|
634
|
+
secure-auth storage, React hooks, and web backend utilities. Values are bound to
|
|
635
|
+
`Memory`, `Disk`, or `Secure` and support typed single-key operations, raw
|
|
636
|
+
inspection, events and observers, cache and write-flush controls, secure
|
|
637
|
+
metadata, transactional migrations with rename/rollback, and configurable web
|
|
638
|
+
backends. The full reference lives in
|
|
639
|
+
[docs/api-reference.md](docs/api-reference.md).
|
|
640
|
+
|
|
641
|
+
## Error Contract
|
|
642
|
+
|
|
643
|
+
Native and web adapters tag classified failures with stable error codes. Use
|
|
644
|
+
`getStorageErrorCode(error)` or `isStorageError(error, code)` to branch on them:
|
|
645
|
+
`keychain_locked` reports a locked Keychain that a retry can recover after
|
|
646
|
+
authentication, secure-scope write or biometric failures carry their own
|
|
647
|
+
codes, and invalid inputs (bad scope, malformed keys, numeric guard
|
|
648
|
+
violations) are rejected before reaching native storage. Errors never swallow
|
|
649
|
+
the underlying cause silently: the original platform message is preserved on
|
|
650
|
+
the error for diagnostics.
|
|
651
|
+
|
|
600
652
|
## Platform Support
|
|
601
653
|
|
|
602
654
|
| Platform | Status |
|
|
@@ -650,9 +702,14 @@ bun run example:android
|
|
|
650
702
|
bun run example:ios
|
|
651
703
|
```
|
|
652
704
|
|
|
653
|
-
Run native example builds before release when changing plugin, native,
|
|
654
|
-
secure storage, or packaging files.
|
|
655
|
-
package
|
|
705
|
+
Run native example builds locally before release when changing plugin, native,
|
|
706
|
+
Nitro, secure storage, or packaging files. GitHub CI does not build the Android
|
|
707
|
+
or iOS example. The package release path also validates package contents and
|
|
708
|
+
dry-run publish behavior.
|
|
709
|
+
|
|
710
|
+
`bun run benchmark` measures only the built web entry with an isolated private
|
|
711
|
+
localStorage implementation; it is not a native Disk or Secure benchmark. See
|
|
712
|
+
[docs/benchmarks.md](docs/benchmarks.md) for sampling and interpretation limits.
|
|
656
713
|
|
|
657
714
|
## License
|
|
658
715
|
|
|
@@ -40,8 +40,11 @@ std::vector<std::string> fromJavaStringArray(alias_ref<JavaStringArray> values)
|
|
|
40
40
|
result.reserve(size);
|
|
41
41
|
for (jsize i = 0; i < size; ++i) {
|
|
42
42
|
auto currentValue = values->getElement(i);
|
|
43
|
-
//
|
|
44
|
-
|
|
43
|
+
// Null entries are dropped so a missing key can never surface as the
|
|
44
|
+
// empty-string clear sentinel used by change listeners.
|
|
45
|
+
if (currentValue) {
|
|
46
|
+
result.push_back(currentValue->toStdString());
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
return result;
|
|
47
50
|
}
|