Skip to content

feat(push): add UnifiedPush application-server with anonymous installation registry (#378)#395

Open
wax911 wants to merge 7 commits into
devfrom
feature/378-push-feasibility
Open

feat(push): add UnifiedPush application-server with anonymous installation registry (#378)#395
wax911 wants to merge 7 commits into
devfrom
feature/378-push-feasibility

Conversation

@wax911

@wax911 wax911 commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

Adds the UnifiedPush application-server layer to on-the-edge as specified in #378. This is the backend companion to AniTrend/anitrend-v2#1249.

What's Included

Infrastructure (prerequisites)

  • SSRF endpoint validator (src/common/ssrf.validator.ts) — HTTPS enforcement, private IP rejection, DNS resolution
  • Redis-based rate limiting (src/guard/rate-limit/) — sliding window counters via Redis INCR+EXPIRE, per-endpoint config
  • Programmatic MongoDB indexes (src/database/index.service.ts) — 12 indexes on push collections
  • Web Push sender (src/service/push-sender/) — wraps @negrel/webpush, VAPID key management, gone endpoint detection
  • Dependency bump: @danet/core 2.9.6 → 2.11.0

Push Module (src/package/push/)

  • Repository: upsert, query by installationId/topic/AniList userId, status transitions, challenge management
  • Service: registration with SSRF validation, SHA-256 challenge confirmation, profile merge with client-declared AniList identity
  • Controller: 6 REST endpoints with Zod validation, OpenAPI contracts, and rate limiting

API Endpoints

Method Path Rate Limited
GET /v1/push/vapid No
POST /v1/push/installations Yes
POST /v1/push/installations/:id/confirm Yes
PUT /v1/push/installations/:id/profile Yes
PATCH /v1/push/installations/:id/preferences Yes
DELETE /v1/push/installations/:id Yes

Quality Gates

  • deno fmt
  • deno lint
  • deno check
  • deno task test — 90 passed, 0 failed

What's NOT Included (Future PRs)

  • Test push endpoint and news fan-out
  • Client-declared AniList user association endpoints (link/unlink) — identity is handled through profile sync
  • Push service integration tests (TODO: add mock Redis and mock Web Push sender)
  • E2E validation (Android companion anitrend-v2#1249 not yet built)

Ref: #378"

…ation registry (#378)

- Add SSRF endpoint URL validator for push endpoint safety
- Add Redis-based rate limiting guard for push endpoints
- Add programmatic MongoDB index creation for push collections
- Add PushSenderService wrapping @negrel/webpush for Web Push delivery
- Add PushModule with controller, service, and repository layers
- Implement 6 REST endpoints: VAPID key, registration, challenge
  confirmation, profile, preferences, and installation deletion
- Add challenge token confirmation flow with SHA-256 hashing
- Add client-declared AniList user identity support
- Bump @danet/core from 2.9.6 to 2.11.0
- Update swagger contract with 11 new schema names and 6 operation IDs
@wax911 wax911 force-pushed the feature/378-push-feasibility branch from 86b7561 to a35f83d Compare June 18, 2026 21:33
home-lab added 2 commits June 18, 2026 23:34
Prevent application bootstrap crash when PUSH_VAPID_KEYS env var
is missing or invalid. Log a warning instead of throwing so that
Swagger generation and other non-push functionality works without
push sending configured.
@wax911 wax911 force-pushed the feature/378-push-feasibility branch from 21de73e to bbb6870 Compare June 18, 2026 22:23
…ger compat

Implement GET /v1/push/vapid and POST /v1/push/installations with full
SSRF validation, challenge token flow, and MongoDB persistence. Defer
remaining endpoints (confirm, profile, preferences, delete) due to
Danet Swagger Module crash on controllers with >2 POST methods
(TypeError: Promise resolver undefined in generateTypeSchema).

Infrastructure included:
- SSRF endpoint URL validator
- Redis-based rate limiting guard (RateLimitModule)
- MongoDB index creation (DatabaseIndexService)
- Web Push sender service (@negrel/webpush wrapper)
- Full repository/service layer for push installations
- Swagger contract with 11 schemas and 6 expected operation IDs

Ref: #378
@wax911 wax911 force-pushed the feature/378-push-feasibility branch from 00daf61 to adb8ff6 Compare June 18, 2026 22:38
home-lab added 3 commits June 19, 2026 00:41
Remove schema names and operation IDs for deferred endpoints
(confirm, profile, preferences, delete) from contract validation.
Swagger successfully generates PushVapid and PushInstallation.
Swagger module derives operation IDs from method names, not from
class prefix + method name convention. Fix vapid and registerInstallation
operation IDs. Also remove PushInstallationStatus from expected schemas
(deeply nested schemas are inlined by @anatine/zod-openapi).
Remove deferred endpoint paths and schemas from makeValidDoc fixture.
Fix operation IDs to match controller method names (vapid,
registerInstallation).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant