|
1 | | -# Zaileys v4 Dependency Justification |
2 | | - |
3 | | -**Last audit:** 2026-05-29 |
4 | | -**Policy:** Setiap dependency MUST dijustifikasi di sini. Jika tidak ada justifikasi, dep harus dihapus dari package.json. |
5 | | - |
6 | | -## Runtime Dependencies (root) |
7 | | - |
8 | | -### baileys |
9 | | -- **Version:** ^7.0.0-rc13 |
10 | | -- **Purpose:** Core WhatsApp Web protocol — semua logic WA didelegate ke library ini |
11 | | -- **Alternatives considered:** whatsmeow (Go, tidak compatible), whatsapp-web.js (less protocol coverage, no rc13 features) |
12 | | -- **Decision rationale:** Upstream resmi, rc13 patch CVE-2026-48063, support TC tokens/album/LID |
13 | | -- **Consumers:** src/connection, src/auth, src/store, src/events (semua subsistem) |
14 | | - |
15 | | -### @zaileys/media-process |
16 | | -- **Version:** workspace:* |
17 | | -- **Purpose:** Native ffmpeg spawn wrapper untuk media (audio/video/image/sticker/document) |
18 | | -- **Alternatives:** sharp+jimp (deprecated commit 8bc790d), fluent-ffmpeg (overhead) |
19 | | -- **Decision:** Internal workspace, native ffmpeg spawn = zero native binary install pain |
20 | | -- **Consumers:** Phase 5 builder media chain |
21 | | - |
22 | | -### async-mutex |
23 | | -- **Version:** ^0.5.0 |
24 | | -- **Purpose:** Mutex untuk concurrent writes di AuthStore adapters (Phase 2) |
25 | | -- **Alternatives:** p-queue (overkill — kita butuh Lock saja), @reduxjs/toolkit createAsyncThunk (irrelevant) |
26 | | -- **Decision:** Baileys sendiri pakai async-mutex — match upstream peer expectation |
27 | | -- **Consumers:** Phase 2 AuthStore/MessageStore adapters |
28 | | - |
29 | | -### lru-cache |
30 | | -- **Version:** ^11.2.7 |
31 | | -- **Purpose:** LRU layer di atas SignalKeyStore (makeCacheableSignalKeyStore pattern dari Baileys) |
32 | | -- **Alternatives:** Native Map dengan manual eviction (~50 LoC, less battle-tested) |
33 | | -- **Decision:** Baileys pakai lru-cache di prod hot path — match |
34 | | -- **Consumers:** Phase 2 AuthStore caching layer |
35 | | - |
36 | | -### pino |
37 | | -- **Version:** ^10.1.0 (verify kompatibel dgn baileys ^9.6 peer — bump down jika perlu) |
38 | | -- **Purpose:** Logger interface yang diterima Baileys WASocket config |
39 | | -- **Alternatives:** winston (heavier), bunyan (abandoned), console.log |
40 | | -- **Decision:** Baileys WASocket menerima Pino-compatible logger; matching version mengurangi peer warning |
41 | | -- **Consumers:** src/utils/logger.ts (Phase 1 stub), src/connection (Phase 3) |
42 | | -- **NOTE:** Audit version — Baileys deps mendeklarasikan pino@^9.6. Downgrade ke ^9.6 untuk hindari dual-version |
43 | | - |
44 | | -### qrcode-terminal |
45 | | -- **Version:** ^0.12.0 |
46 | | -- **Purpose:** Render QR code di terminal untuk pairing flow |
47 | | -- **Alternatives:** qrcode (image output), node-qrcode-terminal (less maintained) |
48 | | -- **Decision:** Stable, zero-dep, support QR rc13 baru (lower ECC, longer URL prefix `wa.me/settings/linked_devices#`) |
49 | | -- **Consumers:** Phase 3 connection QR display |
50 | | - |
51 | | -### nanospinner |
52 | | -- **Version:** ^1.2.2 |
53 | | -- **Purpose:** Terminal spinner untuk connection lifecycle UX |
54 | | -- **Alternatives:** ora (heavier ~10kb), kleur+manual (DIY) |
55 | | -- **Decision:** Lightweight, no chalk dep. Gated by `process.stdout.isTTY` (silent in server) |
56 | | -- **Consumers:** Phase 3 connection feedback |
57 | | - |
58 | | -### valibot |
59 | | -- **Version:** ^1.2.0 |
60 | | -- **Purpose:** Runtime schema validation untuk `Client` options + builder arg validation |
61 | | -- **Alternatives:** zod (heavier, slower), arktype (alpha), manual TS guards (no runtime safety) |
62 | | -- **Decision:** Smallest schema lib (~1kb), tree-shakable, TypeScript-native inference |
63 | | -- **Consumers:** src/client/options.ts (Phase 3), src/builder (Phase 5) |
64 | | - |
65 | | -### audio-decode |
66 | | -- **Version:** ^2.2.3 |
67 | | -- **Purpose:** Decode audio buffer metadata (sample rate, channels) untuk PTT/voice note |
68 | | -- **Alternatives:** music-metadata (Baileys sudah pakai — REUSE itu langsung jika cukup), ffprobe spawn |
69 | | -- **Decision:** EVALUATE — jika music-metadata (transitive via baileys) cukup, HAPUS audio-decode |
70 | | -- **Status:** KEEP for Phase 5 audio metadata extraction; re-evaluate jika music-metadata transitive coverage confirmed (Phase 5) |
71 | | - |
72 | | -## Removed Dependencies (v3 → v4) |
73 | | - |
74 | | -### @seald-io/nedb — REMOVED |
75 | | -- **Why removed:** v4 architecture mengabstraksi storage via AuthStore/MessageStore interface (Phase 2). Default adapter adalah file-JSON, bukan NeDB. NeDB punya scaling limit ~10MB datafile (per CONCERNS.md). |
76 | | -- **Replacement:** Phase 2 FileAuthStore (JSON file per key, atomic writes via fs.rename) |
77 | | - |
78 | | -### lmdb — REMOVED |
79 | | -- **Why removed:** Listed di optionalDependencies tapi `grep -r "lmdb" src/` tanpa hit (per CONCERNS.md L213-216). Bloated install footprint dengan native binaries tidak terpakai. |
80 | | -- **Replacement:** None — jika user butuh fast embedded storage, SqliteAuthStore (Phase 2) lebih portable |
81 | | - |
82 | | -### figlet — REMOVED |
83 | | -- **Why removed:** ASCII art banner di library headless = noise produksi. v4 fokus DX silent-by-default. |
84 | | -- **Replacement:** Optional `showBanner: true` opt-in di Phase 3 dengan simple console.log + chalk-free |
85 | | - |
86 | | -### gradient-string — REMOVED |
87 | | -- **Why removed:** Pasangan figlet — tidak relevan tanpa banner |
88 | | -- **Replacement:** None |
89 | | - |
90 | | -### radashi — REMOVED |
91 | | -- **Why removed:** Hanya 1 fungsi `_.cluster` dipakai (CONCERNS.md L226-230). Heavy dep untuk satu utility. |
92 | | -- **Replacement:** Inline `chunk()` 3-line helper di `src/utils/array.ts` (Phase 1 plan-007 atau plan-006 utils) |
93 | | - |
94 | | -### jimp (jika ada di root) — REMOVED |
95 | | -- **Why removed:** Sharp deprecated (commit 8bc790d), ffmpeg native spawn handle semua transform image |
96 | | -- **Replacement:** ffmpeg image processor di @zaileys/media-process |
97 | | -- **Note:** jimp TETAP dipertahankan di `packages/media-process/package.json` karena masih dipakai di `packages/media-process/src/ffmpeg/image.ts` (sticker resize fallback via Jimp). Root tidak pernah declare jimp — confirmed audit. |
98 | | - |
99 | | -### typescript (^5.9.3 → ^6.0.3) — KEPT sebagai fallback compiler untuk d.ts emit |
100 | | -- **Why kept:** Primary compiler @typescript/native-preview (TS 7 beta / Project Corsa / tsgo). TypeScript stable (^6.0.3) tetap di devDependencies sebagai fallback untuk d.ts emit jika tsgo belum support (per plan-005 audit) dan untuk `typecheck:legacy` validation. |
101 | | -- **Action:** Bump dari ^5.9.3 ke ^6.0.3 (TS 6 sudah stable per npm registry 2026-05-29). Lihat plan-003. |
102 | | - |
103 | | -## DevDependencies (root) |
104 | | - |
105 | | -### @changesets/cli, @commitlint/cli, @commitlint/config-conventional, husky |
106 | | -- **Keep:** Existing tooling jalan baik. No change. |
107 | | - |
108 | | -### @types/node |
109 | | -- **Version:** ^24.10.1 — align dengan workspace mysql-adapter (currently ^20.11.0 — bump ke ^24 di Phase 2) |
110 | | -- **Keep** |
111 | | - |
112 | | -### @types/qrcode-terminal |
113 | | -- **Keep** |
114 | | - |
115 | | -### tsup |
116 | | -- **Version:** ^8.5.1 (verify kompatibel dengan TS 7 beta — lihat plan-003 audit) |
117 | | -- **Keep** |
118 | | - |
119 | | -### tsx |
120 | | -- **Version:** ^4.21.0 — esbuild internal, independent dari TS compiler choice |
121 | | -- **Keep** |
122 | | - |
123 | | -### vitest (NEW) |
124 | | -- **Version:** ^2.x (latest stable) |
125 | | -- **Purpose:** Test runner ESM-native untuk per-phase unit tests |
126 | | -- **Decision:** Phase 1 setup minimal config supaya Phase 2+ langsung pakai |
127 | | -- **Added in plan-008** |
128 | | - |
129 | | -## Workspaces |
130 | | - |
131 | | -### packages/media-process |
132 | | -- **Status:** KEEP. Phase 5 dependency. |
133 | | -- **Internal audit:** jimp masih ACTIVE dipakai di `src/ffmpeg/image.ts` (Jimp import + sticker resize fallback). TIDAK dihapus dari `packages/media-process/package.json` — masih essential untuk image processing path post-refactor 8bc790d. |
134 | | - |
135 | | -### packages/mysql-adapter |
136 | | -- **Status:** EVALUATE for v4 — di v4 arsitektur, ini akan replaced oleh built-in PostgresAuthStore/PostgresMessageStore (Phase 2). |
137 | | -- **Decision:** Keep workspace folder, but mark as DEPRECATED. Will be removed at Phase 2 in favor of built-in adapters. |
138 | | - |
139 | | -## Phase 2 — Storage Peer Dependencies (optional) |
140 | | - |
141 | | -Storage adapters added in Phase 2 plans 004–006 ship as **optional peer dependencies**. End-users only install the backend they actually use; the library degrades gracefully (throws `STORE_NOT_AVAILABLE` when a peer is missing). |
142 | | - |
143 | | -### better-sqlite3 |
144 | | -- **Version:** ^11.0.0 |
145 | | -- **Purpose:** Embedded SQLite driver for `SqliteAuthStore` and `SqliteMessageStore` (plan-004, plan-006) |
146 | | -- **Why this one:** Industry-standard synchronous API, prebuilt binaries for Node 18–22, fastest prepared statements in the ecosystem; matches Baileys' upstream recommendation for embedded persistence |
147 | | -- **Install:** `pnpm add better-sqlite3` |
148 | | -- **Status:** peerDependency (optional) |
149 | | - |
150 | | -### redis |
151 | | -- **Version:** ^4.7.0 |
152 | | -- **Purpose:** Official node-redis v4 client for `RedisAuthStore` and `RedisMessageStore` (plan-005) |
153 | | -- **Why this one:** Modern Promise-based API (v4 series), first-party Redis client, supports SCAN/HSET/Stream commands required by adapter migrations |
154 | | -- **Install:** `pnpm add redis` |
155 | | -- **Status:** peerDependency (optional) |
156 | | - |
157 | | -### pg |
158 | | -- **Version:** ^8.11.0 |
159 | | -- **Purpose:** node-postgres driver for `PostgresAuthStore` and `PostgresMessageStore` (plan-006) |
160 | | -- **Why this one:** Accepts caller-owned `Pool` (zero connection leaks for embedded use), supports `ON CONFLICT` upsert, dominant Node Postgres client |
161 | | -- **Install:** `pnpm add pg` |
162 | | -- **Status:** peerDependency (optional) |
| 1 | +# Zaileys v4 — Dependency Justification |
163 | 2 |
|
164 | | -### Dev-only test helpers |
165 | | -The following live in `devDependencies` ONLY — never shipped to consumers — and exist to enable CI + unit testing without provisioning live infrastructure: |
166 | | - |
167 | | -- **@types/better-sqlite3** — type declarations for tests/scripts that touch the better-sqlite3 surface |
168 | | -- **@types/pg** — type declarations for the postgres adapter tests |
169 | | -- **pg-mem** — pure-JS Postgres simulator used by every `PostgresAuthStore` / `PostgresMessageStore` unit test (replaces a live Postgres server in CI) |
| 3 | +**Last audit:** 2026-06-01 |
| 4 | +**Policy:** Every dependency MUST be justified here. If it cannot be justified, it is removed from `package.json`. |
170 | 5 |
|
171 | | -Real Postgres / Redis integration is exercised via the cross-backend matrix when `DATABASE_URL` / `REDIS_URL` are set in the environment (skipped otherwise). |
| 6 | +Zaileys v4 is a **single package** (no workspaces). Media processing that used to live in |
| 7 | +`@zaileys/media-process` is now inlined under `src/media`. |
172 | 8 |
|
173 | | -## Audit Checklist |
174 | | -- [x] Every `dependencies` key in `package.json` appears as `### {name}` heading above |
175 | | -- [x] Every removed dep listed under "Removed Dependencies" with reason |
176 | | -- [x] No dep listed twice |
177 | | -- [x] No dep in package.json without entry here |
| 9 | +## Runtime dependencies (`dependencies`) |
| 10 | + |
| 11 | +### baileys — `^7.0.0-rc13` |
| 12 | +Core WhatsApp Web (multi-device) protocol; every WA operation delegates here. `rc13` patches the |
| 13 | +message-spoofing vulnerability **CVE-2026-48063** and adds TC tokens / album / LID support. |
| 14 | +Consumers: `src/connection`, `src/auth`, `src/store`, `src/events`, `src/builder`. |
| 15 | + |
| 16 | +### @ffmpeg-installer/ffmpeg — `^1.1.0` |
| 17 | +Ships a prebuilt `ffmpeg` binary for audio/video/sticker transforms. Imported **lazily** and |
| 18 | +wrapped in try/catch — when no prebuilt exists for the platform (e.g. Termux/Android) the code |
| 19 | +falls back to a `ffmpeg` on `PATH`. Consumers: `src/media/ffmpeg`. |
| 20 | + |
| 21 | +### @ffprobe-installer/ffprobe — `^2.1.2` |
| 22 | +Prebuilt `ffprobe` for media duration probing (video thumbnail timing, animated-sticker length). |
| 23 | +Same lazy + PATH-fallback contract as the ffmpeg installer. Consumers: `src/media/ffmpeg`. |
| 24 | + |
| 25 | +### file-type — `^21.1.1` |
| 26 | +Magic-byte media-type detection. **ESM-only** — loaded via dynamic `import()` (helper |
| 27 | +`detectFileType`) so the CJS bundle never top-level-`require()`s it (keeps Bun/Deno/Node<22 |
| 28 | +working). Consumers: `src/media`, `src/builder/media-loader.ts`. |
| 29 | + |
| 30 | +### jimp — `^1.6.0` |
| 31 | +Pure-JS image processing (thumbnail, resize, sticker shaping). The default media path; if the |
| 32 | +optional `sharp` accelerator is installed it is used instead. Consumers: `src/media/ffmpeg/image.ts`. |
| 33 | + |
| 34 | +### node-webpmux — `^3.2.1` |
| 35 | +Reads/writes WebP EXIF to embed sticker-pack metadata. Consumers: `src/media/ffmpeg/sticker.ts`. |
| 36 | + |
| 37 | +### audio-decode — `^2.2.3` |
| 38 | +Decodes audio metadata for PTT/voice notes (waveform + duration). Consumers: `src/media/ffmpeg/audio.ts`. |
| 39 | + |
| 40 | +### async-mutex — `^0.5.0` |
| 41 | +Locking for concurrent writes in the storage adapters; matches Baileys' own upstream usage. |
| 42 | +Consumers: `src/auth`, `src/store`, `src/automation`. |
| 43 | + |
| 44 | +### lru-cache — `^11.2.7` |
| 45 | +LRU layer over the signal-key store (`makeCacheableSignalKeyStore` pattern). Consumers: `src/auth`. |
| 46 | + |
| 47 | +### pino — `^10.x` |
| 48 | +Logger interface accepted by the Baileys socket config. Consumers: `src/utils/logger.ts`, `src/connection`. |
| 49 | + |
| 50 | +### qrcode-terminal — `^0.12.0` |
| 51 | +Renders the login QR in the terminal (rc13 `wa.me/settings/linked_devices#` format). Consumers: `src/connection`. |
| 52 | + |
| 53 | +### nanospinner — `^1.2.2` |
| 54 | +Lightweight connection-lifecycle spinner, gated by `process.stdout.isTTY` (silent on servers). Consumers: `src/connection`. |
| 55 | + |
| 56 | +### valibot — `^1.2.0` |
| 57 | +Tiny (~1kb) tree-shakable runtime schema validation for `Client` options and builder arguments. |
| 58 | +Consumers: `src/client`, `src/builder`. |
| 59 | + |
| 60 | +## Optional peer dependencies (storage) |
| 61 | + |
| 62 | +Storage adapters ship as **optional** peers (`peerDependenciesMeta.*.optional = true`). Users install |
| 63 | +only the backend they use; a missing peer throws `STORE_NOT_AVAILABLE` instead of crashing install. |
| 64 | + |
| 65 | +| Peer | Version | Backs | Install | |
| 66 | +| ---- | ------- | ----- | ------- | |
| 67 | +| `better-sqlite3` | `^11.0.0` | `SqliteAuthStore` / `SqliteMessageStore` | `pnpm add better-sqlite3` | |
| 68 | +| `redis` | `^4.7.0` | `RedisAuthStore` / `RedisMessageStore` | `pnpm add redis` | |
| 69 | +| `pg` | `^8.11.0` | `PostgresAuthStore` / `PostgresMessageStore` | `pnpm add pg` | |
| 70 | +| `convex` | `^1.0.0` | `ConvexAuthStore` / `ConvexMessageStore` (requires deploying `docs/convex/`) | `pnpm add convex` | |
| 71 | + |
| 72 | +## Optional accelerator (not declared) |
| 73 | + |
| 74 | +### sharp |
| 75 | +A faster native image processor. **Not** declared in `package.json` — loaded opportunistically |
| 76 | +(`require` → dynamic `import` fallback) when the user has it installed; otherwise Zaileys uses the |
| 77 | +bundled `jimp` path. Marked `external` in the bundler so it is never bundled. |
| 78 | + |
| 79 | +## Dev dependencies (highlights) |
| 80 | + |
| 81 | +- **@typescript/native-preview (tsgo)** — primary TS 7 compiler for typecheck; **typescript** kept as the `.d.ts`-emit / `typecheck:legacy` fallback. |
| 82 | +- **tsup** — dual ESM/CJS + `.d.ts`/`.d.cts` bundling. A post-build `onSuccess` rewrites all node builtins to the `node:` protocol (Deno/strict-runtime compatibility). |
| 83 | +- **vitest** + **pg-mem** — test runner and a pure-JS Postgres simulator (no live DB in CI). |
| 84 | +- **@types/better-sqlite3**, **@types/pg** — adapter test typings. |
| 85 | +- **@changesets/cli**, **@commitlint/cli**, **husky** — release + commit tooling. |
| 86 | + |
| 87 | +Real Postgres/Redis integration runs only when `DATABASE_URL` / `REDIS_URL` are set (skipped otherwise). |
| 88 | + |
| 89 | +## Removed since v3 |
| 90 | + |
| 91 | +- **@seald-io/nedb**, **lmdb** — replaced by the pluggable `AuthStore`/`MessageStore` interfaces (`file` default, `sqlite` for embedded). |
| 92 | +- **figlet**, **gradient-string** — ASCII banner removed; v4 is silent-by-default. |
| 93 | +- **radashi** — single helper inlined. |
| 94 | +- **@zaileys/media-process** workspace — media inlined into `src/media`. |
| 95 | + |
| 96 | +## Audit checklist |
| 97 | +- [x] Every `dependencies` key in `package.json` has a `###` entry above |
| 98 | +- [x] Every optional peer is listed with its backing adapter |
| 99 | +- [x] No dependency appears twice; nothing in `package.json` is undocumented |
0 commit comments