strata-storage 2.4.2 → 2.5.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/AI-INTEGRATION-GUIDE.md +208 -0
- package/README.md +427 -181
- package/android/AGENTS.md +34 -0
- package/android/CLAUDE.md +51 -0
- package/android/src/main/java/com/strata/storage/SQLiteStorage.java +35 -0
- package/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +191 -27
- package/dist/README.md +427 -181
- package/dist/adapters/capacitor/FilesystemAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/FilesystemAdapter.js +2 -1
- package/dist/adapters/capacitor/PreferencesAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/PreferencesAdapter.js +2 -1
- package/dist/adapters/capacitor/SecureAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/SecureAdapter.js +2 -1
- package/dist/adapters/capacitor/SqliteAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/SqliteAdapter.js +2 -1
- package/dist/adapters/web/CacheAdapter.d.ts.map +1 -1
- package/dist/adapters/web/CacheAdapter.js +11 -3
- package/dist/adapters/web/CookieAdapter.d.ts +37 -1
- package/dist/adapters/web/CookieAdapter.d.ts.map +1 -1
- package/dist/adapters/web/CookieAdapter.js +89 -9
- package/dist/adapters/web/IndexedDBAdapter.d.ts.map +1 -1
- package/dist/adapters/web/IndexedDBAdapter.js +10 -2
- package/dist/adapters/web/LocalStorageAdapter.d.ts +31 -0
- package/dist/adapters/web/LocalStorageAdapter.d.ts.map +1 -1
- package/dist/adapters/web/LocalStorageAdapter.js +92 -19
- package/dist/adapters/web/MemoryAdapter.d.ts +24 -0
- package/dist/adapters/web/MemoryAdapter.d.ts.map +1 -1
- package/dist/adapters/web/MemoryAdapter.js +69 -18
- package/dist/adapters/web/SessionStorageAdapter.d.ts +24 -0
- package/dist/adapters/web/SessionStorageAdapter.d.ts.map +1 -1
- package/dist/adapters/web/SessionStorageAdapter.js +71 -9
- package/dist/adapters/web/URLAdapter.d.ts +59 -0
- package/dist/adapters/web/URLAdapter.d.ts.map +1 -0
- package/dist/adapters/web/URLAdapter.js +234 -0
- package/dist/adapters/web/index.d.ts +1 -0
- package/dist/adapters/web/index.d.ts.map +1 -1
- package/dist/adapters/web/index.js +1 -0
- package/dist/android/AGENTS.md +34 -0
- package/dist/android/CLAUDE.md +51 -0
- package/dist/android/src/main/java/com/strata/storage/SQLiteStorage.java +35 -0
- package/dist/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +191 -27
- package/dist/capacitor.d.ts.map +1 -1
- package/dist/capacitor.js +2 -1
- package/dist/config/support.d.ts +10 -0
- package/dist/config/support.d.ts.map +1 -0
- package/dist/config/support.js +9 -0
- package/dist/core/BaseAdapter.d.ts +8 -0
- package/dist/core/BaseAdapter.d.ts.map +1 -1
- package/dist/core/BaseAdapter.js +34 -14
- package/dist/core/Strata.d.ts +56 -2
- package/dist/core/Strata.d.ts.map +1 -1
- package/dist/core/Strata.js +501 -53
- package/dist/features/encryption.d.ts.map +1 -1
- package/dist/features/encryption.js +3 -2
- package/dist/features/integrity.d.ts +16 -0
- package/dist/features/integrity.d.ts.map +1 -0
- package/dist/features/integrity.js +28 -0
- package/dist/features/observer.d.ts.map +1 -1
- package/dist/features/observer.js +2 -1
- package/dist/features/query.d.ts +7 -1
- package/dist/features/query.d.ts.map +1 -1
- package/dist/features/query.js +9 -2
- package/dist/features/sync.d.ts.map +1 -1
- package/dist/features/sync.js +4 -3
- package/dist/index.d.ts +35 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -30
- package/dist/integrations/angular/index.d.ts +158 -0
- package/dist/integrations/angular/index.d.ts.map +1 -0
- package/dist/integrations/angular/index.js +395 -0
- package/dist/integrations/index.d.ts +15 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +18 -0
- package/dist/integrations/react/index.d.ts +75 -0
- package/dist/integrations/react/index.d.ts.map +1 -0
- package/dist/integrations/react/index.js +191 -0
- package/dist/integrations/vue/index.d.ts +103 -0
- package/dist/integrations/vue/index.d.ts.map +1 -0
- package/dist/integrations/vue/index.js +274 -0
- package/dist/ios/AGENTS.md +33 -0
- package/dist/ios/CLAUDE.md +49 -0
- package/dist/ios/Plugin/KeychainStorage.swift +139 -50
- package/dist/ios/Plugin/SQLiteStorage.swift +40 -0
- package/dist/ios/Plugin/StrataStoragePlugin.m +23 -0
- package/dist/ios/Plugin/StrataStoragePlugin.swift +201 -52
- package/dist/package.json +21 -5
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +2 -1
- package/dist/types/index.d.ts +58 -9
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -13
- package/dist/utils/errors.d.ts +7 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +15 -3
- package/dist/utils/index.d.ts +63 -5
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +109 -16
- package/dist/utils/logger.d.ts +31 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +63 -0
- package/ios/AGENTS.md +33 -0
- package/ios/CLAUDE.md +49 -0
- package/ios/Plugin/KeychainStorage.swift +139 -50
- package/ios/Plugin/SQLiteStorage.swift +40 -0
- package/ios/Plugin/StrataStoragePlugin.m +23 -0
- package/ios/Plugin/StrataStoragePlugin.swift +201 -52
- package/package.json +35 -23
- package/scripts/build.js +16 -5
- package/scripts/configure.js +2 -6
- package/scripts/postinstall.js +2 -2
- package/Readme.md +0 -271
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilesystemAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/capacitor/FilesystemAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"FilesystemAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/capacitor/FilesystemAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAChD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAgB;IAC1C,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAUxC;IAEF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAWrC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAwBpE;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB1E;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBxC;;OAEG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBlD;;OAEG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAwBxD;;OAEG;IACG,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAYlD"}
|
|
@@ -6,6 +6,7 @@ import { BaseAdapter } from "../../core/BaseAdapter.js";
|
|
|
6
6
|
import { StrataStorage } from "../../plugin/index.js";
|
|
7
7
|
import { StorageError } from "../../utils/errors.js";
|
|
8
8
|
import { isCapacitor } from "../../utils/index.js";
|
|
9
|
+
import { logger } from "../../utils/logger.js";
|
|
9
10
|
/**
|
|
10
11
|
* Native filesystem adapter using Capacitor plugin
|
|
11
12
|
*/
|
|
@@ -62,7 +63,7 @@ export class FilesystemAdapter extends BaseAdapter {
|
|
|
62
63
|
return value;
|
|
63
64
|
}
|
|
64
65
|
catch (error) {
|
|
65
|
-
|
|
66
|
+
logger.error(`Failed to get key ${key} from filesystem:`, error);
|
|
66
67
|
return null;
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/capacitor/PreferencesAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"PreferencesAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/capacitor/PreferencesAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAiB;IAC3C,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAUxC;IAEF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAWrC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAwBpE;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB1E;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBxC;;OAEG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBlD;;OAEG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAwBxD;;OAEG;IACG,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAYlD"}
|
|
@@ -6,6 +6,7 @@ import { BaseAdapter } from "../../core/BaseAdapter.js";
|
|
|
6
6
|
import { StrataStorage } from "../../plugin/index.js";
|
|
7
7
|
import { StorageError } from "../../utils/errors.js";
|
|
8
8
|
import { isCapacitor } from "../../utils/index.js";
|
|
9
|
+
import { logger } from "../../utils/logger.js";
|
|
9
10
|
/**
|
|
10
11
|
* Native preferences adapter using Capacitor plugin
|
|
11
12
|
*/
|
|
@@ -62,7 +63,7 @@ export class PreferencesAdapter extends BaseAdapter {
|
|
|
62
63
|
return value;
|
|
63
64
|
}
|
|
64
65
|
catch (error) {
|
|
65
|
-
|
|
66
|
+
logger.error(`Failed to get key ${key} from preferences:`, error);
|
|
66
67
|
return null;
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecureAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/capacitor/SecureAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"SecureAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/capacitor/SecureAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAY;IACtC,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAUxC;IAEF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAWrC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAwBpE;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB1E;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBxC;;OAEG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBlD;;OAEG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAwBxD;;OAEG;IACG,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAajD;;OAEG;IACG,eAAe,CACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,sBAAsB,EAAE,kBAAkB,CAAC;KAChE,GACA,OAAO,CAAC,IAAI,CAAC;IAYhB;;OAEG;IACG,eAAe,CACnB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GACA,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAazB;;OAEG;IACG,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3F;;OAEG;IACG,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAY/E"}
|
|
@@ -6,6 +6,7 @@ import { BaseAdapter } from "../../core/BaseAdapter.js";
|
|
|
6
6
|
import { StrataStorage } from "../../plugin/index.js";
|
|
7
7
|
import { StorageError } from "../../utils/errors.js";
|
|
8
8
|
import { isCapacitor } from "../../utils/index.js";
|
|
9
|
+
import { logger } from "../../utils/logger.js";
|
|
9
10
|
/**
|
|
10
11
|
* Native secure storage adapter using Capacitor plugin
|
|
11
12
|
*/
|
|
@@ -62,7 +63,7 @@ export class SecureAdapter extends BaseAdapter {
|
|
|
62
63
|
return value;
|
|
63
64
|
}
|
|
64
65
|
catch (error) {
|
|
65
|
-
|
|
66
|
+
logger.error(`Failed to get key ${key} from secure storage:`, error);
|
|
66
67
|
return null;
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/capacitor/SqliteAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,WAAW,EACZ,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"SqliteAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/capacitor/SqliteAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,WAAW,EACZ,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAY;IACtC,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAUxC;IAEF,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;gBAEV,MAAM,GAAE,YAAiB;IAMrC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAWrC;;OAEG;IACG,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtD;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IA0BpE;;OAEG;IACG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB1E;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBxC;;OAEG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBlD;;OAEG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA0BxD;;OAEG;IACG,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IA4B9F;;OAEG;IACG,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAejD;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;CAK1C"}
|
|
@@ -6,6 +6,7 @@ import { BaseAdapter } from "../../core/BaseAdapter.js";
|
|
|
6
6
|
import { StrataStorage } from "../../plugin/index.js";
|
|
7
7
|
import { StorageError, TransactionError } from "../../utils/errors.js";
|
|
8
8
|
import { isCapacitor } from "../../utils/index.js";
|
|
9
|
+
import { logger } from "../../utils/logger.js";
|
|
9
10
|
/**
|
|
10
11
|
* Native SQLite adapter using Capacitor plugin
|
|
11
12
|
*/
|
|
@@ -75,7 +76,7 @@ export class SqliteAdapter extends BaseAdapter {
|
|
|
75
76
|
return value;
|
|
76
77
|
}
|
|
77
78
|
catch (error) {
|
|
78
|
-
|
|
79
|
+
logger.error(`Failed to get key ${key} from SQLite:`, error);
|
|
79
80
|
return null;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/web/CacheAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,cAAc,EACf,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"CacheAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/web/CacheAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,cAAc,EACf,MAAM,SAAS,CAAC;AAKjB;;GAEG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC3C,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAW;IACrC,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAUxC;IAEF,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAC,CAAQ;gBAEV,SAAS,SAAsB,EAAE,OAAO,SAA0B;IAM9E;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;OAEG;IACG,UAAU,CAAC,MAAM,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlF;;OAEG;YACW,SAAS;IAWvB;;OAEG;IACH,OAAO,CAAC,QAAQ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;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B;;OAEG;IACH,OAAO,CAAC,YAAY;CAMrB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { BaseAdapter } from "../../core/BaseAdapter.js";
|
|
6
6
|
import { getObjectSize } from "../../utils/index.js";
|
|
7
7
|
import { StorageError, QuotaExceededError, NotSupportedError } from "../../utils/errors.js";
|
|
8
|
+
import { logger } from "../../utils/logger.js";
|
|
8
9
|
/**
|
|
9
10
|
* Cache API adapter for Service Worker environments
|
|
10
11
|
*/
|
|
@@ -92,7 +93,7 @@ export class CacheAdapter extends BaseAdapter {
|
|
|
92
93
|
return data;
|
|
93
94
|
}
|
|
94
95
|
catch (error) {
|
|
95
|
-
|
|
96
|
+
logger.error(`Failed to get key ${key} from cache:`, error);
|
|
96
97
|
return null;
|
|
97
98
|
}
|
|
98
99
|
}
|
|
@@ -176,7 +177,14 @@ export class CacheAdapter extends BaseAdapter {
|
|
|
176
177
|
for (const request of requests) {
|
|
177
178
|
const key = this.urlToKey(request.url);
|
|
178
179
|
const value = await this.get(key);
|
|
179
|
-
|
|
180
|
+
const isStorageQuery = this.isStorageMetadataQuery(condition);
|
|
181
|
+
const normalizedCondition = isStorageQuery
|
|
182
|
+
? condition
|
|
183
|
+
: this.normalizeValueQueryCondition(condition);
|
|
184
|
+
if (value &&
|
|
185
|
+
(isStorageQuery
|
|
186
|
+
? this.queryEngine.matches(value, normalizedCondition)
|
|
187
|
+
: this.queryEngine.matches(value.value, normalizedCondition))) {
|
|
180
188
|
results.push({ key, value: value.value });
|
|
181
189
|
}
|
|
182
190
|
}
|
|
@@ -266,7 +274,7 @@ export class CacheAdapter extends BaseAdapter {
|
|
|
266
274
|
return { data, metadata: metadata?.value };
|
|
267
275
|
}
|
|
268
276
|
catch (error) {
|
|
269
|
-
|
|
277
|
+
logger.error(`Failed to get binary data for key ${key}:`, error);
|
|
270
278
|
return null;
|
|
271
279
|
}
|
|
272
280
|
}
|
|
@@ -5,7 +5,14 @@
|
|
|
5
5
|
import { BaseAdapter } from '@/core/BaseAdapter';
|
|
6
6
|
import type { StorageType, StorageCapabilities, StorageValue, ClearOptions, SizeInfo } from '@/types';
|
|
7
7
|
/**
|
|
8
|
-
* Cookie options
|
|
8
|
+
* Cookie options.
|
|
9
|
+
*
|
|
10
|
+
* NOTE: `HttpOnly` is intentionally absent. The `HttpOnly` attribute can only be
|
|
11
|
+
* set by a server via the `Set-Cookie` response header — JavaScript writing to
|
|
12
|
+
* `document.cookie` cannot mark a cookie HttpOnly (by design, since HttpOnly
|
|
13
|
+
* cookies are invisible to `document.cookie`). Cookies written by this adapter
|
|
14
|
+
* are therefore always readable by client-side script; do not store secrets in
|
|
15
|
+
* the cookie adapter — use the secure adapter (Keychain/Keystore) instead.
|
|
9
16
|
*/
|
|
10
17
|
interface CookieOptions {
|
|
11
18
|
domain?: string;
|
|
@@ -24,6 +31,11 @@ export declare class CookieAdapter extends BaseAdapter {
|
|
|
24
31
|
private cookieOptions;
|
|
25
32
|
private maxCookieSize;
|
|
26
33
|
constructor(prefix?: string, options?: CookieOptions);
|
|
34
|
+
/**
|
|
35
|
+
* Whether the current page is served over a secure (https) context. Used to
|
|
36
|
+
* auto-apply the `Secure` cookie attribute without breaking local http dev.
|
|
37
|
+
*/
|
|
38
|
+
private isSecureContext;
|
|
27
39
|
/**
|
|
28
40
|
* Check if cookies are available
|
|
29
41
|
*/
|
|
@@ -36,22 +48,46 @@ export declare class CookieAdapter extends BaseAdapter {
|
|
|
36
48
|
* Get a value from cookies
|
|
37
49
|
*/
|
|
38
50
|
get<T = unknown>(key: string): Promise<StorageValue<T> | null>;
|
|
51
|
+
/**
|
|
52
|
+
* Get a value from cookies (synchronous)
|
|
53
|
+
*/
|
|
54
|
+
getSync<T = unknown>(key: string): StorageValue<T> | null;
|
|
39
55
|
/**
|
|
40
56
|
* Set a value in cookies
|
|
41
57
|
*/
|
|
42
58
|
set<T = unknown>(key: string, value: StorageValue<T>): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Set a value in cookies (synchronous)
|
|
61
|
+
*/
|
|
62
|
+
setSync<T = unknown>(key: string, value: StorageValue<T>): void;
|
|
43
63
|
/**
|
|
44
64
|
* Remove a value from cookies
|
|
45
65
|
*/
|
|
46
66
|
remove(key: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Remove a value from cookies (synchronous)
|
|
69
|
+
*/
|
|
70
|
+
removeSync(key: string): void;
|
|
47
71
|
/**
|
|
48
72
|
* Clear cookies
|
|
49
73
|
*/
|
|
50
74
|
clear(options?: ClearOptions): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Clear cookies (synchronous)
|
|
77
|
+
*/
|
|
78
|
+
clearSync(options?: ClearOptions): void;
|
|
51
79
|
/**
|
|
52
80
|
* Get all keys
|
|
53
81
|
*/
|
|
54
82
|
keys(pattern?: string | RegExp): Promise<string[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Get all keys (synchronous)
|
|
85
|
+
*/
|
|
86
|
+
keysSync(pattern?: string | RegExp): string[];
|
|
87
|
+
/**
|
|
88
|
+
* Check if key exists (synchronous)
|
|
89
|
+
*/
|
|
90
|
+
hasSync(key: string): boolean;
|
|
55
91
|
/**
|
|
56
92
|
* Get storage size
|
|
57
93
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CookieAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/web/CookieAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACT,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"CookieAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/web/CookieAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,W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;IAI1E;;OAEG;IACH,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI;IAqC/D;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAW7B;;OAEG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI;IA4CvC;;OAEG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAIxD;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE;IAmB7C;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAK7B;;OAEG;IACG,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAmCjD;;OAEG;IACH,OAAO,CAAC,SAAS;IAgBjB;;OAEG;IACH,OAAO,CAAC,SAAS;IAiCjB;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;OAEG;IACH,OAAO,CAAC,aAAa;CAmBtB"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { BaseAdapter } from "../../core/BaseAdapter.js";
|
|
6
6
|
import { StorageError, QuotaExceededError } from "../../utils/errors.js";
|
|
7
|
+
import { logger } from "../../utils/logger.js";
|
|
7
8
|
/**
|
|
8
9
|
* Browser cookie adapter
|
|
9
10
|
*/
|
|
@@ -11,7 +12,7 @@ export class CookieAdapter extends BaseAdapter {
|
|
|
11
12
|
name = 'cookies';
|
|
12
13
|
capabilities = {
|
|
13
14
|
persistent: true,
|
|
14
|
-
synchronous:
|
|
15
|
+
synchronous: true, // document.cookie backend is synchronous
|
|
15
16
|
observable: false, // No native change events
|
|
16
17
|
transactional: false,
|
|
17
18
|
queryable: true,
|
|
@@ -26,11 +27,27 @@ export class CookieAdapter extends BaseAdapter {
|
|
|
26
27
|
constructor(prefix = 'strata_', options = {}) {
|
|
27
28
|
super();
|
|
28
29
|
this.prefix = prefix;
|
|
30
|
+
// Secure-by-default: SameSite=Lax mitigates CSRF/cross-site leakage unless
|
|
31
|
+
// the caller explicitly opts into a different policy. `path` defaults to '/'.
|
|
29
32
|
this.cookieOptions = {
|
|
30
33
|
path: '/',
|
|
34
|
+
sameSite: 'lax',
|
|
31
35
|
...options,
|
|
32
36
|
};
|
|
33
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Whether the current page is served over a secure (https) context. Used to
|
|
40
|
+
* auto-apply the `Secure` cookie attribute without breaking local http dev.
|
|
41
|
+
*/
|
|
42
|
+
isSecureContext() {
|
|
43
|
+
if (typeof window !== 'undefined' && typeof window.isSecureContext === 'boolean') {
|
|
44
|
+
return window.isSecureContext;
|
|
45
|
+
}
|
|
46
|
+
if (typeof location !== 'undefined') {
|
|
47
|
+
return location.protocol === 'https:';
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
34
51
|
/**
|
|
35
52
|
* Check if cookies are available
|
|
36
53
|
*/
|
|
@@ -63,6 +80,12 @@ export class CookieAdapter extends BaseAdapter {
|
|
|
63
80
|
* Get a value from cookies
|
|
64
81
|
*/
|
|
65
82
|
async get(key) {
|
|
83
|
+
return this.getSync(key);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get a value from cookies (synchronous)
|
|
87
|
+
*/
|
|
88
|
+
getSync(key) {
|
|
66
89
|
const cookieKey = this.prefix + key;
|
|
67
90
|
const value = this.getCookie(cookieKey);
|
|
68
91
|
if (!value)
|
|
@@ -72,13 +95,13 @@ export class CookieAdapter extends BaseAdapter {
|
|
|
72
95
|
const parsed = JSON.parse(decoded);
|
|
73
96
|
// Check TTL
|
|
74
97
|
if (this.isExpired(parsed)) {
|
|
75
|
-
|
|
98
|
+
this.removeSync(key);
|
|
76
99
|
return null;
|
|
77
100
|
}
|
|
78
101
|
return parsed;
|
|
79
102
|
}
|
|
80
103
|
catch (error) {
|
|
81
|
-
|
|
104
|
+
logger.error(`Failed to parse cookie ${key}:`, error);
|
|
82
105
|
return null;
|
|
83
106
|
}
|
|
84
107
|
}
|
|
@@ -86,8 +109,14 @@ export class CookieAdapter extends BaseAdapter {
|
|
|
86
109
|
* Set a value in cookies
|
|
87
110
|
*/
|
|
88
111
|
async set(key, value) {
|
|
112
|
+
this.setSync(key, value);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Set a value in cookies (synchronous)
|
|
116
|
+
*/
|
|
117
|
+
setSync(key, value) {
|
|
89
118
|
const cookieKey = this.prefix + key;
|
|
90
|
-
const oldValue =
|
|
119
|
+
const oldValue = this.getSync(key);
|
|
91
120
|
try {
|
|
92
121
|
const serialized = JSON.stringify(value);
|
|
93
122
|
const encoded = encodeURIComponent(serialized);
|
|
@@ -118,7 +147,13 @@ export class CookieAdapter extends BaseAdapter {
|
|
|
118
147
|
* Remove a value from cookies
|
|
119
148
|
*/
|
|
120
149
|
async remove(key) {
|
|
121
|
-
|
|
150
|
+
this.removeSync(key);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Remove a value from cookies (synchronous)
|
|
154
|
+
*/
|
|
155
|
+
removeSync(key) {
|
|
156
|
+
const oldValue = this.getSync(key);
|
|
122
157
|
const cookieKey = this.prefix + key;
|
|
123
158
|
this.deleteCookie(cookieKey);
|
|
124
159
|
if (oldValue) {
|
|
@@ -129,6 +164,12 @@ export class CookieAdapter extends BaseAdapter {
|
|
|
129
164
|
* Clear cookies
|
|
130
165
|
*/
|
|
131
166
|
async clear(options) {
|
|
167
|
+
this.clearSync(options);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Clear cookies (synchronous)
|
|
171
|
+
*/
|
|
172
|
+
clearSync(options) {
|
|
132
173
|
if (!options || (!options.pattern && !options.tags && !options.expiredOnly)) {
|
|
133
174
|
// Clear all cookies with our prefix
|
|
134
175
|
const cookies = this.getAllCookies();
|
|
@@ -140,20 +181,47 @@ export class CookieAdapter extends BaseAdapter {
|
|
|
140
181
|
this.emitChange('*', undefined, undefined, 'local');
|
|
141
182
|
return;
|
|
142
183
|
}
|
|
143
|
-
//
|
|
144
|
-
|
|
184
|
+
// Synchronous filtered clear (mirrors BaseAdapter.clear logic)
|
|
185
|
+
for (const key of this.keysSync()) {
|
|
186
|
+
let shouldDelete = true;
|
|
187
|
+
const pattern = options.pattern || options.prefix;
|
|
188
|
+
if (pattern) {
|
|
189
|
+
shouldDelete = this.filterKeys([key], pattern).length > 0;
|
|
190
|
+
}
|
|
191
|
+
if (shouldDelete && options.tags) {
|
|
192
|
+
const value = this.getSync(key);
|
|
193
|
+
if (!value?.tags || !options.tags.some((tag) => value.tags?.includes(tag))) {
|
|
194
|
+
shouldDelete = false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (shouldDelete && options.expiredOnly) {
|
|
198
|
+
const value = this.getSync(key);
|
|
199
|
+
if (!value || !this.isExpired(value)) {
|
|
200
|
+
shouldDelete = false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (shouldDelete) {
|
|
204
|
+
this.removeSync(key);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
145
207
|
}
|
|
146
208
|
/**
|
|
147
209
|
* Get all keys
|
|
148
210
|
*/
|
|
149
211
|
async keys(pattern) {
|
|
212
|
+
return this.keysSync(pattern);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get all keys (synchronous)
|
|
216
|
+
*/
|
|
217
|
+
keysSync(pattern) {
|
|
150
218
|
const cookies = this.getAllCookies();
|
|
151
219
|
const keys = [];
|
|
152
220
|
for (const [cookieKey] of cookies) {
|
|
153
221
|
if (cookieKey.startsWith(this.prefix)) {
|
|
154
222
|
const key = cookieKey.substring(this.prefix.length);
|
|
155
223
|
// Check if not expired
|
|
156
|
-
const value =
|
|
224
|
+
const value = this.getSync(key);
|
|
157
225
|
if (value) {
|
|
158
226
|
keys.push(key);
|
|
159
227
|
}
|
|
@@ -161,6 +229,13 @@ export class CookieAdapter extends BaseAdapter {
|
|
|
161
229
|
}
|
|
162
230
|
return this.filterKeys(keys, pattern);
|
|
163
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Check if key exists (synchronous)
|
|
234
|
+
*/
|
|
235
|
+
hasSync(key) {
|
|
236
|
+
const value = this.getSync(key);
|
|
237
|
+
return value !== null && !this.isExpired(value);
|
|
238
|
+
}
|
|
164
239
|
/**
|
|
165
240
|
* Get storage size
|
|
166
241
|
*/
|
|
@@ -224,7 +299,12 @@ export class CookieAdapter extends BaseAdapter {
|
|
|
224
299
|
if (options.path) {
|
|
225
300
|
cookie += `; path=${options.path}`;
|
|
226
301
|
}
|
|
227
|
-
|
|
302
|
+
// Determine the effective Secure flag:
|
|
303
|
+
// - honor an explicit `secure` option (never weaken `secure: false`),
|
|
304
|
+
// - otherwise auto-enable on a secure (https) context,
|
|
305
|
+
// - and always enable for SameSite=None, which browsers require to be Secure.
|
|
306
|
+
const secure = options.secure ?? (this.isSecureContext() || options.sameSite === 'none');
|
|
307
|
+
if (secure) {
|
|
228
308
|
cookie += '; secure';
|
|
229
309
|
}
|
|
230
310
|
if (options.sameSite) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedDBAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/web/IndexedDBAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EAC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8B1E;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBxC;;OAEG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBlD;;OAEG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA4BxD;;OAEG;IACG,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IA2C9F;;OAEG;IACG,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAwDjD;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAQzC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5B;;OAEG;IACH,OAAO,CAAC,YAAY;CAMrB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { BaseAdapter } from "../../core/BaseAdapter.js";
|
|
6
6
|
import { createDeferred, getObjectSize } from "../../utils/index.js";
|
|
7
7
|
import { StorageError, QuotaExceededError, TransactionError } from "../../utils/errors.js";
|
|
8
|
+
import { logger } from "../../utils/logger.js";
|
|
8
9
|
/**
|
|
9
10
|
* Browser IndexedDB adapter
|
|
10
11
|
*/
|
|
@@ -97,7 +98,7 @@ export class IndexedDBAdapter extends BaseAdapter {
|
|
|
97
98
|
// Check TTL
|
|
98
99
|
if (this.isExpired(value)) {
|
|
99
100
|
// Don't wait for removal
|
|
100
|
-
this.remove(key).catch(
|
|
101
|
+
this.remove(key).catch(logger.error);
|
|
101
102
|
resolve(null);
|
|
102
103
|
}
|
|
103
104
|
else {
|
|
@@ -214,7 +215,14 @@ export class IndexedDBAdapter extends BaseAdapter {
|
|
|
214
215
|
if (cursor) {
|
|
215
216
|
const record = cursor.value;
|
|
216
217
|
const { key, ...value } = record;
|
|
217
|
-
|
|
218
|
+
const isStorageQuery = this.isStorageMetadataQuery(condition);
|
|
219
|
+
const normalizedCondition = isStorageQuery
|
|
220
|
+
? condition
|
|
221
|
+
: this.normalizeValueQueryCondition(condition);
|
|
222
|
+
if (!this.isExpired(value) &&
|
|
223
|
+
(isStorageQuery
|
|
224
|
+
? this.queryEngine.matches(value, normalizedCondition)
|
|
225
|
+
: this.queryEngine.matches(value.value, normalizedCondition))) {
|
|
218
226
|
results.push({ key, value: value.value });
|
|
219
227
|
}
|
|
220
228
|
cursor.continue();
|
|
@@ -23,26 +23,57 @@ export declare class LocalStorageAdapter extends BaseAdapter {
|
|
|
23
23
|
initialize(config?: {
|
|
24
24
|
prefix?: string;
|
|
25
25
|
}): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the backing Storage object.
|
|
28
|
+
* Subclasses (e.g. SessionStorageAdapter) override this to target a
|
|
29
|
+
* different Storage. All sync/async methods route through it so the
|
|
30
|
+
* subclass inherits correct behavior.
|
|
31
|
+
*/
|
|
32
|
+
protected getStorage(): Storage;
|
|
26
33
|
/**
|
|
27
34
|
* Get a value from localStorage
|
|
28
35
|
*/
|
|
29
36
|
get<T = unknown>(key: string): Promise<StorageValue<T> | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Get a value from localStorage (synchronous)
|
|
39
|
+
*/
|
|
40
|
+
getSync<T = unknown>(key: string): StorageValue<T> | null;
|
|
30
41
|
/**
|
|
31
42
|
* Set a value in localStorage
|
|
32
43
|
*/
|
|
33
44
|
set<T = unknown>(key: string, value: StorageValue<T>): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Set a value in localStorage (synchronous)
|
|
47
|
+
*/
|
|
48
|
+
setSync<T = unknown>(key: string, value: StorageValue<T>): void;
|
|
34
49
|
/**
|
|
35
50
|
* Remove a value from localStorage
|
|
36
51
|
*/
|
|
37
52
|
remove(key: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Remove a value from localStorage (synchronous)
|
|
55
|
+
*/
|
|
56
|
+
removeSync(key: string): void;
|
|
38
57
|
/**
|
|
39
58
|
* Clear localStorage
|
|
40
59
|
*/
|
|
41
60
|
clear(options?: ClearOptions): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Clear localStorage (synchronous)
|
|
63
|
+
*/
|
|
64
|
+
clearSync(options?: ClearOptions): void;
|
|
42
65
|
/**
|
|
43
66
|
* Get all keys
|
|
44
67
|
*/
|
|
45
68
|
keys(pattern?: string | RegExp): Promise<string[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Get all keys (synchronous)
|
|
71
|
+
*/
|
|
72
|
+
keysSync(pattern?: string | RegExp): string[];
|
|
73
|
+
/**
|
|
74
|
+
* Check if key exists (synchronous)
|
|
75
|
+
*/
|
|
76
|
+
hasSync(key: string): boolean;
|
|
46
77
|
/**
|
|
47
78
|
* Get storage size
|
|
48
79
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocalStorageAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/web/LocalStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"LocalStorageAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/web/LocalStorageAdapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,oBAA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