@devraj-labs/rn-storage-kit 0.1.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/LICENSE +21 -0
- package/README.md +235 -0
- package/dist/debug/index.d.ts +3 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/index.js +19 -0
- package/dist/debug/index.js.map +1 -0
- package/dist/debug/storage-debug-panel/index.d.ts +3 -0
- package/dist/debug/storage-debug-panel/index.d.ts.map +1 -0
- package/dist/debug/storage-debug-panel/index.js +19 -0
- package/dist/debug/storage-debug-panel/index.js.map +1 -0
- package/dist/debug/storage-debug-panel/storage-debug-panel-types.d.ts +4 -0
- package/dist/debug/storage-debug-panel/storage-debug-panel-types.d.ts.map +1 -0
- package/dist/debug/storage-debug-panel/storage-debug-panel-types.js +4 -0
- package/dist/debug/storage-debug-panel/storage-debug-panel-types.js.map +1 -0
- package/dist/debug/storage-debug-panel/storage-debug-panel.d.ts +3 -0
- package/dist/debug/storage-debug-panel/storage-debug-panel.d.ts.map +1 -0
- package/dist/debug/storage-debug-panel/storage-debug-panel.js +308 -0
- package/dist/debug/storage-debug-panel/storage-debug-panel.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-colors.d.ts +22 -0
- package/dist/debug/storage-debug-screen/debug-colors.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-colors.js +25 -0
- package/dist/debug/storage-debug-screen/debug-colors.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-data-row/debug-data-row.d.ts +6 -0
- package/dist/debug/storage-debug-screen/debug-data-row/debug-data-row.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-data-row/debug-data-row.js +83 -0
- package/dist/debug/storage-debug-screen/debug-data-row/debug-data-row.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-data-row/index.d.ts +2 -0
- package/dist/debug/storage-debug-screen/debug-data-row/index.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-data-row/index.js +18 -0
- package/dist/debug/storage-debug-screen/debug-data-row/index.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-empty/debug-empty.d.ts +7 -0
- package/dist/debug/storage-debug-screen/debug-empty/debug-empty.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-empty/debug-empty.js +17 -0
- package/dist/debug/storage-debug-screen/debug-empty/debug-empty.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-empty/index.d.ts +2 -0
- package/dist/debug/storage-debug-screen/debug-empty/index.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-empty/index.js +18 -0
- package/dist/debug/storage-debug-screen/debug-empty/index.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-fab/debug-fab.d.ts +7 -0
- package/dist/debug/storage-debug-screen/debug-fab/debug-fab.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-fab/debug-fab.js +21 -0
- package/dist/debug/storage-debug-screen/debug-fab/debug-fab.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-fab/index.d.ts +2 -0
- package/dist/debug/storage-debug-screen/debug-fab/index.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-fab/index.js +18 -0
- package/dist/debug/storage-debug-screen/debug-fab/index.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-header/debug-header-types.d.ts +8 -0
- package/dist/debug/storage-debug-screen/debug-header/debug-header-types.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-header/debug-header-types.js +3 -0
- package/dist/debug/storage-debug-screen/debug-header/debug-header-types.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-header/debug-header.d.ts +4 -0
- package/dist/debug/storage-debug-screen/debug-header/debug-header.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-header/debug-header.js +27 -0
- package/dist/debug/storage-debug-screen/debug-header/debug-header.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-header/index.d.ts +3 -0
- package/dist/debug/storage-debug-screen/debug-header/index.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-header/index.js +19 -0
- package/dist/debug/storage-debug-screen/debug-header/index.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-helpers/format-time.d.ts +2 -0
- package/dist/debug/storage-debug-screen/debug-helpers/format-time.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-helpers/format-time.js +12 -0
- package/dist/debug/storage-debug-screen/debug-helpers/format-time.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-helpers/index.d.ts +3 -0
- package/dist/debug/storage-debug-screen/debug-helpers/index.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-helpers/index.js +19 -0
- package/dist/debug/storage-debug-screen/debug-helpers/index.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-helpers/read-mmkv-data.d.ts +4 -0
- package/dist/debug/storage-debug-screen/debug-helpers/read-mmkv-data.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-helpers/read-mmkv-data.js +29 -0
- package/dist/debug/storage-debug-screen/debug-helpers/read-mmkv-data.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-log-row/debug-log-row.d.ts +9 -0
- package/dist/debug/storage-debug-screen/debug-log-row/debug-log-row.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-log-row/debug-log-row.js +120 -0
- package/dist/debug/storage-debug-screen/debug-log-row/debug-log-row.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-log-row/index.d.ts +2 -0
- package/dist/debug/storage-debug-screen/debug-log-row/index.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-log-row/index.js +18 -0
- package/dist/debug/storage-debug-screen/debug-log-row/index.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-tab-bar/debug-tab-bar.d.ts +6 -0
- package/dist/debug/storage-debug-screen/debug-tab-bar/debug-tab-bar.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-tab-bar/debug-tab-bar.js +51 -0
- package/dist/debug/storage-debug-screen/debug-tab-bar/debug-tab-bar.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-tab-bar/index.d.ts +2 -0
- package/dist/debug/storage-debug-screen/debug-tab-bar/index.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-tab-bar/index.js +18 -0
- package/dist/debug/storage-debug-screen/debug-tab-bar/index.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/debug-toolbar-types.d.ts +10 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/debug-toolbar-types.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/debug-toolbar-types.js +3 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/debug-toolbar-types.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/debug-toolbar.d.ts +4 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/debug-toolbar.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/debug-toolbar.js +22 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/debug-toolbar.js.map +1 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/index.d.ts +3 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/index.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/index.js +19 -0
- package/dist/debug/storage-debug-screen/debug-toolbar/index.js.map +1 -0
- package/dist/debug/storage-debug-screen/index.d.ts +4 -0
- package/dist/debug/storage-debug-screen/index.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/index.js +20 -0
- package/dist/debug/storage-debug-screen/index.js.map +1 -0
- package/dist/debug/storage-debug-screen/storage-debug-screen-types.d.ts +11 -0
- package/dist/debug/storage-debug-screen/storage-debug-screen-types.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/storage-debug-screen-types.js +3 -0
- package/dist/debug/storage-debug-screen/storage-debug-screen-types.js.map +1 -0
- package/dist/debug/storage-debug-screen/storage-debug-screen.d.ts +5 -0
- package/dist/debug/storage-debug-screen/storage-debug-screen.d.ts.map +1 -0
- package/dist/debug/storage-debug-screen/storage-debug-screen.js +140 -0
- package/dist/debug/storage-debug-screen/storage-debug-screen.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/index.d.ts +3 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +19 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/logger-types.d.ts +29 -0
- package/dist/logger/logger-types.d.ts.map +1 -0
- package/dist/logger/logger-types.js +5 -0
- package/dist/logger/logger-types.js.map +1 -0
- package/dist/logger/logger.d.ts +10 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.js +151 -0
- package/dist/logger/logger.js.map +1 -0
- package/dist/mmkv-storage/index.d.ts +2 -0
- package/dist/mmkv-storage/index.d.ts.map +1 -0
- package/dist/mmkv-storage/index.js +18 -0
- package/dist/mmkv-storage/index.js.map +1 -0
- package/dist/mmkv-storage/mmkv-storage.d.ts +11 -0
- package/dist/mmkv-storage/mmkv-storage.d.ts.map +1 -0
- package/dist/mmkv-storage/mmkv-storage.js +156 -0
- package/dist/mmkv-storage/mmkv-storage.js.map +1 -0
- package/dist/secure-storage/index.d.ts +2 -0
- package/dist/secure-storage/index.d.ts.map +1 -0
- package/dist/secure-storage/index.js +18 -0
- package/dist/secure-storage/index.js.map +1 -0
- package/dist/secure-storage/secure-storage.d.ts +9 -0
- package/dist/secure-storage/secure-storage.d.ts.map +1 -0
- package/dist/secure-storage/secure-storage.js +225 -0
- package/dist/secure-storage/secure-storage.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/storage-adapter-types.d.ts +8 -0
- package/dist/types/storage-adapter-types.d.ts.map +1 -0
- package/dist/types/storage-adapter-types.js +3 -0
- package/dist/types/storage-adapter-types.js.map +1 -0
- package/package.json +63 -0
- package/src/index.ts +12 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// ─── Types ─────────────────────────────────────────────────────────────────────
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
// ─── Storage adapters ──────────────────────────────────────────────────────────
|
|
20
|
+
__exportStar(require("./mmkv-storage"), exports);
|
|
21
|
+
__exportStar(require("./secure-storage"), exports);
|
|
22
|
+
// ─── Logger ────────────────────────────────────────────────────────────────────
|
|
23
|
+
__exportStar(require("./logger"), exports);
|
|
24
|
+
// ─── Debug UI ──────────────────────────────────────────────────────────────────
|
|
25
|
+
__exportStar(require("./debug"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kFAAkF;AAClF,0CAAwB;AAExB,kFAAkF;AAClF,iDAA+B;AAC/B,mDAAiC;AAEjC,kFAAkF;AAClF,2CAAyB;AAEzB,kFAAkF;AAClF,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./logger"), exports);
|
|
18
|
+
__exportStar(require("./logger-types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,iDAA+B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type TLogLevel = 'none' | 'error' | 'info' | 'debug';
|
|
2
|
+
export type TLoggerOptions = {
|
|
3
|
+
/** Minimum level to record. Default: 'debug' when enabled. */
|
|
4
|
+
level?: TLogLevel;
|
|
5
|
+
/** Maximum number of entries kept (FIFO). Default: 200 */
|
|
6
|
+
maxEntries?: number;
|
|
7
|
+
/** Auto-delete entries older than this many ms. 0 = disabled. Default: 0 */
|
|
8
|
+
ttl?: number;
|
|
9
|
+
/** Allow logger to run in production builds. Default: false */
|
|
10
|
+
allowInProduction?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type TStorageLogEntry = {
|
|
13
|
+
id: string;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
/** Which storage backend handled this call */
|
|
16
|
+
adapter: 'mmkv' | 'secure';
|
|
17
|
+
/** Which method was called */
|
|
18
|
+
operation: 'set' | 'get' | 'remove' | 'clear' | 'getAllKeys';
|
|
19
|
+
key?: string;
|
|
20
|
+
/** Actual value for MMKV ops at debug level; '***' for secure ops; absent at info level */
|
|
21
|
+
value?: string;
|
|
22
|
+
result?: string | null;
|
|
23
|
+
error?: string;
|
|
24
|
+
durationMs: number;
|
|
25
|
+
/** Whether this operation touched the secure (Keychain) store */
|
|
26
|
+
secure: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type TLogListener = (entry: TStorageLogEntry) => void;
|
|
29
|
+
//# sourceMappingURL=logger-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-types.d.ts","sourceRoot":"","sources":["../../src/logger/logger-types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5D,MAAM,MAAM,cAAc,GAAG;IAC3B,8DAA8D;IAC9D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,8BAA8B;IAC9B,SAAS,EAAE,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;IAC7D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,2FAA2F;IAC3F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-types.js","sourceRoot":"","sources":["../../src/logger/logger-types.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,8DAA8D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TLoggerOptions, TLogListener, TStorageLogEntry } from './logger-types';
|
|
2
|
+
export declare function enableLogger(options?: TLoggerOptions): void;
|
|
3
|
+
export declare function disableLogger(): void;
|
|
4
|
+
export declare function getLogs(): TStorageLogEntry[];
|
|
5
|
+
export declare function clearLogs(): void;
|
|
6
|
+
export declare function onNewLog(cb: TLogListener): void;
|
|
7
|
+
export declare function offNewLog(cb: TLogListener): void;
|
|
8
|
+
export declare function generateId(): string;
|
|
9
|
+
export declare function log(entry: TStorageLogEntry): void;
|
|
10
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EACd,YAAY,EACZ,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AA2DxB,wBAAgB,YAAY,CAAC,OAAO,GAAE,cAAmB,GAAG,IAAI,CAM/D;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED,wBAAgB,OAAO,IAAI,gBAAgB,EAAE,CAE5C;AAED,wBAAgB,SAAS,IAAI,IAAI,CAIhC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAE/C;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAEhD;AAID,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AA8BD,wBAAgB,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAejD"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.enableLogger = enableLogger;
|
|
15
|
+
exports.disableLogger = disableLogger;
|
|
16
|
+
exports.getLogs = getLogs;
|
|
17
|
+
exports.clearLogs = clearLogs;
|
|
18
|
+
exports.onNewLog = onNewLog;
|
|
19
|
+
exports.offNewLog = offNewLog;
|
|
20
|
+
exports.generateId = generateId;
|
|
21
|
+
exports.log = log;
|
|
22
|
+
const react_native_mmkv_1 = require("react-native-mmkv");
|
|
23
|
+
// ─── Persistence ───────────────────────────────────────────────────────────────
|
|
24
|
+
// Logs survive Metro fast-refresh by being persisted in a dedicated MMKV store.
|
|
25
|
+
// Secure values NEVER reach this store — they arrive already masked as '***'.
|
|
26
|
+
const LOG_STORE_ID = 'rn-storage-kit.logs';
|
|
27
|
+
const LOG_STORE_KEY = '__logs__';
|
|
28
|
+
const logStore = new react_native_mmkv_1.MMKV({ id: LOG_STORE_ID });
|
|
29
|
+
function loadPersistedLogs() {
|
|
30
|
+
try {
|
|
31
|
+
const raw = logStore.getString(LOG_STORE_KEY);
|
|
32
|
+
if (!raw)
|
|
33
|
+
return [];
|
|
34
|
+
return JSON.parse(raw);
|
|
35
|
+
}
|
|
36
|
+
catch (_a) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function persistLogs(entries) {
|
|
41
|
+
try {
|
|
42
|
+
logStore.set(LOG_STORE_KEY, JSON.stringify(entries));
|
|
43
|
+
}
|
|
44
|
+
catch (_a) {
|
|
45
|
+
// Non-blocking — in-memory list stays authoritative on failure.
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// ─── Internal state ────────────────────────────────────────────────────────────
|
|
49
|
+
const LEVEL_RANK = {
|
|
50
|
+
none: 0,
|
|
51
|
+
error: 1,
|
|
52
|
+
info: 2,
|
|
53
|
+
debug: 3,
|
|
54
|
+
};
|
|
55
|
+
const state = {
|
|
56
|
+
enabled: false,
|
|
57
|
+
level: 'debug',
|
|
58
|
+
maxEntries: 200,
|
|
59
|
+
ttl: 0,
|
|
60
|
+
allowInProduction: false,
|
|
61
|
+
};
|
|
62
|
+
let logs = loadPersistedLogs();
|
|
63
|
+
const listeners = new Set();
|
|
64
|
+
let counter = 0;
|
|
65
|
+
// ─── Public API ────────────────────────────────────────────────────────────────
|
|
66
|
+
function enableLogger(options = {}) {
|
|
67
|
+
state.enabled = true;
|
|
68
|
+
if (options.level !== undefined)
|
|
69
|
+
state.level = options.level;
|
|
70
|
+
if (options.maxEntries !== undefined)
|
|
71
|
+
state.maxEntries = options.maxEntries;
|
|
72
|
+
if (options.ttl !== undefined)
|
|
73
|
+
state.ttl = options.ttl;
|
|
74
|
+
if (options.allowInProduction !== undefined)
|
|
75
|
+
state.allowInProduction = options.allowInProduction;
|
|
76
|
+
}
|
|
77
|
+
function disableLogger() {
|
|
78
|
+
state.enabled = false;
|
|
79
|
+
}
|
|
80
|
+
function getLogs() {
|
|
81
|
+
return [...logs];
|
|
82
|
+
}
|
|
83
|
+
function clearLogs() {
|
|
84
|
+
logs = [];
|
|
85
|
+
logStore.delete(LOG_STORE_KEY);
|
|
86
|
+
listeners.forEach((cb) => cb(syntheticClearEntry()));
|
|
87
|
+
}
|
|
88
|
+
function onNewLog(cb) {
|
|
89
|
+
listeners.add(cb);
|
|
90
|
+
}
|
|
91
|
+
function offNewLog(cb) {
|
|
92
|
+
listeners.delete(cb);
|
|
93
|
+
}
|
|
94
|
+
// ─── Internal helpers ──────────────────────────────────────────────────────────
|
|
95
|
+
function generateId() {
|
|
96
|
+
return `${Date.now()}-${++counter}`;
|
|
97
|
+
}
|
|
98
|
+
function shouldLog(entry) {
|
|
99
|
+
if (!__DEV__ && !state.allowInProduction)
|
|
100
|
+
return false;
|
|
101
|
+
if (!state.enabled)
|
|
102
|
+
return false;
|
|
103
|
+
if (state.level === 'none')
|
|
104
|
+
return false;
|
|
105
|
+
const rank = LEVEL_RANK[state.level];
|
|
106
|
+
if (rank >= LEVEL_RANK.error && entry.error)
|
|
107
|
+
return true;
|
|
108
|
+
if (rank >= LEVEL_RANK.info && !entry.error)
|
|
109
|
+
return true;
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* At 'info' level we confirm the operation happened but strip payload details.
|
|
114
|
+
*/
|
|
115
|
+
function applyLevelMask(entry) {
|
|
116
|
+
if (state.level === 'info') {
|
|
117
|
+
const { value: _v, result: _r } = entry, rest = __rest(entry, ["value", "result"]);
|
|
118
|
+
return rest;
|
|
119
|
+
}
|
|
120
|
+
return entry;
|
|
121
|
+
}
|
|
122
|
+
function evictExpired(entries) {
|
|
123
|
+
if (state.ttl <= 0)
|
|
124
|
+
return entries;
|
|
125
|
+
const cutoff = Date.now() - state.ttl;
|
|
126
|
+
return entries.filter((e) => e.timestamp >= cutoff);
|
|
127
|
+
}
|
|
128
|
+
function log(entry) {
|
|
129
|
+
if (!shouldLog(entry))
|
|
130
|
+
return;
|
|
131
|
+
const masked = applyLevelMask(entry);
|
|
132
|
+
logs = evictExpired(logs);
|
|
133
|
+
logs.unshift(masked);
|
|
134
|
+
if (logs.length > state.maxEntries) {
|
|
135
|
+
logs = logs.slice(0, state.maxEntries);
|
|
136
|
+
}
|
|
137
|
+
// Persist asynchronously — never blocks the storage call
|
|
138
|
+
setImmediate(() => persistLogs(logs));
|
|
139
|
+
listeners.forEach((cb) => cb(masked));
|
|
140
|
+
}
|
|
141
|
+
function syntheticClearEntry() {
|
|
142
|
+
return {
|
|
143
|
+
id: generateId(),
|
|
144
|
+
timestamp: Date.now(),
|
|
145
|
+
adapter: 'mmkv',
|
|
146
|
+
operation: 'clear',
|
|
147
|
+
durationMs: 0,
|
|
148
|
+
secure: false,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAiEA,oCAMC;AAED,sCAEC;AAED,0BAEC;AAED,8BAIC;AAED,4BAEC;AAED,8BAEC;AAID,gCAEC;AA8BD,kBAeC;AAhJD,yDAAyC;AAQzC,kFAAkF;AAClF,gFAAgF;AAChF,8EAA8E;AAE9E,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAC3C,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,QAAQ,GAAG,IAAI,wBAAI,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC;AAEhD,SAAS,iBAAi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AAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,mBAAmB;IAC1B,OAAO;QACL,EAAE,EAAE,UAAU,EAAE;QAChB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;QACrB,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,CAAC;QACb,MAAM,EAAE,KAAK;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mmkv-storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./mmkv-storage"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mmkv-storage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TStorageAdapter } from '../types';
|
|
2
|
+
export declare class MMKVStorageAdapter<TSchema extends Record<string, unknown> = Record<string, string>> implements TStorageAdapter<TSchema> {
|
|
3
|
+
private storage;
|
|
4
|
+
constructor(id?: string);
|
|
5
|
+
get<K extends keyof TSchema & string>(key: K): Promise<TSchema[K] | null>;
|
|
6
|
+
set<K extends keyof TSchema & string>(key: K, value: TSchema[K]): Promise<void>;
|
|
7
|
+
remove(key: string): Promise<void>;
|
|
8
|
+
clear(): Promise<void>;
|
|
9
|
+
getAllKeys(): Promise<string[]>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=mmkv-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mmkv-storage.d.ts","sourceRoot":"","sources":["../../src/mmkv-storage/mmkv-storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,qBAAa,kBAAkB,CAC7B,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAChE,YAAW,eAAe,CAAC,OAAO,CAAC;IACnC,OAAO,CAAC,OAAO,CAAO;gBAEV,EAAE,SAA2B;IAInC,GAAG,CAAC,CAAC,SAAS,MAAM,OAAO,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IA+BzE,GAAG,CAAC,CAAC,SAAS,MAAM,OAAO,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IA8B/E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0BtB,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CA2BtC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MMKVStorageAdapter = void 0;
|
|
4
|
+
const react_native_mmkv_1 = require("react-native-mmkv");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
class MMKVStorageAdapter {
|
|
7
|
+
constructor(id = 'rn-storage-kit.default') {
|
|
8
|
+
this.storage = new react_native_mmkv_1.MMKV({ id });
|
|
9
|
+
}
|
|
10
|
+
async get(key) {
|
|
11
|
+
var _a;
|
|
12
|
+
const start = Date.now();
|
|
13
|
+
try {
|
|
14
|
+
const raw = (_a = this.storage.getString(key)) !== null && _a !== void 0 ? _a : null;
|
|
15
|
+
const result = raw !== null ? JSON.parse(raw) : null;
|
|
16
|
+
(0, logger_1.log)({
|
|
17
|
+
id: (0, logger_1.generateId)(),
|
|
18
|
+
timestamp: Date.now(),
|
|
19
|
+
adapter: 'mmkv',
|
|
20
|
+
operation: 'get',
|
|
21
|
+
key,
|
|
22
|
+
result: raw,
|
|
23
|
+
durationMs: Date.now() - start,
|
|
24
|
+
secure: false,
|
|
25
|
+
});
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
(0, logger_1.log)({
|
|
30
|
+
id: (0, logger_1.generateId)(),
|
|
31
|
+
timestamp: Date.now(),
|
|
32
|
+
adapter: 'mmkv',
|
|
33
|
+
operation: 'get',
|
|
34
|
+
key,
|
|
35
|
+
error: String(e),
|
|
36
|
+
durationMs: Date.now() - start,
|
|
37
|
+
secure: false,
|
|
38
|
+
});
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async set(key, value) {
|
|
43
|
+
const start = Date.now();
|
|
44
|
+
try {
|
|
45
|
+
const serialized = JSON.stringify(value);
|
|
46
|
+
this.storage.set(key, serialized);
|
|
47
|
+
(0, logger_1.log)({
|
|
48
|
+
id: (0, logger_1.generateId)(),
|
|
49
|
+
timestamp: Date.now(),
|
|
50
|
+
adapter: 'mmkv',
|
|
51
|
+
operation: 'set',
|
|
52
|
+
key,
|
|
53
|
+
value: serialized,
|
|
54
|
+
durationMs: Date.now() - start,
|
|
55
|
+
secure: false,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
(0, logger_1.log)({
|
|
60
|
+
id: (0, logger_1.generateId)(),
|
|
61
|
+
timestamp: Date.now(),
|
|
62
|
+
adapter: 'mmkv',
|
|
63
|
+
operation: 'set',
|
|
64
|
+
key,
|
|
65
|
+
error: String(e),
|
|
66
|
+
durationMs: Date.now() - start,
|
|
67
|
+
secure: false,
|
|
68
|
+
});
|
|
69
|
+
throw e;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async remove(key) {
|
|
73
|
+
const start = Date.now();
|
|
74
|
+
try {
|
|
75
|
+
this.storage.delete(key);
|
|
76
|
+
(0, logger_1.log)({
|
|
77
|
+
id: (0, logger_1.generateId)(),
|
|
78
|
+
timestamp: Date.now(),
|
|
79
|
+
adapter: 'mmkv',
|
|
80
|
+
operation: 'remove',
|
|
81
|
+
key,
|
|
82
|
+
durationMs: Date.now() - start,
|
|
83
|
+
secure: false,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
(0, logger_1.log)({
|
|
88
|
+
id: (0, logger_1.generateId)(),
|
|
89
|
+
timestamp: Date.now(),
|
|
90
|
+
adapter: 'mmkv',
|
|
91
|
+
operation: 'remove',
|
|
92
|
+
key,
|
|
93
|
+
error: String(e),
|
|
94
|
+
durationMs: Date.now() - start,
|
|
95
|
+
secure: false,
|
|
96
|
+
});
|
|
97
|
+
throw e;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async clear() {
|
|
101
|
+
const start = Date.now();
|
|
102
|
+
try {
|
|
103
|
+
this.storage.clearAll();
|
|
104
|
+
(0, logger_1.log)({
|
|
105
|
+
id: (0, logger_1.generateId)(),
|
|
106
|
+
timestamp: Date.now(),
|
|
107
|
+
adapter: 'mmkv',
|
|
108
|
+
operation: 'clear',
|
|
109
|
+
durationMs: Date.now() - start,
|
|
110
|
+
secure: false,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
(0, logger_1.log)({
|
|
115
|
+
id: (0, logger_1.generateId)(),
|
|
116
|
+
timestamp: Date.now(),
|
|
117
|
+
adapter: 'mmkv',
|
|
118
|
+
operation: 'clear',
|
|
119
|
+
error: String(e),
|
|
120
|
+
durationMs: Date.now() - start,
|
|
121
|
+
secure: false,
|
|
122
|
+
});
|
|
123
|
+
throw e;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async getAllKeys() {
|
|
127
|
+
const start = Date.now();
|
|
128
|
+
try {
|
|
129
|
+
const keys = this.storage.getAllKeys();
|
|
130
|
+
(0, logger_1.log)({
|
|
131
|
+
id: (0, logger_1.generateId)(),
|
|
132
|
+
timestamp: Date.now(),
|
|
133
|
+
adapter: 'mmkv',
|
|
134
|
+
operation: 'getAllKeys',
|
|
135
|
+
result: keys.join(', ') || '(empty)',
|
|
136
|
+
durationMs: Date.now() - start,
|
|
137
|
+
secure: false,
|
|
138
|
+
});
|
|
139
|
+
return keys;
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
(0, logger_1.log)({
|
|
143
|
+
id: (0, logger_1.generateId)(),
|
|
144
|
+
timestamp: Date.now(),
|
|
145
|
+
adapter: 'mmkv',
|
|
146
|
+
operation: 'getAllKeys',
|
|
147
|
+
error: String(e),
|
|
148
|
+
durationMs: Date.now() - start,
|
|
149
|
+
secure: false,
|
|
150
|
+
});
|
|
151
|
+
throw e;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.MMKVStorageAdapter = MMKVStorageAdapter;
|
|
156
|
+
//# sourceMappingURL=mmkv-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mmkv-storage.js","sourceRoot":"","sources":["../../src/mmkv-storage/mmkv-storage.ts"],"names":[],"mappings":";;;AAAA,yDAAyC;AACzC,sCAA4C;AAG5C,MAAa,kBAAkB;IAK7B,YAAY,EAAE,GAAG,wBAAwB;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,wBAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,GAAG,CAAmC,GAAM;;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,mCAAI,IAAI,CAAC;YAChD,MAAM,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAgB,CAAC,CAAC,CAAC,IAAI,CAAC;YACrE,IAAA,YAAG,EAAC;gBACF,EAAE,EAAE,IAAA,mBAAU,GAAE;gBAChB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;gBACrB,OAAO,EAAE,MAAM;gBACf,SAAS,EAAE,KAAK;gBAChB,GAAG;gBACH,MAAM,EAAE,GAAG;gBACX,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK;gBAC9B,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAA,YAAG,EAAC;gBACF,EAAE,EAAE,IAAA,mBAAU,GAAE;gBAChB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;gBACrB,OAAO,EAAE,MAAM;gBACf,SAAS,EAAE,KAAK;gBAChB,GAAG;gBACH,KAAK,EAAE,M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index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./secure-storage"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/secure-storage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TStorageAdapter } from '../types';
|
|
2
|
+
export declare class SecureStorageAdapter<TSchema extends Record<string, unknown> = Record<string, string>> implements TStorageAdapter<TSchema> {
|
|
3
|
+
get<K extends keyof TSchema & string>(key: K): Promise<TSchema[K] | null>;
|
|
4
|
+
set<K extends keyof TSchema & string>(key: K, value: TSchema[K]): Promise<void>;
|
|
5
|
+
remove(key: string): Promise<void>;
|
|
6
|
+
clear(): Promise<void>;
|
|
7
|
+
getAllKeys(): Promise<string[]>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=secure-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-storage.d.ts","sourceRoot":"","sources":["../../src/secure-storage/secure-storage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA0C3C,qBAAa,oBAAoB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAChG,YAAW,eAAe,CAAC,OAAO,CAAC;IAE7B,GAAG,CAAC,CAAC,SAAS,MAAM,OAAO,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAgCzE,GAAG,CAAC,CAAC,SAAS,MAAM,OAAO,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IA+B/E,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BtB,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CA2BtC"}
|