@delali/sirannon-db 0.3.6-next.78 → 0.4.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/README.md +31 -3
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@delali/sirannon-db)
|
|
7
7
|
[](https://github.com/assetcorp/sirannon-db/blob/main/LICENSE)
|
|
8
8
|
|
|
9
|
-
Build
|
|
9
|
+
Build an encrypted, networked SQLite service with connection pooling, change data capture, live queries, migrations, backups, device sync, and a client SDK. Applications reach Sirannon over HTTP or WebSocket, while a primary replicates its changes to other Sirannon nodes over gRPC.
|
|
10
10
|
|
|
11
11
|
**Read the full documentation at [sirannon.sondelali.com/docs](https://sirannon.sondelali.com/docs).** Use this page to get started, and turn to the [guides](#documentation) for the detail. The benchmark harness that measures Sirannon against Postgres 17 is under [`benchmarks/server`](https://github.com/assetcorp/sirannon-db/tree/main/benchmarks/server), where a Node load generator drives both engines and a Python step joins their results. The write-up generator rewrites [BENCHMARKS.md](https://github.com/assetcorp/sirannon-db/blob/main/BENCHMARKS.md) from the latest committed run.
|
|
12
12
|
|
|
@@ -61,7 +61,9 @@ import { betterSqlite3 } from '@delali/sirannon-db/driver/better-sqlite3'
|
|
|
61
61
|
const sirannon = new Sirannon({ driver: betterSqlite3() })
|
|
62
62
|
const db = await sirannon.open('app', './data/app.db')
|
|
63
63
|
|
|
64
|
-
await db.execute(
|
|
64
|
+
await db.execute(
|
|
65
|
+
'CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT, active INTEGER NOT NULL DEFAULT 1)',
|
|
66
|
+
)
|
|
65
67
|
await db.execute('INSERT INTO users (name, email) VALUES (?, ?)', ['Ada', 'ada@example.com'])
|
|
66
68
|
|
|
67
69
|
const users = await db.query<{ id: number; name: string }>('SELECT * FROM users')
|
|
@@ -79,11 +81,36 @@ const db = await sirannon.open('app', '/app.db', { walMode: false })
|
|
|
79
81
|
|
|
80
82
|
On React Native, open the database the same way with `expoSqlite()`.
|
|
81
83
|
|
|
84
|
+
### Encrypt a database
|
|
85
|
+
|
|
86
|
+
On Node.js, install Sirannon's encrypting SQLite build beside the library:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pnpm add -E @delali/sirannon-db @delali/sirannon-sqlite
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Create the better-sqlite3 driver with encryption enabled. Return 32 raw key bytes when Sirannon opens the database:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { readFile } from 'node:fs/promises'
|
|
96
|
+
import { Sirannon } from '@delali/sirannon-db'
|
|
97
|
+
import { betterSqlite3 } from '@delali/sirannon-db/driver/better-sqlite3'
|
|
98
|
+
|
|
99
|
+
const loadLedgerKey = async () => new Uint8Array(await readFile('/run/secrets/ledger-key'))
|
|
100
|
+
|
|
101
|
+
const sirannon = new Sirannon({ driver: betterSqlite3({ encryption: true }) })
|
|
102
|
+
const db = await sirannon.open('ledger', './data/ledger.db', {
|
|
103
|
+
encryption: { key: async () => ({ key: await loadLedgerKey(), id: 'ledger-2026-11' }) },
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Store the key in a key service, a system keychain, or a secret file whose permissions restrict access to the application's operating-system account. Retain both keys until a key change finishes. Retain each backup chain's key for as long as you keep that chain. The [encryption guide](https://github.com/assetcorp/sirannon-db/blob/main/docs/encryption.md) covers key changes, encrypted backups, server routes, and Expo's SQLCipher setup.
|
|
108
|
+
|
|
82
109
|
## Package exports
|
|
83
110
|
|
|
84
111
|
| Import | What you get |
|
|
85
112
|
| --- | --- |
|
|
86
|
-
| `@delali/sirannon-db` | Core library: queries, transactions, CDC, live queries, migrations, backups, hooks, metrics, and lifecycle |
|
|
113
|
+
| `@delali/sirannon-db` | Core library: queries, transactions, encryption, CDC, live queries, migrations, backups, hooks, metrics, and lifecycle |
|
|
87
114
|
| `@delali/sirannon-db/driver/*` | SQLite driver adapters, listed in the table above |
|
|
88
115
|
| `@delali/sirannon-db/file-migrations` | A loader for `.up.sql` and `.down.sql` files in a directory |
|
|
89
116
|
| `@delali/sirannon-db/backup` | Backup destination types, chain records, and `restoreBackup` |
|
|
@@ -252,6 +279,7 @@ Read the [security guide](https://sirannon.sondelali.com/docs/security) for each
|
|
|
252
279
|
| [Bulk load](https://sirannon.sondelali.com/docs/bulk-load) | One-transaction imports under relaxed durability, over the server, and through the client SDK |
|
|
253
280
|
| [Migrations](https://sirannon.sondelali.com/docs/migrations) | File-based, programmatic, and bundled migrations, rollback, checksums, baselines, concurrency, and registry migrations |
|
|
254
281
|
| [Hooks, metrics, and lifecycle](https://sirannon.sondelali.com/docs/hooks-metrics-and-lifecycle) | Before and after hooks, metrics callbacks, and the multi-tenant lifecycle |
|
|
282
|
+
| [Encryption](https://github.com/assetcorp/sirannon-db/blob/main/docs/encryption.md) | Encrypted Node and Expo databases, key changes, encrypted backups, and operator routes |
|
|
255
283
|
| [Backups](https://sirannon.sondelali.com/docs/backups) | Copies of an open database to a file and on a schedule, followed by the guides on [destinations](https://sirannon.sondelali.com/docs/backup-destinations), [continuous backups](https://sirannon.sondelali.com/docs/backup-chains), and [restores](https://sirannon.sondelali.com/docs/backup-restore) |
|
|
256
284
|
| [Server](https://sirannon.sondelali.com/docs/server) | Registered operations on the server, caller identity, size limits, write shapes, `acceptSql`, the backup routes, HTTP routes, and the WebSocket protocol |
|
|
257
285
|
| [Registered operations](https://sirannon.sondelali.com/docs/registered-operations) | Named reads and writes, identity-filled arguments, calls over HTTP and WebSocket, capabilities, and refusals |
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delali/sirannon-db",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"description": "A production-grade library that turns SQLite databases into a networked data layer with real-time subscriptions.",
|
|
6
6
|
"author": "Delali (https://sondelali.com)",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
152
|
"@bufbuild/protobuf": ">=2.0.0",
|
|
153
|
-
"@delali/sirannon-sqlite": "0.
|
|
153
|
+
"@delali/sirannon-sqlite": "0.4.0",
|
|
154
154
|
"@grpc/grpc-js": ">=1.10.0",
|
|
155
155
|
"better-sqlite3": ">=12.0.0",
|
|
156
156
|
"etcd3": ">=1.1.2",
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
},
|
|
199
199
|
"devDependencies": {
|
|
200
200
|
"@bufbuild/protobuf": "2.11.0",
|
|
201
|
-
"@delali/sirannon-sqlite": "0.
|
|
201
|
+
"@delali/sirannon-sqlite": "0.4.0",
|
|
202
202
|
"@grpc/grpc-js": "1.14.4",
|
|
203
203
|
"@microsoft/api-extractor": "7.58.12",
|
|
204
204
|
"@types/better-sqlite3": "7.6.13",
|
|
@@ -229,11 +229,11 @@
|
|
|
229
229
|
"vitest": "4.0.18"
|
|
230
230
|
},
|
|
231
231
|
"optionalDependencies": {
|
|
232
|
-
"@delali/sirannon-vfs-darwin-arm64": "0.
|
|
233
|
-
"@delali/sirannon-vfs-darwin-x64": "0.
|
|
234
|
-
"@delali/sirannon-vfs-linux-arm64": "0.
|
|
235
|
-
"@delali/sirannon-vfs-linux-x64": "0.
|
|
236
|
-
"@delali/sirannon-vfs-win32-arm64": "0.
|
|
237
|
-
"@delali/sirannon-vfs-win32-x64": "0.
|
|
232
|
+
"@delali/sirannon-vfs-darwin-arm64": "0.4.0",
|
|
233
|
+
"@delali/sirannon-vfs-darwin-x64": "0.4.0",
|
|
234
|
+
"@delali/sirannon-vfs-linux-arm64": "0.4.0",
|
|
235
|
+
"@delali/sirannon-vfs-linux-x64": "0.4.0",
|
|
236
|
+
"@delali/sirannon-vfs-win32-arm64": "0.4.0",
|
|
237
|
+
"@delali/sirannon-vfs-win32-x64": "0.4.0"
|
|
238
238
|
}
|
|
239
239
|
}
|