react-native-nitro-storage 0.10.0 → 0.10.1
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 +12 -0
- package/README.md +6 -6
- package/android/build.gradle +3 -1
- package/lib/commonjs/core/durability.js +2 -3
- package/lib/commonjs/core/durability.js.map +1 -1
- package/lib/commonjs/storage-core.js +57 -48
- package/lib/commonjs/storage-core.js.map +1 -1
- package/lib/module/core/durability.js +2 -3
- package/lib/module/core/durability.js.map +1 -1
- package/lib/module/storage-core.js +57 -48
- package/lib/module/storage-core.js.map +1 -1
- package/lib/typescript/core/durability.d.ts +2 -3
- package/lib/typescript/core/durability.d.ts.map +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/index.web.d.ts.map +1 -1
- package/lib/typescript/storage-core.d.ts.map +1 -1
- package/lib/typescript/testing.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/core/durability.ts +4 -7
- package/src/storage-core.ts +61 -58
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-storage",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Synchronous React Native storage powered by Nitro Modules and JSI: typed Memory, Disk, Keychain/Android Keystore secure storage, biometric auth, MMKV migration, Expo, Zustand/Jotai persistence, and web IndexedDB support.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@expo/config-plugins": "^57.0.6",
|
|
127
|
-
"@react-native/babel-preset": "^0.86.
|
|
127
|
+
"@react-native/babel-preset": "^0.86.3",
|
|
128
128
|
"@testing-library/react-native": "^13.3.3",
|
|
129
129
|
"@types/react": "~19.2.18"
|
|
130
130
|
},
|
package/src/core/durability.ts
CHANGED
|
@@ -13,9 +13,8 @@ export type DurabilityCoordinator = {
|
|
|
13
13
|
isDiskWritesAsync(): boolean;
|
|
14
14
|
hasPendingDiskWrite(key: string): boolean;
|
|
15
15
|
hasPendingSecureWrite(key: string): boolean;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
readPendingSecureAccessControl(key: string): AccessControl | undefined;
|
|
16
|
+
getPendingDiskWrite(key: string): PendingDiskWrite | undefined;
|
|
17
|
+
getPendingSecureWrite(key: string): PendingSecureWrite | undefined;
|
|
19
18
|
clearPendingDiskWrite(key: string): void;
|
|
20
19
|
clearPendingSecureWrite(key: string): void;
|
|
21
20
|
clearPendingDiskWriteIf(write: PendingDiskWrite): void;
|
|
@@ -235,10 +234,8 @@ export function createDurabilityCoordinator(options: {
|
|
|
235
234
|
isDiskWritesAsync: () => diskWritesAsync,
|
|
236
235
|
hasPendingDiskWrite: (key) => pendingDiskWrites.has(key),
|
|
237
236
|
hasPendingSecureWrite: (key) => pendingSecureWrites.has(key),
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
readPendingSecureAccessControl: (key) =>
|
|
241
|
-
pendingSecureWrites.get(key)?.accessControl,
|
|
237
|
+
getPendingDiskWrite: (key) => pendingDiskWrites.get(key),
|
|
238
|
+
getPendingSecureWrite: (key) => pendingSecureWrites.get(key),
|
|
242
239
|
clearPendingDiskWrite: (key) => {
|
|
243
240
|
pendingDiskWrites.delete(key);
|
|
244
241
|
},
|
package/src/storage-core.ts
CHANGED
|
@@ -554,22 +554,6 @@ export function createStorageCore(
|
|
|
554
554
|
metrics.record(operation, scope, durationMs, keysCount);
|
|
555
555
|
}
|
|
556
556
|
|
|
557
|
-
function readPendingSecureWrite(key: string): string | undefined {
|
|
558
|
-
return durability.readPendingSecureWrite(key);
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
function readPendingDiskWrite(key: string): string | undefined {
|
|
562
|
-
return durability.readPendingDiskWrite(key);
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
function hasPendingDiskWrite(key: string): boolean {
|
|
566
|
-
return durability.hasPendingDiskWrite(key);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
function hasPendingSecureWrite(key: string): boolean {
|
|
570
|
-
return durability.hasPendingSecureWrite(key);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
557
|
function clearPendingDiskWrite(key: string): void {
|
|
574
558
|
durability.clearPendingDiskWrite(key);
|
|
575
559
|
}
|
|
@@ -622,12 +606,18 @@ export function createStorageCore(
|
|
|
622
606
|
return typeof value === "string" ? value : undefined;
|
|
623
607
|
}
|
|
624
608
|
|
|
625
|
-
if (scope === StorageScope.Disk
|
|
626
|
-
|
|
609
|
+
if (scope === StorageScope.Disk) {
|
|
610
|
+
const pending = durability.getPendingDiskWrite(key);
|
|
611
|
+
if (pending !== undefined) {
|
|
612
|
+
return pending.value;
|
|
613
|
+
}
|
|
627
614
|
}
|
|
628
615
|
|
|
629
|
-
if (scope === StorageScope.Secure
|
|
630
|
-
|
|
616
|
+
if (scope === StorageScope.Secure) {
|
|
617
|
+
const pending = durability.getPendingSecureWrite(key);
|
|
618
|
+
if (pending !== undefined) {
|
|
619
|
+
return pending.value;
|
|
620
|
+
}
|
|
631
621
|
}
|
|
632
622
|
|
|
633
623
|
return adapter.backend.get(key, scope);
|
|
@@ -653,18 +643,22 @@ export function createStorageCore(
|
|
|
653
643
|
: undefined;
|
|
654
644
|
}
|
|
655
645
|
|
|
656
|
-
if (scope === StorageScope.Disk
|
|
657
|
-
const pending =
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
646
|
+
if (scope === StorageScope.Disk) {
|
|
647
|
+
const pending = durability.getPendingDiskWrite(key);
|
|
648
|
+
if (pending !== undefined) {
|
|
649
|
+
return pending.value === undefined
|
|
650
|
+
? undefined
|
|
651
|
+
: unescapeCollidingRawValue(pending.value);
|
|
652
|
+
}
|
|
661
653
|
}
|
|
662
654
|
|
|
663
|
-
if (scope === StorageScope.Secure
|
|
664
|
-
const pending =
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
655
|
+
if (scope === StorageScope.Secure) {
|
|
656
|
+
const pending = durability.getPendingSecureWrite(key);
|
|
657
|
+
if (pending !== undefined) {
|
|
658
|
+
return pending.value === undefined
|
|
659
|
+
? undefined
|
|
660
|
+
: unescapeCollidingRawValue(pending.value);
|
|
661
|
+
}
|
|
668
662
|
}
|
|
669
663
|
|
|
670
664
|
const raw = adapter.backend.get(key, scope);
|
|
@@ -1664,28 +1658,32 @@ export function createStorageCore(
|
|
|
1664
1658
|
}
|
|
1665
1659
|
|
|
1666
1660
|
if (nonMemoryScope === StorageScope.Disk) {
|
|
1667
|
-
|
|
1668
|
-
|
|
1661
|
+
const pending = durability.getPendingDiskWrite(storageKey);
|
|
1662
|
+
if (pending !== undefined) {
|
|
1663
|
+
return pending.value;
|
|
1669
1664
|
}
|
|
1670
1665
|
}
|
|
1671
1666
|
|
|
1672
1667
|
if (nonMemoryScope === StorageScope.Secure && !isBiometric) {
|
|
1673
|
-
|
|
1674
|
-
|
|
1668
|
+
const pending = durability.getPendingSecureWrite(storageKey);
|
|
1669
|
+
if (pending !== undefined) {
|
|
1670
|
+
return pending.value;
|
|
1675
1671
|
}
|
|
1676
1672
|
}
|
|
1677
1673
|
|
|
1678
1674
|
migrateRenamesIfNeeded();
|
|
1679
1675
|
|
|
1680
1676
|
if (nonMemoryScope === StorageScope.Disk) {
|
|
1681
|
-
|
|
1682
|
-
|
|
1677
|
+
const pending = durability.getPendingDiskWrite(storageKey);
|
|
1678
|
+
if (pending !== undefined) {
|
|
1679
|
+
return pending.value;
|
|
1683
1680
|
}
|
|
1684
1681
|
}
|
|
1685
1682
|
|
|
1686
1683
|
if (nonMemoryScope === StorageScope.Secure && !isBiometric) {
|
|
1687
|
-
|
|
1688
|
-
|
|
1684
|
+
const pending = durability.getPendingSecureWrite(storageKey);
|
|
1685
|
+
if (pending !== undefined) {
|
|
1686
|
+
return pending.value;
|
|
1689
1687
|
}
|
|
1690
1688
|
}
|
|
1691
1689
|
|
|
@@ -1964,21 +1962,22 @@ export function createStorageCore(
|
|
|
1964
1962
|
const records = getItemStateKeys().map((key) => {
|
|
1965
1963
|
let pending: ItemPendingSnapshot | undefined;
|
|
1966
1964
|
if (nonMemoryScope === StorageScope.Disk) {
|
|
1967
|
-
|
|
1965
|
+
const pendingWrite = durability.getPendingDiskWrite(key);
|
|
1966
|
+
if (pendingWrite !== undefined) {
|
|
1968
1967
|
pending = {
|
|
1969
|
-
value:
|
|
1968
|
+
value: pendingWrite.value,
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
} else if (nonMemoryScope === StorageScope.Secure && !isBiometric) {
|
|
1972
|
+
const pendingWrite = durability.getPendingSecureWrite(key);
|
|
1973
|
+
if (pendingWrite !== undefined) {
|
|
1974
|
+
pending = {
|
|
1975
|
+
value: pendingWrite.value,
|
|
1976
|
+
...(pendingWrite.accessControl === undefined
|
|
1977
|
+
? {}
|
|
1978
|
+
: { accessControl: pendingWrite.accessControl }),
|
|
1970
1979
|
};
|
|
1971
1980
|
}
|
|
1972
|
-
} else if (
|
|
1973
|
-
nonMemoryScope === StorageScope.Secure &&
|
|
1974
|
-
!isBiometric &&
|
|
1975
|
-
durability.hasPendingSecureWrite(key)
|
|
1976
|
-
) {
|
|
1977
|
-
const accessControl = durability.readPendingSecureAccessControl(key);
|
|
1978
|
-
pending = {
|
|
1979
|
-
value: durability.readPendingSecureWrite(key),
|
|
1980
|
-
...(accessControl === undefined ? {} : { accessControl }),
|
|
1981
|
-
};
|
|
1982
1981
|
}
|
|
1983
1982
|
|
|
1984
1983
|
return {
|
|
@@ -2714,13 +2713,15 @@ export function createStorageCore(
|
|
|
2714
2713
|
if (isMemory) return memoryStore.has(storageKey);
|
|
2715
2714
|
if (isBiometric) return adapter.backend.hasSecureBiometric(storageKey);
|
|
2716
2715
|
if (nonMemoryScope === StorageScope.Disk) {
|
|
2717
|
-
|
|
2718
|
-
|
|
2716
|
+
const pending = durability.getPendingDiskWrite(storageKey);
|
|
2717
|
+
if (pending !== undefined) {
|
|
2718
|
+
return pending.value !== undefined;
|
|
2719
2719
|
}
|
|
2720
2720
|
}
|
|
2721
2721
|
if (nonMemoryScope === StorageScope.Secure) {
|
|
2722
|
-
|
|
2723
|
-
|
|
2722
|
+
const pending = durability.getPendingSecureWrite(storageKey);
|
|
2723
|
+
if (pending !== undefined) {
|
|
2724
|
+
return pending.value !== undefined;
|
|
2724
2725
|
}
|
|
2725
2726
|
}
|
|
2726
2727
|
return adapter.backend.has(storageKey, config.scope);
|
|
@@ -2869,15 +2870,17 @@ export function createStorageCore(
|
|
|
2869
2870
|
|
|
2870
2871
|
items.forEach((item, index) => {
|
|
2871
2872
|
if (scope === StorageScope.Disk) {
|
|
2872
|
-
|
|
2873
|
-
|
|
2873
|
+
const pending = durability.getPendingDiskWrite(item.key);
|
|
2874
|
+
if (pending !== undefined) {
|
|
2875
|
+
rawValues[index] = pending.value;
|
|
2874
2876
|
return;
|
|
2875
2877
|
}
|
|
2876
2878
|
}
|
|
2877
2879
|
|
|
2878
2880
|
if (scope === StorageScope.Secure) {
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
+
const pending = durability.getPendingSecureWrite(item.key);
|
|
2882
|
+
if (pending !== undefined) {
|
|
2883
|
+
rawValues[index] = pending.value;
|
|
2881
2884
|
return;
|
|
2882
2885
|
}
|
|
2883
2886
|
}
|