react-native-nitro-storage 0.5.4 → 0.5.6
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/README.md +90 -7
- package/android/build.gradle +5 -5
- package/android/src/main/java/com/nitrostorage/AndroidStorageAdapter.kt +12 -25
- package/app.plugin.js +114 -9
- package/docs/api-reference.md +39 -36
- package/docs/batch-transactions-migrations.md +1 -1
- package/docs/recipes.md +1 -1
- package/docs/secure-storage.md +15 -4
- package/docs/web-backends.md +5 -0
- package/lib/commonjs/index.js +49 -9
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +71 -11
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/indexeddb-backend.js +28 -0
- package/lib/commonjs/indexeddb-backend.js.map +1 -1
- package/lib/commonjs/storage-hooks.js.map +1 -1
- package/lib/commonjs/web-storage-backend.js.map +1 -1
- package/lib/module/index.js +49 -9
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +71 -11
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/indexeddb-backend.js +28 -0
- package/lib/module/indexeddb-backend.js.map +1 -1
- package/lib/module/storage-hooks.js.map +1 -1
- package/lib/module/web-storage-backend.js.map +1 -1
- package/lib/typescript/index.d.ts +21 -9
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/index.web.d.ts +10 -3
- package/lib/typescript/index.web.d.ts.map +1 -1
- package/lib/typescript/indexeddb-backend.d.ts.map +1 -1
- package/lib/typescript/storage-hooks.d.ts +5 -4
- package/lib/typescript/storage-hooks.d.ts.map +1 -1
- package/lib/typescript/web-storage-backend.d.ts +1 -0
- package/lib/typescript/web-storage-backend.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +96 -19
- package/src/index.web.ts +107 -11
- package/src/indexeddb-backend.ts +30 -0
- package/src/storage-hooks.ts +6 -6
- package/src/web-storage-backend.ts +1 -0
|
@@ -2,12 +2,14 @@ import { StorageScope, AccessControl, BiometricLevel } from "./Storage.types";
|
|
|
2
2
|
import type { WebDiskStorageBackend, WebSecureStorageBackend } from "./web-storage-backend";
|
|
3
3
|
import { type SecureStorageMetadata, type SecurityCapabilities, type StorageCapabilities } from "./storage-runtime";
|
|
4
4
|
import { type StorageEventListener } from "./storage-events";
|
|
5
|
+
import type { StorageSetter } from "./storage-hooks";
|
|
5
6
|
export { StorageScope, AccessControl, BiometricLevel } from "./Storage.types";
|
|
6
7
|
export type { Storage } from "./Storage.nitro";
|
|
7
8
|
export { migrateFromMMKV } from "./migration";
|
|
8
9
|
export { getStorageErrorCode, type SecureStorageMetadata, type SecurityCapabilities, type StorageCapabilities, type StorageErrorCode, } from "./storage-runtime";
|
|
9
10
|
export type { StorageBatchChangeEvent, StorageChangeEvent, StorageChangeOperation, StorageChangeSource, StorageEventListener, StorageKeyChangeEvent, } from "./storage-events";
|
|
10
|
-
export type {
|
|
11
|
+
export type { StorageSetter } from "./storage-hooks";
|
|
12
|
+
export type { WebDiskStorageBackend, WebSecureStorageBackend, WebStorageBackend, WebStorageChangeEvent, WebStorageScope, } from "./web-storage-backend";
|
|
11
13
|
export type Validator<T> = (value: unknown) => value is T;
|
|
12
14
|
export type ExpirationConfig = {
|
|
13
15
|
ttlMs: number;
|
|
@@ -24,6 +26,12 @@ export type StorageMetricsEvent = {
|
|
|
24
26
|
keysCount: number;
|
|
25
27
|
};
|
|
26
28
|
export type StorageMetricsObserver = (event: StorageMetricsEvent) => void;
|
|
29
|
+
export type StorageEventObserverOptions = {
|
|
30
|
+
redactSecureValues?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export type StorageExportOptions = {
|
|
33
|
+
includeSecureValues?: boolean;
|
|
34
|
+
};
|
|
27
35
|
export type StorageMetricSummary = {
|
|
28
36
|
count: number;
|
|
29
37
|
totalDurationMs: number;
|
|
@@ -56,7 +64,7 @@ export declare const storage: {
|
|
|
56
64
|
subscribeKey: (scope: StorageScope, key: string, listener: StorageEventListener) => (() => void);
|
|
57
65
|
subscribePrefix: (scope: StorageScope, prefix: string, listener: StorageEventListener) => (() => void);
|
|
58
66
|
subscribeNamespace: (namespace: string, scope: StorageScope, listener: StorageEventListener) => (() => void);
|
|
59
|
-
setEventObserver: (observer?: StorageEventListener) => void;
|
|
67
|
+
setEventObserver: (observer?: StorageEventListener, options?: StorageEventObserverOptions) => void;
|
|
60
68
|
clear: (scope: StorageScope) => void;
|
|
61
69
|
clearAll: () => void;
|
|
62
70
|
clearNamespace: (namespace: string, scope: StorageScope) => void;
|
|
@@ -66,7 +74,8 @@ export declare const storage: {
|
|
|
66
74
|
getKeysByPrefix: (prefix: string, scope: StorageScope) => string[];
|
|
67
75
|
getByPrefix: (prefix: string, scope: StorageScope) => Record<string, string>;
|
|
68
76
|
getAll: (scope: StorageScope) => Record<string, string>;
|
|
69
|
-
export: (scope: StorageScope) => Record<string, string>;
|
|
77
|
+
export: (scope: StorageScope, options?: StorageExportOptions) => Record<string, string>;
|
|
78
|
+
exportSecureUnsafe: () => Record<string, string>;
|
|
70
79
|
size: (scope: StorageScope) => number;
|
|
71
80
|
setAccessControl: (level: AccessControl) => void;
|
|
72
81
|
setSecureWritesAsync: (enabled: boolean) => void;
|
|
@@ -91,7 +100,7 @@ export declare function getWebSecureStorageBackend(): WebSecureStorageBackend |
|
|
|
91
100
|
export declare function setWebDiskStorageBackend(_backend?: WebDiskStorageBackend): void;
|
|
92
101
|
export declare function getWebDiskStorageBackend(): WebDiskStorageBackend | undefined;
|
|
93
102
|
export declare function flushWebStorageBackends(): Promise<void>;
|
|
94
|
-
export
|
|
103
|
+
export type StorageItemConfig<T> = {
|
|
95
104
|
key: string;
|
|
96
105
|
scope: StorageScope;
|
|
97
106
|
defaultValue?: T;
|
|
@@ -108,11 +117,11 @@ export interface StorageItemConfig<T> {
|
|
|
108
117
|
biometric?: boolean;
|
|
109
118
|
biometricLevel?: BiometricLevel;
|
|
110
119
|
accessControl?: AccessControl;
|
|
111
|
-
}
|
|
112
|
-
export
|
|
120
|
+
};
|
|
121
|
+
export type StorageItem<T> = {
|
|
113
122
|
get: () => T;
|
|
114
123
|
getWithVersion: () => VersionedValue<T>;
|
|
115
|
-
set:
|
|
124
|
+
set: StorageSetter<T>;
|
|
116
125
|
setIfVersion: (version: StorageVersion, value: T | ((prev: T) => T)) => boolean;
|
|
117
126
|
delete: () => void;
|
|
118
127
|
has: () => boolean;
|
|
@@ -122,7 +131,7 @@ export interface StorageItem<T> {
|
|
|
122
131
|
deserialize: (value: string) => T;
|
|
123
132
|
scope: StorageScope;
|
|
124
133
|
key: string;
|
|
125
|
-
}
|
|
134
|
+
};
|
|
126
135
|
export declare function createStorageItem<T = undefined>(config: StorageItemConfig<T>): StorageItem<T>;
|
|
127
136
|
export { useStorage, useStorageSelector, useSetStorage } from "./storage-hooks";
|
|
128
137
|
export { createIndexedDBBackend } from "./indexeddb-backend";
|
|
@@ -135,11 +144,14 @@ type BatchReadItem<T> = Pick<StorageItem<T>, "key" | "scope" | "get" | "deserial
|
|
|
135
144
|
_secureAccessControl?: AccessControl;
|
|
136
145
|
};
|
|
137
146
|
type BatchRemoveItem = Pick<StorageItem<unknown>, "key" | "scope" | "delete">;
|
|
147
|
+
type BatchValues<TItems extends readonly BatchReadItem<unknown>[]> = {
|
|
148
|
+
[Index in keyof TItems]: TItems[Index] extends BatchReadItem<infer Value> ? Value : never;
|
|
149
|
+
};
|
|
138
150
|
export type StorageBatchSetItem<T> = {
|
|
139
151
|
item: StorageItem<T>;
|
|
140
152
|
value: T;
|
|
141
153
|
};
|
|
142
|
-
export declare function getBatch
|
|
154
|
+
export declare function getBatch<const TItems extends readonly BatchReadItem<unknown>[]>(items: TItems, scope: StorageScope): BatchValues<TItems>;
|
|
143
155
|
export declare function setBatch<T>(items: readonly StorageBatchSetItem<T>[], scope: StorageScope): void;
|
|
144
156
|
export declare function removeBatch(items: readonly BatchRemoveItem[], scope: StorageScope): void;
|
|
145
157
|
export declare function registerMigration(version: number, migration: Migration): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAc9E,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAML,KAAK,oBAAoB,EAE1B,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAc9E,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAML,KAAK,oBAAoB,EAE1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC9E,YAAY,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,mBAAmB,EACnB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,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AC,CAqJH;AAED,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CACrE,CAAC,EACD;IACE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CACF,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE3D;AAED,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,EACtD,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,EAClC,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/B,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CA6BhC"}
|
|
@@ -6,7 +6,7 @@ export { StorageScope, AccessControl, BiometricLevel } from "./Storage.types";
|
|
|
6
6
|
export { migrateFromMMKV } from "./migration";
|
|
7
7
|
export { getStorageErrorCode, type SecureStorageMetadata, type SecurityCapabilities, type StorageCapabilities, type StorageErrorCode, } from "./storage-runtime";
|
|
8
8
|
export type { StorageBatchChangeEvent, StorageChangeEvent, StorageChangeOperation, StorageChangeSource, StorageEventListener, StorageKeyChangeEvent, } from "./storage-events";
|
|
9
|
-
export type { WebStorageBackend, WebStorageChangeEvent, WebStorageScope, } from "./web-storage-backend";
|
|
9
|
+
export type { WebDiskStorageBackend, WebSecureStorageBackend, WebStorageBackend, WebStorageChangeEvent, WebStorageScope, } from "./web-storage-backend";
|
|
10
10
|
export type Validator<T> = (value: unknown) => value is T;
|
|
11
11
|
export type ExpirationConfig = {
|
|
12
12
|
ttlMs: number;
|
|
@@ -23,6 +23,12 @@ export type StorageMetricsEvent = {
|
|
|
23
23
|
keysCount: number;
|
|
24
24
|
};
|
|
25
25
|
export type StorageMetricsObserver = (event: StorageMetricsEvent) => void;
|
|
26
|
+
export type StorageEventObserverOptions = {
|
|
27
|
+
redactSecureValues?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type StorageExportOptions = {
|
|
30
|
+
includeSecureValues?: boolean;
|
|
31
|
+
};
|
|
26
32
|
export type StorageMetricSummary = {
|
|
27
33
|
count: number;
|
|
28
34
|
totalDurationMs: number;
|
|
@@ -82,7 +88,7 @@ export declare const storage: {
|
|
|
82
88
|
subscribeKey: (scope: StorageScope, key: string, listener: StorageEventListener) => (() => void);
|
|
83
89
|
subscribePrefix: (scope: StorageScope, prefix: string, listener: StorageEventListener) => (() => void);
|
|
84
90
|
subscribeNamespace: (namespace: string, scope: StorageScope, listener: StorageEventListener) => (() => void);
|
|
85
|
-
setEventObserver: (observer?: StorageEventListener) => void;
|
|
91
|
+
setEventObserver: (observer?: StorageEventListener, options?: StorageEventObserverOptions) => void;
|
|
86
92
|
clear: (scope: StorageScope) => void;
|
|
87
93
|
clearAll: () => void;
|
|
88
94
|
clearNamespace: (namespace: string, scope: StorageScope) => void;
|
|
@@ -92,7 +98,8 @@ export declare const storage: {
|
|
|
92
98
|
getKeysByPrefix: (prefix: string, scope: StorageScope) => string[];
|
|
93
99
|
getByPrefix: (prefix: string, scope: StorageScope) => Record<string, string>;
|
|
94
100
|
getAll: (scope: StorageScope) => Record<string, string>;
|
|
95
|
-
export: (scope: StorageScope) => Record<string, string>;
|
|
101
|
+
export: (scope: StorageScope, options?: StorageExportOptions) => Record<string, string>;
|
|
102
|
+
exportSecureUnsafe: () => Record<string, string>;
|
|
96
103
|
size: (scope: StorageScope) => number;
|
|
97
104
|
setAccessControl: (level: AccessControl) => void;
|
|
98
105
|
setSecureWritesAsync: (_enabled: boolean) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../src/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAA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D,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,EAClC,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/B,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CA6BhC;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexeddb-backend.d.ts","sourceRoot":"","sources":["../../src/indexeddb-backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EAExB,MAAM,uBAAuB,CAAC;AAM/B,MAAM,MAAM,uBAAuB,GAAG;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,CAAC;AA4BF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,SAAkB,EACxB,SAAS,SAAqB,EAC9B,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,uBAAuB,CAAC,
|
|
1
|
+
{"version":3,"file":"indexeddb-backend.d.ts","sourceRoot":"","sources":["../../src/indexeddb-backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EAExB,MAAM,uBAAuB,CAAC;AAM/B,MAAM,MAAM,uBAAuB,GAAG;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,CAAC;AA4BF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,SAAkB,EACxB,SAAS,SAAqB,EAC9B,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,uBAAuB,CAAC,CA2PlC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
type HookStorageItem<T> = {
|
|
2
2
|
get: () => T;
|
|
3
|
-
set:
|
|
3
|
+
set: StorageSetter<T>;
|
|
4
4
|
subscribe: (callback: () => void) => () => void;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
6
|
+
export type StorageSetter<T> = (value: T | ((prev: T) => T)) => void;
|
|
7
|
+
export declare function useStorage<T>(item: HookStorageItem<T>): [T, StorageSetter<T>];
|
|
8
|
+
export declare function useStorageSelector<T, TSelected>(item: HookStorageItem<T>, selector: (value: T) => TSelected, isEqual?: (prev: TSelected, next: TSelected) => boolean): [TSelected, StorageSetter<T>];
|
|
9
|
+
export declare function useSetStorage<T>(item: HookStorageItem<T>): StorageSetter<T>;
|
|
9
10
|
export {};
|
|
10
11
|
//# sourceMappingURL=storage-hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-hooks.d.ts","sourceRoot":"","sources":["../../src/storage-hooks.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"storage-hooks.d.ts","sourceRoot":"","sources":["../../src/storage-hooks.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACtB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;AAErE,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAG7E;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,SAAS,EAC7C,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,SAAS,EACjC,OAAO,GAAE,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,KAAK,OAAmB,GACjE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAwB/B;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAE3E"}
|
|
@@ -16,6 +16,7 @@ export type WebStorageBackend = {
|
|
|
16
16
|
size?: () => number;
|
|
17
17
|
subscribe?: (listener: (event: WebStorageChangeEvent) => void) => () => void;
|
|
18
18
|
flush?: () => Promise<void>;
|
|
19
|
+
close?: () => void;
|
|
19
20
|
name?: string;
|
|
20
21
|
};
|
|
21
22
|
export type WebDiskStorageBackend = WebStorageBackend;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-storage-backend.d.ts","sourceRoot":"","sources":["../../src/web-storage-backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC;AAEtE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACxC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KA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AAM,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAExD,KAAK,0BAA0B,GAAG;IAChC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,OAAO,GAAG,SAAS,CAAC;CAC5C,CAAC;AAgBF,wBAAgB,4BAA4B,CAC1C,OAAO,GAAE,0BAA+B,GACvC,iBAAiB,CA6EnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-storage",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
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",
|
|
@@ -111,8 +111,8 @@
|
|
|
111
111
|
"registry": "https://registry.npmjs.org/"
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
|
-
"@expo/config-plugins": "^
|
|
115
|
-
"@react-native/babel-preset": "^0.
|
|
114
|
+
"@expo/config-plugins": "^56.0.7",
|
|
115
|
+
"@react-native/babel-preset": "^0.85.3",
|
|
116
116
|
"@testing-library/react-hooks": "^8.0.1",
|
|
117
117
|
"@testing-library/react-native": "^13.3.3",
|
|
118
118
|
"@types/react": "~19.2.0"
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"peerDependencies": {
|
|
121
121
|
"react": ">=18.2.0",
|
|
122
122
|
"react-native": ">=0.75.0",
|
|
123
|
-
"react-native-nitro-modules": ">=0.35.
|
|
123
|
+
"react-native-nitro-modules": ">=0.35.7"
|
|
124
124
|
},
|
|
125
125
|
"react-native-builder-bob": {
|
|
126
126
|
"source": "src",
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
type StorageEventListener,
|
|
36
36
|
type StorageKeyChangeEvent,
|
|
37
37
|
} from "./storage-events";
|
|
38
|
+
import type { StorageSetter } from "./storage-hooks";
|
|
38
39
|
|
|
39
40
|
export { StorageScope, AccessControl, BiometricLevel } from "./Storage.types";
|
|
40
41
|
export type { Storage } from "./Storage.nitro";
|
|
@@ -54,7 +55,10 @@ export type {
|
|
|
54
55
|
StorageEventListener,
|
|
55
56
|
StorageKeyChangeEvent,
|
|
56
57
|
} from "./storage-events";
|
|
58
|
+
export type { StorageSetter } from "./storage-hooks";
|
|
57
59
|
export type {
|
|
60
|
+
WebDiskStorageBackend,
|
|
61
|
+
WebSecureStorageBackend,
|
|
58
62
|
WebStorageBackend,
|
|
59
63
|
WebStorageChangeEvent,
|
|
60
64
|
WebStorageScope,
|
|
@@ -76,6 +80,12 @@ export type StorageMetricsEvent = {
|
|
|
76
80
|
keysCount: number;
|
|
77
81
|
};
|
|
78
82
|
export type StorageMetricsObserver = (event: StorageMetricsEvent) => void;
|
|
83
|
+
export type StorageEventObserverOptions = {
|
|
84
|
+
redactSecureValues?: boolean;
|
|
85
|
+
};
|
|
86
|
+
export type StorageExportOptions = {
|
|
87
|
+
includeSecureValues?: boolean;
|
|
88
|
+
};
|
|
79
89
|
export type StorageMetricSummary = {
|
|
80
90
|
count: number;
|
|
81
91
|
totalDurationMs: number;
|
|
@@ -229,6 +239,7 @@ const suppressedNativeEvents = new Map<NonMemoryScope, Map<string, number>>([
|
|
|
229
239
|
]);
|
|
230
240
|
let metricsObserver: StorageMetricsObserver | undefined;
|
|
231
241
|
let eventObserver: StorageEventListener | undefined;
|
|
242
|
+
let eventObserverRedactSecureValues = true;
|
|
232
243
|
const metricsCounters = new Map<
|
|
233
244
|
string,
|
|
234
245
|
{ count: number; totalDurationMs: number; maxDurationMs: number }
|
|
@@ -411,6 +422,49 @@ function hasStorageChangeObservers(scope: StorageScope): boolean {
|
|
|
411
422
|
return storageEvents.hasListeners(scope) || eventObserver !== undefined;
|
|
412
423
|
}
|
|
413
424
|
|
|
425
|
+
function shouldReadPreviousEventValues(scope: StorageScope): boolean {
|
|
426
|
+
if (storageEvents.hasListeners(scope)) {
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
if (!eventObserver) {
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
return scope !== StorageScope.Secure || !eventObserverRedactSecureValues;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const SECURE_EVENT_REDACTED_VALUE = "[secure]";
|
|
436
|
+
|
|
437
|
+
function redactSecureKeyChange(
|
|
438
|
+
event: StorageKeyChangeEvent,
|
|
439
|
+
): StorageKeyChangeEvent {
|
|
440
|
+
if (event.scope !== StorageScope.Secure) {
|
|
441
|
+
return event;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return {
|
|
445
|
+
...event,
|
|
446
|
+
oldValue:
|
|
447
|
+
event.oldValue === undefined ? undefined : SECURE_EVENT_REDACTED_VALUE,
|
|
448
|
+
newValue:
|
|
449
|
+
event.newValue === undefined ? undefined : SECURE_EVENT_REDACTED_VALUE,
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function eventForGlobalObserver(event: StorageChangeEvent): StorageChangeEvent {
|
|
454
|
+
if (!eventObserverRedactSecureValues || event.scope !== StorageScope.Secure) {
|
|
455
|
+
return event;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (event.type === "key") {
|
|
459
|
+
return redactSecureKeyChange(event);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
return {
|
|
463
|
+
...event,
|
|
464
|
+
changes: event.changes.map(redactSecureKeyChange),
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
|
|
414
468
|
function emitKeyChange(
|
|
415
469
|
scope: StorageScope,
|
|
416
470
|
key: string,
|
|
@@ -436,7 +490,7 @@ function emitKeyChange(
|
|
|
436
490
|
source,
|
|
437
491
|
);
|
|
438
492
|
storageEvents.emitKey(event);
|
|
439
|
-
eventObserver?.(event);
|
|
493
|
+
eventObserver?.(eventForGlobalObserver(event));
|
|
440
494
|
}
|
|
441
495
|
|
|
442
496
|
function emitBatchChange(
|
|
@@ -466,7 +520,7 @@ function emitBatchChange(
|
|
|
466
520
|
changes,
|
|
467
521
|
};
|
|
468
522
|
storageEvents.emitBatch(event);
|
|
469
|
-
eventObserver?.(event);
|
|
523
|
+
eventObserver?.(eventForGlobalObserver(event));
|
|
470
524
|
}
|
|
471
525
|
|
|
472
526
|
function readPendingSecureWrite(key: string): string | undefined {
|
|
@@ -811,8 +865,12 @@ export const storage = {
|
|
|
811
865
|
): (() => void) => {
|
|
812
866
|
return storage.subscribePrefix(scope, prefixKey(namespace, ""), listener);
|
|
813
867
|
},
|
|
814
|
-
setEventObserver: (
|
|
868
|
+
setEventObserver: (
|
|
869
|
+
observer?: StorageEventListener,
|
|
870
|
+
options: StorageEventObserverOptions = {},
|
|
871
|
+
) => {
|
|
815
872
|
eventObserver = observer;
|
|
873
|
+
eventObserverRedactSecureValues = options.redactSecureValues !== false;
|
|
816
874
|
if (observer) {
|
|
817
875
|
ensureNativeScopeSubscription(StorageScope.Disk);
|
|
818
876
|
ensureNativeScopeSubscription(StorageScope.Secure);
|
|
@@ -823,7 +881,7 @@ export const storage = {
|
|
|
823
881
|
},
|
|
824
882
|
clear: (scope: StorageScope) => {
|
|
825
883
|
measureOperation("storage:clear", scope, () => {
|
|
826
|
-
const previousValues =
|
|
884
|
+
const previousValues = shouldReadPreviousEventValues(scope)
|
|
827
885
|
? storage.getAll(scope)
|
|
828
886
|
: {};
|
|
829
887
|
if (scope === StorageScope.Memory) {
|
|
@@ -927,7 +985,7 @@ export const storage = {
|
|
|
927
985
|
}
|
|
928
986
|
|
|
929
987
|
const keyPrefix = prefixKey(namespace, "");
|
|
930
|
-
const previousValues =
|
|
988
|
+
const previousValues = shouldReadPreviousEventValues(scope)
|
|
931
989
|
? storage.getByPrefix(keyPrefix, scope)
|
|
932
990
|
: {};
|
|
933
991
|
if (scope === StorageScope.Disk) {
|
|
@@ -1077,11 +1135,26 @@ export const storage = {
|
|
|
1077
1135
|
return result;
|
|
1078
1136
|
});
|
|
1079
1137
|
},
|
|
1080
|
-
export: (
|
|
1138
|
+
export: (
|
|
1139
|
+
scope: StorageScope,
|
|
1140
|
+
options: StorageExportOptions = {},
|
|
1141
|
+
): Record<string, string> => {
|
|
1142
|
+
if (scope === StorageScope.Secure && options.includeSecureValues !== true) {
|
|
1143
|
+
throw new Error(
|
|
1144
|
+
"NitroStorage: exporting Secure scope exposes raw secret values. Pass { includeSecureValues: true } or use exportSecureUnsafe().",
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1081
1147
|
return measureOperation("storage:export", scope, () =>
|
|
1082
1148
|
storage.getAll(scope),
|
|
1083
1149
|
);
|
|
1084
1150
|
},
|
|
1151
|
+
exportSecureUnsafe: (): Record<string, string> => {
|
|
1152
|
+
return measureOperation(
|
|
1153
|
+
"storage:exportSecureUnsafe",
|
|
1154
|
+
StorageScope.Secure,
|
|
1155
|
+
() => storage.getAll(StorageScope.Secure),
|
|
1156
|
+
);
|
|
1157
|
+
},
|
|
1085
1158
|
size: (scope: StorageScope): number => {
|
|
1086
1159
|
return measureOperation("storage:size", scope, () => {
|
|
1087
1160
|
assertValidScope(scope);
|
|
@@ -1316,7 +1389,7 @@ export async function flushWebStorageBackends(): Promise<void> {
|
|
|
1316
1389
|
// Native platforms do not use web storage backends.
|
|
1317
1390
|
}
|
|
1318
1391
|
|
|
1319
|
-
export
|
|
1392
|
+
export type StorageItemConfig<T> = {
|
|
1320
1393
|
key: string;
|
|
1321
1394
|
scope: StorageScope;
|
|
1322
1395
|
defaultValue?: T;
|
|
@@ -1333,12 +1406,12 @@ export interface StorageItemConfig<T> {
|
|
|
1333
1406
|
biometric?: boolean;
|
|
1334
1407
|
biometricLevel?: BiometricLevel;
|
|
1335
1408
|
accessControl?: AccessControl;
|
|
1336
|
-
}
|
|
1409
|
+
};
|
|
1337
1410
|
|
|
1338
|
-
export
|
|
1411
|
+
export type StorageItem<T> = {
|
|
1339
1412
|
get: () => T;
|
|
1340
1413
|
getWithVersion: () => VersionedValue<T>;
|
|
1341
|
-
set:
|
|
1414
|
+
set: StorageSetter<T>;
|
|
1342
1415
|
setIfVersion: (
|
|
1343
1416
|
version: StorageVersion,
|
|
1344
1417
|
value: T | ((prev: T) => T),
|
|
@@ -1355,7 +1428,7 @@ export interface StorageItem<T> {
|
|
|
1355
1428
|
deserialize: (value: string) => T;
|
|
1356
1429
|
scope: StorageScope;
|
|
1357
1430
|
key: string;
|
|
1358
|
-
}
|
|
1431
|
+
};
|
|
1359
1432
|
|
|
1360
1433
|
type StorageItemInternal<T> = StorageItem<T> & {
|
|
1361
1434
|
_triggerListeners: () => void;
|
|
@@ -1979,16 +2052,20 @@ type BatchReadItem<T> = Pick<
|
|
|
1979
2052
|
_secureAccessControl?: AccessControl;
|
|
1980
2053
|
};
|
|
1981
2054
|
type BatchRemoveItem = Pick<StorageItem<unknown>, "key" | "scope" | "delete">;
|
|
2055
|
+
type BatchValues<TItems extends readonly BatchReadItem<unknown>[]> = {
|
|
2056
|
+
[Index in keyof TItems]: TItems[Index] extends BatchReadItem<infer Value>
|
|
2057
|
+
? Value
|
|
2058
|
+
: never;
|
|
2059
|
+
};
|
|
1982
2060
|
|
|
1983
2061
|
export type StorageBatchSetItem<T> = {
|
|
1984
2062
|
item: StorageItem<T>;
|
|
1985
2063
|
value: T;
|
|
1986
2064
|
};
|
|
1987
2065
|
|
|
1988
|
-
export function getBatch
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
): unknown[] {
|
|
2066
|
+
export function getBatch<
|
|
2067
|
+
const TItems extends readonly BatchReadItem<unknown>[],
|
|
2068
|
+
>(items: TItems, scope: StorageScope): BatchValues<TItems> {
|
|
1992
2069
|
return measureOperation(
|
|
1993
2070
|
"batch:get",
|
|
1994
2071
|
scope,
|
|
@@ -2067,7 +2144,7 @@ export function getBatch(
|
|
|
2067
2144
|
});
|
|
2068
2145
|
},
|
|
2069
2146
|
items.length,
|
|
2070
|
-
)
|
|
2147
|
+
) as BatchValues<TItems>;
|
|
2071
2148
|
}
|
|
2072
2149
|
|
|
2073
2150
|
export function setBatch<T>(
|
|
@@ -2136,7 +2213,7 @@ export function setBatch<T>(
|
|
|
2136
2213
|
flushSecureWrites();
|
|
2137
2214
|
const storageModule = getStorageModule();
|
|
2138
2215
|
const keys = secureEntries.map(({ item }) => item.key);
|
|
2139
|
-
const oldValues =
|
|
2216
|
+
const oldValues = shouldReadPreviousEventValues(scope)
|
|
2140
2217
|
? (storageModule.getBatch(keys, scope) ?? [])
|
|
2141
2218
|
: [];
|
|
2142
2219
|
const groupedByAccessControl = new Map<
|
|
@@ -2193,7 +2270,7 @@ export function setBatch<T>(
|
|
|
2193
2270
|
|
|
2194
2271
|
const keys = items.map((entry) => entry.item.key);
|
|
2195
2272
|
const values = items.map((entry) => entry.item.serialize(entry.value));
|
|
2196
|
-
const oldValues =
|
|
2273
|
+
const oldValues = shouldReadPreviousEventValues(scope)
|
|
2197
2274
|
? (getStorageModule().getBatch(keys, scope) ?? [])
|
|
2198
2275
|
: [];
|
|
2199
2276
|
|
|
@@ -2252,7 +2329,7 @@ export function removeBatch(
|
|
|
2252
2329
|
if (scope === StorageScope.Secure) {
|
|
2253
2330
|
flushSecureWrites();
|
|
2254
2331
|
}
|
|
2255
|
-
const oldValues =
|
|
2332
|
+
const oldValues = shouldReadPreviousEventValues(scope)
|
|
2256
2333
|
? (getStorageModule().getBatch(keys, scope) ?? [])
|
|
2257
2334
|
: [];
|
|
2258
2335
|
getStorageModule().removeBatch(keys, scope);
|