@pathscale/secure-local-storage-chacha20-poly1305 1.0.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/dist/index.js ADDED
@@ -0,0 +1,656 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var chacha_js = require('@noble/ciphers/chacha.js');
6
+ var utils_js = require('@noble/ciphers/utils.js');
7
+ var pbkdf2_js = require('@noble/hashes/pbkdf2.js');
8
+ var sha2_js = require('@noble/hashes/sha2.js');
9
+
10
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
11
+ /**
12
+ * Browser fingerprinting utility for generating unique browser identifiers
13
+ */
14
+ class BrowserFingerprinting {
15
+ constructor(disabledKeys = []) {
16
+ this.disabledKeys = new Set(disabledKeys);
17
+ }
18
+ /**
19
+ * Generate a comprehensive browser fingerprint
20
+ */
21
+ generateFingerprint() {
22
+ return {
23
+ userAgent: this.isEnabled('UserAgent') ? this.getUserAgent() : '',
24
+ screenPrint: this.isEnabled('ScreenPrint') ? this.getScreenPrint() : '',
25
+ plugins: this.isEnabled('Plugins') ? this.getPlugins() : '',
26
+ fonts: this.isEnabled('Fonts') ? this.getFonts() : '',
27
+ localStorage: this.isEnabled('LocalStorage') ? this.hasLocalStorage() : false,
28
+ sessionStorage: this.isEnabled('SessionStorage') ? this.hasSessionStorage() : false,
29
+ timeZone: this.isEnabled('TimeZone') ? this.getTimeZone() : '',
30
+ language: this.isEnabled('Language') ? this.getLanguage() : '',
31
+ systemLanguage: this.isEnabled('SystemLanguage') ? this.getSystemLanguage() : '',
32
+ cookie: this.isEnabled('Cookie') ? this.hasCookieSupport() : false,
33
+ canvas: this.isEnabled('Canvas') ? this.getCanvasFingerprint() : '',
34
+ hostname: this.isEnabled('Hostname') ? this.getHostname() : '',
35
+ };
36
+ }
37
+ /**
38
+ * Convert fingerprint to a hash string
39
+ */
40
+ fingerprintToString(fingerprint) {
41
+ return Object.values(fingerprint)
42
+ .map(value => String(value))
43
+ .join('|');
44
+ }
45
+ isEnabled(property) {
46
+ return !this.disabledKeys.has(property);
47
+ }
48
+ getUserAgent() {
49
+ return typeof navigator !== 'undefined' ? navigator.userAgent : '';
50
+ }
51
+ getScreenPrint() {
52
+ if (typeof screen === 'undefined')
53
+ return '';
54
+ return `${screen.width}x${screen.height}x${screen.colorDepth}`;
55
+ }
56
+ getPlugins() {
57
+ if (typeof navigator === 'undefined' || !navigator.plugins)
58
+ return '';
59
+ const plugins = Array.from(navigator.plugins)
60
+ .map(plugin => plugin.name)
61
+ .sort()
62
+ .join(',');
63
+ return plugins;
64
+ }
65
+ getFonts() {
66
+ // Basic font detection using canvas
67
+ if (typeof document === 'undefined')
68
+ return '';
69
+ const fonts = [
70
+ 'Arial', 'Helvetica', 'Times New Roman', 'Times', 'Courier New', 'Courier',
71
+ 'Verdana', 'Georgia', 'Palatino', 'Garamond', 'Bookman', 'Comic Sans MS',
72
+ 'Trebuchet MS', 'Arial Black', 'Impact', 'Sans-serif', 'Serif', 'Monospace'
73
+ ];
74
+ const availableFonts = [];
75
+ const canvas = document.createElement('canvas');
76
+ const context = canvas.getContext('2d');
77
+ if (!context)
78
+ return '';
79
+ fonts.forEach(font => {
80
+ context.font = `12px ${font}, monospace`;
81
+ const width1 = context.measureText('mmmmmmmmmmlli').width;
82
+ context.font = `12px ${font}, sans-serif`;
83
+ const width2 = context.measureText('mmmmmmmmmmlli').width;
84
+ if (width1 !== width2) {
85
+ availableFonts.push(font);
86
+ }
87
+ });
88
+ return availableFonts.join(',');
89
+ }
90
+ hasLocalStorage() {
91
+ try {
92
+ return typeof localStorage !== 'undefined';
93
+ }
94
+ catch {
95
+ return false;
96
+ }
97
+ }
98
+ hasSessionStorage() {
99
+ try {
100
+ return typeof sessionStorage !== 'undefined';
101
+ }
102
+ catch {
103
+ return false;
104
+ }
105
+ }
106
+ getTimeZone() {
107
+ try {
108
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
109
+ }
110
+ catch {
111
+ return new Date().getTimezoneOffset().toString();
112
+ }
113
+ }
114
+ getLanguage() {
115
+ if (typeof navigator === 'undefined')
116
+ return '';
117
+ return navigator.language || '';
118
+ }
119
+ getSystemLanguage() {
120
+ if (typeof navigator === 'undefined')
121
+ return '';
122
+ const extendedNavigator = navigator;
123
+ return extendedNavigator.systemLanguage || navigator.language || '';
124
+ }
125
+ hasCookieSupport() {
126
+ if (typeof document === 'undefined')
127
+ return false;
128
+ return navigator.cookieEnabled;
129
+ }
130
+ getCanvasFingerprint() {
131
+ if (typeof document === 'undefined')
132
+ return '';
133
+ try {
134
+ const canvas = document.createElement('canvas');
135
+ const ctx = canvas.getContext('2d');
136
+ if (!ctx)
137
+ return '';
138
+ // Draw some text and shapes to create a unique canvas fingerprint
139
+ ctx.textBaseline = 'top';
140
+ ctx.font = '14px Arial';
141
+ ctx.fillStyle = '#f60';
142
+ ctx.fillRect(125, 1, 62, 20);
143
+ ctx.fillStyle = '#069';
144
+ ctx.fillText('SecureStorage 🔒', 2, 15);
145
+ ctx.fillStyle = 'rgba(102, 204, 0, 0.7)';
146
+ ctx.fillText('SecureStorage 🔒', 4, 17);
147
+ return canvas.toDataURL();
148
+ }
149
+ catch {
150
+ return '';
151
+ }
152
+ }
153
+ getHostname() {
154
+ if (typeof location === 'undefined')
155
+ return '';
156
+ return location.hostname;
157
+ }
158
+ }
159
+
160
+ const ALGORITHM = 'ChaCha20-Poly1305';
161
+ const KEY_BYTES = 32;
162
+ const NONCE_BYTES = 12;
163
+ const PBKDF2_ITERATIONS = 1000;
164
+ const PBKDF2_SALT = 'secure-local-storage-salt';
165
+ /**
166
+ * Encryption utility for secure data storage
167
+ */
168
+ class EncryptionManager {
169
+ constructor(secretKey) {
170
+ this.version = '2.0.0';
171
+ this.textEncoder = new TextEncoder();
172
+ this.textDecoder = new TextDecoder();
173
+ this.secretKey = this.deriveKey(secretKey);
174
+ }
175
+ /**
176
+ * Update the secret key
177
+ */
178
+ updateSecretKey(newSecretKey) {
179
+ this.secretKey.fill(0);
180
+ this.secretKey = this.deriveKey(newSecretKey);
181
+ }
182
+ /**
183
+ * Encrypt data with type preservation
184
+ */
185
+ encrypt(data) {
186
+ const item = {
187
+ data: this.serializeData(data),
188
+ type: this.getDataType(data),
189
+ timestamp: Date.now(),
190
+ version: this.version,
191
+ };
192
+ const serialized = JSON.stringify(item);
193
+ const nonce = utils_js.randomBytes(NONCE_BYTES);
194
+ const plaintext = this.textEncoder.encode(serialized);
195
+ const ciphertext = chacha_js.chacha20poly1305(this.secretKey, nonce).encrypt(plaintext);
196
+ const envelope = {
197
+ algorithm: ALGORITHM,
198
+ nonce: this.encodeBase64(nonce),
199
+ ciphertext: this.encodeBase64(ciphertext),
200
+ version: this.version,
201
+ };
202
+ return JSON.stringify(envelope);
203
+ }
204
+ /**
205
+ * Decrypt data with type restoration
206
+ */
207
+ decrypt(encryptedData) {
208
+ try {
209
+ const envelope = JSON.parse(encryptedData);
210
+ if (!this.isChachaEnvelope(envelope)) {
211
+ throw new Error('Unsupported encrypted data format');
212
+ }
213
+ const nonce = this.decodeBase64(envelope.nonce);
214
+ const ciphertext = this.decodeBase64(envelope.ciphertext);
215
+ const plaintext = chacha_js.chacha20poly1305(this.secretKey, nonce).decrypt(ciphertext);
216
+ const decryptedText = this.textDecoder.decode(plaintext);
217
+ const item = JSON.parse(decryptedText);
218
+ return this.deserializeData(item.data, item.type);
219
+ }
220
+ catch (error) {
221
+ console.warn('Failed to decrypt data:', error);
222
+ return null;
223
+ }
224
+ }
225
+ /**
226
+ * Validate if data was encrypted with this library
227
+ */
228
+ isValidEncryptedData(encryptedData) {
229
+ try {
230
+ const envelope = JSON.parse(encryptedData);
231
+ if (!this.isChachaEnvelope(envelope))
232
+ return false;
233
+ const plaintext = chacha_js.chacha20poly1305(this.secretKey, this.decodeBase64(envelope.nonce)).decrypt(this.decodeBase64(envelope.ciphertext));
234
+ const item = JSON.parse(this.textDecoder.decode(plaintext));
235
+ return item && typeof item.data !== 'undefined' && typeof item.type === 'string';
236
+ }
237
+ catch {
238
+ return false;
239
+ }
240
+ }
241
+ deriveKey(key) {
242
+ return pbkdf2_js.pbkdf2(sha2_js.sha256, key, PBKDF2_SALT, {
243
+ c: PBKDF2_ITERATIONS,
244
+ dkLen: KEY_BYTES,
245
+ });
246
+ }
247
+ serializeData(data) {
248
+ if (data === null || data === undefined) {
249
+ return '';
250
+ }
251
+ if (typeof data === 'object') {
252
+ return JSON.stringify(data);
253
+ }
254
+ return String(data);
255
+ }
256
+ deserializeData(serializedData, type) {
257
+ if (type === 'null' || serializedData === '') {
258
+ return null;
259
+ }
260
+ switch (type) {
261
+ case 'string':
262
+ return serializedData;
263
+ case 'number':
264
+ return Number(serializedData);
265
+ case 'boolean':
266
+ return serializedData === 'true';
267
+ case 'object':
268
+ try {
269
+ return JSON.parse(serializedData);
270
+ }
271
+ catch {
272
+ return null;
273
+ }
274
+ default:
275
+ return serializedData;
276
+ }
277
+ }
278
+ getDataType(data) {
279
+ if (data === null)
280
+ return 'null';
281
+ if (typeof data === 'object')
282
+ return 'object';
283
+ return typeof data;
284
+ }
285
+ isChachaEnvelope(value) {
286
+ if (!value || typeof value !== 'object')
287
+ return false;
288
+ const envelope = value;
289
+ return (envelope.algorithm === ALGORITHM &&
290
+ typeof envelope.nonce === 'string' &&
291
+ typeof envelope.ciphertext === 'string' &&
292
+ typeof envelope.version === 'string');
293
+ }
294
+ encodeBase64(bytes) {
295
+ if (typeof btoa === 'function') {
296
+ let binary = '';
297
+ const chunkSize = 0x8000;
298
+ for (let index = 0; index < bytes.length; index += chunkSize) {
299
+ binary += String.fromCharCode(...Array.from(bytes.subarray(index, index + chunkSize)));
300
+ }
301
+ return btoa(binary);
302
+ }
303
+ const buffer = this.getGlobalBuffer();
304
+ if (buffer)
305
+ return buffer.from(bytes).toString('base64');
306
+ throw new Error('No base64 encoder available');
307
+ }
308
+ decodeBase64(value) {
309
+ if (typeof atob === 'function') {
310
+ const binary = atob(value);
311
+ const bytes = new Uint8Array(binary.length);
312
+ for (let index = 0; index < binary.length; index += 1) {
313
+ bytes[index] = binary.charCodeAt(index);
314
+ }
315
+ return bytes;
316
+ }
317
+ const buffer = this.getGlobalBuffer();
318
+ if (buffer)
319
+ return Uint8Array.from(buffer.from(value, 'base64'));
320
+ throw new Error('No base64 decoder available');
321
+ }
322
+ getGlobalBuffer() {
323
+ return globalThis.Buffer;
324
+ }
325
+ }
326
+
327
+ /**
328
+ * Environment configuration manager for different frameworks
329
+ */
330
+ class EnvironmentManager {
331
+ constructor() {
332
+ this.config = this.loadEnvironmentVariables();
333
+ }
334
+ /**
335
+ * Get configuration from environment variables
336
+ */
337
+ getConfig() {
338
+ const hashKey = this.getHashKey();
339
+ const prefix = this.getPrefix();
340
+ const disabledKeys = this.getDisabledKeys();
341
+ const config = {
342
+ disabledKeys,
343
+ debug: false,
344
+ };
345
+ if (hashKey)
346
+ config.hashKey = hashKey;
347
+ if (prefix)
348
+ config.prefix = prefix;
349
+ return config;
350
+ }
351
+ loadEnvironmentVariables() {
352
+ // Handle different environments with proper typing
353
+ const globalProcess = globalThis.process;
354
+ if (typeof globalProcess !== 'undefined' && globalProcess.env) {
355
+ return globalProcess.env;
356
+ }
357
+ // Handle Vite environment
358
+ const importMeta = ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) });
359
+ if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)) }) !== 'undefined' && importMeta.env) {
360
+ return importMeta.env;
361
+ }
362
+ // Handle browser environment with injected variables
363
+ const globalWindow = window;
364
+ if (typeof window !== 'undefined' && globalWindow.__ENV__) {
365
+ return globalWindow.__ENV__;
366
+ }
367
+ return {};
368
+ }
369
+ getHashKey() {
370
+ return (this.config.REACT_APP_SECURE_LOCAL_STORAGE_HASH_KEY ||
371
+ this.config.VITE_SECURE_LOCAL_STORAGE_HASH_KEY ||
372
+ this.config.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_HASH_KEY ||
373
+ this.config.SECURE_LOCAL_STORAGE_HASH_KEY);
374
+ }
375
+ getPrefix() {
376
+ return (this.config.REACT_APP_SECURE_LOCAL_STORAGE_PREFIX ||
377
+ this.config.VITE_SECURE_LOCAL_STORAGE_PREFIX ||
378
+ this.config.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_PREFIX ||
379
+ this.config.SECURE_LOCAL_STORAGE_PREFIX);
380
+ }
381
+ getDisabledKeys() {
382
+ const disabledKeysStr = this.config.REACT_APP_SECURE_LOCAL_STORAGE_DISABLED_KEYS ||
383
+ this.config.VITE_SECURE_LOCAL_STORAGE_DISABLED_KEYS ||
384
+ this.config.NEXT_PUBLIC_SECURE_LOCAL_STORAGE_DISABLED_KEYS ||
385
+ this.config.SECURE_LOCAL_STORAGE_DISABLED_KEYS;
386
+ if (!disabledKeysStr)
387
+ return [];
388
+ return disabledKeysStr
389
+ .split('|')
390
+ .filter(key => key.trim())
391
+ .map(key => key.trim());
392
+ }
393
+ }
394
+
395
+ /**
396
+ * Secure Local Storage - A secure, encrypted local storage with browser fingerprinting
397
+ */
398
+ class SecureLocalStorage {
399
+ constructor(config = {}) {
400
+ this.isInitialized = false;
401
+ this.environment = new EnvironmentManager();
402
+ const envConfig = this.environment.getConfig();
403
+ // Merge environment config with provided config
404
+ this.config = {
405
+ hashKey: config.hashKey || envConfig.hashKey || this.generateDefaultHashKey(),
406
+ prefix: config.prefix || envConfig.prefix || 'sls_',
407
+ disabledKeys: config.disabledKeys || envConfig.disabledKeys || [],
408
+ debug: config.debug || envConfig.debug || false,
409
+ };
410
+ this.fingerprinting = new BrowserFingerprinting(this.config.disabledKeys);
411
+ this.storageEngine = this.getStorageEngine();
412
+ this.prefix = this.config.prefix || 'sls_';
413
+ this.memoryCache = new Map();
414
+ const secretKey = this.generateSecretKey();
415
+ this.encryption = new EncryptionManager(secretKey);
416
+ this.isInitialized = true;
417
+ this.initializeFromStorage();
418
+ if (this.config.debug) {
419
+ console.log('SecureLocalStorage initialized with config:', this.config);
420
+ }
421
+ }
422
+ /**
423
+ * Get the singleton instance
424
+ */
425
+ static getInstance(config) {
426
+ if (!SecureLocalStorage.instance) {
427
+ SecureLocalStorage.instance = new SecureLocalStorage(config);
428
+ }
429
+ return SecureLocalStorage.instance;
430
+ }
431
+ /**
432
+ * Set an item in secure storage
433
+ */
434
+ setItem(key, value) {
435
+ if (!this.isInitialized) {
436
+ throw new Error('SecureLocalStorage is not initialized');
437
+ }
438
+ try {
439
+ const encryptedValue = this.encryption.encrypt(value);
440
+ const storageKey = this.getStorageKey(key);
441
+ this.storageEngine.setItem(storageKey, encryptedValue);
442
+ this.memoryCache.set(key, value);
443
+ if (this.config.debug) {
444
+ console.log(`Set item: ${key}`, value);
445
+ }
446
+ }
447
+ catch (error) {
448
+ console.error('Failed to set item:', error);
449
+ throw new Error(`Failed to set item: ${key}`);
450
+ }
451
+ }
452
+ /**
453
+ * Get an item from secure storage
454
+ */
455
+ getItem(key) {
456
+ if (!this.isInitialized) {
457
+ throw new Error('SecureLocalStorage is not initialized');
458
+ }
459
+ // First check memory cache for performance
460
+ if (this.memoryCache.has(key)) {
461
+ const value = this.memoryCache.get(key);
462
+ if (this.config.debug) {
463
+ console.log(`Get item from cache: ${key}`, value);
464
+ }
465
+ return value !== undefined ? value : null;
466
+ }
467
+ try {
468
+ const storageKey = this.getStorageKey(key);
469
+ const encryptedValue = this.storageEngine.getItem(storageKey);
470
+ if (!encryptedValue) {
471
+ return null;
472
+ }
473
+ const decryptedValue = this.encryption.decrypt(encryptedValue);
474
+ this.memoryCache.set(key, decryptedValue);
475
+ if (this.config.debug) {
476
+ console.log(`Get item from storage: ${key}`, decryptedValue);
477
+ }
478
+ return decryptedValue;
479
+ }
480
+ catch (error) {
481
+ console.error('Failed to get item:', error);
482
+ return null;
483
+ }
484
+ }
485
+ /**
486
+ * Remove an item from secure storage
487
+ */
488
+ removeItem(key) {
489
+ if (!this.isInitialized) {
490
+ throw new Error('SecureLocalStorage is not initialized');
491
+ }
492
+ try {
493
+ const storageKey = this.getStorageKey(key);
494
+ this.storageEngine.removeItem(storageKey);
495
+ this.memoryCache.delete(key);
496
+ if (this.config.debug) {
497
+ console.log(`Removed item: ${key}`);
498
+ }
499
+ }
500
+ catch (error) {
501
+ console.error('Failed to remove item:', error);
502
+ throw new Error(`Failed to remove item: ${key}`);
503
+ }
504
+ }
505
+ /**
506
+ * Clear all items from secure storage
507
+ */
508
+ clear() {
509
+ if (!this.isInitialized) {
510
+ throw new Error('SecureLocalStorage is not initialized');
511
+ }
512
+ try {
513
+ // Only remove items with our prefix
514
+ const keysToRemove = [];
515
+ for (let i = 0; i < this.storageEngine.length; i++) {
516
+ const key = this.storageEngine.key(i);
517
+ if (key && key.startsWith(this.prefix)) {
518
+ keysToRemove.push(key);
519
+ }
520
+ }
521
+ keysToRemove.forEach(key => {
522
+ this.storageEngine.removeItem(key);
523
+ });
524
+ this.memoryCache.clear();
525
+ if (this.config.debug) {
526
+ console.log('Cleared all secure storage items');
527
+ }
528
+ }
529
+ catch (error) {
530
+ console.error('Failed to clear storage:', error);
531
+ throw new Error('Failed to clear secure storage');
532
+ }
533
+ }
534
+ /**
535
+ * Get all keys in secure storage
536
+ */
537
+ keys() {
538
+ if (!this.isInitialized) {
539
+ throw new Error('SecureLocalStorage is not initialized');
540
+ }
541
+ const keys = [];
542
+ for (let i = 0; i < this.storageEngine.length; i++) {
543
+ const key = this.storageEngine.key(i);
544
+ if (key && key.startsWith(this.prefix)) {
545
+ // Remove prefix to get original key
546
+ keys.push(key.substring(this.prefix.length));
547
+ }
548
+ }
549
+ return keys;
550
+ }
551
+ /**
552
+ * Get the number of items in secure storage
553
+ */
554
+ length() {
555
+ return this.keys().length;
556
+ }
557
+ /**
558
+ * Update configuration
559
+ */
560
+ updateConfig(newConfig) {
561
+ const oldConfig = { ...this.config };
562
+ this.config = { ...this.config, ...newConfig };
563
+ // Regenerate secret key if hash key changed
564
+ if (oldConfig.hashKey !== this.config.hashKey) {
565
+ const newSecretKey = this.generateSecretKey();
566
+ this.encryption.updateSecretKey(newSecretKey);
567
+ }
568
+ // Update fingerprinting if disabled keys changed
569
+ if (oldConfig.disabledKeys !== this.config.disabledKeys) {
570
+ this.fingerprinting = new BrowserFingerprinting(this.config.disabledKeys);
571
+ }
572
+ if (this.config.debug) {
573
+ console.log('Configuration updated:', this.config);
574
+ }
575
+ }
576
+ getStorageEngine() {
577
+ if (typeof localStorage !== 'undefined') {
578
+ return localStorage;
579
+ }
580
+ // Fallback to memory storage for environments without localStorage
581
+ return new MemoryStorage();
582
+ }
583
+ getStorageKey(key) {
584
+ return `${this.prefix}${key}`;
585
+ }
586
+ generateDefaultHashKey() {
587
+ return 'secure-local-storage-default-key';
588
+ }
589
+ generateSecretKey() {
590
+ const fingerprint = this.fingerprinting.generateFingerprint();
591
+ const fingerprintString = this.fingerprinting.fingerprintToString(fingerprint);
592
+ return `${this.config.hashKey}|${fingerprintString}`;
593
+ }
594
+ initializeFromStorage() {
595
+ try {
596
+ const keys = this.keys();
597
+ keys.forEach(key => {
598
+ try {
599
+ const value = this.getItem(key);
600
+ if (value !== null) {
601
+ this.memoryCache.set(key, value);
602
+ }
603
+ }
604
+ catch (error) {
605
+ console.warn(`Failed to load item from storage: ${key}`, error);
606
+ }
607
+ });
608
+ if (this.config.debug) {
609
+ console.log(`Loaded ${this.memoryCache.size} items from storage`);
610
+ }
611
+ }
612
+ catch (error) {
613
+ console.error('Failed to initialize from storage:', error);
614
+ }
615
+ }
616
+ }
617
+ SecureLocalStorage.instance = null;
618
+ /**
619
+ * Memory storage fallback for environments without localStorage
620
+ */
621
+ class MemoryStorage {
622
+ constructor() {
623
+ this.storage = new Map();
624
+ }
625
+ getItem(key) {
626
+ return this.storage.get(key) || null;
627
+ }
628
+ setItem(key, value) {
629
+ this.storage.set(key, value);
630
+ }
631
+ removeItem(key) {
632
+ this.storage.delete(key);
633
+ }
634
+ clear() {
635
+ this.storage.clear();
636
+ }
637
+ key(index) {
638
+ const keys = Array.from(this.storage.keys());
639
+ return keys[index] || null;
640
+ }
641
+ get length() {
642
+ return this.storage.size;
643
+ }
644
+ }
645
+
646
+ /**
647
+ * Default secure local storage instance
648
+ */
649
+ const secureLocalStorage = SecureLocalStorage.getInstance();
650
+
651
+ exports.BrowserFingerprinting = BrowserFingerprinting;
652
+ exports.EncryptionManager = EncryptionManager;
653
+ exports.EnvironmentManager = EnvironmentManager;
654
+ exports.SecureLocalStorage = SecureLocalStorage;
655
+ exports.default = secureLocalStorage;
656
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/fingerprinting.ts","../src/encryption.ts","../src/environment.ts","../src/SecureLocalStorage.ts","../src/index.ts"],"sourcesContent":[null,null,null,null,null],"names":["randomBytes","chacha20poly1305","pbkdf2","sha256"],"mappings":";;;;;;;;;;AAEA;;AAEG;MACU,qBAAqB,CAAA;AAGhC,IAAA,WAAA,CAAY,eAAsC,EAAE,EAAA;QAClD,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC;IAC3C;AAEA;;AAEG;IACI,mBAAmB,GAAA;QACxB,OAAO;AACL,YAAA,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE;AACjE,YAAA,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;AACvE,YAAA,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;AAC3D,YAAA,KAAK,EAAE,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