chirkle 0.0.0-stage → 0.2.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.
Files changed (139) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +326 -2
  3. package/package.json +76 -4
  4. package/pb_hooks/federation/config.js +276 -0
  5. package/pb_hooks/federation/inbox.js +316 -0
  6. package/pb_hooks/federation/messages.js +420 -0
  7. package/pb_hooks/federation/mirror.js +277 -0
  8. package/pb_hooks/federation/net.js +247 -0
  9. package/pb_hooks/federation/peers.js +490 -0
  10. package/pb_hooks/federation/people.js +376 -0
  11. package/pb_hooks/federation/rooms.js +552 -0
  12. package/pb_hooks/federation/worker.js +413 -0
  13. package/pb_hooks/federation.pb.js +141 -0
  14. package/pb_hooks/lib/access.js +102 -0
  15. package/pb_hooks/lib/account.js +31 -0
  16. package/pb_hooks/lib/anonymous.js +189 -0
  17. package/pb_hooks/lib/bulk.js +187 -0
  18. package/pb_hooks/lib/collections.js +587 -0
  19. package/pb_hooks/lib/dms.js +123 -0
  20. package/pb_hooks/lib/emoji.js +28 -0
  21. package/pb_hooks/lib/enrich.js +75 -0
  22. package/pb_hooks/lib/features.js +31 -0
  23. package/pb_hooks/lib/files.js +375 -0
  24. package/pb_hooks/lib/http.js +146 -0
  25. package/pb_hooks/lib/images.js +160 -0
  26. package/pb_hooks/lib/keepalive.js +31 -0
  27. package/pb_hooks/lib/lists.js +173 -0
  28. package/pb_hooks/lib/media.js +635 -0
  29. package/pb_hooks/lib/messages.js +519 -0
  30. package/pb_hooks/lib/moderation.js +128 -0
  31. package/pb_hooks/lib/outbound.js +116 -0
  32. package/pb_hooks/lib/pages.js +171 -0
  33. package/pb_hooks/lib/previews.js +346 -0
  34. package/pb_hooks/lib/reactions.js +110 -0
  35. package/pb_hooks/lib/reads.js +181 -0
  36. package/pb_hooks/lib/records.js +77 -0
  37. package/pb_hooks/lib/rooms.js +148 -0
  38. package/pb_hooks/lib/site.js +102 -0
  39. package/pb_hooks/lib/text.js +110 -0
  40. package/pb_hooks/lib/users.js +81 -0
  41. package/pb_hooks/lib/worker.js +159 -0
  42. package/pb_hooks/main.pb.js +324 -0
  43. package/pb_hooks/telegram/api.js +129 -0
  44. package/pb_hooks/telegram/inbound.js +553 -0
  45. package/pb_hooks/telegram/links.js +157 -0
  46. package/pb_hooks/telegram/outbound.js +352 -0
  47. package/pb_hooks/telegram/people.js +166 -0
  48. package/pb_hooks/telegram/reactions.js +137 -0
  49. package/pb_hooks/telegram/rich.js +192 -0
  50. package/pb_hooks/telegram/worker.js +182 -0
  51. package/pb_hooks/telegram.pb.js +47 -0
  52. package/pb_migrations/1760000000_init.js +150 -0
  53. package/pb_migrations/1760000001_qa_fixes.js +69 -0
  54. package/pb_migrations/1760000002_avatars.js +39 -0
  55. package/pb_migrations/1760000003_direct_messages.js +142 -0
  56. package/pb_migrations/1760000004_attachments.js +28 -0
  57. package/pb_migrations/1760000005_file_names.js +16 -0
  58. package/pb_migrations/1760000006_room_reads.js +41 -0
  59. package/pb_migrations/1760000007_replies.js +23 -0
  60. package/pb_migrations/1760000008_lowercase_emails.js +24 -0
  61. package/pb_migrations/1760000009_reactions.js +32 -0
  62. package/pb_migrations/1760000010_fit_thumbs.js +18 -0
  63. package/pb_migrations/1760000011_forwarding.js +39 -0
  64. package/pb_migrations/1760000012_accounts.js +55 -0
  65. package/pb_migrations/1760000013_qa_pass5.js +19 -0
  66. package/pb_migrations/1760000014_room_access.js +96 -0
  67. package/pb_migrations/1760000015_site.js +46 -0
  68. package/pb_migrations/1760000016_forward_refs.js +43 -0
  69. package/pb_migrations/1760000017_no_dms.js +18 -0
  70. package/pb_migrations/1760000018_attachment_limits.js +24 -0
  71. package/pb_migrations/1760000019_telegram.js +109 -0
  72. package/pb_migrations/1760000020_service_messages.js +21 -0
  73. package/pb_migrations/1760000021_forward_view_index.js +41 -0
  74. package/pb_migrations/1760000022_link_previews.js +43 -0
  75. package/pb_migrations/1760000023_room_writers.js +49 -0
  76. package/pb_migrations/1760000024_message_search.js +51 -0
  77. package/pb_migrations/1760000025_search_dotted_i.js +16 -0
  78. package/pb_migrations/1760000026_push.js +67 -0
  79. package/pb_migrations/1760000027_push_tokens_per_user.js +31 -0
  80. package/pb_migrations/1760000028_media_grid_thumbs.js +18 -0
  81. package/pb_migrations/1760000029_media.js +71 -0
  82. package/pb_migrations/1760000030_collections.js +140 -0
  83. package/pb_migrations/1760000031_unread_limit.js +20 -0
  84. package/pb_migrations/1760000032_federation.js +227 -0
  85. package/pb_migrations/1760000033_federation_requests.js +44 -0
  86. package/pb_migrations/1760000034_telegram_parts.js +26 -0
  87. package/pb_migrations/1760000035_telegram_anonymous.js +16 -0
  88. package/pb_migrations/1760000036_chirkle.js +20 -0
  89. package/pb_migrations/1760000037_file_dims.js +35 -0
  90. package/pb_migrations/1760000038_drop_push.js +64 -0
  91. package/pb_migrations/1760000039_anonymous_rooms.js +40 -0
  92. package/pb_migrations/1760000040_moderators.js +42 -0
  93. package/pb_migrations/1760000041_shared_files.js +500 -0
  94. package/pb_migrations/1760000042_files_src.js +17 -0
  95. package/pb_migrations/1760000043_telegram_reactions.js +21 -0
  96. package/pb_public/assets/access-ALBW2MT2.js +2 -0
  97. package/pb_public/assets/access-ALBW2MT2.js.map +7 -0
  98. package/pb_public/assets/access-PB77EH4F.css +2 -0
  99. package/pb_public/assets/access-PB77EH4F.css.map +7 -0
  100. package/pb_public/assets/app-A3SXD3FF.css +2 -0
  101. package/pb_public/assets/app-A3SXD3FF.css.map +7 -0
  102. package/pb_public/assets/app-NDSIQW4L.js +3 -0
  103. package/pb_public/assets/app-NDSIQW4L.js.map +7 -0
  104. package/pb_public/assets/collections-DHJEOLHW.css +2 -0
  105. package/pb_public/assets/collections-DHJEOLHW.css.map +7 -0
  106. package/pb_public/assets/emoji-WSTVXAW5.css +2 -0
  107. package/pb_public/assets/emoji-WSTVXAW5.css.map +7 -0
  108. package/pb_public/assets/emoji-picker-QYRX6NYL.js +609 -0
  109. package/pb_public/assets/emoji-picker-QYRX6NYL.js.map +7 -0
  110. package/pb_public/assets/inter-cyrillic-JEOLYBOO.woff2 +0 -0
  111. package/pb_public/assets/inter-cyrillic-ext-IYF56FF6.woff2 +0 -0
  112. package/pb_public/assets/inter-greek-IRE366VL.woff2 +0 -0
  113. package/pb_public/assets/inter-latin-NRMW37G5.woff2 +0 -0
  114. package/pb_public/assets/inter-latin-ext-HA22NDSG.woff2 +0 -0
  115. package/pb_public/assets/lazy-4CXRBHHM.js +2 -0
  116. package/pb_public/assets/lazy-4CXRBHHM.js.map +7 -0
  117. package/pb_public/assets/media-7TCBG7WM.css +2 -0
  118. package/pb_public/assets/media-7TCBG7WM.css.map +7 -0
  119. package/pb_public/assets/media-FPRU2QH5.js +2 -0
  120. package/pb_public/assets/media-FPRU2QH5.js.map +7 -0
  121. package/pb_public/assets/notify-L6GERFNO.js +2 -0
  122. package/pb_public/assets/notify-L6GERFNO.js.map +7 -0
  123. package/pb_public/assets/search-3UT4HMES.js +2 -0
  124. package/pb_public/assets/search-3UT4HMES.js.map +7 -0
  125. package/pb_public/assets/switcher-CEUKRLEY.js +2 -0
  126. package/pb_public/assets/switcher-CEUKRLEY.js.map +7 -0
  127. package/pb_public/assets/viewer-DXT7SKOU.js +2 -0
  128. package/pb_public/assets/viewer-DXT7SKOU.js.map +7 -0
  129. package/pb_public/assets/viewer-P7GYCBYM.css +2 -0
  130. package/pb_public/assets/viewer-P7GYCBYM.css.map +7 -0
  131. package/pb_public/icons/apple-touch-icon.png +0 -0
  132. package/pb_public/icons/icon-192.png +0 -0
  133. package/pb_public/icons/icon-512.png +0 -0
  134. package/pb_public/icons/icon.svg +1 -0
  135. package/pb_public/icons/maskable-512.png +0 -0
  136. package/pb_public/index.html +21 -0
  137. package/pb_public/sw.js +1 -0
  138. package/scripts/fetch-pocketbase.sh +63 -0
  139. package/scripts/start.mjs +93 -0
package/README.md CHANGED
@@ -1,3 +1,327 @@
1
- # Temporary Holding Version
1
+ # <img src="logo.svg" alt="" width="36" height="36" align="top"> Chirkle
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A small, fast, real-time group chat. One [PocketBase](https://pocketbase.io) binary is the whole backend
4
+ (auth, data, realtime, static files); the frontend is vanilla TypeScript bundled by esbuild — no framework,
5
+ ~49 KB of JS and ~11 KB of CSS gzipped (`npm run build` fails over its budget: 49.75 KB of JS,
6
+ 11.25 KB of CSS; rarer screens such as the image viewer, search, room access and collections load on first use).
7
+
8
+ <picture>
9
+ <source media="(prefers-color-scheme: dark)" srcset="docs/screenshot-dark.png">
10
+ <img alt="A room in Chirkle: the room list with unread counts on the left; messages with avatars, a reply, a photo and emoji reactions on the right" src="docs/screenshot-light.png">
11
+ </picture>
12
+
13
+ - Public rooms anyone can create; hide rooms you don't care about; creators archive rooms (read-only, history kept)
14
+ - Room access, chosen by each room's creator: **Private** (only the people they add), **Public** (everyone with an account) or **Open Air** (anyone can read it, no account needed; the home page shows these rooms to guests, who log in or sign up to join in); and who can post: everyone who can read it, or only the people they choose (the others read and react)
15
+ - Live messages, edits and deletes (deleted messages leave a placeholder)
16
+ - Full history: scroll back to the very first message of any room (windowed, ≤300 messages in the DOM)
17
+ - Direct messages between any two users, private to them; close a conversation and it comes back on the next message
18
+ - Avatars (or colored initials) and a profile page to change your picture, display name (unique) and password, and to log out
19
+ - Search in any room or DM: every word you type, in any case ("привет" finds "Привет"), newest first; pick a result to go to it, however far back
20
+ - Replies: answer any message with a quote of it; click the quote to jump to the original, however far back
21
+ - Links in messages are clickable and open in a new tab (http, https and www. addresses only)
22
+ - Emoji: a picker in the composer, and reactions on any message (as many different ones as you like), live for everyone
23
+ - Attachments: up to 10 files of 20 MB per message, with an upload progress bar; images shown as thumbnails and videos as their first frame (4 tiles, then "+N"); files are private to whoever can read the message
24
+ - Image viewer: click a thumbnail to see it full size (or a video to play it) and step through the room's images and videos (buttons, arrow keys, swipe);
25
+ loaded only when first used, so it adds nothing to the page's first load
26
+ - Collections: save any image or video from the chat to collections of your own, public or private, and attach from them to messages; subscribe to other people's public collections to use theirs too, with a count of what's new and the new items highlighted; media attached from a collection link to it (or say "Private collection")
27
+ - Select messages (up to 50): forward them to any room or DM, with "Forwarded from" and their attachments (forwards show the original, so nothing is copied), or delete them together when they are yours
28
+ - Unread counts on every room and DM, live, and in sync across your tabs and devices; the total shows in the tab's favicon and title;
29
+ a room with unread messages opens at the first of them, under a "New" line
30
+ - What you were typing is kept per room, even across a reload; "Jump to latest" whenever you are scrolled up
31
+ - Your own branding (title and logo) and, if you like, invite-only signups: set by the admin in PocketBase
32
+ - Telegram bridge (optional): link rooms to Telegram groups through a bot; messages, replies, edits, files and (with the bot an admin) reactions go both ways (deletes from Chirkle to Telegram), Telegram people show under stand-in accounts with their names and pictures — see [Telegram integration](#telegram-integration)
33
+ - Fast room switching: each room's latest messages are kept in the browser (IndexedDB) and shown at once while the
34
+ server answers; unread rooms are fetched ahead. Attachment thumbnails are kept by the service worker, so going back
35
+ to a room (or reloading) doesn't download them again. All of it is cleared on logout
36
+ - Notifications of DMs and replies to you, with a pop-up and/or a sound, turned on in your profile, and of every
37
+ message in the rooms you choose from their menu: they come from the open tab's live connection (even in the
38
+ background), so no push service (Google, Mozilla, Apple) is involved
39
+ - Installable as an app (PWA: Add to Home Screen, the browser's Install button); it opens offline to its shell
40
+ - Optimistic sending with safe retries, reconnect gap-fill, light/dark themes, works on phones
41
+ - A native Android app (Kotlin, Jetpack Compose) with the same features, notifications and a 3 MB download — see
42
+ [Android app](#android-app)
43
+
44
+ <picture>
45
+ <source media="(prefers-color-scheme: dark)" srcset="docs/collections-dark.png">
46
+ <img alt="A collection in Chirkle: the private Moodboard's pictures by month, with Upload, Rename and Make public; the sidebar lists your collections with their counts and a followed one with 3 new" src="docs/collections-light.png">
47
+ </picture>
48
+
49
+ Design: [`docs/DESIGN.md`](docs/DESIGN.md) · Android app: [`docs/ANDROID.md`](docs/ANDROID.md) · QA: [`docs/QA.md`](docs/QA.md) · Refactoring plan: [`docs/REFACTOR.md`](docs/REFACTOR.md) · Archived plans: [MVP build](docs/history/BUILD_PLAN.md), [avatars, DMs, attachments](docs/history/NEXT_FEATURES_PLAN.md)
50
+
51
+ ## Requirements
52
+
53
+ - Node.js ≥ 22 and npm ≥ 11
54
+ - Linux or macOS (x64/arm64) — `npm start` and `npm run setup` download the matching PocketBase binary (Windows: WSL or Docker)
55
+ - Optional, for the server's workers: `ffmpeg` (video posters) and `curl` (link previews) on the `PATH`
56
+ - For e2e tests: Playwright's Chromium (`npx playwright install chromium`)
57
+
58
+ ## Quick start
59
+
60
+ ```sh
61
+ npm install
62
+ npm start # builds the web app, downloads PocketBase on the first run, serves http://127.0.0.1:8090
63
+ ```
64
+
65
+ Or without a clone, from npm (the package ships the built web app and the server's hooks and migrations):
66
+
67
+ ```sh
68
+ npx chirkle # data in ./pb_data
69
+ npx chirkle chat.example.com # HTTPS with Let's Encrypt on ports 80/443
70
+ ```
71
+
72
+ Open the page and sign up. The first run prints a link to create the admin (superuser) account, or create one with
73
+ `npx chirkle superuser upsert you@example.com <password>` (`npm start -- superuser upsert …` in a clone).
74
+ `HOST` and `PORT` choose the address (default `127.0.0.1:8090`; `HOST=0.0.0.0` to reach it from other machines),
75
+ `CHIRKLE_DATA` the data directory (default `./pb_data`), and any other `pocketbase serve` flags can follow
76
+ (`npx chirkle --http=0.0.0.0:80`). The settings of [Deploying](#deploying) (`TRUSTED_PROXY` behind a reverse proxy, …)
77
+ apply as they are. PocketBase is kept in the package's `bin/` (or `~/.cache/chirkle/` when that isn't writable).
78
+
79
+ ## Getting started (development)
80
+
81
+ ```sh
82
+ npm ci
83
+ npm run setup # downloads the pinned PocketBase (checksum-verified) into bin/
84
+ npm run dev # esbuild watch + PocketBase on http://127.0.0.1:8090
85
+ ```
86
+
87
+ Open http://127.0.0.1:8090 and sign up (top right). The dev database lives in `pb_data/` — delete it to start over.
88
+ The PocketBase admin UI is at http://127.0.0.1:8090/_/ (create a superuser with
89
+ `bin/pocketbase superuser upsert you@example.com <password> --dir=pb_data`).
90
+
91
+ ## Scripts
92
+
93
+ | Script | What it does |
94
+ |---|---|
95
+ | `npm start` | Production build, then the server (`scripts/start.mjs`, the package's `chirkle` command): PocketBase on http://127.0.0.1:8090 with `pb_data/` |
96
+ | `npm run dev` | Unminified watch build into `pb_public/` + `pocketbase serve --dev` |
97
+ | `npm run build` | Production build (hashed assets) into `pb_public/`; fails if over the size budget |
98
+ | `npm run release -- <version>` | Gives the npm package and the Android app the next version and starts the app's changelog; then publish a GitHub Release tagged `v<version>` ([Releasing](#releasing)) |
99
+ | `npm run typecheck` | `tsc` (strict) for the frontend, tests and scripts, plus `pb_hooks/` + `pb_migrations/` against PocketBase's generated types (`types/pocketbase.d.ts`, written by `scripts/pb-types.sh`) |
100
+ | `npm run lint` | Biome: formatting, lint rules, import order (`npm run format` applies the fixes) |
101
+ | `npm run lint:sinks` | Fails if frontend code uses `innerHTML` & co. (XSS guard) |
102
+ | `npm test` | Unit tests (Vitest + happy-dom, no server) and component tests (views and services against a real, throwaway PocketBase) |
103
+ | `npm run test:unit` | Only the unit tests: no server, ~10 s |
104
+ | `npm run test:int` | Integration tests: schema, API rules, hooks, realtime, pagination |
105
+ | `npm run test:e2e` | Playwright end-to-end tests against the production build |
106
+ | `npm run schema:snapshot` | Rewrite `docs/schema.snapshot.json` (every collection's API rules, fields and indexes, and the rate limits) after a migration changes them; `test:int` fails while it is out of date |
107
+ | `npm run screenshots` | Rewrite the README screenshots (`docs/screenshot-*.png`, `docs/collections-*.png`): a throwaway server with made-up people, messages and collections, photographed in Chromium after `npm run build` |
108
+ | `npm run check` | typecheck + lint + lint:sinks + test + test:int + build (what CI runs before e2e) |
109
+
110
+ Every test run starts its own PocketBase on a free port with a temp data dir — nothing to clean up, and no fakes
111
+ except a stub Telegram Bot API for the bridge's tests. CI (`.github/workflows/ci.yml`) runs typecheck, lint and build, then unit, integration and e2e side by side, e2e once
112
+ per browser (Chromium, Firefox, WebKit).
113
+
114
+ ## Project layout
115
+
116
+ ```
117
+ pb_migrations/ schema + API rules (the source of truth for access control)
118
+ pb_hooks/ server-side hooks: trimming, soft delete, edit/archive stamps, DM + unread routes, guards, security headers;
119
+ telegram.pb.js + telegram/: the optional Telegram bridge
120
+ web/src/ frontend: api.ts (the only module that talks to PocketBase, through pb.ts, a minimal client), router,
121
+ store, cache.ts (the room cache), sw.ts (the service worker), views/, lib/ (pure logic)
122
+ web/styles/ app.css (bundles app/*.css, one file per part) and viewer.css
123
+ web/public/ icons/: the logo (logo.svg) as icon.svg and the PNG app icons, served as they are
124
+ scripts/ build, dev, fetch-pocketbase, pb-types (PocketBase's types for the hooks), html-sink check
125
+ tests/ unit/, integration/, e2e/, perf/ (scale measurements), support/ (PocketBase harness, Telegram stub, helpers)
126
+ android/ the Android app (docs/ANDROID.md): core/data (API, realtime, database, sync), core/ui, feature/*, app
127
+ ```
128
+
129
+ ## Deploying
130
+
131
+ Build once, then copy `bin/pocketbase`, `pb_public/`, `pb_migrations/` and `pb_hooks/` to the server.
132
+ Migrations run automatically on start, and nothing is served until they are done, so they change only the database.
133
+ What stored files need moving (the shared files of DESIGN.md §37) the media worker does afterwards, while the server
134
+ runs.
135
+
136
+ ```sh
137
+ npm ci && npm run setup && npm run build
138
+ rsync -a bin/pocketbase pb_public pb_migrations pb_hooks server:/opt/chirkle/
139
+ ```
140
+
141
+ With a domain pointing at the server, PocketBase serves HTTPS itself (Let's Encrypt):
142
+
143
+ ```ini
144
+ # /etc/systemd/system/chirkle.service
145
+ [Unit]
146
+ Description=Chirkle (PocketBase)
147
+ After=network-online.target
148
+
149
+ [Service]
150
+ User=chirkle
151
+ WorkingDirectory=/opt/chirkle
152
+ ExecStart=/opt/chirkle/pocketbase serve chat.example.com --hooksPool=100 --dir=/opt/chirkle/pb_data --publicDir=/opt/chirkle/pb_public --migrationsDir=/opt/chirkle/pb_migrations --hooksDir=/opt/chirkle/pb_hooks
153
+ Restart=on-failure
154
+ AmbientCapabilities=CAP_NET_BIND_SERVICE
155
+ LimitNOFILE=65536
156
+
157
+ [Install]
158
+ WantedBy=multi-user.target
159
+ ```
160
+
161
+ ```sh
162
+ sudo systemctl enable --now chirkle
163
+ sudo -u chirkle /opt/chirkle/pocketbase superuser upsert you@example.com <password> --dir=/opt/chirkle/pb_data
164
+ ```
165
+
166
+ Behind an existing reverse proxy instead, use `serve --http=127.0.0.1:8090` and proxy to it (keep
167
+ `/api/realtime` unbuffered — it is a Server-Sent Events stream — and let request bodies through up to 210 MB, since a
168
+ message may carry 10 files of 20 MB), and start PocketBase with
169
+ `TRUSTED_PROXY=X-Forwarded-For` (`Environment=` in the unit). The rate limits are per client IP: without it, every
170
+ request seems to come from the proxy, and one client tripping a limit trips it for everyone. The rightmost address of
171
+ the header is used, the one your proxy added. The Docker image sets it (Dokku always runs a proxy in front); run it
172
+ with `-e TRUSTED_PROXY=off` if clients reach port 8090 directly, since they could then choose their own IP. Unset, the
173
+ setting is left as configured under *Settings → Application* in the admin UI.
174
+
175
+ ### Dokku
176
+
177
+ The `Dockerfile` builds the production image (frontend + pinned PocketBase), and `app.json` gives Dokku its health
178
+ check. On the server:
179
+
180
+ ```sh
181
+ dokku apps:create chirkle
182
+ # All data (SQLite + uploads) lives in /pb_data: keep it on the host. The directory is owned by uid 32767, the
183
+ # image's user.
184
+ dokku storage:ensure-directory chirkle
185
+ dokku storage:mount chirkle /var/lib/dokku/data/storage/chirkle:/pb_data
186
+ dokku domains:set chirkle chat.example.com
187
+ # nginx allows 1 MB bodies by default; a message may carry 10 files of 20 MB.
188
+ dokku nginx:set chirkle client-max-body-size 210m
189
+ dokku letsencrypt:enable chirkle # with the dokku-letsencrypt plugin
190
+ ```
191
+
192
+ Then deploy (`git push dokku master` from a clone with `dokku@server:chirkle` as the `dokku` remote) and create a
193
+ superuser:
194
+
195
+ ```sh
196
+ dokku run chirkle /app/pocketbase superuser upsert you@example.com <password> --dir=/pb_data
197
+ ```
198
+
199
+ Settings go in as environment variables (`dokku config:set chirkle KEY=value`, which restarts the app); the image already
200
+ sets `TRUSTED_PROXY` for Dokku's proxy. `dokku logs chirkle -t` shows PocketBase's output; the app's own log (request
201
+ log and errors from hooks) is in the admin UI under *Logs*.
202
+
203
+ ### Running it
204
+
205
+ **Branding and invite-only signups:** in the admin UI, *Collections → site*, edit the one record: `title` and `logo`
206
+ are shown in the app bar, on the login page and in the tab's title. Tick `invite_only` and fill `invite_code` to let
207
+ only people who have the code sign up (they enter it on the Sign up form; it is case-sensitive). Change the code to stop
208
+ the old one working; leave it empty to close signups. Existing accounts are unaffected, and you can still create
209
+ accounts yourself under *Collections → users*.
210
+
211
+ **Backups:** in the admin UI, *Settings → Backups* — schedule automatic backups (optionally to S3-compatible
212
+ storage). Uploaded files (avatars, attachments) live in `pb_data/storage` (or S3, under *Settings → Files storage*) and
213
+ are part of the backups, so plan disk space for them. **Rate limits** (per IP: messages 10 per 5 s, edits/deletes 20
214
+ per 10 s, reactions 30 per 10 s, forwarding and deleting several messages 20 requests per minute each, password changes 5 per minute, new rooms 5 per minute, opening DMs 10 per minute, marking rooms read 120 per minute, signups 20 per minute; PocketBase defaults for the rest)
215
+ are set by the migrations and adjustable under *Settings → Rate limits*.
216
+
217
+ ## Android app
218
+
219
+ In active development alongside the web client (it was frozen 2026-10-21..23): web features and fixes are ported to
220
+ it ([`CLAUDE.md`](CLAUDE.md), [`android/PARITY.md`](android/PARITY.md)).
221
+
222
+ A native client for any server running Chirkle, with several accounts at once on one server or many (`android/`,
223
+ design: [`docs/ANDROID.md`](docs/ANDROID.md), §17 for servers and accounts). It needs JDK 17+
224
+ (21 recommended) and the Android SDK (`ANDROID_HOME`, or `sdk.dir` in `android/local.properties`); Gradle fetches the
225
+ rest. Its tests start PocketBase from `bin/`, so run `npm run setup` first.
226
+
227
+ ```sh
228
+ cd android
229
+ ./gradlew assembleDebug # app/build/outputs/apk/debug: offers http://10.0.2.2:8090 (the dev server, from the emulator)
230
+ ./gradlew check # lint, unit tests, API tests against PocketBase, UI tests on Robolectric
231
+ ./gradlew checkApkSize -Pchirkle.server=https://chat.example.org -Pchirkle.appId=org.example.chirkle
232
+ ```
233
+
234
+ People choose their server when they log in or sign up (Change server), and add more accounts from their profile.
235
+ A build only sets the server offered first: `-Pchirkle.devServer=http://192.168.1.20:8090` for a debug build on a device,
236
+ `chirkle.server` for a release (without one, the app asks for a server, and no host's links open in the app). Debug builds
237
+ take http addresses; release builds take https only. The app notifies of DMs and replies to you by checking each
238
+ account's server about every 15 minutes (WorkManager), with no Google services and nothing to set up on the server
239
+ (ANDROID.md §21). Links to rooms on the build's server open in the app once `ANDROID_CERT_SHA256` is
240
+ set (`/.well-known/assetlinks.json`; `ANDROID_APP_ID` only for a build with another `chirkle.appId`). An admin can set
241
+ `min_android_version` on the site record to make older apps ask for an update. What is built and what isn't yet:
242
+ [`docs/ANDROID.md` §16](docs/ANDROID.md#16-implementation-2026-10-18), and [`android/PARITY.md`](android/PARITY.md).
243
+
244
+ ## Releasing
245
+
246
+ One version for the npm package and the Android app. `npm run release -- 0.2.0` sets it in `package.json` and
247
+ `android/app/build.gradle.kts` (versionCode + 1) and creates `fastlane/…/changelogs/<versionCode>.txt` to fill in.
248
+ Commit, push, then publish a GitHub Release with the new tag `v0.2.0`. The Release workflow
249
+ (`.github/workflows/release.yml`) checks the versions, attaches the signed APK, tags `android-v0.2.0` for F-Droid and
250
+ stages `chirkle@0.2.0` on npm; approve it on npmjs.com (2FA) to publish it. Setup and details:
251
+ [`docs/ANDROID.md` §28.7](docs/ANDROID.md#287-one-release-for-the-app-and-the-npm-package-2026-11-08).
252
+
253
+ ## Link previews
254
+
255
+ Messages show a line under them for each link: the page's favicon and title ([`docs/DESIGN.md` §28](docs/DESIGN.md)).
256
+ The server fetches them with `curl` (in the Docker image), only from public addresses. Set `LINK_PREVIEWS=off` to turn
257
+ it off.
258
+
259
+ ## Media grid
260
+
261
+ Each room's Media button shows its images and videos as a grid ([`docs/DESIGN.md` §30](docs/DESIGN.md)). A worker on
262
+ the server makes their thumbnails ahead of time, and a poster frame for each video with `ffmpeg` (in the Docker
263
+ image), which the room shows too, so browsers don't load videos just to draw their first frame. Set `FFMPEG=off` to
264
+ go without: videos then show their first frame in the room as before, and plain tiles in the grid.
265
+
266
+ ## Telegram integration
267
+
268
+ An optional bridge between rooms and Telegram groups ([`docs/DESIGN.md` §26](docs/DESIGN.md)). A bot sits in your
269
+ groups; once a group is linked to a room, messages, replies, edits and files go both ways (deletes only from Chirkle
270
+ to Telegram), and reactions too where the bot is a group admin. Telegram people show in the room under stand-in users ("Ann Lee (TG)") with their names and pictures;
271
+ the bot posts Chirkle messages with the author's name above them.
272
+
273
+ **Setup**
274
+
275
+ 1. Create a bot with [@BotFather](https://t.me/BotFather) (`/newbot`) and keep its token. Turn its privacy mode off
276
+ (`/setprivacy` → Disable) so it sees group messages; if the bot is already in a group, remove it and add it again.
277
+ 2. Set the environment and restart:
278
+ - `TELEGRAM_BOT_TOKEN` — the bot's token (without it the bridge is off)
279
+ - `TELEGRAM_WEBHOOK_URL` — `https://<your domain>/api/telegram/webhook` (without it the bridge polls Telegram,
280
+ for local development)
281
+
282
+ With Dokku: `dokku config:set chirkle TELEGRAM_BOT_TOKEN='…' TELEGRAM_WEBHOOK_URL='https://chat.example.com/api/telegram/webhook'`.
283
+ 3. Add the bot to a Telegram group. A row for it appears in the admin UI under *Collections → tg_links*: pick the
284
+ room and tick `enabled`. `/chatid` in the group says whether it is linked. Make the bot a group admin to bring
285
+ reactions over: Telegram tells only admins about them. Tick `anonymous` too to repost the
286
+ room's messages to that group without their authors' names.
287
+
288
+ To make a room **anonymous**, tick `anonymous` on its row under *Collections → rooms* in the admin UI. Messages
289
+ posted from then on show the room's name instead of their authors to everyone but the authors themselves (and
290
+ superusers); see DESIGN.md §35. Telegram groups linked to it get the room's name as the author too.
291
+
292
+ The bridge is self-contained: `pb_hooks/telegram.pb.js`, `pb_hooks/telegram/` and its own `tg_*` collections. Delete
293
+ the first two to remove it.
294
+
295
+ ## Linked instances
296
+
297
+ Two or more servers running this app can share rooms and let their people write DMs to each other
298
+ ([`docs/DESIGN.md` §33](docs/DESIGN.md)). Each room has a home server; the others keep a copy, and messages, edits,
299
+ replies, reactions and files go both ways. People from the other server show under stand-in users named after them
300
+ ("Ann (B)"). Only the admins of both servers pair them and choose which rooms to share.
301
+
302
+ **Setup** (on each server)
303
+
304
+ 1. Turn it on: in the admin UI, set *Settings → Application → Application URL* to the server's public address, e.g.
305
+ `https://chat.example.com`, then tick `federation` on the record under *Collections → site*. Peers are reached over
306
+ https, on public addresses only. The address is part of the ids the peers keep, so it can't be changed while any
307
+ peer is listed. (A server set up with the old `FEDERATION_ORIGIN` variable gets both done by its next start's
308
+ migration; the variable is no longer read after that.)
309
+ 2. Pair: on server A, under *Collections → fed_peers*, add a row with B's address and a short label for its people
310
+ (`B`); tick `dms` to let people write DMs across. A sends B the request, and it shows on B as a row with status
311
+ `requested` (B checks with A that it really asked). B's admin accepts by setting its status to `active`, choosing
312
+ a label for A's people (and `dms`); both rows are then `active`. Deleting the request declines it. A request B
313
+ can't be reached for is sent again every minute; one nobody accepts expires after 7 days. If both admins add
314
+ each other, they pair at once.
315
+ 3. Share a room: on its home, add a row under *fed_shares* with the room and the peer. The peer's admin finds it under
316
+ *fed_shares* there and ticks `accepted`; the room then appears there, named "general (A)", with its latest 200
317
+ messages. Private rooms too: each side's admins add their own people (on the copy, by editing its members), and the
318
+ room's creator can add people from the other server by their address, `ann@b.example`.
319
+ 4. DMs: with `dms` ticked on both sides, people type `name@b.example` in "New message".
320
+
321
+ Suspend a peer by setting its `status` to `suspended`; delete its row to unpair (the copies are archived, DMs become
322
+ read-only). The feature is self-contained: `pb_hooks/federation.pb.js`, `pb_hooks/federation/` and the `fed_*`
323
+ collections; while `federation` isn't ticked, its routes answer 404 and nothing is sent.
324
+
325
+ ## License
326
+
327
+ [GNU General Public License v3.0](LICENSE) or later.
package/package.json CHANGED
@@ -1,6 +1,78 @@
1
1
  {
2
2
  "name": "chirkle",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "A small, fast, real-time group chat: one PocketBase server, a vanilla TypeScript web app",
5
+ "license": "GPL-3.0-or-later",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/border-radius/chirkle.git"
9
+ },
10
+ "homepage": "https://github.com/border-radius/chirkle#readme",
11
+ "keywords": [
12
+ "chat",
13
+ "pocketbase",
14
+ "self-hosted",
15
+ "realtime"
16
+ ],
17
+ "type": "module",
18
+ "bin": {
19
+ "chirkle": "scripts/start.mjs"
20
+ },
21
+ "files": [
22
+ "pb_public/",
23
+ "pb_hooks/",
24
+ "pb_migrations/",
25
+ "scripts/start.mjs",
26
+ "scripts/fetch-pocketbase.sh"
27
+ ],
28
+ "engines": {
29
+ "node": ">=22",
30
+ "npm": ">=11"
31
+ },
32
+ "os": [
33
+ "linux",
34
+ "darwin"
35
+ ],
36
+ "cpu": [
37
+ "x64",
38
+ "arm64"
39
+ ],
40
+ "scripts": {
41
+ "start": "node scripts/start.mjs",
42
+ "prepack": "npm run build",
43
+ "setup": "sh scripts/fetch-pocketbase.sh",
44
+ "release": "node scripts/release.mjs",
45
+ "dev": "node scripts/dev.mjs",
46
+ "build": "node scripts/build.mjs",
47
+ "typecheck": "sh scripts/pb-types.sh && tsc --noEmit && tsc --noEmit -p tsconfig.server.json",
48
+ "lint": "biome check .",
49
+ "format": "biome check --write .",
50
+ "lint:sinks": "sh scripts/check-no-html-sinks.sh",
51
+ "test": "vitest run --project unit --project component",
52
+ "test:unit": "vitest run --project unit",
53
+ "test:watch": "vitest --project unit --project component",
54
+ "test:int": "vitest run --project integration",
55
+ "test:e2e": "playwright test",
56
+ "screenshots": "node --no-warnings scripts/screenshots.ts",
57
+ "profile:web": "node --no-warnings scripts/profile-web.ts",
58
+ "schema:snapshot": "vitest run --project integration -u tests/integration/schema.snapshot.test.ts",
59
+ "check": "npm run typecheck && npm run lint && npm run lint:sinks && npm test && npm run test:int && npm run build"
60
+ },
61
+ "devDependencies": {
62
+ "@axe-core/playwright": "4.13.0",
63
+ "@biomejs/biome": "2.5.14",
64
+ "@playwright/test": "1.63.0",
65
+ "@types/node": "22.20.5",
66
+ "@vitest/coverage-v8": "5.0.2",
67
+ "esbuild": "0.28.2",
68
+ "eventsource": "5.1.2",
69
+ "happy-dom": "20.14.5",
70
+ "playwright-core": "1.63.0",
71
+ "pocketbase": "0.28.1",
72
+ "typescript": "7.0.2",
73
+ "vitest": "5.0.2"
74
+ },
75
+ "allowScripts": {
76
+ "esbuild@0.28.2": true
77
+ }
78
+ }