axiodb 22.14.1 → 22.16.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 +14 -9
- package/lib/Services/Auth/AuthSeeder.service.d.ts +2 -1
- package/lib/Services/Auth/AuthSeeder.service.js +5 -3
- package/lib/Services/Indexation.operation.d.ts +1 -0
- package/lib/Services/Indexation.operation.js +3 -2
- package/lib/config/Interfaces/Operation/Indexation.operation.interface.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,17 +114,22 @@ Node.js ≥20 and npm are required; the command offers platform-specific
|
|
|
114
114
|
installation help when they are missing.
|
|
115
115
|
|
|
116
116
|
```bash
|
|
117
|
-
axiodb serve http
|
|
118
|
-
axiodb serve tcp
|
|
119
|
-
axiodb serve tcp-auth
|
|
120
|
-
axiodb serve full
|
|
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
|
|
121
|
+
axiodb serve tcp-auth mypassword # same, seeding admin with mypassword
|
|
121
122
|
```
|
|
122
123
|
|
|
123
|
-
The HTTP and TCP ports are fixed at `27018` and `27019`. The `tcp-auth`
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
The HTTP and TCP ports are fixed at `27018` and `27019`. The `http`, `tcp-auth`
|
|
125
|
+
and `full` presets seed the shared `admin` account; pass an optional password as
|
|
126
|
+
the second argument to choose it yourself and skip the forced first-login change.
|
|
127
|
+
Without one, `admin/admin` is seeded and TCP refuses it until the password is
|
|
128
|
+
changed through HTTP/GUI, since TCP has no password-change command. The `tcp`
|
|
129
|
+
preset creates no admin account and rejects the password argument.
|
|
130
|
+
|
|
131
|
+
When embedding, the same option is `AdminPassword` in the `AxioDB` constructor.
|
|
132
|
+
In Docker it is `AXIODB_ADMIN_PASSWORD`.
|
|
128
133
|
|
|
129
134
|
|
|
130
135
|
## Basic CRUD
|
|
@@ -7,7 +7,8 @@ import { AxioDB } from "../Indexation.operation";
|
|
|
7
7
|
*/
|
|
8
8
|
export default class AuthSeeder {
|
|
9
9
|
private readonly axioDBInstance;
|
|
10
|
-
|
|
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
|
|
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:
|
|
82
|
+
mustChangePassword: !this.adminPassword,
|
|
81
83
|
isActive: true,
|
|
82
84
|
createdAt: new Date().toISOString(),
|
|
83
85
|
};
|
|
@@ -63,7 +63,7 @@ class AxioDB {
|
|
|
63
63
|
throw new Error("Only one instance of AxioDB is allowed.");
|
|
64
64
|
}
|
|
65
65
|
AxioDB._instance = this;
|
|
66
|
-
const { GUI, RootName, CustomPath, TCP, TCPAuth, TLS, TLSCertPath, TLSKeyPath, Cache, minTTL, maxTTL, cacheClearUp } = options;
|
|
66
|
+
const { GUI, RootName, CustomPath, TCP, TCPAuth, AdminPassword, TLS, TLSCertPath, TLSKeyPath, Cache, minTTL, maxTTL, cacheClearUp } = options;
|
|
67
67
|
this.RootName = RootName || Keys_1.General.DBMS_Name;
|
|
68
68
|
this.currentPATH = path_1.default.resolve(CustomPath || ".");
|
|
69
69
|
this.fileManager = new FileManager_1.default();
|
|
@@ -81,6 +81,7 @@ class AxioDB {
|
|
|
81
81
|
this.HTTP = options.HTTP !== undefined ? options.HTTP : (this.GUI ? true : false);
|
|
82
82
|
this.TCP = TCP !== undefined ? TCP : false;
|
|
83
83
|
this.TCPAuth = TCPAuth !== undefined ? TCPAuth : false;
|
|
84
|
+
this.AdminPassword = AdminPassword;
|
|
84
85
|
this.TLS = TLS !== undefined ? TLS : false;
|
|
85
86
|
this.TLSCertPath = TLSCertPath;
|
|
86
87
|
this.TLSKeyPath = TLSKeyPath;
|
|
@@ -125,7 +126,7 @@ class AxioDB {
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
if (this.GUI || this.HTTP || (this.TCP && this.TCPAuth)) {
|
|
128
|
-
yield new AuthSeeder_service_1.default(this).seedIfNeeded();
|
|
129
|
+
yield new AuthSeeder_service_1.default(this, this.AdminPassword).seedIfNeeded();
|
|
129
130
|
LoginRateLimiter_service_1.default.startCleanupSweep();
|
|
130
131
|
}
|
|
131
132
|
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.
|
|
3
|
+
"version": "22.16.0",
|
|
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",
|