@vex-chat/spire 1.0.0 → 1.0.2

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.
Files changed (66) hide show
  1. package/README.md +38 -38
  2. package/dist/ClientManager.d.ts +1 -3
  3. package/dist/ClientManager.js +7 -50
  4. package/dist/ClientManager.js.map +1 -1
  5. package/dist/Database.d.ts +49 -6
  6. package/dist/Database.js +255 -80
  7. package/dist/Database.js.map +1 -1
  8. package/dist/Spire.d.ts +0 -3
  9. package/dist/Spire.js +116 -81
  10. package/dist/Spire.js.map +1 -1
  11. package/dist/db/schema.d.ts +1 -0
  12. package/dist/migrations/2026-04-14_argon2id-password-hashing.d.ts +3 -0
  13. package/dist/migrations/2026-04-14_argon2id-password-hashing.js +12 -0
  14. package/dist/migrations/2026-04-14_argon2id-password-hashing.js.map +1 -0
  15. package/dist/run.js +0 -1
  16. package/dist/run.js.map +1 -1
  17. package/dist/server/avatar.d.ts +1 -3
  18. package/dist/server/avatar.js +7 -11
  19. package/dist/server/avatar.js.map +1 -1
  20. package/dist/server/errors.d.ts +3 -6
  21. package/dist/server/errors.js +2 -28
  22. package/dist/server/errors.js.map +1 -1
  23. package/dist/server/file.d.ts +1 -2
  24. package/dist/server/file.js +5 -7
  25. package/dist/server/file.js.map +1 -1
  26. package/dist/server/index.d.ts +1 -2
  27. package/dist/server/index.js +35 -33
  28. package/dist/server/index.js.map +1 -1
  29. package/dist/server/invite.d.ts +1 -2
  30. package/dist/server/invite.js +1 -1
  31. package/dist/server/invite.js.map +1 -1
  32. package/dist/server/rateLimit.d.ts +13 -3
  33. package/dist/server/rateLimit.js +57 -6
  34. package/dist/server/rateLimit.js.map +1 -1
  35. package/dist/server/user.d.ts +1 -2
  36. package/dist/server/user.js +10 -8
  37. package/dist/server/user.js.map +1 -1
  38. package/dist/utils/jwtSecret.d.ts +3 -3
  39. package/dist/utils/jwtSecret.js +5 -6
  40. package/dist/utils/jwtSecret.js.map +1 -1
  41. package/dist/utils/loadEnv.js +1 -1
  42. package/dist/utils/loadEnv.js.map +1 -1
  43. package/package.json +17 -8
  44. package/src/ClientManager.ts +7 -60
  45. package/src/Database.ts +308 -89
  46. package/src/Spire.ts +122 -119
  47. package/src/__tests__/Database.spec.ts +0 -17
  48. package/src/db/schema.ts +1 -0
  49. package/src/migrations/2026-04-14_argon2id-password-hashing.ts +18 -0
  50. package/src/run.ts +0 -1
  51. package/src/server/avatar.ts +7 -14
  52. package/src/server/errors.ts +3 -32
  53. package/src/server/file.ts +5 -10
  54. package/src/server/index.ts +37 -37
  55. package/src/server/invite.ts +0 -2
  56. package/src/server/rateLimit.ts +43 -9
  57. package/src/server/user.ts +9 -9
  58. package/src/utils/jwtSecret.ts +5 -6
  59. package/src/utils/loadEnv.ts +1 -1
  60. package/dist/__tests__/Database.spec.d.ts +0 -1
  61. package/dist/__tests__/Database.spec.js +0 -136
  62. package/dist/__tests__/Database.spec.js.map +0 -1
  63. package/dist/utils/createLogger.d.ts +0 -5
  64. package/dist/utils/createLogger.js +0 -35
  65. package/dist/utils/createLogger.js.map +0 -1
  66. package/src/utils/createLogger.ts +0 -47
package/README.md CHANGED
@@ -1,56 +1,52 @@
1
1
  # @vex-chat/spire
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@vex-chat/spire?style=flat-square&color=cb3837&logo=npm)](https://www.npmjs.com/package/@vex-chat/spire)
4
- [![CI](https://img.shields.io/github/actions/workflow/status/vex-protocol/spire/build.yml?branch=master&style=flat-square&logo=github&label=CI)](https://github.com/vex-protocol/spire/actions/workflows/build.yml)
5
- [![Released](https://img.shields.io/github/release-date/vex-protocol/spire?style=flat-square&label=released)](https://github.com/vex-protocol/spire/releases)
4
+ [![CI](https://img.shields.io/github/actions/workflow/status/vex-protocol/spire-js/build.yml?branch=master&style=flat-square&logo=github&label=CI)](https://github.com/vex-protocol/spire-js/actions/workflows/build.yml)
5
+ [![Released](https://img.shields.io/github/release-date/vex-protocol/spire-js?style=flat-square&label=released)](https://github.com/vex-protocol/spire-js/releases)
6
6
  [![License](https://img.shields.io/npm/l/@vex-chat/spire?style=flat-square&color=blue)](./LICENSE)
7
- [![Type Coverage](https://img.shields.io/badge/dynamic/json?style=flat-square&label=type-coverage&prefix=%E2%89%A5&suffix=%25&query=$.typeCoverage.atLeast&url=https://raw.githubusercontent.com/vex-protocol/spire/master/package.json&color=3178c6&logo=typescript)](https://github.com/plantain-00/type-coverage)
7
+ [![Type Coverage](https://img.shields.io/badge/dynamic/json?style=flat-square&label=type-coverage&prefix=%E2%89%A5&suffix=%25&query=$.typeCoverage.atLeast&url=https://raw.githubusercontent.com/vex-protocol/spire-js/master/package.json&color=3178c6&logo=typescript)](https://github.com/plantain-00/type-coverage)
8
8
  [![Node](https://img.shields.io/node/v/@vex-chat/spire?style=flat-square&color=339933&logo=nodedotjs)](./package.json)
9
- [![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/vex-protocol/spire?style=flat-square&label=Scorecard)](https://securityscorecards.dev/viewer/?uri=github.com/vex-protocol/spire)
9
+ [![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/vex-protocol/spire-js?style=flat-square&label=Scorecard)](https://securityscorecards.dev/viewer/?uri=github.com/vex-protocol/spire-js)
10
10
  [![Socket](https://socket.dev/api/badge/npm/package/@vex-chat/spire)](https://socket.dev/npm/package/@vex-chat/spire)
11
11
 
12
- Reference server implementation for the [Vex](https://vex.wtf) encrypted chat platform. NodeJS + SQLite + TypeScript, running the wire protocol defined in [@vex-chat/types](https://github.com/vex-protocol/types-js).
12
+ Reference server implementation for the [Vex](https://vex.wtf) protocol.
13
13
 
14
14
  ## What's in the box
15
15
 
16
- - **REST API** (Express 5) for auth, registration, users, servers, channels, invites, and file upload.
17
- - **WebSocket server** (native `ws`) for real-time messaging, presence, and push notifications. Frames are msgpack-encoded per the AsyncAPI spec in `@vex-chat/types`.
18
- - **SQLite persistence** via Kysely + better-sqlite3. Single-file DB, zero external services.
19
- - **Runtime validation** on every trust boundary: every request body, query string, and WebSocket payload is parsed through a Zod schema before any logic runs.
20
- - **Interactive docs** — [Scalar](https://scalar.com) at `/docs` for the OpenAPI spec, the [AsyncAPI web component](https://www.asyncapi.com) at `/async-docs` for the WebSocket protocol. Both production-gated for security.
21
- - **Authentication** via `@vex-chat/crypto` signing keys plus JWT session tokens. Password hashing via native `node:crypto` PBKDF2.
16
+ - **REST API** (Express 5) for full e2e messaging including auth, registration, users, servers, channels, invites, and file upload.
22
17
 
23
18
  ## Install
24
19
 
25
- From public npm:
26
-
27
- ```sh
28
- npm install @vex-chat/spire
29
- ```
30
-
31
20
  Or clone the repo:
32
21
 
33
22
  ```sh
34
- git clone git@github.com:vex-protocol/spire
35
- cd spire
23
+ git clone git@github.com:vex-protocol/spire-js
24
+ cd spire-js
36
25
  npm ci
37
26
  ```
38
27
 
39
- ## Running the server
28
+ ## Running the server (Docker)
40
29
 
41
- Spire runs directly from source via `node --experimental-strip-types` — no pre-compile step needed in dev or prod. From a clone:
30
+ From a clone, with Docker and Docker Compose installed:
42
31
 
43
32
  ```sh
44
- npm start
33
+ cp .env.example .env
34
+ # set SPK, JWT_SECRET, DB_TYPE, … (see Configuration)
35
+ docker compose up --build
45
36
  ```
46
37
 
47
- Or equivalently:
38
+ Compose builds the image from this repo’s `Dockerfile`, starts Spire with a persistent **`spire-data`** volume mounted at `/data` (SQLite + `files/`, `avatars/`, `emoji/`), and fronts it with **nginx** on **port 8080**. Use **http://localhost:8080** for HTTP and WebSocket.
39
+
40
+ ## Running without Docker
41
+
42
+ For local development or if you installed from npm, Spire runs with `node --experimental-strip-types` (no separate compile step):
48
43
 
49
44
  ```sh
50
- node --experimental-strip-types src/run.ts
45
+ npm start
46
+ # or: node --experimental-strip-types src/run.ts
51
47
  ```
52
48
 
53
- From an npm install, the source ships in the tarball under `node_modules/@vex-chat/spire/src/`, so you can run it directly:
49
+ From an npm install, sources live under `node_modules/@vex-chat/spire/src/`:
54
50
 
55
51
  ```sh
56
52
  node --experimental-strip-types node_modules/@vex-chat/spire/src/run.ts
@@ -58,30 +54,34 @@ node --experimental-strip-types node_modules/@vex-chat/spire/src/run.ts
58
54
 
59
55
  ## Configuration
60
56
 
61
- Spire reads configuration from environment variables. Use a `.env` file at the repo root (or wherever you run it from) `dotenv` picks it up automatically.
57
+ Spire reads configuration from environment variables. **Docker Compose:** put them in a `.env` file next to `docker-compose.yml` (the `env_file` entry injects them into the container). **Bare Node:** `dotenv` loads `.env` from the process working directory when you run `src/run.ts`.
62
58
 
63
59
  ### Required
64
60
 
65
- | Variable | Description |
66
- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
67
- | `SPK` | Server private key, hex-encoded. Generate one with `npm run gen-spk`. Used for server identity signing and as the default JWT secret if `JWT_SECRET` isn't set. |
68
- | `DB_TYPE` | `sqlite`, `sqlite3`, or `sqlite3mem`. Controls database backend. `sqlite3mem` runs an in-memory database useful for tests. (MySQL support was removed in `1.0.0`; operators on older deploys should migrate out.) |
69
- | `CANARY` | `true` to enable canary mode (runs extra runtime assertions). `false` for standard production. |
61
+ | Variable | Description |
62
+ | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
63
+ | `SPK` | Server private key, hex-encoded. Generate with `npm run gen-spk` (prints `SPK` and `JWT_SECRET` lines). Used for server identity signing (NaCl). |
64
+ | `JWT_SECRET` | Hex or string used as the **HMAC secret for JWTs** **required** and must be **separate from `SPK`**. `npm run gen-spk` emits a dedicated value; do not reuse `SPK` here. |
65
+ | `DB_TYPE` | `sqlite3` or `sqlite3mem`. All values use **SQLite** via `better-sqlite3` (file or `:memory:`). |
70
66
 
71
67
  ### Optional
72
68
 
73
- | Variable | Default | Description |
74
- | ------------ | ------------- | -------------------------------------------------------------------------------------------------- |
75
- | `API_PORT` | `16777` | Port for the REST API and WebSocket server. |
76
- | `NODE_ENV` | `development` | `production` enables hardened Helmet CSP and disables interactive `/docs` / `/async-docs` viewers. |
77
- | `JWT_SECRET` | `SPK` | Override the JWT signing secret. Falls back to `SPK` if unset. |
69
+ | Variable | Default | Description |
70
+ | -------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
71
+ | `API_PORT` | `16777` | Port for the REST API and WebSocket server (see `Spire` default in code if unset). |
72
+ | `NODE_ENV` | _(unset)_ | Set to `production` to disable interactive `/docs` / `/async-docs`. If unset or any other value, doc viewers are mounted. `helmet()` runs in all modes. |
73
+ | `CORS_ORIGINS` | _(empty)_ | Comma-separated allowed `Origin` values. If set, only those origins may use credentialed browser requests. If unset, Spire **reflects the request `Origin`** so self-hosted Spire and arbitrary app origins (Tauri, localhost, etc.) work without configuration — appropriate for bearer-token APIs; set an allowlist if you need to restrict which sites may call your instance from users' browsers. |
74
+ | `DEV_API_KEY` | _(empty)_ | When set, requests that send header `x-dev-api-key` with the same value (constant-time compare) **skip in-process rate limiters**. The same gate enables **`GET /status/process`** (404 without a valid key): a small JSON snapshot of the Spire Node process (PID, uptime, `memoryUsage`, cumulative `resourceUsage`, WebSocket client count). Dev / load-testing only — never set in production. |
75
+ | `CANARY` | _(unset)_ | |
78
76
 
79
77
  ### Sample `.env`
80
78
 
81
79
  ```sh
82
- SPK=a1b2c3... # generate with `npm run gen-spk`
80
+ # Run `npm run gen-spk` and paste the two lines it prints (SPK + JWT_SECRET).
81
+ SPK=a1b2c3...
82
+ JWT_SECRET=d4e5f6...
83
83
  DB_TYPE=sqlite
84
- CANARY=false
84
+ # CANARY=true
85
85
  API_PORT=16777
86
86
  NODE_ENV=production
87
87
  ```
@@ -2,7 +2,6 @@ import type { Database } from "./Database.ts";
2
2
  import type { BaseMsg, Device, User, UserRecord } from "@vex-chat/types";
3
3
  import type WebSocket from "ws";
4
4
  import { EventEmitter } from "events";
5
- import { type SpireOptions } from "./Spire.ts";
6
5
  export declare const POWER_LEVELS: {
7
6
  CREATE: number;
8
7
  DELETE: number;
@@ -17,11 +16,10 @@ export declare class ClientManager extends EventEmitter {
17
16
  private db;
18
17
  private device;
19
18
  private failed;
20
- private log;
21
19
  private notify;
22
20
  private user;
23
21
  private userDetails;
24
- constructor(ws: WebSocket, db: Database, notify: (userID: string, event: string, transmissionID: string) => void, userDetails: User, options?: SpireOptions);
22
+ constructor(ws: WebSocket, db: Database, notify: (userID: string, event: string, transmissionID: string) => void, userDetails: User);
25
23
  getDevice(): Device;
26
24
  getUser(): UserRecord;
27
25
  send(msg: BaseMsg, header?: Uint8Array): void;
@@ -3,10 +3,8 @@ import { setTimeout as sleep } from "node:timers/promises";
3
3
  import { xConcat, XUtils } from "@vex-chat/crypto";
4
4
  import { xSignOpen } from "@vex-chat/crypto";
5
5
  import { MailWSSchema, SocketAuthErrors } from "@vex-chat/types";
6
- import pc from "picocolors";
7
6
  import { parse as uuidParse, validate as uuidValidate } from "uuid";
8
7
  import { TOKEN_EXPIRY } from "./Spire.js";
9
- import { createLogger } from "./utils/createLogger.js";
10
8
  import { createUint8UUID } from "./utils/createUint8UUID.js";
11
9
  import { msgpack } from "./utils/msgpack.js";
12
10
  export const POWER_LEVELS = {
@@ -27,11 +25,10 @@ export class ClientManager extends EventEmitter {
27
25
  db;
28
26
  device;
29
27
  failed = false;
30
- log;
31
28
  notify;
32
29
  user;
33
30
  userDetails;
34
- constructor(ws, db, notify, userDetails, options) {
31
+ constructor(ws, db, notify, userDetails) {
35
32
  super();
36
33
  this.conn = ws;
37
34
  this.db = db;
@@ -39,7 +36,6 @@ export class ClientManager extends EventEmitter {
39
36
  this.userDetails = userDetails;
40
37
  this.device = null;
41
38
  this.notify = notify;
42
- this.log = createLogger("client-manager", options?.logLevel || "error");
43
39
  this.initListeners();
44
40
  this.challenge();
45
41
  }
@@ -56,25 +52,12 @@ export class ClientManager extends EventEmitter {
56
52
  return this.user;
57
53
  }
58
54
  send(msg, header) {
59
- if (header) {
60
- this.log.debug(pc.bold(pc.red("OUTH")), header.toString());
61
- }
62
- else {
63
- this.log.debug(pc.bold(pc.red("OUTH")), emptyHeader.toString());
64
- }
65
55
  const packedMessage = packMessage(msg, header);
66
- this.log.info(pc.bold("⟶ ") +
67
- responseColor(msg.type.toUpperCase()) +
68
- " " +
69
- this.toString() +
70
- " " +
71
- pc.yellow(Buffer.byteLength(packedMessage)));
72
- this.log.debug(pc.bold(pc.red("OUT")), msg);
73
56
  try {
74
57
  this.conn.send(packedMessage);
75
58
  }
76
- catch (err) {
77
- this.log.warn(String(err));
59
+ catch (_err) {
60
+ // debugger: WS send failed
78
61
  this.fail();
79
62
  }
80
63
  }
@@ -103,7 +86,6 @@ export class ClientManager extends EventEmitter {
103
86
  if (this.failed) {
104
87
  return;
105
88
  }
106
- this.log.warn("Connection closed.");
107
89
  this.conn.close();
108
90
  this.failed = true;
109
91
  this.emit("fail");
@@ -124,23 +106,15 @@ export class ClientManager extends EventEmitter {
124
106
  this.fail();
125
107
  });
126
108
  this.conn.on("message", (message) => {
127
- const [header, msg] = unpackMessage(message);
128
109
  const size = Buffer.byteLength(message);
129
110
  if (size > MAX_MSG_SIZE) {
130
- this.sendErr(msg.transmissionID, "Message is too big. Received size " +
111
+ this.sendErr("00000000-0000-0000-0000-000000000000", "Message is too big. Received size " +
131
112
  String(size) +
132
113
  " while max size is " +
133
114
  String(MAX_MSG_SIZE));
134
115
  return;
135
116
  }
136
- this.log.info(pc.bold("⟵ ") +
137
- pc.bold(msg.type.toUpperCase()) +
138
- " " +
139
- this.toString() +
140
- " " +
141
- pc.yellow(String(size)));
142
- this.log.debug(pc.bold(pc.red("INH")), header.toString());
143
- this.log.debug(pc.bold(pc.red("IN")), msg);
117
+ const [header, msg] = unpackMessage(message);
144
118
  if (!msg.type) {
145
119
  this.sendErr(msg.transmissionID, "Message type is required.");
146
120
  return;
@@ -173,7 +147,6 @@ export class ClientManager extends EventEmitter {
173
147
  void this.verifyResponse(msg);
174
148
  break;
175
149
  default:
176
- this.log.info("unsupported message %s", msg.type);
177
150
  break;
178
151
  }
179
152
  });
@@ -191,7 +164,6 @@ export class ClientManager extends EventEmitter {
191
164
  const mail = mailResult.data;
192
165
  try {
193
166
  await this.db.saveMail(mail, header, this.getDevice().deviceID, this.getUser().userID);
194
- this.log.info("Received mail for " + mail.recipient);
195
167
  const deviceDetails = await this.db.retrieveDevice(mail.recipient);
196
168
  if (!deviceDetails) {
197
169
  this.sendErr(msg.transmissionID, "No associated user record found for device.");
@@ -201,13 +173,12 @@ export class ClientManager extends EventEmitter {
201
173
  this.notify(deviceDetails.owner, "mail", msg.transmissionID, null, mail.recipient);
202
174
  }
203
175
  catch (err) {
204
- this.log.error(String(err));
205
176
  this.sendErr(msg.transmissionID, String(err));
206
177
  }
207
178
  }
208
179
  break;
209
180
  default:
210
- this.log.info("Unsupported resource type " + msg.resourceType);
181
+ break;
211
182
  }
212
183
  }
213
184
  ping() {
@@ -220,8 +191,7 @@ export class ClientManager extends EventEmitter {
220
191
  this.send(p);
221
192
  }
222
193
  async pingLoop() {
223
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- intentional infinite loop
224
- while (true) {
194
+ while (!this.failed) {
225
195
  this.ping();
226
196
  await sleep(5000);
227
197
  }
@@ -279,7 +249,6 @@ export class ClientManager extends EventEmitter {
279
249
  }
280
250
  }
281
251
  if (!message) {
282
- this.log.warn("Signature verification failed!");
283
252
  this.sendAuthError(SocketAuthErrors.BadSignature);
284
253
  this.fail();
285
254
  return;
@@ -289,12 +258,10 @@ export class ClientManager extends EventEmitter {
289
258
  this.authorize(msg.transmissionID);
290
259
  }
291
260
  else {
292
- this.log.warn("Token is bad!");
293
261
  this.sendAuthError(SocketAuthErrors.InvalidToken);
294
262
  }
295
263
  }
296
264
  else {
297
- this.log.info("User is not registered.");
298
265
  this.sendAuthError(SocketAuthErrors.UserNotRegistered);
299
266
  this.fail();
300
267
  }
@@ -312,14 +279,4 @@ function unpackMessage(msg) {
312
279
  const msgb = msgpack.decode(msgp.slice(32));
313
280
  return [msgh, msgb];
314
281
  }
315
- const responseColor = (status) => {
316
- switch (status) {
317
- case "ERROR":
318
- return pc.bold(pc.red(status));
319
- case "SUCCESS":
320
- return pc.bold(pc.green(status));
321
- default:
322
- return status;
323
- }
324
- };
325
282
  //# sourceMappingURL=ClientManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClientManager.js","sourceRoot":"","sources":["../src/ClientManager.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpE,OAAO,EAAqB,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;CACb,CAAC;AAEF,SAAS,WAAW;IAChB,OAAO,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,MAAM,OAAO,aAAc,SAAQ,YAAY;IACnC,KAAK,GAAY,IAAI,CAAC;IACtB,MAAM,GAAY,KAAK,CAAC;IACxB,WAAW,GAAe,eAAe,EAAE,CAAC;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BAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;gBACjB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YACvC,CAAC;iBAAM,CAAC;gBACJ,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;YACtD,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;YAEvD,IAAI,CAAC,IAAI,EAAE,CAAC;QAChB,CAAC;IACL,CAAC;CACJ;AAED,SAAS,WAAW,CAAC,GAAY,EAAE,MAAmB;IAClD,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,MAAM,IAAI,WAAW,EAAE,CAAC;IACrC,OAAO,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAC9B,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAElC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/B,iGAAiG;IACjG,MAAM,IAAI,GAAY,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAErD,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACxB,CAAC"}
@@ -1,11 +1,36 @@
1
1
  import type { SpireOptions } from "./Spire.ts";
2
2
  import type { Channel, Device, DevicePayload, Emoji, FileSQL, Invite, KeyBundle, MailWS, Permission, PreKeysWS, RegistrationPayload, Server, UserRecord } from "@vex-chat/types";
3
3
  import { EventEmitter } from "events";
4
- export declare const ITERATIONS = 1000;
4
+ /** Internal record that includes the hash algorithm discriminator. */
5
+ export interface InternalUserRecord extends UserRecord {
6
+ hashAlgo: string;
7
+ }
5
8
  export declare class Database extends EventEmitter {
6
9
  private db;
7
- private log;
10
+ /** Underlying better-sqlite3 handle (file or :memory:). */
11
+ private readonly rawSqlite;
12
+ /**
13
+ * In-process cache for {@link retrieveUserDeviceList} when queried for a
14
+ * single owner. Libvex calls GET /user/:id/devices on every outgoing
15
+ * `forward()`; stress runs otherwise hammer SQLite with identical reads.
16
+ * Cleared on device create/delete and when the DB is closed.
17
+ */
18
+ private readonly userDeviceListCache;
19
+ /**
20
+ * Short TTL cache for {@link retrieveEmojiList} (key = server id, stored as
21
+ * `emojis.owner`). The noise harness fires `emoji.retrieveList` as a
22
+ * follow-up on ~1/25 successful ops, so this path can contend on SQLite
23
+ * before heavier surfaces. Invalidated on emoji create/delete.
24
+ */
25
+ private readonly emojiListByServerCache;
26
+ private static readonly USER_DEVICE_LIST_CACHE_TTL_MS;
27
+ private static readonly EMOJI_LIST_CACHE_TTL_MS;
8
28
  constructor(options?: SpireOptions);
29
+ /**
30
+ * Dev-only snapshot of SQLite files + pragmas (same process as Spire).
31
+ * Not for production callers.
32
+ */
33
+ getDevSqliteMonitor(): Record<string, unknown>;
9
34
  close(): Promise<void>;
10
35
  createChannel(name: string, serverID: string): Promise<Channel>;
11
36
  createDevice(owner: string, payload: DevicePayload): Promise<Device>;
@@ -32,6 +57,7 @@ export declare class Database extends EventEmitter {
32
57
  isHealthy(): Promise<boolean>;
33
58
  markDeviceLogin(device: Device): Promise<void>;
34
59
  markUserSeen(user: UserRecord): Promise<void>;
60
+ rehashPassword(userID: string, newHash: string): Promise<void>;
35
61
  /**
36
62
  * Retrives a list of users that should be notified when a specific resourceID
37
63
  * experiences changes.
@@ -43,7 +69,7 @@ export declare class Database extends EventEmitter {
43
69
  retrieveChannels(serverID: string): Promise<Channel[]>;
44
70
  retrieveDevice(deviceID: string): Promise<Device | null>;
45
71
  retrieveEmoji(emojiID: string): Promise<Emoji | null>;
46
- retrieveEmojiList(userID: string): Promise<Emoji[]>;
72
+ retrieveEmojiList(serverID: string): Promise<Emoji[]>;
47
73
  retrieveFile(fileID: string): Promise<FileSQL | null>;
48
74
  retrieveGroupMembers(channelID: string): Promise<UserRecord[]>;
49
75
  retrieveInvite(inviteID: string): Promise<Invite | null>;
@@ -54,11 +80,28 @@ export declare class Database extends EventEmitter {
54
80
  retrieveServer(serverID: string): Promise<null | Server>;
55
81
  retrieveServerInvites(serverID: string): Promise<Invite[]>;
56
82
  retrieveServers(userID: string): Promise<Server[]>;
57
- retrieveUser(userIdentifier: string): Promise<null | UserRecord>;
83
+ retrieveUser(userIdentifier: string): Promise<InternalUserRecord | null>;
58
84
  retrieveUserDeviceList(userIDs: string[]): Promise<Device[]>;
59
- retrieveUsers(): Promise<UserRecord[]>;
85
+ retrieveUsers(): Promise<InternalUserRecord[]>;
60
86
  saveMail(mail: MailWS, header: Uint8Array, deviceID: string, userID: string): Promise<void>;
61
87
  saveOTK(userID: string, deviceID: string, otks: PreKeysWS[]): Promise<void>;
62
88
  private init;
63
89
  }
64
- export declare const hashPassword: (password: string, salt: Uint8Array) => NonSharedBuffer;
90
+ /**
91
+ * Hash a password with Argon2id (new default).
92
+ * Returns the encoded hash string which embeds salt, params, and digest.
93
+ */
94
+ export declare function hashPasswordArgon2(password: string): Promise<string>;
95
+ /**
96
+ * Verify a password against either Argon2id or legacy PBKDF2 storage.
97
+ * Returns `{ valid, needsRehash }` — callers should rehash on success
98
+ * when `needsRehash` is true.
99
+ */
100
+ export declare function verifyPassword(password: string, stored: {
101
+ hashAlgo: string;
102
+ passwordHash: string;
103
+ passwordSalt: string;
104
+ }): Promise<{
105
+ needsRehash: boolean;
106
+ valid: boolean;
107
+ }>;