
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
sqljs-manager
Advanced tools
This package provides a simple and efficient solution for managing SQLite databases in the browser, with optional encryption for secure storage and support for exporting, importing, and uploading databases to a server.
Install the package using npm or yarn:
npm install your-database-package-name
or
yarn add your-database-package-name
Database Management:
Encryption (Optional):
Export and Import:
Server Interaction:
Local Storage Support:
import { DatabaseManager } from "your-database-package-name";
const dbManager = new DatabaseManager({
locateFile: (file) => `/path-to-your-wasm/${file}` // Specify the path to sql-wasm.wasm
});
// Execute SQL commands
await dbManager.initialize([
"CREATE TABLE expenses (id INTEGER PRIMARY KEY, date TEXT, amount REAL)"
]);
dbManager.execute("INSERT INTO expenses (date, amount) VALUES (?, ?)", ["2023-12-03", 100]);
console.log(dbManager.execute("SELECT * FROM expenses"));
To enable encryption, initialize an EncryptionManager:
import { EncryptionManager } from "your-database-package-name";
const encryptionManager = new EncryptionManager();
await encryptionManager.generateKey(); // Generate a new encryption key
// Optionally, export and import keys
const exportedKey = await encryptionManager.exportKey();
await encryptionManager.importKey(exportedKey);
You can export the database as plain or encrypted data:
const dump = await dbManager.exportDatabase();
Import previously exported dumps (plain or encrypted):
await dbManager.importDatabase(dump);
await dbManager.saveToLocalStorage();
await dbManager.loadFromLocalStorage("secure-password");
Upload a database dump to a server endpoint:
import { uploadDatabaseToServer } from "your-database-package-name";
await uploadDatabaseToServer(dbManager, "https://your-server.com");
This package relies on the sql-wasm.wasm file for SQLite operations in the browser. You need to ensure this file is accessible from your project.
sql-wasm.wasm:Place the File:
Copy sql-wasm.wasm from the sql.js package into your public directory (or equivalent for your build tool).
Configure Path:
Pass the correct path to the DatabaseManager using the locateFile option:
const dbManager = new DatabaseManager({
locateFile: (file) => `/path-to-wasm/${file}` // Adjust the path as needed
});
Default Path:
If no locateFile is provided, the package will attempt to locate the file at /path-to-public/sql-wasm.wasm. Ensure this path is valid in your project structure.
DatabaseManagerexecute(query: string, params?: any[]): any[]
exportDatabase(): Promise<Uint8Array | { iv: Uint8Array; encrypted: Uint8Array }>
importDatabase(dump: Uint8Array | { iv: Uint8Array; encrypted: Uint8Array }): Promise<void>
saveToLocalStorage(): Promise<void>
loadFromLocalStorage(password: string): Promise<void>
EncryptionManagergenerateKey(): Promise<void>
exportKey(): Promise<Uint8Array>
importKey(key: Uint8Array): Promise<void>
encrypt(data: Uint8Array): Promise<{ iv: Uint8Array; encrypted: Uint8Array }>
Uint8Array.decrypt(data: { iv: Uint8Array; encrypted: Uint8Array }): Promise<Uint8Array>
This package is licensed under the MIT License.
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
FAQs
Database Manager with optional encryption for SQLite in the browser.
The npm package sqljs-manager receives a total of 1 weekly downloads. As such, sqljs-manager popularity was classified as not popular.
We found that sqljs-manager demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.