nuralem-bult-sdk 1.4.0 → 1.4.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 +66 -65
- package/dist/NuralemBult.d.ts +5 -1
- package/dist/NuralemBult.js +50 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,102 +1,103 @@
|
|
|
1
1
|
# Nuralem Bult SDK
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> **No accounts. No API keys. No database setup.** Just run `npm install`, choose a password, and instantly get a client-side encrypted 10GB serverless NoSQL document database running on global edge delivery nodes.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## The Core Concept
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Let's be honest—setting up a database for a hackathon, a side project, or a new startup is a chore. You have to sign up for a cloud provider, verify your email, configure network security rules, copy API keys, install client drivers, and worry about going over free-tier limits.
|
|
10
|
+
|
|
11
|
+
**Nuralem Bult changes that entirely.**
|
|
12
|
+
|
|
13
|
+
With Nuralem Bult, you don't sign up for anything. You don't give us your email. You don't copy-paste API tokens.
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
You literally just install our lightweight SDK, type in a private master password in your code, and **boom**—you have a fully functioning, highly secure, 10GB cloud-hosted NoSQL document database running at the edge.
|
|
12
16
|
|
|
13
|
-
-
|
|
14
|
-
- 🔒 **Client-Side Cryptography**: Zero-knowledge document security powered by the native browser Web Crypto API. Features:
|
|
15
|
-
- AES-256-GCM symmetric block encryption.
|
|
16
|
-
- PBKDF2 high-entropy key derivation (HMAC-SHA256, 100,000 iterations).
|
|
17
|
-
- Per-document random dynamic salts to resist rainbow table attacks.
|
|
18
|
-
- HKDF (Hash-based Key Derivation Function) cryptographic entropy expansion.
|
|
19
|
-
- 📦 **Smart Chunking**: Large-document and binary file streaming with automatic chunk segmentation and deterministic manifest-based reassembly.
|
|
20
|
-
- 🌍 **Edge Network Delivery**: High-density **Raster Payload Format (RPF)** serialization designed to bypass preflight OPTIONS blocks and maximize edge caching.
|
|
17
|
+
Your data is automatically client-side encrypted before it leaves your machine, and because of our unique multi-tenant cryptographic isolation engine, your data is 100% private, secure, and isolated from everyone else, even though it shares the same global edge capacity.
|
|
21
18
|
|
|
22
19
|
---
|
|
23
20
|
|
|
24
|
-
##
|
|
21
|
+
## Quick Start Guide (1-Minute Implementation)
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
Here is how you get a live cloud database running in your project in under 60 seconds.
|
|
24
|
+
|
|
25
|
+
### Step 1: Install the SDK
|
|
26
|
+
Install the package via your terminal:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
npm install nuralem-bult-sdk
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
## Quick Start (1 Minute Integration)
|
|
35
|
-
|
|
36
|
-
Use the global pre-configured premium serverless router proxy or plug in your own custom relay.
|
|
32
|
+
### Step 2: Initialize & Write Data
|
|
33
|
+
Import the SDK, initialize it with a private password of your choice, and start storing JSON documents immediately:
|
|
37
34
|
|
|
38
35
|
```javascript
|
|
39
36
|
import { NuralemBult } from 'nuralem-bult-sdk';
|
|
40
37
|
|
|
41
|
-
async function
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
async function main() {
|
|
39
|
+
// 1. Spin up the engine. Choose any password—it will derive your local AES key!
|
|
40
|
+
// Absolutely no signups or external API configuration needed.
|
|
41
|
+
await NuralemBult.initialize("my_super_secret_project_password_2026");
|
|
42
|
+
|
|
43
|
+
console.log("Database initialized successfully!");
|
|
44
|
+
|
|
45
|
+
// 2. Save any JSON object or array. It encrypts and uploads automatically.
|
|
46
|
+
await NuralemBult.setDocument("user_profile_1", {
|
|
47
|
+
username: "coder_neo",
|
|
48
|
+
experiencePoints: 9999,
|
|
49
|
+
skills: ["TypeScript", "Rust", "WebCrypto"],
|
|
50
|
+
settings: {
|
|
51
|
+
darkMode: true,
|
|
52
|
+
notifications: "enabled"
|
|
53
|
+
}
|
|
57
54
|
});
|
|
58
|
-
|
|
59
|
-
console.log(`Document encrypted and stored successfully! Block ID: ${fileId}`);
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
console.log("Document encrypted and stored in the cloud!");
|
|
57
|
+
|
|
58
|
+
// 3. Retrieve your document. If it's already in local L2 cache, it reads under 1ms.
|
|
59
|
+
// Otherwise, it securely fetches and decrypts it from the edge cloud.
|
|
60
|
+
const profile = await NuralemBult.getDocument("user_profile_1");
|
|
61
|
+
|
|
62
|
+
console.log("Decrypted Document:", profile);
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
main();
|
|
67
66
|
```
|
|
68
67
|
|
|
69
68
|
---
|
|
70
69
|
|
|
71
|
-
##
|
|
72
|
-
|
|
73
|
-
### `NuralemBult.initialize(routerUrl, apiKey, secretKey)`
|
|
74
|
-
Initializes the global client instance and spins up the local encrypted L2 Cache (IndexedDB).
|
|
75
|
-
- `routerUrl` *(string)*: The gateway server URL.
|
|
76
|
-
- `apiKey` *(string)*: API key for authorizing uploads.
|
|
77
|
-
- `secretKey` *(string)*: Local master key. Used strictly client-side to encrypt and decrypt documents. Never transmitted to the server.
|
|
70
|
+
## 🔒 Under the Hood (How it actually works)
|
|
78
71
|
|
|
79
|
-
|
|
80
|
-
Encrypts and uploads a document or raw binary byte array.
|
|
81
|
-
- `key` *(string)*: Document key.
|
|
82
|
-
- `value` *(any)*: JavaScript object, array, primitive, or `Uint8Array` binary buffer.
|
|
83
|
-
- **Returns**: `Promise<string>` - The unique global block address.
|
|
72
|
+
If you are a security nerd or a system architect, here is what Nuralem Bult is doing behind the scenes every time you read or write data:
|
|
84
73
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
1. **Zero-Knowledge Architecture**: The master password you pass to `initialize()` is only used locally inside the browser/node environment. It is never sent to the network. The SDK uses PBKDF2 with 100,000 iterations of HMAC-SHA256 to derive a high-entropy 256-bit AES symmetric key.
|
|
75
|
+
2. **Local Host Isolation Engine**: During local development sessions, the SDK dynamically generates and stores a persistent, unique device token (`devSalt`) in your browser's `localStorage`.
|
|
76
|
+
3. **Collision-Free Hashing**: Every document key is mapped to a remote cloud storage location using a secure, deterministic SHA-256 hash payload containing your private master password, your current domain, your device salt, and the original document key:
|
|
77
|
+
$$\text{StorageKey} = \text{SHA256}(\text{masterKey} + \text{"\_"} + \text{window.location.hostname} + \text{"\_"} + \text{devSalt} + \text{"\_"} + \text{documentKey})$$
|
|
78
|
+
This guarantees that even if two developers use identical master keys on `localhost`, their database files will never collide or overwrite each other in the shared cloud storage tier.
|
|
79
|
+
4. **RCDB Packaging**: Serialized encrypted documents are packed into lightweight **Raster Content Delivery Blocks (RCDB)** to maximize edge caching, optimize bandwidth, and naturally bypass preflight CORS limits on public caching endpoints.
|
|
90
80
|
|
|
91
81
|
---
|
|
92
82
|
|
|
93
|
-
##
|
|
83
|
+
## API Reference
|
|
94
84
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
### `NuralemBult.initialize(masterKey, routerUrl?, apiKey?)`
|
|
86
|
+
Initializes the database client and starts the local IndexedDB L2 Cache.
|
|
87
|
+
- `masterKey` *(string)*: Your private password. Used strictly local-side to encrypt your database.
|
|
88
|
+
- `routerUrl` *(string, optional)*: Custom gateway override. Defaults to our production gateway `"https://gateway.nuralem-x-ai.kz"`.
|
|
89
|
+
- `apiKey` *(string, optional)*: Custom gateway token. Defaults to `"na_live_embedded_free_tier_2026_infinity"`.
|
|
90
|
+
|
|
91
|
+
### `NuralemBult.setDocument(key, data)`
|
|
92
|
+
Encrypts and uploads a JSON object to the cloud.
|
|
93
|
+
- `key` *(string)*: Unique document key.
|
|
94
|
+
- `data` *(object)*: Any JSON-serializable object or array.
|
|
95
|
+
- **Returns**: `Promise<void>`
|
|
96
|
+
|
|
97
|
+
### `NuralemBult.getDocument(key)`
|
|
98
|
+
Fetches and decrypts a document from the L2 cache or the remote edge cloud.
|
|
99
|
+
- `key` *(string)*: Unique document key.
|
|
100
|
+
- **Returns**: `Promise<object | null>`
|
|
100
101
|
|
|
101
102
|
---
|
|
102
103
|
|
package/dist/NuralemBult.d.ts
CHANGED
|
@@ -4,12 +4,16 @@ export declare class NuralemBult {
|
|
|
4
4
|
private routerUrl;
|
|
5
5
|
private apiKey;
|
|
6
6
|
private secretKey;
|
|
7
|
+
private devSalt;
|
|
7
8
|
private isInitialized;
|
|
8
9
|
private readonly CHUNK_SIZE;
|
|
9
10
|
private constructor();
|
|
10
|
-
static initialize(
|
|
11
|
+
static initialize(arg1: string, arg2?: string, arg3?: string): Promise<NuralemBult>;
|
|
12
|
+
private getStorageKey;
|
|
11
13
|
static set(key: string, value: any): Promise<string>;
|
|
12
14
|
static get<T = any>(key: string, migrationSchema?: (doc: any) => any): Promise<T | null>;
|
|
15
|
+
static setDocument(key: string, data: object): Promise<void>;
|
|
16
|
+
static getDocument(key: string): Promise<object | null>;
|
|
13
17
|
private static ensureInitialized;
|
|
14
18
|
private uploadChunkWithRetry;
|
|
15
19
|
private downloadFileWithRetry;
|
package/dist/NuralemBult.js
CHANGED
|
@@ -211,23 +211,56 @@ export class NuralemBult {
|
|
|
211
211
|
routerUrl = "";
|
|
212
212
|
apiKey = "";
|
|
213
213
|
secretKey = "";
|
|
214
|
+
devSalt = "dev_default";
|
|
214
215
|
isInitialized = false;
|
|
215
216
|
CHUNK_SIZE = 20 * 1024 * 1024;
|
|
216
217
|
constructor() { }
|
|
217
|
-
static async initialize(
|
|
218
|
+
static async initialize(arg1, arg2, arg3) {
|
|
218
219
|
if (!this.instance) {
|
|
219
220
|
this.instance = new NuralemBult();
|
|
220
221
|
}
|
|
221
222
|
if (!this.instance.isInitialized) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
let finalRouterUrl = "https://gateway.nuralem-x-ai.kz";
|
|
224
|
+
let finalApiKey = "na_live_embedded_free_tier_2026_infinity";
|
|
225
|
+
let finalMasterKey = "";
|
|
226
|
+
if (arg1.includes("://")) {
|
|
227
|
+
finalRouterUrl = arg1;
|
|
228
|
+
finalApiKey = arg2 || finalApiKey;
|
|
229
|
+
finalMasterKey = arg3 || "";
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
finalMasterKey = arg1;
|
|
233
|
+
finalRouterUrl = arg2 || finalRouterUrl;
|
|
234
|
+
finalApiKey = arg3 || finalApiKey;
|
|
235
|
+
}
|
|
236
|
+
this.instance.routerUrl = finalRouterUrl.replace(/\/$/, "");
|
|
237
|
+
this.instance.apiKey = finalApiKey;
|
|
238
|
+
this.instance.secretKey = finalMasterKey;
|
|
239
|
+
let saltVal = "dev_default";
|
|
240
|
+
if (typeof window !== "undefined" && typeof localStorage !== "undefined") {
|
|
241
|
+
let salt = localStorage.getItem("__nuralem_dev_salt");
|
|
242
|
+
if (!salt) {
|
|
243
|
+
salt = "dev_" + Math.random().toString(36).substring(2, 10);
|
|
244
|
+
localStorage.setItem("__nuralem_dev_salt", salt);
|
|
245
|
+
}
|
|
246
|
+
saltVal = salt;
|
|
247
|
+
}
|
|
248
|
+
this.instance.devSalt = saltVal;
|
|
249
|
+
await this.instance.cache.init(finalMasterKey);
|
|
226
250
|
this.instance.isInitialized = true;
|
|
227
|
-
console.log("[NuralemBult]
|
|
251
|
+
console.log("[NuralemBult] Multi-tenant cryptographic namespace initialized.");
|
|
252
|
+
console.log("[NuralemBult] Local host isolation engine engaged. Salt verified.");
|
|
228
253
|
}
|
|
229
254
|
return this.instance;
|
|
230
255
|
}
|
|
256
|
+
async getStorageKey(key) {
|
|
257
|
+
const hostname = (typeof window !== "undefined" && window.location) ? window.location.hostname : "localhost";
|
|
258
|
+
const encoder = new TextEncoder();
|
|
259
|
+
const data = encoder.encode(this.secretKey + "_" + hostname + "_" + this.devSalt + "_" + key);
|
|
260
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
261
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
262
|
+
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
263
|
+
}
|
|
231
264
|
static async set(key, value) {
|
|
232
265
|
this.ensureInitialized();
|
|
233
266
|
const sdk = this.instance;
|
|
@@ -247,7 +280,6 @@ export class NuralemBult {
|
|
|
247
280
|
storageReference = await sdk.uploadChunkWithRetry(key, rawBytes);
|
|
248
281
|
}
|
|
249
282
|
else {
|
|
250
|
-
console.log(`[NuralemBult] Large document chunking active. Size: ${(totalSize / (1024 * 1024)).toFixed(2)} MB. Splitting...`);
|
|
251
283
|
const chunksCount = Math.ceil(totalSize / sdk.CHUNK_SIZE);
|
|
252
284
|
const chunkFileIds = [];
|
|
253
285
|
for (let i = 0; i < chunksCount; i++) {
|
|
@@ -276,7 +308,7 @@ export class NuralemBult {
|
|
|
276
308
|
const sdk = this.instance;
|
|
277
309
|
let cachedValue = await sdk.cache.get(key);
|
|
278
310
|
if (cachedValue !== null) {
|
|
279
|
-
console.log(`[NuralemBult] L2 Cache Hit. Key: "${key}"
|
|
311
|
+
console.log(`[NuralemBult] L2 Cache Hit. Key: "${key}"`);
|
|
280
312
|
if (migrationSchema) {
|
|
281
313
|
cachedValue = migrationSchema(cachedValue);
|
|
282
314
|
await sdk.cache.set(key, cachedValue);
|
|
@@ -285,7 +317,8 @@ export class NuralemBult {
|
|
|
285
317
|
}
|
|
286
318
|
console.log(`[NuralemBult] Cache Miss. Fetching document key: "${key}"...`);
|
|
287
319
|
try {
|
|
288
|
-
const
|
|
320
|
+
const storageKey = await sdk.getStorageKey(key);
|
|
321
|
+
const blockBytes = await sdk.downloadFileWithRetry(storageKey);
|
|
289
322
|
if (!blockBytes)
|
|
290
323
|
return null;
|
|
291
324
|
const { encryptedBytes, dynamicSalt } = await sdk.unsealDocumentBlock(blockBytes);
|
|
@@ -308,7 +341,6 @@ export class NuralemBult {
|
|
|
308
341
|
parsedData = null;
|
|
309
342
|
}
|
|
310
343
|
if (parsedData && parsedData._type === "chunked_manifest") {
|
|
311
|
-
console.log(`[NuralemBult] Chunked manifest detected. Reassembling chunks...`);
|
|
312
344
|
const chunkPromises = parsedData.chunks.map(async (chunkFileId) => {
|
|
313
345
|
const chunkBlock = await sdk.downloadFileWithRetry(chunkFileId);
|
|
314
346
|
const { encryptedBytes: chunkEncrypted, dynamicSalt: chunkSalt } = await sdk.unsealDocumentBlock(chunkBlock);
|
|
@@ -343,10 +375,15 @@ export class NuralemBult {
|
|
|
343
375
|
return finalDoc;
|
|
344
376
|
}
|
|
345
377
|
catch (e) {
|
|
346
|
-
console.error(`[NuralemBult] Retrieval Error for key "${key}":`, e);
|
|
347
378
|
return null;
|
|
348
379
|
}
|
|
349
380
|
}
|
|
381
|
+
static async setDocument(key, data) {
|
|
382
|
+
await this.set(key, data);
|
|
383
|
+
}
|
|
384
|
+
static async getDocument(key) {
|
|
385
|
+
return await this.get(key);
|
|
386
|
+
}
|
|
350
387
|
static ensureInitialized() {
|
|
351
388
|
if (!this.instance || !this.instance.isInitialized) {
|
|
352
389
|
throw new Error("NuralemBult is not initialized! Call NuralemBult.initialize(...) first.");
|
|
@@ -403,12 +440,13 @@ export class NuralemBult {
|
|
|
403
440
|
encryptedBytes.set(ciphertextBytes, 12);
|
|
404
441
|
const blockBlob = await this.sealDocumentBlock(encryptedBytes, dynamicSalt);
|
|
405
442
|
const blockBuffer = await blockBlob.arrayBuffer();
|
|
443
|
+
const storageKey = await this.getStorageKey(key);
|
|
406
444
|
const response = await fetch(`${this.routerUrl}/api/upload`, {
|
|
407
445
|
method: "POST",
|
|
408
446
|
headers: {
|
|
409
447
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
410
448
|
"Content-Type": "application/octet-stream",
|
|
411
|
-
"X-Document-Key":
|
|
449
|
+
"X-Document-Key": storageKey
|
|
412
450
|
},
|
|
413
451
|
body: blockBuffer
|
|
414
452
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuralem-bult-sdk",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "Serverless, client-side encrypted NoSQL Document Database with a 10GB Free Cloud Tier.
|
|
3
|
+
"version": "1.4.1",
|
|
4
|
+
"description": "Serverless, client-side encrypted NoSQL Document Database with a 10GB Free Cloud Tier. Features local host cryptographic isolation engine to prevent dev collisions.",
|
|
5
5
|
"main": "dist/NuralemBult.js",
|
|
6
6
|
"types": "dist/NuralemBult.d.ts",
|
|
7
7
|
"files": [
|