- ADR-0001: decision to extract auth/payment into shared @marketplaces/* packages - Scaffold packages/auth, packages/payment; @marketplaces/auth now holds the real telegram (customer+admin QR/session) and ed25519 (future admin challenge/response) auth implementation, pushed to sources.vitanova.network/sdarbinyan/vitanovaPackages - Rewire ~30 call sites to import from @marketplaces/auth; delete migrated originals from core/auth, core/admin-auth, services/, models/ - Replace environment coupling with AUTH_API_URL/TELEGRAM_BOT_USERNAME injection tokens and isDevMode(); wired as file:packages/auth pending registry publish - Add TRACK-S §8: bootstrap per-marketplace admin login + marketplace-scoped sub-admin invite/role endpoints - Build, arch:check:boundaries, and full test suite (103/103) all green Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
3.3 KiB
id, title, status, date, supersedes, tags
| id | title | status | date | supersedes | tags | ||||
|---|---|---|---|---|---|---|---|---|---|
| ADR-0001 | Extract auth and payment into shared @marketplaces packages | active | 2026-08-17 |
|
ADR-0001: Extract auth and payment into shared @marketplaces packages
Context
marketplaces currently owns auth end-to-end: customer auth (core/auth — VK ID, OTP, session, facade), admin auth (core/admin-auth — ed25519-verified admin sessions, permission guards, interceptor), and a legacy services/auth.service.ts. Payment/finance logic (core/finance, core/pricing) is server-owned per Phase 1 and Phase 7 contracts — the frontend piece is thin (gateways/tokens, no business logic).
Multiple marketplace projects beyond this repo need the same auth and payment client logic. Duplicating it per-project drifts fast (auth bugs get fixed in one place, not others) and blocks a consistent security posture across projects — directly relevant to TRACK-S-SECURITY-RBAC-CONTRACT.md, which already treats auth/RBAC as the single most serious cross-cutting concern.
Decision
Extract auth and payment client logic into two standalone, independently versioned npm packages:
@marketplaces/auth— customer auth (VK ID/OTP/session), admin auth (ed25519 verification, permission guards, interceptors), token/session management.@marketplaces/payment— payment/finance client gateways, FX/pricing models, checkout client contracts (thin — business logic stays backend per Phase 1/7).
Each package:
- Lives in its own git repo (handed over separately; this repo does not host it long-term).
- Is consumed by
marketplaces(and other projects) as an installed node_modules dependency — imported, never copy-pasted. - Is versioned with semver; CI on the package repo auto-bumps and publishes on push to
main, driven by conventional commit prefixes already used in this repo (feat:/fix:/etc — semantic-release reads these directly). - Ships with its own test suite;
marketplacestreats it as a black-box dependency, not source to edit in place.
Rollout order: scaffold packages and CI in this repo first (reversible, local-only) → hand over target git repo → publish → migrate marketplaces call sites to import from the package → delete the in-repo originals only after the app builds and passes tests against the package.
Consequences
marketplacesloses direct edit access to auth/payment source — changes go through the package's own repo/PR/release cycle. Slower iteration, but consistent behavior across all consuming projects.- ~30 call sites in
marketplaces(seecore/auth,core/admin-auth,services/auth.service.ts, interceptors) need import rewiring during migration — tracked as follow-up work, not done in this ADR. - New failure mode: package registry/CI outage blocks
marketplacesbuilds if a version bump lands mid-incident. Pin exact versions, do not use floating ranges, to keep this bounded. - TRACK-S-SECURITY-RBAC-CONTRACT.md §8 (admin provisioning) becomes package-owned behavior once migrated — that doc's endpoint contracts stay backend-side and unaffected, only the frontend client implementation moves.