cryptodb 2.4.3__tar.gz
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.
- cryptodb-2.4.3/.gitignore +24 -0
- cryptodb-2.4.3/LICENSE +65 -0
- cryptodb-2.4.3/PKG-INFO +61 -0
- cryptodb-2.4.3/README.md +40 -0
- cryptodb-2.4.3/client/node/README.md +192 -0
- cryptodb-2.4.3/client/python/README.md +191 -0
- cryptodb-2.4.3/examples/mini-chain/README.md +39 -0
- cryptodb-2.4.3/pyproject.toml +51 -0
- cryptodb-2.4.3/python/nedb/__init__.py +92 -0
- cryptodb-2.4.3/python/nedb/autoindex.py +142 -0
- cryptodb-2.4.3/python/nedb/backends/__init__.py +0 -0
- cryptodb-2.4.3/python/nedb/backends/redis_backend.py +115 -0
- cryptodb-2.4.3/python/nedb/cascade.py +130 -0
- cryptodb-2.4.3/python/nedb/concurrent.py +218 -0
- cryptodb-2.4.3/python/nedb/crypto.py +294 -0
- cryptodb-2.4.3/python/nedb/engine.py +783 -0
- cryptodb-2.4.3/python/nedb/index.py +98 -0
- cryptodb-2.4.3/python/nedb/log.py +216 -0
- cryptodb-2.4.3/python/nedb/merkle.py +62 -0
- cryptodb-2.4.3/python/nedb/mongo.py +824 -0
- cryptodb-2.4.3/python/nedb/proof.py +126 -0
- cryptodb-2.4.3/python/nedb/query.py +305 -0
- cryptodb-2.4.3/python/nedb/redis_compat.py +516 -0
- cryptodb-2.4.3/python/nedb/relations.py +51 -0
- cryptodb-2.4.3/python/nedb/resp2.py +250 -0
- cryptodb-2.4.3/python/nedb/server.py +1011 -0
- cryptodb-2.4.3/python/nedb/snapshot.py +216 -0
- cryptodb-2.4.3/python/nedb/sql.py +430 -0
- cryptodb-2.4.3/python/nedb/store.py +68 -0
- cryptodb-2.4.3/python/nedb/wrap_redis.py +725 -0
- cryptodb-2.4.3/rust/nedb-v2/README.md +179 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
.venv/
|
|
9
|
+
|
|
10
|
+
# Rust
|
|
11
|
+
/rust/target/
|
|
12
|
+
**/*.rs.bk
|
|
13
|
+
Cargo.lock
|
|
14
|
+
|
|
15
|
+
# Node / napi
|
|
16
|
+
node_modules/
|
|
17
|
+
*.node
|
|
18
|
+
npm/
|
|
19
|
+
|
|
20
|
+
# misc
|
|
21
|
+
.DS_Store
|
|
22
|
+
|
|
23
|
+
# Ephemeral maturin staging copy (CI stages python/nedb here before build)
|
|
24
|
+
rust/crates/nedb-py/python/
|
cryptodb-2.4.3/LICENSE
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Licensor: Interchained LLC, VibeCode 101, and/or the applicable copyright holders of NEDB
|
|
4
|
+
|
|
5
|
+
Licensed Work: NEDB, including all source code, documentation, examples, tests, build scripts, specifications, APIs, SDKs, packages, binaries, and derivative works distributed from or based on the NEDB repository.
|
|
6
|
+
|
|
7
|
+
Copyright: Copyright (c) 2026 Interchained LLC, VibeCode 101, and contributors. All rights reserved.
|
|
8
|
+
|
|
9
|
+
Change Date: Four years after the first publicly available distribution of each specific version of the Licensed Work under this License.
|
|
10
|
+
|
|
11
|
+
Change License: GNU Affero General Public License v3.0 or later.
|
|
12
|
+
|
|
13
|
+
Additional Use Grant:
|
|
14
|
+
|
|
15
|
+
You may use the Licensed Work only for non-production purposes, including evaluation, development, testing, research, local experimentation, security review, benchmarking, and personal learning.
|
|
16
|
+
|
|
17
|
+
No production use is granted automatically.
|
|
18
|
+
|
|
19
|
+
For clarity, the following uses are not permitted unless you have prior written permission from the Licensor:
|
|
20
|
+
|
|
21
|
+
1. Using the Licensed Work in production.
|
|
22
|
+
2. Using the Licensed Work to store, process, serve, index, replicate, query, or manage production data.
|
|
23
|
+
3. Offering the Licensed Work, or any derivative work, as a hosted, managed, embedded, bundled, white-labeled, commercial, paid, revenue-generating, or customer-facing product or service.
|
|
24
|
+
4. Offering database-as-a-service, storage-as-a-service, cache-as-a-service, search-as-a-service, analytics-as-a-service, AI-memory-as-a-service, agent-memory-as-a-service, blockchain-indexing-as-a-service, or any substantially similar service using the Licensed Work.
|
|
25
|
+
5. Using the Licensed Work to compete with NEDB, Interchained LLC, VibeCode 101, AiAssist Secure, or any affiliated product, service, infrastructure platform, database engine, AI runtime, agent platform, or hosted developer infrastructure.
|
|
26
|
+
6. Embedding the Licensed Work into commercial software, SaaS products, internal business systems, enterprise systems, hosted infrastructure, blockchain infrastructure, AI-agent infrastructure, or customer deliverables.
|
|
27
|
+
7. Removing, hiding, modifying, or misrepresenting this License, copyright notices, attribution notices, authorship notices, repository references, or licensing notices.
|
|
28
|
+
8. Circumventing license checks, access controls, paid licensing requirements, commercial-use restrictions, attribution requirements, or technical protections included with the Licensed Work.
|
|
29
|
+
9. Using the Licensed Work in a way that implies endorsement, partnership, sponsorship, certification, or approval by the Licensor without written permission.
|
|
30
|
+
10. Reselling, relicensing, sublicensing, renting, leasing, or otherwise commercially exploiting the Licensed Work except as expressly authorized in writing.
|
|
31
|
+
|
|
32
|
+
Additional production, commercial, hosted, enterprise, embedded, OEM, resale, white-label, managed-service, competitive, or otherwise restricted use grants are available only by separate written permission from the Licensor.
|
|
33
|
+
|
|
34
|
+
Written permission must be obtained from at least one of the following authorized licensing contacts:
|
|
35
|
+
|
|
36
|
+
[founders@vibecode-101.com](mailto:founders@vibecode-101.com)
|
|
37
|
+
[dev@interchained.org](mailto:dev@interchained.org)
|
|
38
|
+
|
|
39
|
+
Permission is valid only if it is expressly granted in writing by an authorized representative of the Licensor and specifically identifies the permitted use, scope, duration, parties, and any applicable commercial terms.
|
|
40
|
+
|
|
41
|
+
A general email conversation, informal message, pull request, issue comment, social media message, verbal discussion, repository access, package download, or contribution acceptance does not create a production, commercial, hosted, enterprise, resale, or competitive use license.
|
|
42
|
+
|
|
43
|
+
Terms:
|
|
44
|
+
|
|
45
|
+
The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
|
|
46
|
+
|
|
47
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
|
|
48
|
+
|
|
49
|
+
If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase or obtain a separate commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
|
|
50
|
+
|
|
51
|
+
All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work, and the Change Date may vary for each version of the Licensed Work released by Licensor.
|
|
52
|
+
|
|
53
|
+
You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
|
|
54
|
+
|
|
55
|
+
Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
|
|
56
|
+
|
|
57
|
+
This License does not grant you any right in any trademark, service mark, trade name, logo, domain name, brand identity, product name, project name, or other identifier of Licensor or its affiliates, except as expressly required to preserve legally required notices.
|
|
58
|
+
|
|
59
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, TITLE, SECURITY, ACCURACY, AVAILABILITY, DATA INTEGRITY, PERFORMANCE, AND FITNESS FOR PRODUCTION USE.
|
|
60
|
+
|
|
61
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, LICENSOR SHALL NOT BE LIABLE FOR ANY CLAIM, DAMAGES, LOSSES, COSTS, EXPENSES, BUSINESS INTERRUPTION, LOST PROFITS, LOST REVENUE, LOST DATA, SECURITY INCIDENTS, SERVICE OUTAGES, OR OTHER LIABILITY ARISING FROM OR RELATED TO THE LICENSED WORK OR YOUR USE OF THE LICENSED WORK.
|
|
62
|
+
|
|
63
|
+
Notice:
|
|
64
|
+
|
|
65
|
+
The Business Source License is not an Open Source license. However, each version of the Licensed Work will become available under the Change License on the applicable Change Date, or on the fourth anniversary of the first publicly available distribution of that version under this License, whichever comes first.
|
cryptodb-2.4.3/PKG-INFO
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cryptodb
|
|
3
|
+
Version: 2.4.3
|
|
4
|
+
Summary: NEDB — a versioned, self-compressing, time-traveling embedded database (replay-protected, idempotent, relational, searchable) with durable AOF persistence and a server daemon (nedbd).
|
|
5
|
+
Project-URL: Homepage, https://github.com/aiassistsecure/nedb
|
|
6
|
+
Project-URL: Repository, https://github.com/aiassistsecure/nedb
|
|
7
|
+
Author: Eth-Interchained
|
|
8
|
+
License: GPL-3.0-or-later
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: compression,database,dedup,embedded,git,graph,mvcc,persistence,redis,search,server,time-travel,versioning
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Database :: Database Engines/Servers
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Requires-Dist: pycryptodome>=3.19
|
|
18
|
+
Provides-Extra: encryption
|
|
19
|
+
Requires-Dist: cryptography>=41; extra == 'encryption'
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
<h1 align="center">CryptoDB</h1>
|
|
23
|
+
<p align="center"><b>The database that can prove it never lied.</b></p>
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
CryptoDB is a **content-addressed, hash-chained, time-traveling** datastore. Every version of every record is an immutable, **BLAKE2b-verified** object in a Merkle DAG — nothing is ever overwritten, and the store can prove its own integrity on demand.
|
|
28
|
+
|
|
29
|
+
If your data is evidence — ledgers, audit trails, provenance, anything you may one day have to *defend* — CryptoDB makes the history itself tamper-evident and replayable.
|
|
30
|
+
|
|
31
|
+
## Why CryptoDB
|
|
32
|
+
|
|
33
|
+
- 🔒 **Tamper-evident by construction.** `verify()` re-hashes every object against its content address. Flip a single byte on disk and it's caught — silently impossible to forge history.
|
|
34
|
+
- ⏪ **Time-travel is a query.** `AS OF <seq>` returns the exact state at any point. `VALID AS OF <time>` adds bi-temporal validity — *what was true, as of when.*
|
|
35
|
+
- 🧬 **Causal provenance.** `caused_by` links every record to the facts that produced it; `TRACE` walks the graph. Audit **why**, not just **what**.
|
|
36
|
+
- 🔐 **Encrypted at rest** (AES-256-GCM), RESP2 wire protocol, SQL / Redis / Mongo adapters, a `nedbd-v2` server daemon.
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install cryptodb # Node (native addon)
|
|
42
|
+
pip install cryptodb # Python
|
|
43
|
+
cargo add cryptodb # Rust
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Reach for it when
|
|
47
|
+
|
|
48
|
+
Audit logs · financial & token ledgers · compliance trails · supply-chain provenance · anything where **provable, replayable history is the product**, not a nice-to-have.
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
import { NedbCore } from "cryptodb";
|
|
52
|
+
const db = new NedbCore();
|
|
53
|
+
db.put("ledger", "acct:alice", JSON.stringify({ balance: 100 }));
|
|
54
|
+
db.put("ledger", "acct:alice", JSON.stringify({ balance: 250 }));
|
|
55
|
+
db.getAsOf("ledger", "acct:alice", 0n); // → balance 100, the past, intact
|
|
56
|
+
db.verify(); // → true: nothing was tampered
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
<sub>CryptoDB is a distribution of the **NEDB** engine, tuned for verifiability. Engine development happens upstream at [Eth-Interchained/nedb](https://github.com/Eth-Interchained/nedb). © Interchained LLC.</sub>
|
cryptodb-2.4.3/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<h1 align="center">CryptoDB</h1>
|
|
2
|
+
<p align="center"><b>The database that can prove it never lied.</b></p>
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
CryptoDB is a **content-addressed, hash-chained, time-traveling** datastore. Every version of every record is an immutable, **BLAKE2b-verified** object in a Merkle DAG — nothing is ever overwritten, and the store can prove its own integrity on demand.
|
|
7
|
+
|
|
8
|
+
If your data is evidence — ledgers, audit trails, provenance, anything you may one day have to *defend* — CryptoDB makes the history itself tamper-evident and replayable.
|
|
9
|
+
|
|
10
|
+
## Why CryptoDB
|
|
11
|
+
|
|
12
|
+
- 🔒 **Tamper-evident by construction.** `verify()` re-hashes every object against its content address. Flip a single byte on disk and it's caught — silently impossible to forge history.
|
|
13
|
+
- ⏪ **Time-travel is a query.** `AS OF <seq>` returns the exact state at any point. `VALID AS OF <time>` adds bi-temporal validity — *what was true, as of when.*
|
|
14
|
+
- 🧬 **Causal provenance.** `caused_by` links every record to the facts that produced it; `TRACE` walks the graph. Audit **why**, not just **what**.
|
|
15
|
+
- 🔐 **Encrypted at rest** (AES-256-GCM), RESP2 wire protocol, SQL / Redis / Mongo adapters, a `nedbd-v2` server daemon.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install cryptodb # Node (native addon)
|
|
21
|
+
pip install cryptodb # Python
|
|
22
|
+
cargo add cryptodb # Rust
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Reach for it when
|
|
26
|
+
|
|
27
|
+
Audit logs · financial & token ledgers · compliance trails · supply-chain provenance · anything where **provable, replayable history is the product**, not a nice-to-have.
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { NedbCore } from "cryptodb";
|
|
31
|
+
const db = new NedbCore();
|
|
32
|
+
db.put("ledger", "acct:alice", JSON.stringify({ balance: 100 }));
|
|
33
|
+
db.put("ledger", "acct:alice", JSON.stringify({ balance: 250 }));
|
|
34
|
+
db.getAsOf("ledger", "acct:alice", 0n); // → balance 100, the past, intact
|
|
35
|
+
db.verify(); // → true: nothing was tampered
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
<sub>CryptoDB is a distribution of the **NEDB** engine, tuned for verifiability. Engine development happens upstream at [Eth-Interchained/nedb](https://github.com/Eth-Interchained/nedb). © Interchained LLC.</sub>
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# nedb-engine-client
|
|
2
|
+
|
|
3
|
+
> TypeScript/JavaScript client for [nedbd](https://github.com/Eth-Interchained/nedb) — the NEDB server daemon.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/nedb-engine-client)
|
|
6
|
+
[](https://github.com/Eth-Interchained/nedb/blob/master/LICENSE)
|
|
7
|
+
|
|
8
|
+
Connect to any running `nedbd` instance from Node.js or the browser. No engine embedded, no native dependencies. Just fetch.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install nedb-engine-client
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Requires Node.js ≥ 18 (uses native `fetch`). Works in modern browsers too.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { NedbClient } from "nedb-engine-client";
|
|
26
|
+
|
|
27
|
+
const db = new NedbClient({ url: "http://127.0.0.1:7070", db: "mydb" });
|
|
28
|
+
|
|
29
|
+
// Write a document
|
|
30
|
+
await db.put("blocks", "618000", {
|
|
31
|
+
height: 618000,
|
|
32
|
+
hash: "000000000000000000024bead8df69990852c202db0e0097c1a12ea637d7e96d",
|
|
33
|
+
txCount: 2734,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Query with NQL
|
|
37
|
+
const rows = await db.query("FROM blocks ORDER BY height DESC LIMIT 10");
|
|
38
|
+
|
|
39
|
+
// Time-travel: what did the DB look like at seq 100?
|
|
40
|
+
const old = await db.query("FROM blocks AS OF 100 WHERE height > 600000");
|
|
41
|
+
|
|
42
|
+
// Bi-temporal: what was true on 2024-06-15?
|
|
43
|
+
const valid = await db.query('FROM policy VALID AS OF "2024-06-15"');
|
|
44
|
+
|
|
45
|
+
// BLAKE2b Merkle head — changes on every write, anchorable
|
|
46
|
+
const head = await db.head();
|
|
47
|
+
|
|
48
|
+
// Tamper-evidence check across all objects
|
|
49
|
+
const report = await db.verify();
|
|
50
|
+
console.assert(report.ok, "tamper detected!");
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## nedbd — start the server
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm install nedb-engine # or: pip install nedb-engine
|
|
59
|
+
|
|
60
|
+
# v2 DAG engine (recommended — instant cold start, tamper-evident)
|
|
61
|
+
NEDBD_DAG=1 nedbd --data ./data
|
|
62
|
+
|
|
63
|
+
# Check health
|
|
64
|
+
curl http://127.0.0.1:7070/health
|
|
65
|
+
# {"ok":true,"version":"2.0.8","service":"nedbd","encrypted":true}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## API reference
|
|
71
|
+
|
|
72
|
+
### Constructor
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
const db = new NedbClient({
|
|
76
|
+
url: "http://127.0.0.1:7070", // nedbd base URL
|
|
77
|
+
db: "mydb", // database name
|
|
78
|
+
token: "secret", // bearer auth (optional)
|
|
79
|
+
autoCreate: true, // create DB on first write
|
|
80
|
+
readTimeoutMs: 3_000, // query timeout
|
|
81
|
+
writeTimeoutMs: 30_000, // write timeout
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Writes
|
|
86
|
+
|
|
87
|
+
| Method | Description |
|
|
88
|
+
|--------|-------------|
|
|
89
|
+
| `db.put(coll, id, doc, opts?)` | Write a document |
|
|
90
|
+
| `db.delete(coll, id)` | Tombstone delete (history preserved in DAG) |
|
|
91
|
+
| `db.batch(ops)` | Batch put/del in one HTTP round-trip |
|
|
92
|
+
| `db.createIndex(coll, field)` | Create sorted index for ORDER BY |
|
|
93
|
+
|
|
94
|
+
**Put options:**
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
await db.put("claims", "c1", { fact: "..." }, {
|
|
98
|
+
causedBy: ["abc123hash"], // DAG causal provenance
|
|
99
|
+
validFrom: "2024-01-01", // bi-temporal valid window
|
|
100
|
+
validTo: "2024-12-31",
|
|
101
|
+
evidence: "sensor-42", // human-readable provenance note
|
|
102
|
+
confidence: 0.95, // confidence score 0–1
|
|
103
|
+
idem: "dedup-key", // idempotency key
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Reads
|
|
108
|
+
|
|
109
|
+
| Method | Description |
|
|
110
|
+
|--------|-------------|
|
|
111
|
+
| `db.get(coll, id)` | Fetch current version of a document |
|
|
112
|
+
| `db.query(nql)` | NQL query → array of objects |
|
|
113
|
+
| `db.queryFull(nql)` | NQL query → full response (rows + seq + head) |
|
|
114
|
+
|
|
115
|
+
### NQL — NEDB Query Language
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
FROM <collection>
|
|
119
|
+
[AS OF <seq>] transaction time (when was it written?)
|
|
120
|
+
[VALID AS OF "<date>"] valid time (when was it true in the world?)
|
|
121
|
+
[WHERE field = value [AND ...]] op: = != < <= > >=
|
|
122
|
+
[ORDER BY field [DESC]]
|
|
123
|
+
[LIMIT n]
|
|
124
|
+
[GROUP BY field COUNT|SUM|AVG|MIN|MAX]
|
|
125
|
+
[TRACE caused_by [REVERSE]] causal graph traversal
|
|
126
|
+
[SEARCH "text"] full-text search
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Integrity
|
|
130
|
+
|
|
131
|
+
| Method | Description |
|
|
132
|
+
|--------|-------------|
|
|
133
|
+
| `db.verify()` | BLAKE2b tamper-evidence check across all objects |
|
|
134
|
+
| `db.head()` | Current Merkle root — changes on every write |
|
|
135
|
+
| `db.seq()` | Current global sequence number |
|
|
136
|
+
| `db.log(limit?)` | Recent write log |
|
|
137
|
+
| `db.checkpoint()` | Explicit checkpoint (no-op on v2 DAG) |
|
|
138
|
+
|
|
139
|
+
### Server management
|
|
140
|
+
|
|
141
|
+
| Method | Description |
|
|
142
|
+
|--------|-------------|
|
|
143
|
+
| `db.health()` | Server health — version, databases, encryption |
|
|
144
|
+
| `db.ping()` | Boolean reachability check |
|
|
145
|
+
| `db.listDatabases()` | All databases on this server |
|
|
146
|
+
| `db.createDatabase()` | Create this database explicitly |
|
|
147
|
+
| `db.dropDatabase()` | Drop this database (irreversible) |
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Error handling
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
import { NedbClient, NedbError } from "nedb-engine-client";
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
await db.put("coll", "id", { data: "value" });
|
|
158
|
+
} catch (e) {
|
|
159
|
+
if (e instanceof NedbError) {
|
|
160
|
+
console.error(`HTTP ${e.status}: ${e.message}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Queries on missing collections return `[]` rather than throwing — resilient by default.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Batch writes
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
await db.batch([
|
|
173
|
+
{ op: "put", coll: "blocks", id: "618001", doc: { height: 618001 } },
|
|
174
|
+
{ op: "put", coll: "blocks", id: "618002", doc: { height: 618002 } },
|
|
175
|
+
{ op: "del", coll: "blocks", id: "617999" },
|
|
176
|
+
]);
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
One HTTP request, multiple ops — best throughput for bulk ingestion.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Links
|
|
184
|
+
|
|
185
|
+
- **Engine:** [pip install nedb-engine](https://pypi.org/project/nedb-engine/) · [npm install nedb-engine](https://www.npmjs.com/package/nedb-engine)
|
|
186
|
+
- **Python client:** [pip install nedb-engine-client](https://pypi.org/project/nedb-engine-client/)
|
|
187
|
+
- **Source:** [github.com/Eth-Interchained/nedb](https://github.com/Eth-Interchained/nedb)
|
|
188
|
+
- **Studio:** [studio.interchained.org](https://studio.interchained.org)
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
© [INTERCHAINED, LLC](https://interchained.org) · GPL-3.0-or-later · Built with [Hyperagent](https://hyperagent.com/refer/J2G6TCD7)
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# nedb-engine-client
|
|
2
|
+
|
|
3
|
+
> Async Python client for [nedbd](https://github.com/Eth-Interchained/nedb) — the NEDB server daemon.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/nedb-engine-client/)
|
|
6
|
+
[](https://pypi.org/project/nedb-engine-client/)
|
|
7
|
+
[](https://github.com/Eth-Interchained/nedb/blob/master/LICENSE)
|
|
8
|
+
|
|
9
|
+
Connect to any running `nedbd` instance — local or remote — with a clean async API. No engine code embedded, no Rust toolchain required. Just HTTP.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install nedb-engine-client
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Requires Python ≥ 3.8 and `httpx`.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import asyncio
|
|
27
|
+
from nedb_client import NedbClient
|
|
28
|
+
|
|
29
|
+
async def main():
|
|
30
|
+
async with NedbClient("http://127.0.0.1:7070", db="mydb") as db:
|
|
31
|
+
|
|
32
|
+
# Write a document
|
|
33
|
+
await db.put("blocks", "618000", {
|
|
34
|
+
"height": 618000,
|
|
35
|
+
"hash": "000000000000000000024bead8df69990852c202db0e0097c1a12ea637d7e96d",
|
|
36
|
+
"tx_count": 2734,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
# Query with NQL
|
|
40
|
+
rows = await db.query("FROM blocks ORDER BY height DESC LIMIT 10")
|
|
41
|
+
|
|
42
|
+
# Time-travel: what did the DB look like at seq 100?
|
|
43
|
+
old = await db.query("FROM blocks AS OF 100 WHERE height > 600000")
|
|
44
|
+
|
|
45
|
+
# Bi-temporal: what was true on 2024-06-15?
|
|
46
|
+
valid = await db.query('FROM policy VALID AS OF "2024-06-15"')
|
|
47
|
+
|
|
48
|
+
# Causal trace: why was this written?
|
|
49
|
+
trace = await db.query("FROM blocks TRACE caused_by")
|
|
50
|
+
|
|
51
|
+
# BLAKE2b Merkle head — changes on every write, anchorable
|
|
52
|
+
head = await db.head()
|
|
53
|
+
print(f"head: {head}")
|
|
54
|
+
|
|
55
|
+
# Tamper-evidence check across all objects
|
|
56
|
+
report = await db.verify()
|
|
57
|
+
assert report["ok"], "tamper detected!"
|
|
58
|
+
|
|
59
|
+
asyncio.run(main())
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## nedbd — start the server
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install nedb-engine
|
|
68
|
+
|
|
69
|
+
# v1 AOF engine (default)
|
|
70
|
+
nedbd --data ./data
|
|
71
|
+
|
|
72
|
+
# v2 DAG engine (recommended — instant cold start, tamper-evident)
|
|
73
|
+
NEDBD_DAG=1 nedbd --data ./data
|
|
74
|
+
|
|
75
|
+
# With AES-256-GCM encryption
|
|
76
|
+
NEDBD_DAG=1 NEDB_TMK=<32-byte-hex> nedbd --data ./data
|
|
77
|
+
|
|
78
|
+
# Check health
|
|
79
|
+
curl http://127.0.0.1:7070/health
|
|
80
|
+
# {"ok":true,"version":"2.0.8","service":"nedbd","encrypted":true}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## API reference
|
|
86
|
+
|
|
87
|
+
### Client lifecycle
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
# Async context manager (recommended)
|
|
91
|
+
async with NedbClient(url, db=name, token=token) as db:
|
|
92
|
+
...
|
|
93
|
+
|
|
94
|
+
# Manual
|
|
95
|
+
db = NedbClient(url="http://127.0.0.1:7070", db="mydb", token="secret")
|
|
96
|
+
await db.open()
|
|
97
|
+
await db.close()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Writes
|
|
101
|
+
|
|
102
|
+
| Method | Description |
|
|
103
|
+
|--------|-------------|
|
|
104
|
+
| `await db.put(coll, id, doc, **opts)` | Write a document |
|
|
105
|
+
| `await db.delete(coll, id)` | Tombstone delete (history preserved in DAG) |
|
|
106
|
+
| `await db.batch(ops)` | Batch put/del in one HTTP round-trip |
|
|
107
|
+
| `await db.create_index(coll, field)` | Create sorted index for ORDER BY |
|
|
108
|
+
|
|
109
|
+
**Put options:**
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
await db.put("claims", "c1", {"fact": "..."},
|
|
113
|
+
caused_by=["abc123hash"], # DAG causal provenance
|
|
114
|
+
valid_from="2024-01-01", # bi-temporal valid window
|
|
115
|
+
valid_to="2024-12-31",
|
|
116
|
+
evidence="sensor-42", # human-readable provenance note
|
|
117
|
+
confidence=0.95, # confidence score 0–1
|
|
118
|
+
idem="dedup-key", # idempotency key
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Reads
|
|
123
|
+
|
|
124
|
+
| Method | Description |
|
|
125
|
+
|--------|-------------|
|
|
126
|
+
| `await db.get(coll, id)` | Fetch current version of a document |
|
|
127
|
+
| `await db.query(nql)` | NQL query → list of dicts |
|
|
128
|
+
| `await db.query_full(nql)` | NQL query → full response (rows + seq + head) |
|
|
129
|
+
|
|
130
|
+
### NQL — NEDB Query Language
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
FROM <collection>
|
|
134
|
+
[AS OF <seq>] transaction time (when was it written?)
|
|
135
|
+
[VALID AS OF "<date>"] valid time (when was it true in the world?)
|
|
136
|
+
[WHERE field = value [AND ...]] op: = != < <= > >=
|
|
137
|
+
[ORDER BY field [DESC]]
|
|
138
|
+
[LIMIT n]
|
|
139
|
+
[GROUP BY field COUNT|SUM|AVG|MIN|MAX]
|
|
140
|
+
[TRACE caused_by [REVERSE]] causal graph traversal
|
|
141
|
+
[SEARCH "text"] full-text search
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Integrity
|
|
145
|
+
|
|
146
|
+
| Method | Description |
|
|
147
|
+
|--------|-------------|
|
|
148
|
+
| `await db.verify()` | BLAKE2b tamper-evidence check across all objects |
|
|
149
|
+
| `await db.head()` | Current Merkle root — changes on every write |
|
|
150
|
+
| `await db.seq()` | Current global sequence number |
|
|
151
|
+
| `await db.log(limit)` | Recent write log |
|
|
152
|
+
| `await db.checkpoint()` | Explicit checkpoint (no-op on v2 DAG) |
|
|
153
|
+
|
|
154
|
+
### Server management
|
|
155
|
+
|
|
156
|
+
| Method | Description |
|
|
157
|
+
|--------|-------------|
|
|
158
|
+
| `await db.health()` | Server health — version, databases, encryption |
|
|
159
|
+
| `await db.ping()` | Boolean reachability check |
|
|
160
|
+
| `await db.list_databases()` | All databases on this server |
|
|
161
|
+
| `await db.create_database()` | Create this database explicitly |
|
|
162
|
+
| `await db.drop_database()` | Drop this database (irreversible) |
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Error handling
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
from nedb_client import NedbClient, NedbError
|
|
170
|
+
|
|
171
|
+
async with NedbClient("http://127.0.0.1:7070", db="mydb") as db:
|
|
172
|
+
try:
|
|
173
|
+
await db.put("coll", "id", {"data": "value"})
|
|
174
|
+
except NedbError as e:
|
|
175
|
+
print(f"HTTP {e.status}: {e.message}")
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Queries on missing collections return `[]` rather than raising — resilient by default.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Links
|
|
183
|
+
|
|
184
|
+
- **Engine:** [pip install nedb-engine](https://pypi.org/project/nedb-engine/) · [npm install nedb-engine](https://www.npmjs.com/package/nedb-engine)
|
|
185
|
+
- **JS/TS client:** [npm install nedb-engine-client](https://www.npmjs.com/package/nedb-engine-client)
|
|
186
|
+
- **Source:** [github.com/Eth-Interchained/nedb](https://github.com/Eth-Interchained/nedb)
|
|
187
|
+
- **Studio:** [studio.interchained.org](https://studio.interchained.org)
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
© [INTERCHAINED, LLC](https://interchained.org) · GPL-3.0-or-later · Built with [Hyperagent](https://hyperagent.com/refer/J2G6TCD7)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# NEDB Mini-Chain
|
|
2
|
+
|
|
3
|
+
> The database where your data **is** a blockchain.
|
|
4
|
+
|
|
5
|
+
A ~80-line runnable micro case-study for `nedb-engine`. It tells NEDB's whole
|
|
6
|
+
story in one gamified console run — and uses the exact primitives
|
|
7
|
+
(`caused_by` / `AS OF` / `verify`) that back the real ITC node (**itcd**),
|
|
8
|
+
where NEDB replaces LevelDB as the block-index + chainstate.
|
|
9
|
+
|
|
10
|
+
## Run
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install nedb-engine
|
|
14
|
+
node mini-chain.mjs # default 5,000 blocks
|
|
15
|
+
node mini-chain.mjs 50000 # crank it
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## What it demonstrates
|
|
19
|
+
|
|
20
|
+
| Step | NEDB feature | Why it matters |
|
|
21
|
+
|------|--------------|----------------|
|
|
22
|
+
| ⛏ Mine N blocks | content-addressed writes | one doc per block; hash-chained automatically |
|
|
23
|
+
| ⚡ Read them back | indexed `get` | real writes/sec + reads/sec from *your* machine |
|
|
24
|
+
| ⏳ Time-travel | `getAsOf(seq)` (MVCC) | read any block as it was at a past sequence |
|
|
25
|
+
| 🧭 Provenance | `link` / `neighbors` (causal DAG) | walk a block's `prev` edge |
|
|
26
|
+
| 🛡 Tamper-evidence | `verify()` (BLAKE2b) | corrupt a block on disk → `verify()` flips to `false` |
|
|
27
|
+
|
|
28
|
+
The tamper step is **real**: it flips a byte in a block's on-disk object and
|
|
29
|
+
re-opens the store — `verify()` catches the BLAKE2b mismatch. You can't fake
|
|
30
|
+
history in NEDB.
|
|
31
|
+
|
|
32
|
+
## Storage strategy
|
|
33
|
+
|
|
34
|
+
One document per block in a `blocks` collection, keyed by height, each carrying
|
|
35
|
+
`prev`. Time-travel, causal provenance, and tamper-proofing come **free** — no
|
|
36
|
+
extra tables, no external indexer. That is the same model itcd uses for the ITC
|
|
37
|
+
chain.
|
|
38
|
+
|
|
39
|
+
*© Interchained LLC — GPL-3.0-or-later*
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# nedb-engine — pure-Python distribution. The engine, durable AOF persistence,
|
|
2
|
+
# and the nedbd server are all pure Python, so we ship a universal py3-none-any
|
|
3
|
+
# wheel + sdist that installs on every platform/Python with no toolchain. The
|
|
4
|
+
# Rust core (rust/) remains for the napi (npm) addon and future native PyPI
|
|
5
|
+
# acceleration, reintroduced additively; `nedb._native` already imports lazily
|
|
6
|
+
# and the package works identically without it.
|
|
7
|
+
[build-system]
|
|
8
|
+
requires = ["hatchling"]
|
|
9
|
+
build-backend = "hatchling.build"
|
|
10
|
+
|
|
11
|
+
[project]
|
|
12
|
+
name = "cryptodb"
|
|
13
|
+
version = "2.4.3"
|
|
14
|
+
description = "NEDB — a versioned, self-compressing, time-traveling embedded database (replay-protected, idempotent, relational, searchable) with durable AOF persistence and a server daemon (nedbd)."
|
|
15
|
+
readme = "README.md"
|
|
16
|
+
requires-python = ">=3.8"
|
|
17
|
+
license = { text = "GPL-3.0-or-later" }
|
|
18
|
+
authors = [{ name = "Eth-Interchained" }]
|
|
19
|
+
keywords = ["database", "embedded", "mvcc", "time-travel", "versioning",
|
|
20
|
+
"compression", "dedup", "graph", "search", "redis", "git", "persistence", "server"]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 3 - Alpha",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"License :: OSI Approved :: Apache Software License",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Topic :: Database :: Database Engines/Servers",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
dependencies = [
|
|
30
|
+
# AES-256-GCM at-rest encryption (pycryptodome — pre-built wheels for all platforms
|
|
31
|
+
# including Windows MinGW, no cffi / C compiler required).
|
|
32
|
+
# Also accepted: cryptography>=41 (falls back automatically if pycryptodome absent).
|
|
33
|
+
"pycryptodome>=3.19",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
# Alternative crypto backend (for installations that already have cryptography).
|
|
38
|
+
encryption = ["cryptography>=41"]
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
nedbd = "nedb.server:main"
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/aiassistsecure/nedb"
|
|
45
|
+
Repository = "https://github.com/aiassistsecure/nedb"
|
|
46
|
+
|
|
47
|
+
[tool.hatch.build.targets.wheel]
|
|
48
|
+
packages = ["python/nedb"]
|
|
49
|
+
|
|
50
|
+
[tool.hatch.build.targets.sdist]
|
|
51
|
+
include = ["python/nedb", "README.md", "LICENSE"]
|