[READ-ONLY] Mirror of https://github.com/flo-bit/atproto-notify.
0

Configure Feed

Select the types of activity you want to include in your feed.

atproto-notify / apps / relay / src / env.ts
2.5 kB 81 lines
1import type { ServiceJwtVerifier } from '@atcute/xrpc-server/auth'; 2 3/** A Telegram delivery channel. */ 4export interface TelegramChannel { 5 platform: 'telegram'; 6 /** Telegram chat id (stored as `channels.platform_user_id`). */ 7 platformUserId: string; 8} 9 10/** A web push delivery channel (a browser PushSubscription). */ 11export interface WebPushChannel { 12 platform: 'webpush'; 13 endpoint: string; 14 p256dh: string; 15 auth: string; 16} 17 18/** Where a notification can be delivered. */ 19export type DeliveryChannel = TelegramChannel | WebPushChannel; 20 21/** 22 * Work item placed on `DISPATCH_QUEUE` and handled by the `queue` consumer. 23 * Discriminated on `kind`. Notifications fan out to any channel; pending-request 24 * prompts are Telegram-only (they use inline approve/deny buttons). 25 */ 26export type DispatchJob = 27 | { 28 kind: 'notification'; 29 channel: DeliveryChannel; 30 title: string; 31 body: string; 32 uri?: string; 33 senderDid: string; 34 } 35 | { 36 kind: 'pendingRequest'; 37 channel: TelegramChannel; 38 requestId: string; 39 senderTitle: string; 40 senderDescription?: string; 41 senderIconUrl?: string; 42 senderDid: string; 43 }; 44 45/** Cloudflare bindings + vars + secrets, as declared in `wrangler.toml`. */ 46export interface Env { 47 /** D1 database holding all persistent state. */ 48 DB: D1Database; 49 /** KV namespace used for DID-doc caching and rate-limit counters. */ 50 CACHE: KVNamespace; 51 /** Queue producer for async delivery. */ 52 DISPATCH_QUEUE: Queue<DispatchJob>; 53 54 /** `did:web:notifs.atmo.tools` — this relay's DID (var). */ 55 RELAY_DID: string; 56 /** Telegram bot username, used to build deep links (var). */ 57 BOT_USERNAME: string; 58 59 /** Telegram bot token (secret). */ 60 TELEGRAM_BOT_TOKEN: string; 61 /** Shared secret embedded in the Telegram webhook path (secret). */ 62 TELEGRAM_WEBHOOK_SECRET: string; 63 64 /** VAPID public key — base64url uncompressed point; also the browser's applicationServerKey (var). */ 65 VAPID_PUBLIC_KEY: string; 66 /** VAPID contact subject, e.g. "mailto:you@example.com" (var). */ 67 VAPID_SUBJECT: string; 68 /** VAPID private signing key as JWK JSON (secret). */ 69 VAPID_PRIVATE_JWK: string; 70} 71 72/** 73 * Per-request application context threaded through XRPC handlers. The verifier 74 * is memoized per `Env` (see `auth/verifier.ts`); `ctx` is request-scoped and 75 * used for `waitUntil` fire-and-forget work. 76 */ 77export interface AppContext { 78 env: Env; 79 ctx: ExecutionContext; 80 verifier: ServiceJwtVerifier; 81}