You want to help build a Telegram auth plugin. Telegram, the platform where bots talk to bots about talking to bots. Sounds about right. Come on in.
git clone https://github.com/vcode-sh/better-auth-telegram.git
cd better-auth-telegram
npm install- Node.js >= 22 (see
.nvmrc-- yes, I pinned it, I'm not an animal) - npm >= 10
These are the incantations. Learn them. Love them. Run them before pushing.
npm run dev # Watch mode build -- for the impatient
npm run build # Production build (ESM + CJS + DTS) -- the real thing
npm run type-check # TypeScript strict check -- the compiler judges you so I don't have to
npm test # Run all tests -- you'd be surprised how many people skip this
npm run test:watch # Watch mode -- for when you're in the zone
npm run test:ui # Vitest UI -- pretty graphs that prove you did something
npm run test:coverage # Coverage report -- the number must go up
npm run lint # Biome lint check -- it has opinions and they are correct
npm run lint:fix # Auto-fix -- let the machine do the boring partsrc/
index.ts Server plugin entry (endpoints, schema, hooks)
client.ts Client plugin (widget init, API methods, Mini App helpers)
verify.ts HMAC-SHA-256 verification via Web Crypto API
types.ts TypeScript interfaces
constants.ts Error codes, defaults, PLUGIN_ID
*.test.ts Co-located tests
Not guidelines. Not suggestions. Rules.
- Tests live next to their code as
*.test.ts-- no hunting through a distant__tests__folder like it's 2017 - Run
npm run lint:fixbefore committing -- Biome catches things your eyes won't - All tests must pass with
npm test-- a failing test suite is not a "known issue," it's a blocker - Type safety everywhere -- no
anyat public API boundaries, this isn't JavaScript - Security first, features second -- validate inputs, verify signatures, no shortcuts
- Async verification only -- all crypto goes through
crypto.subtle, no synchronousnode:crypto - Use
APIErrorfrombetter-auth/api-- rawctx.json({ error })died in v0.4.0, let it rest - Update CHANGELOG.md for user-facing changes -- the changelog is a love letter to your future maintainers
I maintain 90%+ coverage. Not because I worship the metric, but because untested code is just a theory.
- Verification: crypto tests in
verify.test.ts-- HMAC paths, replay attacks, edge cases - Server plugin: endpoint tests in
index.test.ts-- signin, link, unlink, config, Mini App flows - Client plugin: mock
$fetch, test widget init and API methods inclient.test.ts - Security: adversarial inputs, timestamp manipulation, malformed data
- Fork the repo and branch off
main(notdevelop, notfeature-branch-from-six-months-ago) - Write tests for your new code (yes, before the PR, not "I'll add them later")
- Make sure absolutely everything passes:
npm run type-check && npm test && npm run lint
- Update documentation if applicable (it is applicable more often than you think)
- Update
CHANGELOG.mdunder an[Unreleased]section - Open a PR with a clear description -- "misc fixes" tells me nothing
- Bugs: use the bug report template
- Features: use the feature request template
- Security: see SECURITY.md -- do NOT open a public issue for vulnerabilities unless you enjoy chaos
There is one. It's in CODE_OF_CONDUCT.md. The short version: don't be awful. The long version: read the file.