react-native-nitro-storage 0.5.7 → 0.5.9

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 ADDED
@@ -0,0 +1,356 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format follows Keep a Changelog and the project adheres to SemVer.
6
+
7
+ ## 0.5.9 - 2026-06-11
8
+
9
+ ### Fixed
10
+
11
+ - Added a package-owned Android manifest initializer so storage setup no longer requires generated `MainApplication` edits in Expo or bare React Native apps.
12
+ - Tied the Expo config plugin run-once metadata to the package version so updated package plugin behavior is reapplied correctly after package upgrades.
13
+
14
+ ### Changed
15
+
16
+ - Included `CHANGELOG.md` in the packed package docs.
17
+
18
+ ## 0.5.8 - 2026-06-11
19
+
20
+ ### Changed
21
+
22
+ - Refactor native and web entrypoints to share the same storage core for item, batch, transaction, migration, metrics, import/export, and event behavior.
23
+ - Strengthen TypeScript checks with stricter compiler options so missing returns, switch fallthrough, and unchecked optional shapes are caught during package validation.
24
+
25
+ ### Fixed
26
+
27
+ - Regenerate Nitrogen output and package build artifacts before pack-content audits so clean release and CI environments validate the actual published tarball.
28
+
29
+ ## 0.5.7 - 2026-06-10
30
+
31
+ ### Added
32
+
33
+ - Add C++ sanitizer release gates for AddressSanitizer, ThreadSanitizer, and UndefinedBehaviorSanitizer so native storage regressions can be isolated before publishing.
34
+ - Add C++ stress coverage for listener unsubscribe behavior, hydrated batch key indexes, and concurrent Memory scope access.
35
+
36
+ ### Changed
37
+
38
+ - Speed up iOS Secure batch operations by reusing the resolved Keychain access group and access-control level across each batch instead of re-reading configuration per key.
39
+ - Refactor iOS Secure set/get/delete helpers so single-item and batch paths share Keychain status handling and cache updates.
40
+ - Strengthen TypeScript inference parity on web by exporting `StorageSetter` and preserving tuple value types from `getBatch()`.
41
+
42
+ ### Fixed
43
+
44
+ - Keep native and web public TypeScript entrypoints aligned so IDEs infer storage setters and batch tuple results consistently across React Native and web imports.
45
+ - Keep the README, issue template, package metadata, and release notes aligned with the current `0.5.7` package surface.
46
+
47
+ ## 0.5.6 - 2026-05-22
48
+
49
+ ### Added
50
+
51
+ - Update the package baseline to Expo SDK 56, React Native 0.85.3, React 19.2.3, TypeScript 6.0.3, and Nitro Modules 0.35.7.
52
+ - Add secure export guardrails: `storage.export(StorageScope.Secure)` now requires an explicit `{ includeSecureValues: true }` opt-in, with `storage.exportSecureUnsafe()` available for short-lived secure migration flows.
53
+ - Add secure event observer redaction options so `storage.setEventObserver()` redacts Secure values by default and requires explicit opt-in for raw Secure event values.
54
+ - Add Expo plugin Android backup rules that exclude Nitro Storage secure preference files from cloud backup and device transfer.
55
+ - Add public web backend contract exports for `WebDiskStorageBackend` and `WebSecureStorageBackend` from the native and web entrypoints.
56
+
57
+ ### Changed
58
+
59
+ - Close replaced web storage backends so IndexedDB-backed `BroadcastChannel` and database handles do not leak after backend swaps.
60
+ - Update README and package docs for the current secure export, event observer, Expo backup, web backend, and TypeScript usage surface.
61
+ - Preserve tuple value types in `getBatch()` so IDEs infer each returned value from its matching `StorageItem`.
62
+
63
+ ### Fixed
64
+
65
+ - Avoid Metro private `metro-config/src/defaults/exclusionList` imports and exclude generated Android `.cxx` directories from Metro and Watchman scans.
66
+ - Remove package-owned Android native log spam for expected unavailable biometric storage paths.
67
+ - Modernize Android Gradle assignment syntax to avoid package-owned Gradle warnings.
68
+
69
+ ## 0.5.4 - 2026-05-13
70
+
71
+ ### Fixed
72
+
73
+ - Align web secure runtime validation with native for access-control and biometric levels.
74
+ - Preserve secure biometric and access-control item semantics during transaction rollback.
75
+ - Keep web raw batch writes from indexing keys whose values were not written.
76
+ - Reject fractional C++ secure access-control and biometric levels before casting them for native adapters.
77
+ - Publish GitHub Releases to npm through a Trusted Publishing/OIDC workflow.
78
+ - Resolve the package build's TypeScript binary lookup warning during release checks.
79
+
80
+ ## 0.5.2 - 2026-04-27
81
+
82
+ ### Fixed
83
+
84
+ - Make `createIndexedDBBackend().flush()` reject queued IndexedDB write failures after surfacing them through `onError`.
85
+ - Stabilize the release benchmark gate by sampling each benchmark three times while keeping the same regression thresholds.
86
+ - Correct package content check commands in the release documentation for current Bun.
87
+
88
+ ## 0.5.1 - 2026-04-24
89
+
90
+ ### Added
91
+
92
+ - Add `storage.export(scope)` for raw string snapshots that can be restored with `storage.import(data, scope)`.
93
+ - Add event subscriptions with `storage.subscribe`, `storage.subscribeKey`, `storage.subscribePrefix`, and `storage.subscribeNamespace`.
94
+ - Add `StorageItem#subscribeSelector()` for selector-based subscriptions with equality checks.
95
+ - Add `storage.setEventObserver()` for devtools and storage event logging integrations.
96
+ - Add enforced JS/TS and C++ coverage gates for the package release path.
97
+
98
+ ### Changed
99
+
100
+ - Improve Memory namespace clear notification fan-out so subscribers under the cleared namespace are notified consistently.
101
+ - Improve web key-index fast paths when the active backend exposes indexed key operations.
102
+ - Emit batch change envelopes for raw import/export-adjacent workflows and batch writes/removes.
103
+ - Document raw import/export workflows and warn that Secure exports expose secret values.
104
+ - Refactor the publish script to validate release docs, report check timings, support coverage gates, and avoid redundant pack dry-runs.
105
+
106
+ ## 0.5.0 - 2026-04-18
107
+
108
+ ### Added
109
+
110
+ - Add secure-storage capability metadata with `storage.getSecurityCapabilities()`.
111
+ - Add metadata-only secure key inspection with `storage.getSecureMetadata(key)` and `storage.getAllSecureMetadata()`.
112
+ - Add public `SecurityCapabilities` and `SecureStorageMetadata` types.
113
+ - Add security policy and focused docs for secure storage, React hooks, and MMKV migration.
114
+
115
+ ### Changed
116
+
117
+ - Refresh README positioning, badges, platform support, security model, storage-library comparison guidance, and benchmark guidance for npm/GitHub discoverability.
118
+ - Tighten README decisioning with an at-a-glance API map, Expo plugin options, bare Android setup, migration paths, and a release checklist.
119
+ - Split detailed usage material into focused docs for API reference, React hooks, secure storage, web backends, batch/transaction/migration workflows, recipes, MMKV migration, and benchmarks.
120
+ - 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.
121
+ - Harden publish dry-runs, package docs syncing, and npm pack content validation.
122
+
123
+ ## 0.4.5 - 2026-04-14
124
+
125
+ ### Added
126
+
127
+ - Add configurable web Disk backend hooks: `setWebDiskStorageBackend()`, `getWebDiskStorageBackend()`, and `flushWebStorageBackends()`.
128
+ - Extend the web backend contract with optional batch, sizing, subscription, and flush hooks for higher-performance custom backends.
129
+ - Add IndexedDB backend support for `getMany`, `setMany`, `removeMany`, `size`, `flush`, and `BroadcastChannel`-based cross-tab sync.
130
+ - Expand regression coverage for web backend overrides, backend subscription-driven cache invalidation, backend flush hooks, IndexedDB broadcast sync, and IndexedDB error surfacing.
131
+ - Add Disk write buffering APIs: `coalesceDiskWrites`, `storage.setDiskWritesAsync()`, `storage.flushDiskWrites()`, and `storage.getCapabilities()`.
132
+ - Add structured storage error classification via `getStorageErrorCode()` while keeping `isKeychainLockedError()` as the convenience helper, and tag native bridge errors with stable `[nitro-error:<code>]` markers.
133
+
134
+ ### Changed
135
+
136
+ - Upgrade to **Nitro Modules 0.35.4** and regenerate bindings against the latest stable Nitro 0.35 line.
137
+ - Migrate `nitro.json` to the current schema (`$schema`, `ignorePaths`, `gitAttributesGeneratedFlag`, and `autolinking.all.language = "c++"`).
138
+ - Raise the published `react-native-nitro-modules` requirement to `>= 0.35.4` so package metadata matches the tested Nitro baseline.
139
+ - Refresh root tooling to current patch releases for linting, testing, and workspace orchestration.
140
+ - Switch web operation timing to `performance.now()` when available for tighter metrics on fast paths.
141
+
142
+ ## 0.4.2/0.4.3 - 2026-03-05
143
+
144
+ ### Fixed
145
+
146
+ - Fix crash on Android devices without biometric hardware — all biometric storage paths now catch initialization failures gracefully (non-biometric operations unaffected).
147
+ - Fix Android keystore corruption recovery incorrectly wiping data on a locked keystore — only `AEADBadTagException` now triggers wipe; all other init failures throw without touching stored data.
148
+ - Synchronize `AndroidStorageAdapter.invalidateSecureKeysCache()` under instance lock to close a race between concurrent reads and writes.
149
+ - Synchronize `setSecureBatch`/`deleteSecureBatch` under instance lock to prevent cache rebuild racing a mid-batch write.
150
+ - Propagate `SharedPreferences.commit()` failures out of `applySecureEditor` instead of swallowing them.
151
+ - Fix `IOSStorageAdapterCpp::clearDisk()` using `dictionaryRepresentation` (includes OS-injected keys) — switched to `persistentDomainForName:` scoped strictly to the app suite.
152
+ - Fix `clearSecure()`/`clearSecureBiometric()` clearing the in-memory key cache before confirming `SecItemDelete` succeeded — cache is now only updated after the deletion is confirmed.
153
+ - Fix potential unexpected biometric auth prompt in `getSecure()` — added `kSecUseAuthenticationUI = kSecUseAuthenticationUIFail` consistent with `hasSecure()`.
154
+ - Fix `setKeychainAccessGroup()` race where a concurrent `getAllKeysSecure()` could observe a stale cache between group update and cache invalidation — both are now updated atomically under both mutexes.
155
+ - Fix CFErrorRef leak in `SecAccessControlCreateWithFlags` error path.
156
+ - Fix `setSecureBiometricWithLevel()` incorrectly reporting "value restored" when backup restoration itself threw — now propagates the composite error.
157
+ - Mark `secureKeyCacheHydrated_` as `std::atomic<bool>` to satisfy the C++ memory model.
158
+ - Fix `HybridStorage::addOnChange()` unsubscribe lambda capturing `this` raw pointer — switched to `std::weak_ptr` capture to prevent use-after-free if `HybridStorage` is destroyed before the JS unsubscribe callback fires.
159
+ - Validate access control level in `setSecureAccessControl()` (must be 0–4) and biometric level in `setSecureBiometricWithLevel()` (must be 0–2) — invalid values now throw instead of being silently passed to the native adapter.
160
+ - Fix `clearSecureBiometric()` calling `onScopeClear` which unnecessarily evicted all secure keys from the index — now only marks the index stale for lazy re-hydration.
161
+ - Fix `fromJavaStringArray()` silently dropping null JNI array elements — null entries are now preserved as empty strings to maintain positional alignment.
162
+ - Extend `isKeychainLockedError()` to detect Android `KeyPermanentlyInvalidatedException` and `InvalidKeyException` in addition to existing iOS/Android patterns.
163
+ - Fix web `getAll()` performing O(n) individual reads — switched to `WebStorage.getBatch()`.
164
+ - Fix web `subscribe()` accumulating `window.addEventListener("storage", …)` calls — now reference-counted and removed when the last subscriber unsubscribes.
165
+ - Fix web `import()` for Secure scope skipping `flushSecureWrites()` and `setSecureAccessControl()` before writing.
166
+ - Expand ProGuard/R8 keep rules with explicit method-signature patterns so JNI-callable methods survive aggressive R8 shrinking in release builds.
167
+
168
+ ## 0.4.1 - 2026-03-04
169
+
170
+ ### Added
171
+
172
+ - Add `storage.import(data, scope)` to bulk-load a `Record<string, string>` of raw key/value pairs into any scope in one call. Memory imports are atomic (all keys visible simultaneously before any listener fires).
173
+ - Add `createIndexedDBBackend(dbName?, storeName?)` factory (exported from `react-native-nitro-storage/indexeddb-backend`) that wraps IndexedDB with a write-through in-memory cache, enabling persistent web Secure storage for large payloads without blocking the UI thread.
174
+
175
+ ### Fixed
176
+
177
+ - Fix TTL expiry notification: subscribers registered via `item.subscribe()` are now correctly notified when a value expires on `item.get()` — both on cache-hit expiry and on envelope-parse expiry. Previously the notification was only emitted by the native event bus, which is not triggered in write-through or coalesced paths.
178
+ - Fix `setBatch` Memory atomicity: all values in a Memory-scope batch are now written to the store before any listener is notified, eliminating partial-batch observation windows. Items with `validate` or `expiration` config fall back to per-item sets to preserve those semantics.
179
+
180
+ ### Changed
181
+
182
+ - Upgrade to **Nitro Modules 0.35.0** — regenerate nitrogen specs with the new `registerAllNatives()` JNI entry point, fixing the Kotlin `HybridObject` `jni::global_ref` memory leak (Nitro #1238).
183
+ - Update `cpp-adapter.cpp` to use `registerAllNatives()` instead of the deprecated `initialize(vm)` shim.
184
+ - Bump to **React 19.2.0** and **React Native 0.83.2** across workspace and example.
185
+ - Add `--provenance` flag to `npm publish` for npm supply-chain attestation.
186
+
187
+ ## 0.4.0 - 2026-02-25
188
+
189
+ ### Added
190
+
191
+ - Add prefix query APIs: `storage.getKeysByPrefix(prefix, scope)` and `storage.getByPrefix(prefix, scope)`.
192
+ - Add optimistic concurrency APIs on items: `item.getWithVersion()` and `item.setIfVersion(version, value)`.
193
+ - Add storage metrics APIs: `storage.setMetricsObserver`, `storage.getMetricsSnapshot`, and `storage.resetMetrics`.
194
+ - Add `biometricLevel` item/auth config and native bridge support for `setSecureBiometricWithLevel`.
195
+ - Add configurable web Secure backend hooks: `setWebSecureStorageBackend` and `getWebSecureStorageBackend`.
196
+ - Add native prefix key retrieval plumbing (`getKeysByPrefix`) across Nitro spec, C++ core/bindings, Android, and iOS.
197
+ - Add regression coverage for prefix APIs, versioned APIs, metrics APIs, secure coalescing with access control, cross-tab web updates, and transaction rollback batch behavior.
198
+
199
+ ### Changed
200
+
201
+ - Optimize non-memory transaction rollback paths to use batch native/web writes and removals.
202
+ - Improve batch read semantics by using per-item cache hits and returning each item's default when raw batch data is missing.
203
+ - Improve native/web secure write coalescing by preserving optional access control without violating strict optional typing.
204
+ - Keep iOS secure keychain cache/index behavior aligned with new prefix query and biometric-level paths.
205
+ - Expand README/API docs to cover the new public API surface with concrete TypeScript use-case snippets.
206
+
207
+ ## 0.3.2 - 2026-02-22
208
+
209
+ ### Added
210
+
211
+ - Add `storage.setSecureWritesAsync(enabled)` to toggle Android secure writes between synchronous `commit()` and asynchronous `apply()`.
212
+ - Add `storage.flushSecureWrites()` for deterministic flush control of coalesced secure writes.
213
+ - Add native `removeByPrefix(prefix, scope)` plumbing and route namespace clears through the native/web prefix path.
214
+ - Add dedicated C++ binding tests for `HybridStorage` behavior (`cpp/bindings/HybridStorageTest.cpp`), wired into `test:cpp`.
215
+ - Add type-level public API tests (`test:types`) and package content guard checks (`check:pack`).
216
+
217
+ ### Changed
218
+
219
+ - Skip unnecessary read path on direct `item.set(value)` writes (still reads for updater functions).
220
+ - Reuse TTL envelope parse results while entries remain unexpired to avoid repeated JSON parse/deserialization work.
221
+ - Group secure raw batch writes by per-item access control so secure batch paths stay fast even with mixed access-control settings.
222
+ - Optimize C++ batch listener dispatch by copying scoped listeners once per batch operation.
223
+ - Avoid duplicate secure biometric clearing calls by relying on secure clear paths that already include biometric cleanup.
224
+ - Optimize web secure/disk key bookkeeping with an indexed key cache (faster `size`, `getAllKeys`, and namespace clears without repeated `localStorage` scans).
225
+ - Improve iOS secure key union performance by deduplicating with an `unordered_set`.
226
+ - Extract shared React hooks into `src/storage-hooks.ts` to reduce native/web entrypoint duplication.
227
+ - Expand benchmark coverage to include Disk and Secure scope throughput checks and tighten regression thresholds.
228
+ - 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.
229
+
230
+ ## 0.3.1 - 2026-02-16
231
+
232
+ ### Changed
233
+
234
+ - Isolate web Secure scope keys under `__secure_` prefix while keeping biometric fallback under `__bio_`.
235
+ - Align `storage.clear(StorageScope.Secure)` with biometric cleanup semantics.
236
+ - Update README installation, enum docs, and quality command docs to match current APIs.
237
+
238
+ ### Fixed
239
+
240
+ - Fix web scope bleed where clearing Disk/Secure could wipe the other secure domain.
241
+ - Fix biometric listener updates by emitting change notifications for biometric set/delete/clear paths.
242
+ - Fix secure namespace cleanup by flushing pending secure writes before namespace removal.
243
+ - Fix secure access-control leakage by applying access control at write time and disabling coalesced raw batch path when access control is configured.
244
+ - Fix global `storage.setAccessControl(...)` handling so non-item raw secure writes keep the configured level instead of being forced back to default.
245
+ - Fix Android secure key enumeration to return deduplicated key sets when secure and biometric stores share key names.
246
+
247
+ ## 0.3.0 - 2026-02-15
248
+
249
+ ### Added
250
+
251
+ - Add `useStorageSelector(item, selector, isEqual?)` to reduce rerenders from unrelated object updates.
252
+ - Add opt-in `coalesceSecureWrites` and per-item `readCache` controls in `createStorageItem` config.
253
+
254
+ ### Changed
255
+
256
+ - Switch default serialization to a primitive fast path for primitives while preserving JSON compatibility for objects and legacy values.
257
+ - Replace broad listener fan-out with key-indexed registries and automatic pruning for memory/native/web paths.
258
+
259
+ ### Fixed
260
+
261
+ - Route native batch calls through true adapter-level batch APIs (HybridStorage + iOS/Android adapters) instead of per-key loops.
262
+ - Add read-through cache invalidation on scoped/key change events and native/web clear paths.
263
+
264
+ ## 0.2.1 - 2026-02-15
265
+
266
+ ### Added
267
+
268
+ - Add explicit package `exports` for ESM/CJS/react-native/web resolution.
269
+
270
+ ### Fixed
271
+
272
+ - Preserve validation and TTL semantics in batch APIs by falling back to per-item paths when needed.
273
+ - Preserve item-level semantics in transaction `setItem`/`removeItem` by using item methods directly.
274
+ - Decode native batch missing values correctly to avoid empty-string ambiguity on iOS/Android C++ bindings.
275
+ - Avoid duplicate observer updates on native/web `setBatch` paths.
276
+ - Scope iOS disk storage to a dedicated UserDefaults suite and avoid clearing unrelated app defaults.
277
+ - Use a package-specific Android master-key alias for encrypted storage initialization and recovery.
278
+ - Expo config plugin now preserves existing `NSFaceIDUsageDescription` values.
279
+ - Expo config plugin makes Android biometric permissions opt-in.
280
+
281
+ ### Changed
282
+
283
+ - Raise `react` peer dependency floor to `>=18.2.0`.
284
+
285
+ ## 0.2.0 - 2026-02-15
286
+
287
+ ### Added
288
+
289
+ - Export `migrateFromMMKV` from the package root entrypoint.
290
+ - Add dedicated web storage tests and include `index.web.ts` in coverage collection.
291
+ - Add `runTransaction(scope, fn)` with rollback on thrown errors.
292
+ - Add versioned migration APIs: `registerMigration` and `migrateToLatest`.
293
+ - Add schema-aware storage options: `validate` and `onValidationError`.
294
+ - Add per-item TTL support via `expiration.ttlMs`.
295
+
296
+ ### Fixed
297
+
298
+ - Validate batch operation scope to prevent mixed-scope usage.
299
+ - Avoid duplicate native remove calls in `removeBatch`.
300
+ - Clear cached item values on `delete()` to prevent stale reads (native and web).
301
+
302
+ ### Changed
303
+
304
+ - Standardize internal package scripts and README contributor commands to Bun/Bunx.
305
+ - Expand README with complete API behavior/throws documentation.
306
+ - Strengthen native and web test coverage for validation, TTL, migrations, and transactions.
307
+
308
+ ## 0.1.4 - 2026-02-09
309
+
310
+ ### Added
311
+
312
+ - Add `clearAll` event.
313
+
314
+ ### Fixed
315
+
316
+ - Fix Android behavior.
317
+
318
+ ### Changed
319
+
320
+ - Bump react-native-nitro-modules to the latest version and raise the peer dependency floor.
321
+
322
+ ## 0.1.3 - 2026-01-22
323
+
324
+ ### Fixed
325
+
326
+ - Prevent ProGuard from stripping the JNI class in release builds.
327
+
328
+ ## 0.1.2 - 2026-01-07
329
+
330
+ ### Added
331
+
332
+ - Finalize batch operations and clean up the implementation.
333
+ - Add missing batch coverage and exclude web from the coverage report.
334
+
335
+ ### Changed
336
+
337
+ - Point types to the correct path and simplify bob targets.
338
+
339
+ ## 0.1.1 - 2025-12-15
340
+
341
+ ### Added
342
+
343
+ - MMKV migration utility.
344
+ - Benchmark UI improvements.
345
+
346
+ ### Changed
347
+
348
+ - Update native build configs.
349
+ - Update README screenshots.
350
+ - Add tests for memory item deletion and MMKV migration, and simplify the README.
351
+
352
+ ## 0.1.0 - 2025-12-15
353
+
354
+ ### Added
355
+
356
+ - Initial public release from the private repository.
package/README.md CHANGED
@@ -7,6 +7,7 @@
7
7
  [![React Native](https://img.shields.io/badge/react--native-%3E%3D0.75-61dafb)](https://reactnative.dev/)
8
8
  [![Expo](https://img.shields.io/badge/expo-SDK%2056-000020)](https://docs.expo.dev/)
9
9
  [![Nitro Modules](https://img.shields.io/badge/nitro--modules-%3E%3D0.35.7-black)](https://nitro.margelo.com/)
10
+ [![TypeScript](https://img.shields.io/badge/typescript-6.0-3178c6)](https://www.typescriptlang.org/)
10
11
 
11
12
  Synchronous Memory, Disk, and Secure storage for React Native, Expo development
12
13
  builds, and web. Nitro Storage is powered by
@@ -91,9 +92,11 @@ Add the config plugin before prebuilding native iOS and Android projects:
91
92
  | `addBiometricPermissions` | `false` | Adds Android biometric and fingerprint permissions. |
92
93
  | `configureAndroidBackup` | `true` | Writes Android backup rules that exclude secure storage files. |
93
94
 
94
- The plugin also initializes the Android storage adapter in `MainApplication`.
95
- Set `configureAndroidBackup: false` only when your app maintains equivalent
96
- backup and device-transfer exclusions for Nitro Storage secure files.
95
+ Android adapter initialization is owned by the package through an Android
96
+ manifest initializer, so apps should not edit `MainApplication` to call
97
+ `AndroidStorageAdapter.init(this)`. Set `configureAndroidBackup: false` only
98
+ when your app maintains equivalent backup and device-transfer exclusions for
99
+ Nitro Storage secure files.
97
100
 
98
101
  ## Quick Start
99
102
 
@@ -379,6 +382,8 @@ Secure scope is only as strong as the backend you configure.
379
382
 
380
383
  - **Expo Go error:** build a development client; Expo Go cannot load Nitro
381
384
  modules.
385
+ - **Android not initialized:** rebuild the native app after installing or
386
+ upgrading the package so the Android manifest initializer is merged.
382
387
  - **Secure values fail after Android restore:** keep `configureAndroidBackup:
383
388
  true` or provide equivalent backup exclusions.
384
389
  - **Biometric prompt does not appear:** set `biometric: true` on the item and
@@ -0,0 +1,9 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <application>
3
+ <provider
4
+ android:name="com.nitrostorage.NitroStorageInitializer"
5
+ android:authorities="${applicationId}.nitrostorage-initializer"
6
+ android:exported="false"
7
+ android:initOrder="100" />
8
+ </application>
9
+ </manifest>
@@ -0,0 +1,38 @@
1
+ package com.nitrostorage
2
+
3
+ import android.content.ContentProvider
4
+ import android.content.ContentValues
5
+ import android.database.Cursor
6
+ import android.net.Uri
7
+
8
+ class NitroStorageInitializer : ContentProvider() {
9
+ override fun onCreate(): Boolean {
10
+ context?.applicationContext?.let(AndroidStorageAdapter::init)
11
+ return true
12
+ }
13
+
14
+ override fun query(
15
+ uri: Uri,
16
+ projection: Array<out String>?,
17
+ selection: String?,
18
+ selectionArgs: Array<out String>?,
19
+ sortOrder: String?,
20
+ ): Cursor? = null
21
+
22
+ override fun getType(uri: Uri): String? = null
23
+
24
+ override fun insert(uri: Uri, values: ContentValues?): Uri? = null
25
+
26
+ override fun delete(
27
+ uri: Uri,
28
+ selection: String?,
29
+ selectionArgs: Array<out String>?,
30
+ ): Int = 0
31
+
32
+ override fun update(
33
+ uri: Uri,
34
+ values: ContentValues?,
35
+ selection: String?,
36
+ selectionArgs: Array<out String>?,
37
+ ): Int = 0
38
+ }
package/app.plugin.js CHANGED
@@ -1,12 +1,12 @@
1
1
  const {
2
2
  withInfoPlist,
3
3
  withAndroidManifest,
4
- withMainApplication,
5
4
  withDangerousMod,
6
5
  createRunOncePlugin,
7
6
  } = require("@expo/config-plugins");
8
7
  const fs = require("fs");
9
8
  const path = require("path");
9
+ const pkg = require("./package.json");
10
10
 
11
11
  const DATA_EXTRACTION_RULES_RESOURCE =
12
12
  "@xml/nitro_storage_data_extraction_rules";
@@ -152,57 +152,13 @@ const withNitroStorage = (config, props = {}) => {
152
152
  ]);
153
153
  }
154
154
 
155
- config = withMainApplication(config, (config) => {
156
- const { modResults } = config;
157
- const { language, contents } = modResults;
158
-
159
- if (language === "java") {
160
- if (!contents.includes("AndroidStorageAdapter.init")) {
161
- const importStatement =
162
- "import com.nitrostorage.AndroidStorageAdapter;";
163
- const initStatement = " AndroidStorageAdapter.init(this);";
164
-
165
- if (!contents.includes(importStatement)) {
166
- modResults.contents = contents.replace(
167
- /(package .*;\n)/,
168
- `$1\n${importStatement}\n`,
169
- );
170
- }
171
-
172
- modResults.contents = modResults.contents.replace(
173
- /(super\.onCreate\(\);)/,
174
- `$1\n${initStatement}`,
175
- );
176
- }
177
- } else if (language === "kt") {
178
- if (!contents.includes("AndroidStorageAdapter.init")) {
179
- const importStatement = "import com.nitrostorage.AndroidStorageAdapter";
180
- const initStatement = " AndroidStorageAdapter.init(this)";
181
-
182
- if (!contents.includes(importStatement)) {
183
- modResults.contents = contents.replace(
184
- /(package .*\n)/,
185
- `$1\n${importStatement}\n`,
186
- );
187
- }
188
-
189
- modResults.contents = modResults.contents.replace(
190
- /(super\.onCreate\(\))/,
191
- `$1\n${initStatement}`,
192
- );
193
- }
194
- }
195
-
196
- return config;
197
- });
198
-
199
155
  return config;
200
156
  };
201
157
 
202
158
  module.exports = createRunOncePlugin(
203
159
  withNitroStorage,
204
- "react-native-nitro-storage",
205
- "1.0.0",
160
+ pkg.name,
161
+ pkg.version,
206
162
  );
207
163
  module.exports.withNitroStorage = withNitroStorage;
208
164
  module.exports._internal = {