Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@magieno/web-sqlite
Advanced tools
Web SQLite is a wrapper for Sqlite on Wasm that uses the Origin Private File System to persist the sqlite database file.
Web SQLite is a wrapper for SQLite Wasm that uses the Origin Private File System (OPFS) to persist the SQLite database file.
It only supports OPFS as a persistence mechanism.
npm install @magieno/web-sqlite
This library has two important files: web-sqlite.js
and web-sqlite-worker.js
.
Due to some browser restrictions, SQLite WASM can only persist over OPFS in a Worker.
Behind the scenes, WebSqlite communicates with a worker to run the SQL statements and return you the results
on the main thread.
1- Install the NPM package
npm install @magieno/web-sqlite
2- Import the web-sqlite
library in your code
import {WebSqlite} from "@magieno/web-sqlite";
const webSqliteWorkerPath = "assets/js/web-sqlite-worker.js"; // Must correspond to the path in your final deployed build.
const filename = "/test.sqlite3"; // This is the name of your database. It corresponds to the path in the OPFS.
const sqliteClient = new WebSqlite(filename, webSqliteWorkerPath)
await sqliteClient.init();
await sqliteClient.executeSql("CREATE TABLE IF NOT EXISTS test(a,b)");
await sqliteClient.executeSql("INSERT INTO test VALUES(?, ?)", [6,7]);
const results = await sqliteClient.executeSql("SELECT * FROM test");
3- Copy the node_modules/@magieno/web-sqlite/dist/bundle/web-sqlite-worker.js
to your final bundle
This is dependent on the framework you are using but the idea is that this .js file should be copied and available in your build.
4- You also need to copy the files third_party/sqlite/3.41.2/
file to your final bundle, in the same folder of your final bundle next to web-sqlite-worker.js
.
5- Warning Your server must set the following Http headers when serving your files
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
We have created a repository that contains demos that you can look at:
FAQs
Web SQLite is a wrapper for Sqlite on Wasm that uses the Origin Private File System to persist the sqlite database file.
The npm package @magieno/web-sqlite receives a total of 0 weekly downloads. As such, @magieno/web-sqlite popularity was classified as not popular.
We found that @magieno/web-sqlite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.