1.0.2 • Published 8 months ago
@rattawitdev/shared-state v1.0.2
@rattawitdev/shared-state
A secure shared state management library with encryption support for web applications.
Features
- Secure state management with AES encryption
- TypeScript support
- LocalStorage-based persistence
- Event-based state updates
- Sensitive data clearing
Installation
npm install @rattawitdev/shared-stateUsage
import { getState, updateState, subscribe, clearSensitiveData } from '@rattawitdev/shared-state';
// Get current state
const state = getState();
// Update state
updateState({
user: {
id: '123',
name: 'John Doe'
}
});
// Subscribe to state changes
const unsubscribe = subscribe((newState) => {
console.log('State changed:', newState);
});
// Clear sensitive data
clearSensitiveData();Configuration
Set the encryption key using the SHARED_STATE_ENCRYPTION_KEY environment variable:
export SHARED_STATE_ENCRYPTION_KEY=your-secure-key-hereDevelopment
# Install dependencies
npm install
# Build the package
npm run build
# Run tests
npm testLicense
MIT