@bantis/local-cipher 2.1.0 → 2.3.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/README.md CHANGED
@@ -1,7 +1,90 @@
1
1
  # @bantis/local-cipher
2
+ <p align="center">
3
+ <a href="https://badge.fury.io/js/@bantis%2Flocal-cipher"><img src="https://badge.fury.io/js/@bantis%2Flocal-cipher.svg" alt="npm version"></a>
4
+ <img src="https://img.shields.io/npm/dm/@bantis/local-cipher.svg" alt="npm downloads">
5
+ <img src="https://img.shields.io/bundlephobia/minzip/@bantis/local-cipher.svg" alt="bundle size">
6
+ <img src="https://img.shields.io/npm/l/@bantis/local-cipher.svg" alt="license">
7
+ </p>
2
8
 
3
- [![npm version](https://img.shields.io/npm/v/@bantis/local-cipher.svg)](https://www.npmjs.com/package/@bantis/local-cipher)
4
- [![npm downloads](https://img.shields.io/npm/dm/@bantis/local-cipher.svg)](https://www.npmjs.com/package/@bantis/local-cipher)
9
+ ## Storage Manager & Cookies Update (v2.2.0+) 🚀
10
+
11
+ `@bantis/local-cipher` now includes powerful built-in managers for `sessionStorage`, `localStorage`, and `Cookies`. It acts as a comprehensive manager that supports Plaintext (unencrypted) or Encrypted storage modes instantly out of the box.
12
+
13
+ ### Quick Unencrypted Storage
14
+
15
+ ```typescript
16
+ import { localStore, sessionStore, cookies } from '@bantis/local-cipher';
17
+
18
+ // Local / Session Storage
19
+ await localStore.set('myKey', { user: 'admin' });
20
+ const user = await localStore.get('myKey');
21
+ localStore.remove('myKey');
22
+
23
+ // Easy cookies with domain and expiration options
24
+ await cookies.set('tracker', 'tracker123', { expires: new Date(Date.now() + 86400000) });
25
+ ```
26
+
27
+ ### Encrypted Managers Setup
28
+
29
+ If you need encryption, instantiate the managers with your secret key. The wrapper ensures identical APIs but powered by Web Crypto API.
30
+
31
+ ```typescript
32
+ import { createEncryptedStorage, createEncryptedCookieManager } from '@bantis/local-cipher';
33
+
34
+ const secureStore = createEncryptedStorage('sessionStorage', 'super-secret-key');
35
+ await secureStore.set('authToken', 'ey...');
36
+
37
+ const secureCookies = createEncryptedCookieManager('super-secret-key', '.yourdomain.com');
38
+ await secureCookies.set('session_id', 'hash-value', {
39
+ domain: '.yourdomain.com', // Shareable across subdomains!
40
+ expires: 30
41
+ });
42
+ ```
43
+
44
+ ---
45
+
46
+ ## React & Angular Integrations
47
+
48
+ We provide first-class support for modern frontend frameworks.
49
+
50
+ ### React
51
+
52
+ ```typescript
53
+ import { useLocalStore } from '@bantis/local-cipher/react';
54
+
55
+ function MyComponent() {
56
+ // Syncs seamlessly with localStorage
57
+ const [theme, setTheme] = useLocalStore('theme', 'dark');
58
+
59
+ return <button onClick={() => setTheme('light')}>Set Light</button>;
60
+ }
61
+ ```
62
+
63
+ ### Angular
64
+
65
+ ```typescript
66
+ import { StorageService } from '@bantis/local-cipher/angular';
67
+
68
+ @Injectable({ providedIn: 'root' })
69
+ export class AuthService {
70
+ constructor(private storage: StorageService) {}
71
+
72
+ async saveToken(token: string) {
73
+ // Use plain...
74
+ await this.storage.local.set('token', token);
75
+
76
+ // Or create encrypted cookie!
77
+ const secureCookie = this.storage.createEncryptedCookieManager('secret');
78
+ // Set cookie token!
79
+ }
80
+ }
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Advanced Usage & Manual Configuration 🛠️
86
+
87
+ For complete control over storage limits, compression, and encryption events, you can manually instantiate `SecureStorage` as shown below.
5
88
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
89
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue)](https://www.typescriptlang.org/)
7
90
 
@@ -23,7 +23,7 @@ export declare class SecureStorageService {
23
23
  /**
24
24
  * Observable de eventos de storage
25
25
  */
26
- events$: any;
26
+ events$: Observable<StorageEventData>;
27
27
  constructor(config?: SecureStorageConfig);
28
28
  /**
29
29
  * Guarda un valor encriptado
@@ -0,0 +1,22 @@
1
+ import { SecureStorage } from '../core/SecureStorage';
2
+ import { SecureCookie } from '../core/SecureCookie';
3
+ export declare class StorageService {
4
+ /** Acceso directo a localStorage sin cifrar */
5
+ local: import("../managers").PlainStorage;
6
+ /** Acceso directo a sessionStorage sin cifrar */
7
+ session: import("../managers").PlainStorage;
8
+ /** Acceso directo a cookies sin cifrar */
9
+ cookies: import("../managers").PlainCookie;
10
+ /**
11
+ * Crea una instancia de almacenamiento sincronizado y cifrado
12
+ * @param engine local o session storage
13
+ * @param secretKey Llave de cifrado
14
+ */
15
+ createEncryptedStorage(engine: 'localStorage' | 'sessionStorage', secretKey: string): SecureStorage;
16
+ /**
17
+ * Crea un gestor de cookies cifradas
18
+ * @param secretKey Llave de cifrado
19
+ * @param domain Configuración de subdominios
20
+ */
21
+ createEncryptedCookieManager(secretKey: string, domain?: string): SecureCookie;
22
+ }
package/dist/angular.d.ts CHANGED
@@ -7,3 +7,4 @@
7
7
  */
8
8
  export * from './index';
9
9
  export { SecureStorageService } from './angular/SecureStorageService';
10
+ export { StorageService } from './angular/StorageService';