@citadeldb/wasm 0.2.0 → 0.2.1
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 +68 -0
- package/package.json +5 -3
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @citadeldb/wasm
|
|
2
|
+
|
|
3
|
+
WebAssembly bindings for [Citadel](https://github.com/yp3y5akh0v/citadel) — an encrypted-first embedded database engine.
|
|
4
|
+
|
|
5
|
+
Every value is encrypted at rest with AES-256-CTR + HMAC-SHA256. Runs entirely in the browser or Node.js with no server required.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @citadeldb/wasm
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import init, { CitadelDb } from "@citadeldb/wasm";
|
|
17
|
+
|
|
18
|
+
await init();
|
|
19
|
+
|
|
20
|
+
const db = new CitadelDb("my-passphrase");
|
|
21
|
+
|
|
22
|
+
// SQL
|
|
23
|
+
db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT NOT NULL);");
|
|
24
|
+
db.execute("INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob');");
|
|
25
|
+
const result = db.query("SELECT * FROM users;");
|
|
26
|
+
// { columns: ["id", "name"], rows: [[1, "Alice"], [2, "Bob"]] }
|
|
27
|
+
|
|
28
|
+
// Key-value
|
|
29
|
+
db.put(new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6]));
|
|
30
|
+
const value = db.get(new Uint8Array([1, 2, 3]));
|
|
31
|
+
|
|
32
|
+
// Named tables
|
|
33
|
+
db.tablePut("sessions", new Uint8Array([1]), new Uint8Array([2]));
|
|
34
|
+
|
|
35
|
+
// Stats
|
|
36
|
+
const stats = db.stats();
|
|
37
|
+
// { entryCount, totalPages, treeDepth }
|
|
38
|
+
|
|
39
|
+
// Cleanup
|
|
40
|
+
db.free();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API
|
|
44
|
+
|
|
45
|
+
| Method | Description |
|
|
46
|
+
|--------|-------------|
|
|
47
|
+
| `new CitadelDb(passphrase)` | Create an in-memory encrypted database |
|
|
48
|
+
| `execute(sql)` | Execute DDL/DML, returns rows affected |
|
|
49
|
+
| `executeBatch(sql)` | Execute multiple statements |
|
|
50
|
+
| `query(sql)` | Execute SELECT, returns `{ columns, rows }` |
|
|
51
|
+
| `put(key, value)` | Insert into default table |
|
|
52
|
+
| `get(key)` | Get from default table |
|
|
53
|
+
| `delete(key)` | Delete from default table |
|
|
54
|
+
| `tablePut(table, key, value)` | Insert into named table |
|
|
55
|
+
| `tableGet(table, key)` | Get from named table |
|
|
56
|
+
| `tableDelete(table, key)` | Delete from named table |
|
|
57
|
+
| `stats()` | Database statistics |
|
|
58
|
+
| `free()` | Release resources |
|
|
59
|
+
|
|
60
|
+
## SQL Support
|
|
61
|
+
|
|
62
|
+
CREATE/DROP TABLE, CREATE/DROP INDEX, INSERT, SELECT, UPDATE, DELETE, JOINs (INNER, LEFT, RIGHT, CROSS), subqueries, aggregates, DISTINCT, GROUP BY, ORDER BY, LIMIT/OFFSET, BETWEEN, LIKE, CASE, prepared statements.
|
|
63
|
+
|
|
64
|
+
Types: INTEGER, REAL, TEXT, BLOB, BOOLEAN.
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT OR Apache-2.0
|
package/package.json
CHANGED
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
"name": "@citadeldb/wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "WASM bindings for Citadel encrypted database",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.1",
|
|
6
|
+
"keywords": ["database", "wasm", "encryption", "sql", "embedded-database", "webassembly"],
|
|
7
|
+
"repository": {"type": "git", "url": "https://github.com/yp3y5akh0v/citadel"},
|
|
6
8
|
"license": "MIT OR Apache-2.0",
|
|
7
9
|
"files": [
|
|
8
10
|
"citadel_wasm_bg.wasm",
|
|
9
11
|
"citadel_wasm.js",
|
|
10
12
|
"citadel_wasm_bg.js",
|
|
11
13
|
"citadel_wasm.d.ts",
|
|
12
|
-
"LICENSE-
|
|
13
|
-
"LICENSE-
|
|
14
|
+
"LICENSE-APACHE",
|
|
15
|
+
"LICENSE-MIT"
|
|
14
16
|
],
|
|
15
17
|
"main": "citadel_wasm.js",
|
|
16
18
|
"types": "citadel_wasm.d.ts",
|