@xbg.solutions/bpsk-utils-secure-storage 1.2.3

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.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * src/lib/constants/secure-storage.constants.ts
3
+ * Constants for secure storage configuration
4
+ *
5
+ * @deprecated This file has been consolidated into central configuration.
6
+ * New code should import from '@/lib/config/app.config.ts' instead.
7
+ *
8
+ * Legacy storage constants - use central config for new development.
9
+ */
10
+ /**
11
+ * @deprecated Use APP_CONFIG.security.storage instead
12
+ * Default time to live for stored items in seconds
13
+ */
14
+ export declare const STORAGE_DEFAULT_TTL: number;
15
+ /**
16
+ * @deprecated Use APP_CONFIG.security.storage instead
17
+ * Prefix for all storage keys to prevent collisions with other applications
18
+ */
19
+ export declare const STORAGE_PREFIX: any;
20
+ /**
21
+ * @deprecated Use APP_CONFIG.security.storage instead
22
+ * Default expiration for auth tokens in seconds
23
+ */
24
+ export declare const AUTH_TOKEN_TTL: number;
25
+ /**
26
+ * @deprecated Use APP_CONFIG.security.storage instead
27
+ * Storage key for email link authentication
28
+ */
29
+ export declare const EMAIL_FOR_SIGN_IN_KEY: string;
30
+ /**
31
+ * @deprecated Use APP_CONFIG.security.storage instead
32
+ * Storage namespace for authentication
33
+ */
34
+ export declare const AUTH_NAMESPACE: string;
35
+ /**
36
+ * @deprecated Use APP_CONFIG.security.storage instead
37
+ * Storage namespace for user preferences
38
+ */
39
+ export declare const PREFS_NAMESPACE: string;
40
+ //# sourceMappingURL=secure-storage.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-storage.constants.d.ts","sourceRoot":"","sources":["../../src/constants/secure-storage.constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAyC,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,cAAc,KAAqC,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,cAAc,QAA2C,CAAC;AAEvE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAgD,CAAC;AAEnF;;;GAGG;AACH,eAAO,MAAM,cAAc,QAA4C,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,eAAe,QAA6C,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * src/lib/constants/secure-storage.constants.ts
3
+ * Constants for secure storage configuration
4
+ *
5
+ * @deprecated This file has been consolidated into central configuration.
6
+ * New code should import from '@/lib/config/app.config.ts' instead.
7
+ *
8
+ * Legacy storage constants - use central config for new development.
9
+ */
10
+ import { APP_CONFIG } from '@xbg.solutions/bpsk-core';
11
+ /**
12
+ * @deprecated Use APP_CONFIG.security.storage instead
13
+ * Default time to live for stored items in seconds
14
+ */
15
+ export const STORAGE_DEFAULT_TTL = APP_CONFIG.security.storage.defaultTTL;
16
+ /**
17
+ * @deprecated Use APP_CONFIG.security.storage instead
18
+ * Prefix for all storage keys to prevent collisions with other applications
19
+ */
20
+ export const STORAGE_PREFIX = APP_CONFIG.security.storage.prefix;
21
+ /**
22
+ * @deprecated Use APP_CONFIG.security.storage instead
23
+ * Default expiration for auth tokens in seconds
24
+ */
25
+ export const AUTH_TOKEN_TTL = APP_CONFIG.security.storage.authTokenTTL;
26
+ /**
27
+ * @deprecated Use APP_CONFIG.security.storage instead
28
+ * Storage key for email link authentication
29
+ */
30
+ export const EMAIL_FOR_SIGN_IN_KEY = APP_CONFIG.security.storage.emailForSignInKey;
31
+ /**
32
+ * @deprecated Use APP_CONFIG.security.storage instead
33
+ * Storage namespace for authentication
34
+ */
35
+ export const AUTH_NAMESPACE = APP_CONFIG.security.storage.authNamespace;
36
+ /**
37
+ * @deprecated Use APP_CONFIG.security.storage instead
38
+ * Storage namespace for user preferences
39
+ */
40
+ export const PREFS_NAMESPACE = APP_CONFIG.security.storage.prefsNamespace;
41
+ //# sourceMappingURL=secure-storage.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-storage.constants.js","sourceRoot":"","sources":["../../src/constants/secure-storage.constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;AAE1E;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC;AAEvE;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC;AAEnF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './constants/secure-storage.constants';
2
+ export * from './stores/secure-storage';
3
+ export type * from './types/storage.types';
4
+ export * from './utils/secure-storage';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,sCAAsC,CAAC;AAGrD,cAAc,yBAAyB,CAAC;AAGxC,mBAAmB,uBAAuB,CAAC;AAG3C,cAAc,wBAAwB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
1
+ // Secure storage package barrel exports
2
+ // Constants
3
+ export * from './constants/secure-storage.constants';
4
+ // Stores
5
+ export * from './stores/secure-storage';
6
+ // Utils
7
+ export * from './utils/secure-storage';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,YAAY;AACZ,cAAc,sCAAsC,CAAC;AAErD,SAAS;AACT,cAAc,yBAAyB,CAAC;AAKxC,QAAQ;AACR,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface SecureStorageState {
2
+ encrypted: boolean;
3
+ namespace: string | null;
4
+ }
5
+ export declare const secureStorageStore: import("svelte/store").Writable<SecureStorageState>;
6
+ //# sourceMappingURL=secure-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-storage.d.ts","sourceRoot":"","sources":["../../src/stores/secure-storage.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,eAAO,MAAM,kBAAkB,qDAG7B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { writable } from 'svelte/store';
2
+ export const secureStorageStore = writable({
3
+ encrypted: true,
4
+ namespace: null
5
+ });
6
+ //# sourceMappingURL=secure-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-storage.js","sourceRoot":"","sources":["../../src/stores/secure-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAOxC,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAqB;IAC7D,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * src/lib/types/storage.types.ts
3
+ * Type definitions for secure storage
4
+ */
5
+ /**
6
+ * Available storage mechanisms
7
+ */
8
+ export type StorageMechanism = 'localStorage' | 'sessionStorage' | 'cookie' | 'memory';
9
+ /**
10
+ * Encryption configuration
11
+ */
12
+ export type StorageEncryption = {
13
+ /** Whether encryption is enabled */
14
+ enabled: boolean;
15
+ /** Passphrase used to derive the AES-GCM encryption key via PBKDF2 */
16
+ key?: string;
17
+ };
18
+ /**
19
+ * Cookie-specific options
20
+ */
21
+ export type CookieOptions = {
22
+ /** Whether the cookie should be secure (HTTPS only) */
23
+ secure?: boolean;
24
+ /** SameSite attribute for the cookie */
25
+ sameSite?: 'strict' | 'lax' | 'none';
26
+ /** Path for the cookie */
27
+ path?: string;
28
+ /** Domain for the cookie */
29
+ domain?: string;
30
+ };
31
+ /**
32
+ * Options for storage operations
33
+ */
34
+ export type StorageOptions = {
35
+ /** Storage mechanism to use */
36
+ mechanism?: StorageMechanism;
37
+ /** Fallback mechanisms if primary fails */
38
+ fallbackMechanisms?: StorageMechanism[];
39
+ /** Namespace for partitioning storage */
40
+ namespace?: string;
41
+ /** Encryption configuration */
42
+ encryption?: StorageEncryption;
43
+ /** Time to live in seconds (0 for no expiration) */
44
+ ttl?: number;
45
+ /** Options specific to cookie storage */
46
+ cookieOptions?: CookieOptions;
47
+ /** Whether to operate on all storage mechanisms */
48
+ allMechanisms?: boolean;
49
+ };
50
+ /**
51
+ * Stored value with metadata
52
+ */
53
+ export type StorageValue = {
54
+ /** The actual stored value */
55
+ value: any;
56
+ /** Timestamp when the value was created */
57
+ createdAt: number;
58
+ /** Timestamp when the value expires (0 for no expiration) */
59
+ expiresAt: number;
60
+ /** Schema version for potential future migrations */
61
+ version: number;
62
+ };
63
+ /**
64
+ * Storage adapter interface for different mechanisms
65
+ */
66
+ export interface StorageAdapter {
67
+ /**
68
+ * Retrieves a value from storage
69
+ * @param key Storage key
70
+ * @returns The stored value or null if not found
71
+ */
72
+ get(key: string): string | null;
73
+ /**
74
+ * Stores a value in storage
75
+ * @param key Storage key
76
+ * @param value Value to store
77
+ * @param options Additional options for specific mechanisms
78
+ * @returns True if storage was successful
79
+ */
80
+ set(key: string, value: string, options?: any): boolean;
81
+ /**
82
+ * Removes a value from storage
83
+ * @param key Storage key
84
+ * @returns True if removal was successful
85
+ */
86
+ remove(key: string): boolean;
87
+ /**
88
+ * Clears storage
89
+ * @param keyPrefix Optional prefix to only clear keys with this prefix
90
+ * @returns True if clear was successful
91
+ */
92
+ clear(keyPrefix?: string): boolean;
93
+ }
94
+ //# sourceMappingURL=storage.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.types.d.ts","sourceRoot":"","sources":["../../src/types/storage.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,sEAAsE;IACtE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,uDAAuD;IACvD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IACrC,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,+BAA+B;IAC/B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,2CAA2C;IAC3C,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACxC,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,mDAAmD;IACnD,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,8BAA8B;IAC9B,KAAK,EAAE,GAAG,CAAC;IACX,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAEhC;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC;IAExD;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAE7B;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * src/lib/types/storage.types.ts
3
+ * Type definitions for secure storage
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=storage.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.types.js","sourceRoot":"","sources":["../../src/types/storage.types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * src/lib/utils/secure-storage.ts
3
+ * Secure storage utility
4
+ *
5
+ * A utility for securely storing and retrieving data with support for:
6
+ * - Multiple storage mechanisms (cookies, localStorage, sessionStorage)
7
+ * - Storage strategy selection based on data sensitivity
8
+ * - Automatic data expiration
9
+ * - Environment detection (browser vs SSR)
10
+ * - Encryption for client-side storage
11
+ * - Integration with error handling
12
+ */
13
+ import type { StorageOptions, StorageMechanism } from '../types/storage.types';
14
+ export declare const secureStorage: {
15
+ setItem: <T>(key: string, value: T, options?: StorageOptions) => boolean;
16
+ setItemAsync: <T>(key: string, value: T, options?: StorageOptions) => Promise<boolean>;
17
+ getItem: <T>(key: string, options?: StorageOptions) => T | null;
18
+ getItemAsync: <T>(key: string, options?: StorageOptions) => Promise<T | null>;
19
+ removeItem: (key: string, options?: StorageOptions) => boolean;
20
+ clear: (options?: {
21
+ mechanism?: StorageMechanism;
22
+ namespace?: string;
23
+ allMechanisms?: boolean;
24
+ }) => boolean;
25
+ safeSet: <T>(key: string, value: T, options?: StorageOptions) => Promise<boolean>;
26
+ safeGet: <T>(key: string, options?: StorageOptions) => Promise<T | null>;
27
+ safeRemove: (key: string, options?: StorageOptions) => Promise<boolean>;
28
+ safeClear: (options?: {
29
+ mechanism?: StorageMechanism;
30
+ namespace?: string;
31
+ allMechanisms?: boolean;
32
+ }) => Promise<boolean>;
33
+ };
34
+ //# sourceMappingURL=secure-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-storage.d.ts","sourceRoot":"","sources":["../../src/utils/secure-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAIjB,MAAM,wBAAwB,CAAC;AAw7BhC,eAAO,MAAM,aAAa;cA7dP,CAAC,OACX,MAAM,SACJ,CAAC,YACC,cAAc,KACtB,OAAO;mBAyDkB,CAAC,OACtB,MAAM,SACJ,CAAC,YACC,cAAc,KACtB,OAAO,CAAC,OAAO,CAAC;cAoDF,CAAC,OACX,MAAM,YACF,cAAc,KACtB,CAAC,GAAG,IAAI;mBAgEiB,CAAC,OACtB,MAAM,YACF,cAAc,KACtB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;sBAqEb,MAAM,YACF,cAAc,KACtB,OAAO;sBAmDc;QACtB,SAAS,CAAC,EAAE,gBAAgB,CAAC;QAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,KAAQ,OAAO;cAoDO,CAAC,OACjB,MAAM,SACJ,CAAC,YACC,cAAc,KACtB,OAAO,CAAC,OAAO,CAAC;cA6CI,CAAC,OACjB,MAAM,YACF,cAAc,KACtB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;sBAgBb,MAAM,YACF,cAAc,KACtB,OAAO,CAAC,OAAO,CAAC;0BAce;QAChC,SAAS,CAAC,EAAE,gBAAgB,CAAC;QAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,KAAQ,OAAO,CAAC,OAAO,CAAC;CAwBuB,CAAC"}
@@ -0,0 +1,801 @@
1
+ /**
2
+ * src/lib/utils/secure-storage.ts
3
+ * Secure storage utility
4
+ *
5
+ * A utility for securely storing and retrieving data with support for:
6
+ * - Multiple storage mechanisms (cookies, localStorage, sessionStorage)
7
+ * - Storage strategy selection based on data sensitivity
8
+ * - Automatic data expiration
9
+ * - Environment detection (browser vs SSR)
10
+ * - Encryption for client-side storage
11
+ * - Integration with error handling
12
+ */
13
+ import { loggerService, ApplicationError, handleError, normalizeError, tryCatch } from '@xbg.solutions/bpsk-core';
14
+ import { STORAGE_DEFAULT_TTL, STORAGE_PREFIX } from '../constants/secure-storage.constants';
15
+ // Create a context-aware logger
16
+ const storageLogger = loggerService.withContext('SecureStorage');
17
+ /**
18
+ * Detects if running in browser environment
19
+ * @returns True if in browser environment, false if in SSR
20
+ */
21
+ function isBrowser() {
22
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
23
+ }
24
+ /**
25
+ * Creates a storage key with proper prefix and namespace
26
+ * @param key The base storage key
27
+ * @param namespace Optional namespace to partition storage
28
+ * @returns Prefixed and namespaced storage key
29
+ */
30
+ function createStorageKey(key, namespace) {
31
+ const prefix = STORAGE_PREFIX;
32
+ return namespace
33
+ ? `${prefix}_${namespace}_${key}`
34
+ : `${prefix}_${key}`;
35
+ }
36
+ /**
37
+ * Checks whether the Web Crypto API is available in the current environment.
38
+ */
39
+ function isSubtleCryptoAvailable() {
40
+ return typeof globalThis.crypto !== 'undefined'
41
+ && typeof globalThis.crypto.subtle !== 'undefined';
42
+ }
43
+ /**
44
+ * Derives an AES-GCM CryptoKey from a passphrase using PBKDF2.
45
+ * Uses a fixed salt derived from the passphrase so the same passphrase
46
+ * always produces the same key (no salt storage needed).
47
+ */
48
+ async function deriveKey(passphrase) {
49
+ const encoder = new TextEncoder();
50
+ const keyMaterial = await crypto.subtle.importKey('raw', encoder.encode(passphrase), 'PBKDF2', false, ['deriveKey']);
51
+ // Use a deterministic salt derived from the passphrase so we don't
52
+ // need to store a separate salt alongside the ciphertext.
53
+ const salt = encoder.encode(`secure-storage-salt:${passphrase}`);
54
+ return crypto.subtle.deriveKey({ name: 'PBKDF2', salt, iterations: 100000, hash: 'SHA-256' }, keyMaterial, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']);
55
+ }
56
+ /**
57
+ * Encrypts a value using AES-GCM via the Web Crypto API.
58
+ * Returns a base64-encoded string containing the 12-byte IV prepended to the ciphertext.
59
+ * Falls back to base64 encoding when SubtleCrypto is unavailable (SSR).
60
+ */
61
+ async function encryptValue(value, encryptionKey) {
62
+ try {
63
+ const stringValue = JSON.stringify(value);
64
+ if (!isSubtleCryptoAvailable() || !encryptionKey) {
65
+ // Fallback: base64 encode (SSR / no key provided)
66
+ return btoa(unescape(encodeURIComponent(stringValue)));
67
+ }
68
+ const key = await deriveKey(encryptionKey);
69
+ const iv = crypto.getRandomValues(new Uint8Array(12));
70
+ const encoded = new TextEncoder().encode(stringValue);
71
+ const cipherBuffer = await crypto.subtle.encrypt({ name: 'AES-GCM', iv }, key, encoded);
72
+ // Prepend IV to ciphertext and base64-encode the whole thing
73
+ const combined = new Uint8Array(iv.length + cipherBuffer.byteLength);
74
+ combined.set(iv, 0);
75
+ combined.set(new Uint8Array(cipherBuffer), iv.length);
76
+ return btoa(String.fromCharCode(...combined));
77
+ }
78
+ catch (error) {
79
+ throw new ApplicationError('Failed to encrypt value for storage', {
80
+ cause: error instanceof Error ? error : new Error(String(error)),
81
+ category: 'storage',
82
+ context: { operation: 'encrypt' }
83
+ });
84
+ }
85
+ }
86
+ /**
87
+ * Decrypts an AES-GCM encrypted value from storage.
88
+ * Expects the base64-encoded string to contain a 12-byte IV prepended to the ciphertext.
89
+ * Falls back to base64 decoding when SubtleCrypto is unavailable (SSR).
90
+ */
91
+ async function decryptValue(encryptedValue, encryptionKey) {
92
+ try {
93
+ if (!isSubtleCryptoAvailable() || !encryptionKey) {
94
+ // Fallback: base64 decode
95
+ const jsonString = decodeURIComponent(escape(atob(encryptedValue)));
96
+ return JSON.parse(jsonString);
97
+ }
98
+ const combined = Uint8Array.from(atob(encryptedValue), c => c.charCodeAt(0));
99
+ const iv = combined.slice(0, 12);
100
+ const ciphertext = combined.slice(12);
101
+ const key = await deriveKey(encryptionKey);
102
+ const decryptedBuffer = await crypto.subtle.decrypt({ name: 'AES-GCM', iv }, key, ciphertext);
103
+ const jsonString = new TextDecoder().decode(decryptedBuffer);
104
+ return JSON.parse(jsonString);
105
+ }
106
+ catch (error) {
107
+ throw new ApplicationError('Failed to decrypt value from storage', {
108
+ cause: error instanceof Error ? error : new Error(String(error)),
109
+ category: 'storage',
110
+ context: { operation: 'decrypt' }
111
+ });
112
+ }
113
+ }
114
+ /**
115
+ * Prepares a value for storage with metadata
116
+ * @param value The value to store
117
+ * @param options Storage options
118
+ * @returns Storage value with metadata
119
+ */
120
+ function prepareValue(value, options = {}) {
121
+ const { ttl = STORAGE_DEFAULT_TTL } = options;
122
+ const expiresAt = ttl > 0
123
+ ? Date.now() + ttl * 1000
124
+ : 0; // 0 means no expiration
125
+ return {
126
+ value,
127
+ createdAt: Date.now(),
128
+ expiresAt,
129
+ version: 1, // For potential future migrations
130
+ };
131
+ }
132
+ /**
133
+ * Checks if a stored value is expired
134
+ * @param storageValue The storage value with metadata
135
+ * @returns True if the value is expired
136
+ */
137
+ function isExpired(storageValue) {
138
+ if (!storageValue.expiresAt || storageValue.expiresAt === 0) {
139
+ return false; // No expiration set
140
+ }
141
+ return Date.now() > storageValue.expiresAt;
142
+ }
143
+ /**
144
+ * Creates an adapter for localStorage
145
+ * @returns Storage adapter for localStorage
146
+ */
147
+ function localStorageAdapter() {
148
+ return {
149
+ get(key) {
150
+ if (!isBrowser())
151
+ return null;
152
+ return localStorage.getItem(key);
153
+ },
154
+ set(key, value) {
155
+ if (!isBrowser())
156
+ return false;
157
+ try {
158
+ localStorage.setItem(key, value);
159
+ return true;
160
+ }
161
+ catch (error) {
162
+ storageLogger.error('LocalStorage set failed', error instanceof Error ? error : new Error(String(error)), {
163
+ key,
164
+ error: error instanceof Error ? error.message : String(error)
165
+ });
166
+ return false;
167
+ }
168
+ },
169
+ remove(key) {
170
+ if (!isBrowser())
171
+ return false;
172
+ try {
173
+ localStorage.removeItem(key);
174
+ return true;
175
+ }
176
+ catch (error) {
177
+ storageLogger.error('LocalStorage remove failed', error instanceof Error ? error : new Error(String(error)), {
178
+ key
179
+ });
180
+ return false;
181
+ }
182
+ },
183
+ clear(keyPrefix) {
184
+ if (!isBrowser())
185
+ return false;
186
+ try {
187
+ if (keyPrefix) {
188
+ // Only clear keys with the specified prefix
189
+ Object.keys(localStorage)
190
+ .filter(key => key.startsWith(keyPrefix))
191
+ .forEach(key => localStorage.removeItem(key));
192
+ }
193
+ else {
194
+ localStorage.clear();
195
+ }
196
+ return true;
197
+ }
198
+ catch (error) {
199
+ storageLogger.error('LocalStorage clear failed', error instanceof Error ? error : new Error(String(error)));
200
+ return false;
201
+ }
202
+ }
203
+ };
204
+ }
205
+ /**
206
+ * Creates an adapter for sessionStorage
207
+ * @returns Storage adapter for sessionStorage
208
+ */
209
+ function sessionStorageAdapter() {
210
+ return {
211
+ get(key) {
212
+ if (!isBrowser())
213
+ return null;
214
+ return sessionStorage.getItem(key);
215
+ },
216
+ set(key, value) {
217
+ if (!isBrowser())
218
+ return false;
219
+ try {
220
+ sessionStorage.setItem(key, value);
221
+ return true;
222
+ }
223
+ catch (error) {
224
+ storageLogger.error('SessionStorage set failed', error instanceof Error ? error : new Error(String(error)), {
225
+ key,
226
+ error: error instanceof Error ? error.message : String(error)
227
+ });
228
+ return false;
229
+ }
230
+ },
231
+ remove(key) {
232
+ if (!isBrowser())
233
+ return false;
234
+ try {
235
+ sessionStorage.removeItem(key);
236
+ return true;
237
+ }
238
+ catch (error) {
239
+ storageLogger.error('SessionStorage remove failed', error instanceof Error ? error : new Error(String(error)), {
240
+ key
241
+ });
242
+ return false;
243
+ }
244
+ },
245
+ clear(keyPrefix) {
246
+ if (!isBrowser())
247
+ return false;
248
+ try {
249
+ if (keyPrefix) {
250
+ // Only clear keys with the specified prefix
251
+ Object.keys(sessionStorage)
252
+ .filter(key => key.startsWith(keyPrefix))
253
+ .forEach(key => sessionStorage.removeItem(key));
254
+ }
255
+ else {
256
+ sessionStorage.clear();
257
+ }
258
+ return true;
259
+ }
260
+ catch (error) {
261
+ storageLogger.error('SessionStorage clear failed', error instanceof Error ? error : new Error(String(error)));
262
+ return false;
263
+ }
264
+ }
265
+ };
266
+ }
267
+ /**
268
+ * Creates an adapter for cookies
269
+ * @returns Storage adapter for cookies
270
+ */
271
+ function cookieAdapter() {
272
+ return {
273
+ get(key) {
274
+ if (!isBrowser())
275
+ return null;
276
+ const cookies = document.cookie.split(';');
277
+ for (let i = 0; i < cookies.length; i++) {
278
+ const cookie = cookies[i].trim();
279
+ if (cookie.startsWith(key + '=')) {
280
+ return decodeURIComponent(cookie.substring(key.length + 1));
281
+ }
282
+ }
283
+ return null;
284
+ },
285
+ set(key, value, options = {}) {
286
+ if (!isBrowser())
287
+ return false;
288
+ try {
289
+ const { secure = true, sameSite = 'strict', path = '/', domain, maxAge } = options;
290
+ let cookieString = `${key}=${encodeURIComponent(value)}`;
291
+ // Note: HttpOnly can only be set from the server, not client-side JavaScript
292
+ // This is just for documentation purposes
293
+ if (secure)
294
+ cookieString += '; Secure';
295
+ if (sameSite)
296
+ cookieString += `; SameSite=${sameSite}`;
297
+ if (path)
298
+ cookieString += `; Path=${path}`;
299
+ if (domain)
300
+ cookieString += `; Domain=${domain}`;
301
+ if (maxAge !== undefined)
302
+ cookieString += `; Max-Age=${maxAge}`;
303
+ document.cookie = cookieString;
304
+ return true;
305
+ }
306
+ catch (error) {
307
+ storageLogger.error('Cookie set failed', error instanceof Error ? error : new Error(String(error)), {
308
+ key,
309
+ error: error instanceof Error ? error.message : String(error)
310
+ });
311
+ return false;
312
+ }
313
+ },
314
+ remove(key) {
315
+ if (!isBrowser())
316
+ return false;
317
+ try {
318
+ // Set expiration to past date to remove cookie
319
+ document.cookie = `${key}=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
320
+ return true;
321
+ }
322
+ catch (error) {
323
+ storageLogger.error('Cookie remove failed', error instanceof Error ? error : new Error(String(error)), {
324
+ key
325
+ });
326
+ return false;
327
+ }
328
+ },
329
+ clear(keyPrefix) {
330
+ if (!isBrowser())
331
+ return false;
332
+ try {
333
+ const cookies = document.cookie.split(';');
334
+ for (let i = 0; i < cookies.length; i++) {
335
+ const cookie = cookies[i].trim();
336
+ const keyValue = cookie.split('=');
337
+ const cookieKey = keyValue[0];
338
+ if (!keyPrefix || cookieKey.startsWith(keyPrefix)) {
339
+ document.cookie = `${cookieKey}=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
340
+ }
341
+ }
342
+ return true;
343
+ }
344
+ catch (error) {
345
+ storageLogger.error('Cookie clear failed', error instanceof Error ? error : new Error(String(error)));
346
+ return false;
347
+ }
348
+ }
349
+ };
350
+ }
351
+ /**
352
+ * Memory storage for SSR or fallback when other mechanisms fail
353
+ */
354
+ const memoryStorage = new Map();
355
+ /**
356
+ * Creates an adapter for in-memory storage
357
+ * @returns Storage adapter for in-memory storage
358
+ */
359
+ function memoryStorageAdapter() {
360
+ return {
361
+ get(key) {
362
+ return memoryStorage.get(key) || null;
363
+ },
364
+ set(key, value) {
365
+ try {
366
+ memoryStorage.set(key, value);
367
+ return true;
368
+ }
369
+ catch (error) {
370
+ storageLogger.error('Memory storage set failed', error instanceof Error ? error : new Error(String(error)), {
371
+ key
372
+ });
373
+ return false;
374
+ }
375
+ },
376
+ remove(key) {
377
+ try {
378
+ memoryStorage.delete(key);
379
+ return true;
380
+ }
381
+ catch (error) {
382
+ storageLogger.error('Memory storage remove failed', error instanceof Error ? error : new Error(String(error)), {
383
+ key
384
+ });
385
+ return false;
386
+ }
387
+ },
388
+ clear(keyPrefix) {
389
+ try {
390
+ if (keyPrefix) {
391
+ // Only clear keys with the specified prefix
392
+ for (const key of memoryStorage.keys()) {
393
+ if (key.startsWith(keyPrefix)) {
394
+ memoryStorage.delete(key);
395
+ }
396
+ }
397
+ }
398
+ else {
399
+ memoryStorage.clear();
400
+ }
401
+ return true;
402
+ }
403
+ catch (error) {
404
+ storageLogger.error('Memory storage clear failed', error instanceof Error ? error : new Error(String(error)));
405
+ return false;
406
+ }
407
+ }
408
+ };
409
+ }
410
+ /**
411
+ * Gets an adapter for the specified storage mechanism
412
+ * @param mechanism Storage mechanism to use
413
+ * @returns Appropriate storage adapter
414
+ */
415
+ function getAdapter(mechanism) {
416
+ switch (mechanism) {
417
+ case 'localStorage':
418
+ return localStorageAdapter();
419
+ case 'sessionStorage':
420
+ return sessionStorageAdapter();
421
+ case 'cookie':
422
+ return cookieAdapter();
423
+ case 'memory':
424
+ default:
425
+ return memoryStorageAdapter();
426
+ }
427
+ }
428
+ /**
429
+ * Secure storage utility implementation
430
+ */
431
+ function createSecureStorage() {
432
+ /**
433
+ * Sets a value in secure storage (synchronous — uses async encryption internally
434
+ * but falls back gracefully for sync callers via safeSet).
435
+ * @param key Storage key
436
+ * @param value Value to store
437
+ * @param options Storage options
438
+ * @returns True if storage was successful
439
+ */
440
+ const setItem = (key, value, options = {}) => {
441
+ try {
442
+ const { mechanism = 'localStorage', namespace, encryption = { enabled: false }, ttl, cookieOptions } = options;
443
+ // Prepare full storage key
444
+ const storageKey = createStorageKey(key, namespace);
445
+ // Prepare the value with metadata (expiration, etc.)
446
+ const preparedValue = prepareValue(value, { ttl });
447
+ // For sync path, only JSON-stringify (async encryption handled in setItemAsync)
448
+ const stringifiedValue = JSON.stringify(preparedValue);
449
+ // Get the appropriate adapter
450
+ const adapter = getAdapter(mechanism);
451
+ // For cookies, handle special options
452
+ if (mechanism === 'cookie' && cookieOptions) {
453
+ return adapter.set(storageKey, stringifiedValue, {
454
+ secure: cookieOptions.secure,
455
+ sameSite: cookieOptions.sameSite,
456
+ path: cookieOptions.path,
457
+ domain: cookieOptions.domain,
458
+ maxAge: ttl
459
+ });
460
+ }
461
+ // Store using the selected adapter
462
+ return adapter.set(storageKey, stringifiedValue);
463
+ }
464
+ catch (error) {
465
+ const normalizedError = normalizeError(error, 'Failed to set storage item', {
466
+ category: 'storage',
467
+ context: { key, operation: 'setItem' }
468
+ });
469
+ storageLogger.error(`Storage set failed for key "${key}"`, normalizedError);
470
+ return false;
471
+ }
472
+ };
473
+ /**
474
+ * Sets a value in secure storage with optional AES-GCM encryption.
475
+ * @param key Storage key
476
+ * @param value Value to store
477
+ * @param options Storage options
478
+ * @returns True if storage was successful
479
+ */
480
+ const setItemAsync = async (key, value, options = {}) => {
481
+ try {
482
+ const { mechanism = 'localStorage', namespace, encryption = { enabled: false }, ttl, cookieOptions } = options;
483
+ const storageKey = createStorageKey(key, namespace);
484
+ const preparedValue = prepareValue(value, { ttl });
485
+ let stringifiedValue;
486
+ if (encryption.enabled) {
487
+ stringifiedValue = await encryptValue(preparedValue, encryption.key);
488
+ }
489
+ else {
490
+ stringifiedValue = JSON.stringify(preparedValue);
491
+ }
492
+ const adapter = getAdapter(mechanism);
493
+ if (mechanism === 'cookie' && cookieOptions) {
494
+ return adapter.set(storageKey, stringifiedValue, {
495
+ secure: cookieOptions.secure,
496
+ sameSite: cookieOptions.sameSite,
497
+ path: cookieOptions.path,
498
+ domain: cookieOptions.domain,
499
+ maxAge: ttl
500
+ });
501
+ }
502
+ return adapter.set(storageKey, stringifiedValue);
503
+ }
504
+ catch (error) {
505
+ const normalizedError = normalizeError(error, 'Failed to set storage item', {
506
+ category: 'storage',
507
+ context: { key, operation: 'setItemAsync' }
508
+ });
509
+ storageLogger.error(`Storage set failed for key "${key}"`, normalizedError);
510
+ return false;
511
+ }
512
+ };
513
+ /**
514
+ * Gets a value from secure storage (synchronous — no decryption support).
515
+ * For encrypted values use getItemAsync instead.
516
+ * @param key Storage key
517
+ * @param options Storage options
518
+ * @returns The stored value, or null if not found or expired
519
+ */
520
+ const getItem = (key, options = {}) => {
521
+ try {
522
+ const { mechanism = 'localStorage', namespace, fallbackMechanisms = [] } = options;
523
+ const storageKey = createStorageKey(key, namespace);
524
+ const adapter = getAdapter(mechanism);
525
+ let rawValue = adapter.get(storageKey);
526
+ if (rawValue === null && fallbackMechanisms.length > 0) {
527
+ for (const fallbackMechanism of fallbackMechanisms) {
528
+ const fallbackAdapter = getAdapter(fallbackMechanism);
529
+ rawValue = fallbackAdapter.get(storageKey);
530
+ if (rawValue !== null) {
531
+ storageLogger.info(`Retrieved value from fallback mechanism: ${fallbackMechanism}`, {
532
+ key, primaryMechanism: mechanism, fallbackMechanism
533
+ });
534
+ break;
535
+ }
536
+ }
537
+ }
538
+ if (rawValue === null)
539
+ return null;
540
+ let storageValue;
541
+ try {
542
+ storageValue = JSON.parse(rawValue);
543
+ }
544
+ catch (error) {
545
+ storageLogger.warn(`Failed to parse stored value for key "${key}"`, {
546
+ key, error: error instanceof Error ? error.message : String(error)
547
+ });
548
+ adapter.remove(storageKey);
549
+ return null;
550
+ }
551
+ if (isExpired(storageValue)) {
552
+ storageLogger.info(`Expired value removed for key "${key}"`, {
553
+ key, expiresAt: new Date(storageValue.expiresAt).toISOString()
554
+ });
555
+ adapter.remove(storageKey);
556
+ return null;
557
+ }
558
+ return storageValue.value;
559
+ }
560
+ catch (error) {
561
+ const normalizedError = normalizeError(error, 'Failed to get storage item', {
562
+ category: 'storage',
563
+ context: { key, operation: 'getItem' }
564
+ });
565
+ storageLogger.error(`Storage get failed for key "${key}"`, normalizedError);
566
+ return null;
567
+ }
568
+ };
569
+ /**
570
+ * Gets a value from secure storage with optional AES-GCM decryption.
571
+ * @param key Storage key
572
+ * @param options Storage options
573
+ * @returns The stored value, or null if not found or expired
574
+ */
575
+ const getItemAsync = async (key, options = {}) => {
576
+ try {
577
+ const { mechanism = 'localStorage', namespace, encryption = { enabled: false }, fallbackMechanisms = [] } = options;
578
+ const storageKey = createStorageKey(key, namespace);
579
+ const adapter = getAdapter(mechanism);
580
+ let rawValue = adapter.get(storageKey);
581
+ if (rawValue === null && fallbackMechanisms.length > 0) {
582
+ for (const fallbackMechanism of fallbackMechanisms) {
583
+ const fallbackAdapter = getAdapter(fallbackMechanism);
584
+ rawValue = fallbackAdapter.get(storageKey);
585
+ if (rawValue !== null) {
586
+ storageLogger.info(`Retrieved value from fallback mechanism: ${fallbackMechanism}`, {
587
+ key, primaryMechanism: mechanism, fallbackMechanism
588
+ });
589
+ break;
590
+ }
591
+ }
592
+ }
593
+ if (rawValue === null)
594
+ return null;
595
+ let storageValue;
596
+ try {
597
+ if (encryption.enabled) {
598
+ storageValue = await decryptValue(rawValue, encryption.key);
599
+ }
600
+ else {
601
+ storageValue = JSON.parse(rawValue);
602
+ }
603
+ }
604
+ catch (error) {
605
+ storageLogger.warn(`Failed to parse stored value for key "${key}"`, {
606
+ key, error: error instanceof Error ? error.message : String(error)
607
+ });
608
+ adapter.remove(storageKey);
609
+ return null;
610
+ }
611
+ if (isExpired(storageValue)) {
612
+ storageLogger.info(`Expired value removed for key "${key}"`, {
613
+ key, expiresAt: new Date(storageValue.expiresAt).toISOString()
614
+ });
615
+ adapter.remove(storageKey);
616
+ return null;
617
+ }
618
+ return storageValue.value;
619
+ }
620
+ catch (error) {
621
+ const normalizedError = normalizeError(error, 'Failed to get storage item', {
622
+ category: 'storage',
623
+ context: { key, operation: 'getItemAsync' }
624
+ });
625
+ storageLogger.error(`Storage get failed for key "${key}"`, normalizedError);
626
+ return null;
627
+ }
628
+ };
629
+ /**
630
+ * Removes an item from secure storage
631
+ * @param key Storage key
632
+ * @param options Storage options
633
+ * @returns True if removal was successful
634
+ */
635
+ const removeItem = (key, options = {}) => {
636
+ try {
637
+ const { mechanism = 'localStorage', namespace, allMechanisms = false } = options;
638
+ // Prepare full storage key
639
+ const storageKey = createStorageKey(key, namespace);
640
+ if (allMechanisms) {
641
+ // Remove from all storage mechanisms
642
+ let success = true;
643
+ const mechanisms = ['localStorage', 'sessionStorage', 'cookie', 'memory'];
644
+ for (const mech of mechanisms) {
645
+ const adapter = getAdapter(mech);
646
+ const result = adapter.remove(storageKey);
647
+ // Track overall success
648
+ success = success && result;
649
+ }
650
+ return success;
651
+ }
652
+ else {
653
+ // Remove only from specified mechanism
654
+ const adapter = getAdapter(mechanism);
655
+ return adapter.remove(storageKey);
656
+ }
657
+ }
658
+ catch (error) {
659
+ const normalizedError = normalizeError(error, 'Failed to remove storage item', {
660
+ category: 'storage',
661
+ context: { key, operation: 'removeItem' }
662
+ });
663
+ storageLogger.error(`Storage remove failed for key "${key}"`, normalizedError);
664
+ return false;
665
+ }
666
+ };
667
+ /**
668
+ * Clears secure storage
669
+ * @param options Storage options
670
+ * @returns True if clear was successful
671
+ */
672
+ const clear = (options = {}) => {
673
+ try {
674
+ const { mechanism = 'localStorage', namespace, allMechanisms = false } = options;
675
+ // Prepare namespace prefix if needed
676
+ const keyPrefix = namespace
677
+ ? `${STORAGE_PREFIX}_${namespace}_`
678
+ : STORAGE_PREFIX;
679
+ if (allMechanisms) {
680
+ // Clear all storage mechanisms
681
+ let success = true;
682
+ const mechanisms = ['localStorage', 'sessionStorage', 'cookie', 'memory'];
683
+ for (const mech of mechanisms) {
684
+ const adapter = getAdapter(mech);
685
+ const result = adapter.clear(keyPrefix);
686
+ // Track overall success
687
+ success = success && result;
688
+ }
689
+ return success;
690
+ }
691
+ else {
692
+ // Clear only specified mechanism
693
+ const adapter = getAdapter(mechanism);
694
+ return adapter.clear(keyPrefix);
695
+ }
696
+ }
697
+ catch (error) {
698
+ const normalizedError = normalizeError(error, 'Failed to clear storage', {
699
+ category: 'storage',
700
+ context: { operation: 'clear' }
701
+ });
702
+ storageLogger.error('Storage clear failed', normalizedError);
703
+ return false;
704
+ }
705
+ };
706
+ /**
707
+ * Safely attempts to store a value and handles errors
708
+ * @param key Storage key
709
+ * @param value Value to store
710
+ * @param options Storage options
711
+ * @returns True if storage was successful
712
+ */
713
+ const safeSet = async (key, value, options = {}) => {
714
+ const timerLabel = `secureStorage_set_${key}`;
715
+ const timerId = storageLogger.startTimer(timerLabel);
716
+ try {
717
+ const result = setItem(key, value, options);
718
+ if (!result && options.fallbackMechanisms && options.fallbackMechanisms.length > 0) {
719
+ // Try fallback mechanisms if primary fails
720
+ for (const fallbackMechanism of options.fallbackMechanisms) {
721
+ storageLogger.info(`Trying fallback mechanism for set: ${fallbackMechanism}`, {
722
+ key,
723
+ primaryMechanism: options.mechanism,
724
+ fallbackMechanism
725
+ });
726
+ const fallbackResult = setItem(key, value, {
727
+ ...options,
728
+ mechanism: fallbackMechanism
729
+ });
730
+ if (fallbackResult) {
731
+ storageLogger.info(`Successfully set using fallback mechanism: ${fallbackMechanism}`, {
732
+ key
733
+ });
734
+ return true;
735
+ }
736
+ }
737
+ }
738
+ return result;
739
+ }
740
+ catch (error) {
741
+ handleError(error, { key, operation: 'safeSet' });
742
+ return false;
743
+ }
744
+ finally {
745
+ storageLogger.endTimer(timerId);
746
+ }
747
+ };
748
+ /**
749
+ * Safely attempts to retrieve a value and handles errors
750
+ * @param key Storage key
751
+ * @param options Storage options
752
+ * @returns The stored value or null if not found or error
753
+ */
754
+ const safeGet = async (key, options = {}) => {
755
+ const result = await tryCatch(async () => {
756
+ return getItem(key, options);
757
+ });
758
+ // Return null if tryCatch returns undefined (on error)
759
+ return result ?? null;
760
+ };
761
+ /**
762
+ * Safely attempts to remove a value and handles errors
763
+ * @param key Storage key
764
+ * @param options Storage options
765
+ * @returns True if removal was successful
766
+ */
767
+ const safeRemove = async (key, options = {}) => {
768
+ const result = await tryCatch(async () => {
769
+ return removeItem(key, options);
770
+ }, () => false);
771
+ // Return false if tryCatch returns undefined (should never happen due to the errorHandler)
772
+ return result === true;
773
+ };
774
+ /**
775
+ * Safely attempts to clear storage and handles errors
776
+ * @param options Storage options
777
+ * @returns True if clear was successful
778
+ */
779
+ const safeClear = async (options = {}) => {
780
+ const result = await tryCatch(async () => {
781
+ return clear(options);
782
+ }, () => false);
783
+ // Return false if tryCatch returns undefined (should never happen due to the errorHandler)
784
+ return result === true;
785
+ };
786
+ return {
787
+ setItem,
788
+ setItemAsync,
789
+ getItem,
790
+ getItemAsync,
791
+ removeItem,
792
+ clear,
793
+ safeSet,
794
+ safeGet,
795
+ safeRemove,
796
+ safeClear
797
+ };
798
+ }
799
+ // Export singleton instance
800
+ export const secureStorage = createSecureStorage();
801
+ //# sourceMappingURL=secure-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secure-storage.js","sourceRoot":"","sources":["../../src/utils/secure-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAS5F,gCAAgC;AAChC,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;AAEjE;;;GAGG;AACH,SAAS,SAAS;IAChB,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,GAAW,EAAE,SAAkB;IACvD,MAAM,MAAM,GAAG,cAAc,CAAC;IAC9B,OAAO,SAAS;QACd,CAAC,CAAC,GAAG,MAAM,IA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AAM,QAAQ,CAAC,KAAK,IAAI,EAAE;YACvC,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QAEhB,2FAA2F;QAC3F,OAAO,MAAM,KAAK,IAAI,CAAC;IACzB,CAAC,CAAC;IAEF;;;;OAIG;IACH,MAAM,SAAS,GAAG,KAAK,EAAE,UAIrB,EAAE,EAAoB,EAAE;QAC1B,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,KAAK,IAAI,EAAE;YACvC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QAEhB,2FAA2F;QAC3F,OAAO,MAAM,KAAK,IAAI,CAAC;IACzB,CAAC,CAAC;IAEF,OAAO;QACL,OAAO;QACP,YAAY;QACZ,OAAO;QACP,YAAY;QACZ,UAAU;QACV,KAAK;QACL,OAAO;QACP,OAAO;QACP,UAAU;QACV,SAAS;KACV,CAAC;AACJ,CAAC;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@xbg.solutions/bpsk-utils-secure-storage",
3
+ "version": "1.2.3",
4
+ "description": "XBG Secure Storage - Encrypted client-side storage with key derivation",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "type": "module",
8
+ "files": ["lib"],
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "build:watch": "tsc --watch",
12
+ "clean": "rm -rf lib",
13
+ "prepublishOnly": "npm run build"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "dependencies": {
19
+ "@xbg.solutions/bpsk-core": "^1.0.0"
20
+ },
21
+ "peerDependencies": {
22
+ "svelte": "^5.0.0"
23
+ }
24
+ }