react-native-nitro-storage 0.13.0 → 0.15.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 +31 -0
- package/README.md +260 -7
- package/cpp/bindings/HybridStorage.cpp +21 -0
- package/cpp/bindings/HybridStorage.hpp +2 -0
- package/cpp/core/NativeStorageAdapter.hpp +6 -0
- package/docs/api-reference.md +68 -43
- package/docs/batch-transactions-migrations.md +7 -0
- package/docs/qa/agent-device-replay.md +106 -0
- package/docs/secure-storage.md +12 -6
- package/ios/IOSStorageAdapterCpp.hpp +12 -0
- package/ios/IOSStorageAdapterCpp.mm +180 -2
- package/lib/commonjs/Storage.types.js +4 -2
- package/lib/commonjs/Storage.types.js.map +1 -1
- package/lib/commonjs/core/durability.js +30 -2
- package/lib/commonjs/core/durability.js.map +1 -1
- package/lib/commonjs/index.js +16 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +10 -1
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/shared.js +6 -0
- package/lib/commonjs/shared.js.map +1 -1
- package/lib/commonjs/storage-core.js +116 -3
- package/lib/commonjs/storage-core.js.map +1 -1
- package/lib/commonjs/testing.js +32 -2
- package/lib/commonjs/testing.js.map +1 -1
- package/lib/module/Storage.types.js +4 -2
- package/lib/module/Storage.types.js.map +1 -1
- package/lib/module/core/durability.js +30 -2
- package/lib/module/core/durability.js.map +1 -1
- package/lib/module/index.js +16 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +10 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/shared.js +5 -0
- package/lib/module/shared.js.map +1 -1
- package/lib/module/storage-core.js +117 -4
- package/lib/module/storage-core.js.map +1 -1
- package/lib/module/testing.js +31 -1
- package/lib/module/testing.js.map +1 -1
- package/lib/typescript/Storage.nitro.d.ts +2 -0
- package/lib/typescript/Storage.nitro.d.ts.map +1 -1
- package/lib/typescript/Storage.types.d.ts +4 -2
- package/lib/typescript/Storage.types.d.ts.map +1 -1
- package/lib/typescript/core/durability.d.ts +7 -1
- package/lib/typescript/core/durability.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +8 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/index.web.d.ts +8 -3
- package/lib/typescript/index.web.d.ts.map +1 -1
- package/lib/typescript/shared.d.ts +9 -1
- package/lib/typescript/shared.d.ts.map +1 -1
- package/lib/typescript/storage-core.d.ts +34 -4
- package/lib/typescript/storage-core.d.ts.map +1 -1
- package/lib/typescript/storage-platform.d.ts +2 -0
- package/lib/typescript/storage-platform.d.ts.map +1 -1
- package/lib/typescript/testing.d.ts +16 -5
- package/lib/typescript/testing.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/HybridStorageSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridStorageSpec.hpp +2 -0
- package/package.json +2 -2
- package/src/Storage.nitro.ts +2 -0
- package/src/Storage.types.ts +4 -2
- package/src/core/durability.ts +46 -2
- package/src/index.ts +24 -0
- package/src/index.web.ts +18 -0
- package/src/shared.ts +27 -1
- package/src/storage-core.ts +182 -8
- package/src/storage-platform.ts +2 -0
- package/src/testing.ts +42 -0
package/src/testing.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createIndexedDBBackend as createIndexedDBBackendFromSubpath } from "./indexeddb-backend";
|
|
2
2
|
import {
|
|
3
3
|
assertAccessControlLevel,
|
|
4
|
+
assertProtectedDataListener,
|
|
4
5
|
notifyAllListeners,
|
|
5
6
|
notifyKeyListeners,
|
|
6
7
|
} from "./shared";
|
|
@@ -23,6 +24,10 @@ import type {
|
|
|
23
24
|
|
|
24
25
|
export { StorageScope, AccessControl, BiometricLevel } from "./Storage.types";
|
|
25
26
|
export { isKeychainLockedError } from "./shared";
|
|
27
|
+
export type {
|
|
28
|
+
StorageScheduledFlushError,
|
|
29
|
+
StorageScheduledFlushErrorObserver,
|
|
30
|
+
} from "./core/durability";
|
|
26
31
|
export { migrateFromMMKV } from "./migration";
|
|
27
32
|
export { getStorageErrorCode, isStorageError } from "./storage-runtime";
|
|
28
33
|
export {
|
|
@@ -80,6 +85,8 @@ export type {
|
|
|
80
85
|
WebStorageScope,
|
|
81
86
|
} from "./web-storage-backend";
|
|
82
87
|
export type {
|
|
88
|
+
SecureAccessControlMigrationOptions,
|
|
89
|
+
SecureAccessControlMigrationResult,
|
|
83
90
|
SetItemConfig,
|
|
84
91
|
SetStorageItem,
|
|
85
92
|
StorageBatchSetItem,
|
|
@@ -220,6 +227,7 @@ function buildTestingModule() {
|
|
|
220
227
|
backend,
|
|
221
228
|
changeSource: "native",
|
|
222
229
|
applyAccessControlOnSecureRawWrite: true,
|
|
230
|
+
supportsSecureAccessControlMigration: () => true,
|
|
223
231
|
ensureScopeSubscription: (_scope: NonMemoryScope) => {},
|
|
224
232
|
maybeCleanupScopeSubscription: (_scope: NonMemoryScope) => {},
|
|
225
233
|
onWillEmitChanges: () => {},
|
|
@@ -233,6 +241,8 @@ function buildTestingModule() {
|
|
|
233
241
|
|
|
234
242
|
const core = createStorageCore(buildAdapter);
|
|
235
243
|
const { internals } = core;
|
|
244
|
+
let protectedDataAvailable = true;
|
|
245
|
+
const protectedDataListeners = new Set<() => void>();
|
|
236
246
|
|
|
237
247
|
const storage = {
|
|
238
248
|
...core.storage,
|
|
@@ -240,6 +250,14 @@ function buildTestingModule() {
|
|
|
240
250
|
assertAccessControlLevel(level);
|
|
241
251
|
internals.setSecureDefaultAccessControl(level);
|
|
242
252
|
},
|
|
253
|
+
isProtectedDataAvailable: (): boolean => protectedDataAvailable,
|
|
254
|
+
onProtectedDataAvailable: (listener: () => void): (() => void) => {
|
|
255
|
+
assertProtectedDataListener(listener);
|
|
256
|
+
protectedDataListeners.add(listener);
|
|
257
|
+
return () => {
|
|
258
|
+
protectedDataListeners.delete(listener);
|
|
259
|
+
};
|
|
260
|
+
},
|
|
243
261
|
setSecureWritesAsync: (_enabled: boolean) => {},
|
|
244
262
|
setKeychainAccessGroup: (_group: string) => {},
|
|
245
263
|
getCapabilities: (): StorageCapabilities => ({
|
|
@@ -277,8 +295,26 @@ function buildTestingModule() {
|
|
|
277
295
|
}),
|
|
278
296
|
};
|
|
279
297
|
|
|
298
|
+
const setProtectedDataAvailable = (available: boolean): void => {
|
|
299
|
+
if (typeof available !== "boolean") {
|
|
300
|
+
throw new TypeError(
|
|
301
|
+
"NitroStorage: Protected data availability must be a boolean",
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
const wasAvailable = protectedDataAvailable;
|
|
305
|
+
protectedDataAvailable = available;
|
|
306
|
+
if (available && !wasAvailable) {
|
|
307
|
+
Array.from(protectedDataListeners).forEach((listener) => {
|
|
308
|
+
listener();
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
|
|
280
313
|
const reset = (): void => {
|
|
314
|
+
protectedDataAvailable = true;
|
|
315
|
+
protectedDataListeners.clear();
|
|
281
316
|
storage.setEventObserver(undefined);
|
|
317
|
+
storage.setScheduledFlushErrorObserver(undefined);
|
|
282
318
|
storage.setMetricsObserver(undefined);
|
|
283
319
|
storage.resetMetrics();
|
|
284
320
|
storage.clearAll();
|
|
@@ -298,8 +334,10 @@ function buildTestingModule() {
|
|
|
298
334
|
removeBatch: core.removeBatch,
|
|
299
335
|
registerMigration: core.registerMigration,
|
|
300
336
|
migrateToLatest: core.migrateToLatest,
|
|
337
|
+
migrateSecureAccessControl: core.migrateSecureAccessControl,
|
|
301
338
|
runTransaction: core.runTransaction,
|
|
302
339
|
createSecureAuthStorage: core.createSecureAuthStorage,
|
|
340
|
+
setProtectedDataAvailable,
|
|
303
341
|
reset,
|
|
304
342
|
};
|
|
305
343
|
}
|
|
@@ -319,8 +357,12 @@ export const setBatch = defaultModule.setBatch;
|
|
|
319
357
|
export const removeBatch = defaultModule.removeBatch;
|
|
320
358
|
export const registerMigration = defaultModule.registerMigration;
|
|
321
359
|
export const migrateToLatest = defaultModule.migrateToLatest;
|
|
360
|
+
export const migrateSecureAccessControl =
|
|
361
|
+
defaultModule.migrateSecureAccessControl;
|
|
322
362
|
export const runTransaction = defaultModule.runTransaction;
|
|
323
363
|
export const createSecureAuthStorage = defaultModule.createSecureAuthStorage;
|
|
364
|
+
export const setMockProtectedDataAvailable =
|
|
365
|
+
defaultModule.setProtectedDataAvailable;
|
|
324
366
|
|
|
325
367
|
export function setWebSecureStorageBackend(
|
|
326
368
|
_backend?: WebSecureStorageBackend,
|