react-native-nitro-storage 0.8.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 +107 -25
- package/README.md +140 -27
- 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 +109 -293
- package/cpp/bindings/HybridStorage.hpp +17 -10
- 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 +859 -145
- 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 +860 -146
- 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 +12 -3
- 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/nitrogen/generated/shared/c++/HybridStorageSpec.hpp +1 -1
- package/package.json +3 -3
- package/react-native-nitro-storage.podspec +3 -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 -199
- package/src/storage-runtime.ts +6 -0
- package/src/testing.ts +8 -1
package/src/storage-runtime.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type StorageErrorCode =
|
|
|
3
3
|
| "authentication_required"
|
|
4
4
|
| "key_invalidated"
|
|
5
5
|
| "storage_corruption"
|
|
6
|
+
| "storage_compensation_failed"
|
|
6
7
|
| "biometric_unavailable"
|
|
7
8
|
| "unsupported";
|
|
8
9
|
|
|
@@ -61,6 +62,7 @@ const STORAGE_ERROR_CODES = new Set<StorageErrorCode>([
|
|
|
61
62
|
"authentication_required",
|
|
62
63
|
"key_invalidated",
|
|
63
64
|
"storage_corruption",
|
|
65
|
+
"storage_compensation_failed",
|
|
64
66
|
"biometric_unavailable",
|
|
65
67
|
"unsupported",
|
|
66
68
|
]);
|
|
@@ -84,6 +86,10 @@ export function getStorageErrorCode(
|
|
|
84
86
|
return undefined;
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
export function isStorageError(err: unknown, code: StorageErrorCode): boolean {
|
|
90
|
+
return getStorageErrorCode(err) === code;
|
|
91
|
+
}
|
|
92
|
+
|
|
87
93
|
export function isLockedStorageErrorCode(
|
|
88
94
|
code: StorageErrorCode | undefined,
|
|
89
95
|
): boolean {
|
package/src/testing.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { StorageScope, AccessControl } from "./Storage.types";
|
|
|
15
15
|
export { StorageScope, AccessControl, BiometricLevel } from "./Storage.types";
|
|
16
16
|
export { isKeychainLockedError } from "./shared";
|
|
17
17
|
export { migrateFromMMKV } from "./migration";
|
|
18
|
-
export { getStorageErrorCode } from "./storage-runtime";
|
|
18
|
+
export { getStorageErrorCode, isStorageError } from "./storage-runtime";
|
|
19
19
|
export { createIndexedDBBackend } from "./indexeddb-backend";
|
|
20
20
|
export {
|
|
21
21
|
describeWebBackendCapabilities,
|
|
@@ -101,6 +101,9 @@ function createInMemoryBackend(): InMemoryBackend {
|
|
|
101
101
|
},
|
|
102
102
|
remove: (key, scope) => {
|
|
103
103
|
storeFor(scope).delete(key);
|
|
104
|
+
if (scope === StorageScope.Secure) {
|
|
105
|
+
biometricStore.delete(key);
|
|
106
|
+
}
|
|
104
107
|
},
|
|
105
108
|
clear: (scope) => {
|
|
106
109
|
storeFor(scope).clear();
|
|
@@ -128,6 +131,9 @@ function createInMemoryBackend(): InMemoryBackend {
|
|
|
128
131
|
removeBatch: (keys, scope) => {
|
|
129
132
|
const store = storeFor(scope);
|
|
130
133
|
keys.forEach((key) => store.delete(key));
|
|
134
|
+
if (scope === StorageScope.Secure) {
|
|
135
|
+
keys.forEach((key) => biometricStore.delete(key));
|
|
136
|
+
}
|
|
131
137
|
},
|
|
132
138
|
removeByPrefix: (prefix, scope) => {
|
|
133
139
|
const store = storeFor(scope);
|
|
@@ -141,6 +147,7 @@ function createInMemoryBackend(): InMemoryBackend {
|
|
|
141
147
|
getSecureBiometric: (key) => biometricStore.get(key),
|
|
142
148
|
setSecureBiometricWithLevel: (key, value) => {
|
|
143
149
|
biometricStore.set(key, value);
|
|
150
|
+
storeFor(StorageScope.Secure).delete(key);
|
|
144
151
|
},
|
|
145
152
|
deleteSecureBiometric: (key) => {
|
|
146
153
|
biometricStore.delete(key);
|