axiodb 22.15.1 โ†’ 22.17.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 CHANGED
@@ -1,41 +1,40 @@
1
1
  # AxioDB: The Embedded Database for Node.js
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/axiodb.svg)](https://badge.fury.io/js/axiodb)
4
- [![npm version shields](https://img.shields.io/npm/v/axiodb?logo=npm&label=npm)](https://www.npmjs.com/package/axiodb)
5
4
  [![npm downloads total](https://img.shields.io/npm/dt/axiodb.svg)](https://www.npmjs.com/package/axiodb)
6
5
  [![npm downloads yearly](https://img.shields.io/npm/dy/axiodb.svg)](https://www.npmjs.com/package/axiodb)
7
6
  [![npm downloads weekly](https://img.shields.io/npm/dw/axiodb.svg)](https://www.npmjs.com/package/axiodb)
8
7
  [![npm downloads monthly](https://img.shields.io/npm/dm/axiodb.svg)](https://www.npmjs.com/package/axiodb)
8
+ [![jsDelivr hits](https://img.shields.io/jsdelivr/npm/hm/axiodb.svg)](https://www.jsdelivr.com/package/npm/axiodb)
9
9
  [![install size](https://img.shields.io/npm/unpacked-size/axiodb?label=install%20size)](https://www.npmjs.com/package/axiodb)
10
- [![jsDelivr hits](https://img.shields.io/jsdelivr/npm/hm/axiodb?label=jsDelivr)](https://www.jsdelivr.com/package/npm/axiodb)
11
10
  [![npm types](https://img.shields.io/npm/types/axiodb?label=types)](https://www.npmjs.com/package/axiodb)
12
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
13
-
14
- [![Push to Registry](https://github.com/nexoral/AxioDB/actions/workflows/Push.yml/badge.svg?branch=main)](https://github.com/nexoral/AxioDB/actions/workflows/Push.yml)
15
- [![CodeQL](https://github.com/nexoral/AxioDB/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/nexoral/AxioDB/actions/workflows/github-code-scanning/codeql)
16
- [![Socket Security](https://socket.dev/api/badge/npm/package/axiodb)](https://socket.dev/npm/package/axiodb)
17
- [![GitHub Stars](https://img.shields.io/github/stars/nexoral/AxioDB?style=social)](https://github.com/nexoral/AxioDB)
18
-
11
+ [![Zero native deps](https://img.shields.io/badge/dependencies-0%20native-success)](https://www.npmjs.com/package/axiodb)
19
12
  [![Node.js Version](https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen)](https://nodejs.org)
20
13
  [![Tested on Node.js](https://img.shields.io/badge/tested%20on-20%20%7C%2021%20%7C%2022%20%7C%2023%20%7C%2024%20%7C%2025%20%7C%2026-blue)](https://github.com/nexoral/AxioDB/actions/workflows/Push.yml)
14
+ [![Bun tested](https://img.shields.io/badge/Bun%20tested-v1.4.0-black?logo=bun)](https://bun.sh)
15
+ [![Deno partial](https://img.shields.io/badge/Deno-partial%209%2F12-red)](https://deno.com)
21
16
  [![TypeScript](https://img.shields.io/badge/TypeScript-6.0-blue)](https://www.typescriptlang.org/)
22
- [![Zero Dependencies](https://img.shields.io/badge/dependencies-0%20native-success)](https://www.npmjs.com/package/axiodb)
23
-
24
- ๐Ÿ‘‰ **[Official Documentation โ€” axiodb.in](https://axiodb.in/)**: Full guides, API reference, and examples. This README is a quick start โ€” see the site for everything else.
25
-
26
- ---
17
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
18
+ [![GitHub Stars](https://img.shields.io/github/stars/nexoral/AxioDB?style=social)](https://github.com/nexoral/AxioDB)
19
+ [![GitHub Forks](https://img.shields.io/github/forks/nexoral/AxioDB?style=social)](https://github.com/nexoral/AxioDB/forks)
20
+ [![Contributors](https://img.shields.io/github/contributors/nexoral/AxioDB)](https://github.com/nexoral/AxioDB/graphs/contributors)
21
+ [![Last Commit](https://img.shields.io/github/last-commit/nexoral/AxioDB)](https://github.com/nexoral/AxioDB/commits/main)
27
22
 
28
- ## What is AxioDB?
23
+ [![Push to Registry](https://github.com/nexoral/AxioDB/actions/workflows/Push.yml/badge.svg?branch=main)](https://github.com/nexoral/AxioDB/actions/workflows/Push.yml)
24
+ [![CodeQL](https://github.com/nexoral/AxioDB/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/nexoral/AxioDB/actions/workflows/github-code-scanning/codeql)
29
25
 
30
- **Embedded database for Node.js, zero native deps.** Replaces SQLite, LowDB, NeDB & raw JSON files. `npm install axiodb` and you have a database โ€” MongoDB-style queries, ACID transactions, no server, no `node-gyp`, no `electron-rebuild`.
26
+ ๐Ÿ‘‰ **[Official Documentation โ€” axiodb.in](https://axiodb.in/)**: full guides, API reference, and examples. This README is a quick start.
31
27
 
32
- **Problem:** `better-sqlite3` needs compiled binaries, `electron-rebuild` on every Electron update, per-platform builds. Plain JSON files have no query/cache/index.
28
+ ## Quick start
33
29
 
34
- **Solution:** AxioDB is a file-based document database with ACID transactions and MongoDB-style queries on plain JavaScript objects.
30
+ ```bash
31
+ npm install axiodb
32
+ ```
35
33
 
36
34
  ```javascript
37
35
  const { AxioDB } = require('axiodb');
38
- const db = new AxioDB({ GUI: true }); // Dashboard at http://localhost:27018
36
+
37
+ const db = new AxioDB({ GUI: true }); // Dashboard at http://localhost:27018
39
38
  const users = await (await db.createDB('AppDB')).createCollection('users');
40
39
 
41
40
  await users.insert({ name: 'Alice', age: 30 });
@@ -43,32 +42,86 @@ const { data } = await users.query({ age: { $gt: 25 } }).Sort({ age: -1 }).Limit
43
42
  console.log(data.documents);
44
43
  ```
45
44
 
46
- ## Objective
45
+ No server to run, no `node-gyp`, no `electron-rebuild`. Requires Node.js โ‰ฅ20 (also verified on Bun v1.4.0).
46
+
47
+ ## Why AxioDB
48
+
49
+ **The problem.** `better-sqlite3` needs compiled binaries and an `electron-rebuild` on every Electron update. Plain JSON files have no query layer, no cache, and no indexes. NeDB has been unmaintained since 2016.
47
50
 
48
- **Great for:** Electron, CLI tools, embedded systems, local-first apps, rapid prototyping.
51
+ **The solution.** A file-based document database with MongoDB-style queries and real ACID transactions, running on plain JavaScript objects โ€” pure JS, so it installs on any platform Node.js runs on.
52
+
53
+ ## When to use it
54
+
55
+ **Great for** Electron apps, CLI tools, embedded and local-first software, and rapid prototyping.
56
+
57
+ **Sweet spot** 10Kโ€“500K documents in a local application that wants a real database without a database server.
58
+
59
+ **Not for** datasets beyond ~500K documents, hundreds of concurrent users, JOINs, or replication/sharding โ€” use PostgreSQL or MongoDB there. Measured limits, including per-document disk overhead and scan costs: [axiodb.in/limitations](https://axiodb.in/limitations).
60
+
61
+ ## Features
49
62
 
50
- **Sweet spot:** Local applications, desktop apps, CLI tools, and services that need a simple document database without a separate database server.
63
+ **Core** โ€” the embedded engine
51
64
 
52
- **Not for:** 10M+ docs, hundreds of concurrent users, JOINs, replication/sharding โ€” use PostgreSQL/MongoDB.
65
+ * **MongoDB-style queries** โ€” `{ age: { $gt: 25 } }`, 19 operators, plus `.hint()` and `.findByIds()`
66
+ * **ACID transactions** โ€” commit/rollback, savepoints, write-ahead log, crash recovery via `Transaction.recoverTransactions()`
67
+ * **Aggregation** โ€” 19 stages including `$lookup` joins, extensible through `OperatorRegistry`
68
+ * **Indexes** โ€” dual-write memory + disk index, served by a TTL-backed `IndexCache`
69
+ * **InMemoryCache** โ€” per-instance, invalidated on write, tunable via `{ Cache, minTTL, maxTTL, cacheClearUp }`
53
70
 
54
- ---
71
+ **Self-hostable server** โ€” the same engine, reachable remotely
72
+
73
+ * **Embedded** โ€” `new AxioDB({...})` in-process, no server, the default
74
+ * **HTTP API** โ€” port 27018, 41 documented endpoints, REST and OpenAPI
75
+ * **AxioDBCloud (TCP)** โ€” port 27019, 32 commands, optional `TCPAuth` and TLS
76
+ * **MCP server** โ€” port 27020, 43 tools for AI agents, bundled in the Docker image only
77
+ * **Docker** โ€” `theankansaha/axiodb`, every surface configurable by environment variable
78
+
79
+ **Clients and apps**
80
+
81
+ * **Dashboard** โ€” browser UI served by the HTTP surface, for browsing collections and running queries
82
+ * **AxioDBCloud client** โ€” the TypeScript client for the TCP surface, with connection pooling and auto-reconnect
83
+ * **CLI** โ€” Go binary for 12 platforms: interactive REPL, TLS, export/import
84
+ * **Desktop app** โ€” Electron GUI for Linux, macOS, and Windows
85
+
86
+ ## Stability
87
+
88
+ AxioDB is **actively developed and not yet at 1.0**. Semantic versioning is followed, but treat minor releases with care and keep independent backups of your data directory.
89
+
90
+ | Tier | What it covers |
91
+ |---|---|
92
+ | **Stable** | Core CRUD, queries, indexes, transactions, aggregation, InMemoryCache |
93
+ | **Usable, evolving** | HTTP API, AxioDBCloud TCP, Dashboard, CLI, RBAC, MCP server |
94
+ | **Experimental** | Deno support, currently passing 9 of 12 engine tests โ€” worker threads are pending |
95
+
96
+ Data at rest is stored as plain JSON files, not encrypted. Encrypt the volume if that matters to you.
97
+
98
+ ## Testing
99
+
100
+ The full suite is **329 tests across 14 suites**, all passing, each in an isolated child process. Benchmarked at 100,000 documents on an AMD Ryzen 5 5500U / Node v26.8.1:
101
+
102
+ | Operation | Time |
103
+ |---|---|
104
+ | Indexed query | 1โ€“2 ms |
105
+ | `documentId` lookup | <1 ms |
106
+ | Cache hit | <1 ms |
107
+ | Insert single | ~31 ms |
108
+ | Rollback | ~8 ms |
109
+
110
+ Full per-suite breakdown: [axiodb.in/performance](https://axiodb.in/performance).
111
+
112
+ Run it yourself with `npm test`.
55
113
 
56
114
  ## Installation
57
115
 
58
- ### npm (Library)
116
+ ### npm โ€” the library
59
117
 
60
118
  ```bash
61
119
  npm install axiodb
62
- # Node.js โ‰ฅ20 (also verified on Bun v1.4.0)
63
120
  ```
64
121
 
65
- ### CLI & Desktop GUI (System-wide)
122
+ ### CLI and Desktop GUI โ€” system-wide
66
123
 
67
- AxioDB ships a CLI tool and a native Desktop GUI (Electron). The installer
68
- presents a menu โ€” **1) CLI**, **2) GUI**, **3) Both** โ€” when run interactively,
69
- and defaults to CLI when piped (`curl | bash`).
70
-
71
- #### Quick Install (interactive)
124
+ AxioDB ships a Go CLI and an Electron desktop app for Linux, macOS, and Windows. The installer shows a menu when run interactively โ€” **1)** CLI, **2)** GUI, **3)** both โ€” and defaults to CLI when piped.
72
125
 
73
126
  ```bash
74
127
  # Linux / macOS
@@ -78,60 +131,43 @@ curl -fsSL https://raw.githubusercontent.com/nexoral/AxioDB/main/cli/Scripts/ins
78
131
  irm https://raw.githubusercontent.com/nexoral/AxioDB/main/cli/Scripts/install.ps1 | iex
79
132
  ```
80
133
 
81
- #### Non-Interactive (choose what you want)
82
-
83
- Set `CHOICE` before piping to select without the menu:
134
+ In scripts and CI, set `CHOICE` before piping to skip the menu:
84
135
 
85
136
  | `CHOICE` | Installs |
86
137
  |----------|----------|
87
- | `1` | CLI only |
88
- | `2` | GUI (Desktop) only |
138
+ | `1` | CLI only (also the default when piped) |
139
+ | `2` | Desktop GUI only |
89
140
  | `3` | CLI + GUI |
90
141
 
91
142
  ```bash
92
- # GUI (Desktop app) โ€” Linux
143
+ # Desktop GUI โ€” Linux
93
144
  curl -fsSL https://raw.githubusercontent.com/nexoral/AxioDB/main/cli/Scripts/install.sh | CHOICE=2 bash
94
145
 
95
- # GUI (Desktop app) โ€” Windows
146
+ # Desktop GUI โ€” Windows
96
147
  $env:CHOICE=2; irm https://raw.githubusercontent.com/nexoral/AxioDB/main/cli/Scripts/install.ps1 | iex
97
148
 
98
- # Both CLI + GUI โ€” Linux
149
+ # CLI + GUI โ€” Linux
99
150
  curl -fsSL https://raw.githubusercontent.com/nexoral/AxioDB/main/cli/Scripts/install.sh | CHOICE=3 bash
100
151
 
101
- # Both CLI + GUI โ€” Windows
152
+ # CLI + GUI โ€” Windows
102
153
  $env:CHOICE=3; irm https://raw.githubusercontent.com/nexoral/AxioDB/main/cli/Scripts/install.ps1 | iex
103
154
  ```
104
155
 
105
- You can also download installers directly from
106
- [GitHub Releases](https://github.com/nexoral/AxioDB/releases).
107
-
108
- #### Start a temporary local server
156
+ Prebuilt binaries are also on [GitHub Releases](https://github.com/nexoral/AxioDB/releases).
109
157
 
110
- The CLI can start a disposable local AxioDB server for development. It installs
111
- the published `axiodb` npm package into a temporary directory, keeps the server
112
- attached to the terminal, and deletes its data when you press `Ctrl+C`.
113
- Node.js โ‰ฅ20 and npm are required; the command offers platform-specific
114
- installation help when they are missing.
158
+ ### Docker
115
159
 
116
160
  ```bash
117
- axiodb serve http # HTTP API only: http://localhost:27018/api
118
- axiodb serve tcp # TCP without authentication: axiodb://localhost:27019
119
- axiodb serve tcp-auth # TCP authentication only
120
- axiodb serve full # HTTP + authenticated TCP, GUI disabled
161
+ docker run -d --name axiodb-server \
162
+ -p 27018:27018 -p 27019:27019 \
163
+ -v axiodb-data:/app \
164
+ theankansaha/axiodb
121
165
  ```
122
166
 
123
- The HTTP and TCP ports are fixed at `27018` and `27019`. The `tcp-auth` preset
124
- seeds `admin/admin`, but the server requires the first password change through
125
- HTTP/GUI and TCP currently has no password-change command, so this preset is
126
- intended for inspecting the authentication server setup rather than immediate
127
- authenticated client access.
128
-
167
+ All surfaces default to on, with a seeded `admin` account. See [Docker/README.md](Docker/README.md) for every environment variable.
129
168
 
130
169
  ## Basic CRUD
131
170
 
132
- CRUD means **Create, Read, Update, and Delete**. The following example creates a database and
133
- collection, then demonstrates each basic operation:
134
-
135
171
  ```javascript
136
172
  const { AxioDB } = require('axiodb');
137
173
 
@@ -139,51 +175,57 @@ const db = new AxioDB();
139
175
  const database = await db.createDB('AppDB');
140
176
  const users = await database.createCollection('users');
141
177
 
142
- // Create: insert a document. AxioDB adds documentId and updatedAt automatically.
178
+ // Create โ€” documentId and updatedAt are added automatically.
143
179
  const created = await users.insert({ name: 'Alice', email: 'alice@example.com', age: 30 });
144
180
  const userId = created.data.documentId;
145
181
 
146
- // Read: query documents and execute the chainable reader.
182
+ // Read โ€” the reader is chainable and lazy until .exec().
147
183
  const result = await users.query({ age: { $gte: 18 } }).exec();
148
- console.log(result.data.documents);
149
184
 
150
- // Update: update the first document matching the query.
185
+ // Update โ€” the first document matching the query.
151
186
  await users.update({ documentId: userId }).UpdateOne({ age: 31 });
152
187
 
153
- // Delete: delete the first document matching the query.
188
+ // Delete โ€” the first document matching the query.
154
189
  await users.delete({ documentId: userId }).deleteOne();
155
190
  ```
156
191
 
157
- Use `UpdateMany()` or `deleteMany()` when the operation should affect every matching document.
158
- Updates are flat merges; MongoDB update operators such as `$inc`, `$set`, and `$push` are not
159
- supported.
192
+ Use `UpdateMany()` and `deleteMany()` to affect every match. Updates are flat merges โ€” MongoDB update operators like `$inc`, `$set`, and `$push` are not supported.
160
193
 
161
- ## Features
194
+ ## Running a local server
195
+
196
+ `axiodb serve` starts a disposable AxioDB for development: it installs the published npm package into a temporary directory, keeps the server attached to your terminal, and deletes the data on `Ctrl+C`. Requires Node.js โ‰ฅ20 and npm.
197
+
198
+ ```bash
199
+ axiodb serve http # HTTP API only
200
+ axiodb serve tcp # TCP, no authentication
201
+ axiodb serve tcp-auth mypassword # authenticated TCP
202
+ axiodb serve full # HTTP + authenticated TCP
203
+ ```
204
+
205
+ Ports are fixed at `27018` (HTTP) and `27019` (TCP). The optional password seeds the shared `admin` account; `tcp-auth` requires one, since it has no HTTP surface to rotate the password through. Embedding uses the `AdminPassword` constructor option, and Docker uses `AXIODB_ADMIN_PASSWORD`.
162
206
 
163
- * **Zero native deps** โ€” pure JS, no `node-gyp`, no `electron-rebuild`
164
- * **MongoDB-style queries** โ€” `{ age: { $gt: 25 } }`, 19 operators + `hint()` + `findByIds()`
165
- * **ACID transactions** โ€” `savepoint`/`rollbackTo`/`WAL`, crashes recover via `Transaction.recoverTransactions()`
166
- * **Aggregation** โ€” 19 stages, `$lookup` joins, `OperatorRegistry` custom ops
167
- * **InMemoryCache + indexes** โ€” per-instance cache, dual-write, auto `IndexCache`
168
- * **Configurable cache** โ€” `{ Cache, minTTL, maxTTL, cacheClearUp }` controls the per-instance InMemoryCache (default `5โ€“15m` randomized TTL, `Cache: false` disables it) โ†’ [axiodb.in/api-reference](https://axiodb.in/api-reference)
169
- * **Ports:** GUI `27018` ยท TCP `27019` `AxioDBCloud` ยท MCP `27020` Docker-only
207
+ ## Documentation
170
208
 
171
- > **Docs:** `axiodb.in` is the single source โ€” this README is a quick start only.
209
+ | Page | Covers |
210
+ |---|---|
211
+ | [axiodb.in](https://axiodb.in/) | Documentation home |
212
+ | [Create a database](https://axiodb.in/create-database) | Constructor options, collections, indexes |
213
+ | [API reference](https://axiodb.in/api-reference) | Full method signatures and types |
214
+ | [AxioDBCloud](https://axiodb.in/cloud) | Remote TCP access, TLS, authentication |
215
+ | [Server API](https://axiodb.in/server-api) | The 41 HTTP endpoints |
216
+ | [CLI](https://axiodb.in/cli) | Go CLI reference |
217
+ | [Docker](https://axiodb.in/docker) | Image and environment variables |
218
+ | [Security](https://axiodb.in/security) | RBAC roles, password policy, rate limits |
219
+ | [MCP server](https://axiodb.in/mcp-server) | AI agent integration |
220
+ | [Limitations](https://axiodb.in/limitations) | Scope and measured limits |
221
+ | [Comparison](https://axiodb.in/comparison) | Against SQLite, JSON files, lowdb, nedb, better-sqlite3 |
172
222
 
173
- * **AxioDBCloud (TCP)** โ€” remote `AxioDBCloud` client, 30 commands, optional `TCPAuth` + `TLS` โ†’ [axiodb.in/cloud](https://axiodb.in/cloud)
174
- * **CLI (Go)** โ€” `axiodb document insert/query` `--hint` `find-by-ids` `transaction begin/commit` `user change-password` (HTTP `27018` for management, TCP `27019` for data) โ†’ [axiodb.in/cli](https://axiodb.in/cli)
175
- * **Docker** โ€” `theankansaha/axiodb` `AXIODB_GUI/TCP/MCP` `27018/27019/27020` โ†’ [axiodb.in/docker](https://axiodb.in/docker)
176
- * **MCP Server** โ€” 43 tools `axiodb_login` โ†’ `sessionId` + `withConfirmation` `Docker/mcp/tools/*.js` โ†’ [axiodb.in/mcp-server](https://axiodb.in/mcp-server)
177
- * **GUI + RBAC** โ€” `Super Admin/Admin/View`, `mustChangePassword`, `LoginRateLimiter` โ†’ [axiodb.in/security](https://axiodb.in/security)
178
- * **API & Types** โ€” `Document/src/data/serverApi.ts` 41 endpoints `openapi.json`, TS 6.0 strict โ†’ [axiodb.in/api-reference](https://axiodb.in/api-reference) [axiodb.in/server-api](https://axiodb.in/server-api)
223
+ ## Contributing, security & license
179
224
 
180
- ---
225
+ Contributions are welcome โ€” see [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
181
226
 
182
- ## Contributing, License & Support
227
+ Security issues: report privately through [GitHub Security Advisories](https://github.com/nexoral/AxioDB/security/advisories/new). Policy details in [SECURITY.md](SECURITY.md).
183
228
 
184
- * **Contributing:** see [CONTRIBUTING.md](CONTRIBUTING.md) + [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
185
- * **Security:** see [SECURITY.md](SECURITY.md) โ€” `admin/admin` must change password, report via GitHub Security Advisories
186
- * **License:** MIT โ€” [LICENSE](LICENSE)
187
- * **Support:** โญ star, ๐Ÿ› issues, ๐Ÿ’ก discussions โ€” [https://github.com/nexoral/AxioDB](https://github.com/nexoral/AxioDB) ยท [sponsor](https://github.com/sponsors/AnkanSaha)
229
+ Released under the [MIT License](LICENSE). Author: Ankan Saha.
188
230
 
189
- **Author:** Ankan Saha ยท **Docs:** `cd Document && npm run dev` `http://localhost:5173`
231
+ Support the project with a โญ on [GitHub](https://github.com/nexoral/AxioDB) or through [GitHub Sponsors](https://github.com/sponsors/AnkanSaha).
@@ -7,7 +7,8 @@ import { AxioDB } from "../Indexation.operation";
7
7
  */
8
8
  export default class AuthSeeder {
9
9
  private readonly axioDBInstance;
10
- constructor(axioDBInstance: AxioDB);
10
+ private readonly adminPassword?;
11
+ constructor(axioDBInstance: AxioDB, adminPassword?: string);
11
12
  seedIfNeeded(): Promise<void>;
12
13
  private seedPermissions;
13
14
  private seedRoles;
@@ -23,8 +23,9 @@ const Permissions_1 = require("../../config/Keys/Permissions");
23
23
  * where seeding itself is a no-op but the cache still needs rebuilding).
24
24
  */
25
25
  class AuthSeeder {
26
- constructor(axioDBInstance) {
26
+ constructor(axioDBInstance, adminPassword) {
27
27
  this.axioDBInstance = axioDBInstance;
28
+ this.adminPassword = adminPassword;
28
29
  }
29
30
  seedIfNeeded() {
30
31
  return __awaiter(this, void 0, void 0, function* () {
@@ -72,12 +73,13 @@ class AuthSeeder {
72
73
  }
73
74
  seedDefaultAdmin(usersCollection) {
74
75
  return __awaiter(this, void 0, void 0, function* () {
75
- const passwordHash = yield PasswordHasher_helper_1.default.hashPassword(Permissions_1.DEFAULT_ADMIN_PASSWORD);
76
+ const password = this.adminPassword || Permissions_1.DEFAULT_ADMIN_PASSWORD;
77
+ const passwordHash = yield PasswordHasher_helper_1.default.hashPassword(password);
76
78
  const document = {
77
79
  username: Permissions_1.DEFAULT_ADMIN_USERNAME,
78
80
  passwordHash,
79
81
  role: Permissions_1.SUPER_ADMIN_ROLE,
80
- mustChangePassword: true,
82
+ mustChangePassword: !this.adminPassword,
81
83
  isActive: true,
82
84
  createdAt: new Date().toISOString(),
83
85
  };
@@ -10,6 +10,7 @@ import { InMemoryCache } from "../Memory/memory.operation";
10
10
  * @param {string} options.CustomPath - Custom path for database storage. Defaults to current directory.
11
11
  * @param {boolean} options.TCP - Enable/disable TCP server (port 27019). Defaults to false.
12
12
  * @param {boolean} options.TCPAuth - Require username/password authentication (same RBAC users as the GUI) for TCP connections. Defaults to false.
13
+ * @param {string} options.AdminPassword - Password the admin account is seeded with when the config database is first created, clearing its forced password change so it can authenticate over TCP immediately. Defaults to the built-in admin/admin, which TCP rejects until rotated through the HTTP/GUI. Ignored once the users collection already exists.
13
14
  * @param {boolean} options.Cache - Enable the built-in InMemoryCache shared across the whole instance. Defaults to true.
14
15
  * @param {number} options.minTTL - Minimum cache entry lifetime in minutes. Defaults to 5.
15
16
  * @param {number} options.maxTTL - Maximum cache entry lifetime in minutes. Defaults to 15.
@@ -34,6 +35,7 @@ export declare class AxioDB {
34
35
  private HTTP;
35
36
  private TCP;
36
37
  private TCPAuth;
38
+ private readonly AdminPassword?;
37
39
  private TLS;
38
40
  private ready;
39
41
  private _initializing;
@@ -41,6 +41,7 @@ const memory_operation_1 = require("../Memory/memory.operation");
41
41
  * @param {string} options.CustomPath - Custom path for database storage. Defaults to current directory.
42
42
  * @param {boolean} options.TCP - Enable/disable TCP server (port 27019). Defaults to false.
43
43
  * @param {boolean} options.TCPAuth - Require username/password authentication (same RBAC users as the GUI) for TCP connections. Defaults to false.
44
+ * @param {string} options.AdminPassword - Password the admin account is seeded with when the config database is first created, clearing its forced password change so it can authenticate over TCP immediately. Defaults to the built-in admin/admin, which TCP rejects until rotated through the HTTP/GUI. Ignored once the users collection already exists.
44
45
  * @param {boolean} options.Cache - Enable the built-in InMemoryCache shared across the whole instance. Defaults to true.
45
46
  * @param {number} options.minTTL - Minimum cache entry lifetime in minutes. Defaults to 5.
46
47
  * @param {number} options.maxTTL - Maximum cache entry lifetime in minutes. Defaults to 15.
@@ -63,7 +64,7 @@ class AxioDB {
63
64
  throw new Error("Only one instance of AxioDB is allowed.");
64
65
  }
65
66
  AxioDB._instance = this;
66
- const { GUI, RootName, CustomPath, TCP, TCPAuth, TLS, TLSCertPath, TLSKeyPath, Cache, minTTL, maxTTL, cacheClearUp } = options;
67
+ const { GUI, RootName, CustomPath, TCP, TCPAuth, AdminPassword, TLS, TLSCertPath, TLSKeyPath, Cache, minTTL, maxTTL, cacheClearUp } = options;
67
68
  this.RootName = RootName || Keys_1.General.DBMS_Name;
68
69
  this.currentPATH = path_1.default.resolve(CustomPath || ".");
69
70
  this.fileManager = new FileManager_1.default();
@@ -81,6 +82,7 @@ class AxioDB {
81
82
  this.HTTP = options.HTTP !== undefined ? options.HTTP : (this.GUI ? true : false);
82
83
  this.TCP = TCP !== undefined ? TCP : false;
83
84
  this.TCPAuth = TCPAuth !== undefined ? TCPAuth : false;
85
+ this.AdminPassword = AdminPassword;
84
86
  this.TLS = TLS !== undefined ? TLS : false;
85
87
  this.TLSCertPath = TLSCertPath;
86
88
  this.TLSKeyPath = TLSKeyPath;
@@ -125,7 +127,7 @@ class AxioDB {
125
127
  }
126
128
  }
127
129
  if (this.GUI || this.HTTP || (this.TCP && this.TCPAuth)) {
128
- yield new AuthSeeder_service_1.default(this).seedIfNeeded();
130
+ yield new AuthSeeder_service_1.default(this, this.AdminPassword).seedIfNeeded();
129
131
  LoginRateLimiter_service_1.default.startCleanupSweep();
130
132
  }
131
133
  if (this.HTTP) {
@@ -8,6 +8,12 @@ export interface AxioDBOptions {
8
8
  TCP?: boolean;
9
9
  /** Require username/password authentication (same RBAC users as the GUI) for TCP connections. Defaults to false. */
10
10
  TCPAuth?: boolean;
11
+ /**
12
+ * Initial password for the seeded `admin` account, applied only when the `config` database
13
+ * is first created. Sets `mustChangePassword: false` so the account is immediately usable
14
+ * over TCP; omitting it keeps the default `admin`/`admin` and the existing rotation gate.
15
+ */
16
+ AdminPassword?: string;
11
17
  /** Encrypt TCP connections with TLS instead of plaintext. Requires `TLSCertPath` and `TLSKeyPath`. Defaults to false - existing plaintext deployments are unaffected unless this is explicitly turned on. */
12
18
  TLS?: boolean;
13
19
  /** Path to a PEM-encoded TLS certificate file. Required when `TLS: true`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axiodb",
3
- "version": "22.15.1",
3
+ "version": "22.17.1",
4
4
  "description": "The embedded database for Node.js. Replaces SQLite, LowDB, NeDB & raw JSON files with MongoDB-style queries, ACID transactions, zero native dependencies, and built-in InMemoryCache. No compilation, no platform issues. Perfect for desktop apps, CLI tools, and embedded systems.",
5
5
  "main": "./lib/config/DB.js",
6
6
  "types": "./lib/config/DB.d.ts",