Commit graph

13 commits

Author SHA1 Message Date
senke
b8eed72f96 feat(webrtc): coturn ICE config endpoint + frontend wiring + ops template (v1.0.9 item 1.2)
Closes FUNCTIONAL_AUDIT.md §4 #1: WebRTC 1:1 calls had working
signaling but no NAT traversal, so calls between two peers behind
symmetric NAT (corporate firewalls, mobile carrier CGNAT, Incus
container default networking) failed silently after the SDP exchange.

Backend:
  - GET /api/v1/config/webrtc (public) returns {iceServers: [...]}
    built from WEBRTC_STUN_URLS / WEBRTC_TURN_URLS / *_USERNAME /
    *_CREDENTIAL env vars. Half-config (URLs without creds, or vice
    versa) deliberately omits the TURN block — a half-configured TURN
    surfaces auth errors at call time instead of falling back cleanly
    to STUN-only.
  - 4 handler tests cover the matrix.

Frontend:
  - services/api/webrtcConfig.ts caches the config for the page
    lifetime and falls back to the historical hardcoded Google STUN
    if the fetch fails.
  - useWebRTC fetches at mount, hands iceServers synchronously to
    every RTCPeerConnection, exposes a {hasTurn, loaded} hint.
  - CallButton tooltip warns up-front when TURN isn't configured
    instead of letting calls time out silently.

Ops:
  - infra/coturn/turnserver.conf — annotated template with the SSRF-
    safe denied-peer-ip ranges, prometheus exporter, TLS for TURNS,
    static lt-cred-mech (REST-secret rotation deferred to v1.1).
  - infra/coturn/README.md — Incus deploy walkthrough, smoke test
    via turnutils_uclient, capacity rules of thumb.
  - docs/ENV_VARIABLES.md gains a 13bis. WebRTC ICE servers section.

Coturn deployment itself is a separate ops action — this commit lands
the plumbing so the deploy can light up the path with zero code
changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 23:38:42 +02:00
senke
85bdce6b46 chore(api): orval-migrate search/social wrappers + drop dead auth duplicates (v1.0.9 item 1.6)
Two consolidations:

(1) Annotate `/search`, `/search/suggestions`, `/social/trending` with
swag tags so orval generates typed clients for them. Migrate
`searchApi` and `socialApi` (the two remaining hand-written wrappers
in `apps/web/src/services/api/`) to delegate to the generated
functions. Removes the last drift surface where backend changes to
those endpoints could silently mismatch the SPA.

(2) Delete two orphan auth-service implementations that have parallel-
implemented login/register/verifyEmail with stale wire shapes:
  - apps/web/src/services/authService.ts  (only its own test imports it)
  - apps/web/src/features/auth/services/authService.ts  (re-exported
    from features/auth/index.ts but the barrel itself has zero
    importers across the SPA)

The active path remains `services/api/auth.ts` (the integration layer
that owns token storage, csrf, and proactive refresh) — the duplicates
were dead post-v1.0.8 orval migration and silently diverged from the
true backend shape (e.g., the deleted services still expected
`access_token` at the root of the register response, never matched
current backend, broke when v1.0.9 item 1.4 changed the shape).

Net diff: -944 LOC of dead code, +typed orval clients for 2 more
endpoints, zero importer rewires.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 23:25:07 +02:00
senke
083b5718a7 feat(auth): defer JWT to post-verify + verify-email header (v1.0.9 items 1.3+1.4)
Item 1.4 — Register no longer issues an access+refresh token pair. The
prior flow set httpOnly cookies at register but the AuthMiddleware
refused them on every protected route until the user had verified
their email (`core/auth/service.go:527`). Users ended up with dead
credentials and a "logged in but locked out" UX. Register now returns
{user, verification_required: true, message} and the SPA's existing
"check your email" notice fires naturally.

Item 1.3 — `POST /auth/verify-email` reads the token from the
`X-Verify-Token` header in preference to the `?token=…` query param.
Query param logged a deprecation warning but stays accepted so emails
dispatched before this release still work. Headers don't leak through
proxy/CDN access logs that record URL but not headers.

Tests: 18 test files updated (sed `_, _, err :=` → `_, err :=` for the
new Register signature). `core/auth/handler_test.go` gets a
`registerVerifyLogin` helper for tests that exercise post-login flows
(refresh, logout). Two new E2E `@critical` specs lock in the defer-JWT
contract and the header read-path.

OpenAPI + orval regenerated to reflect the new RegisterResponse shape
and the verify-email header parameter.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 22:56:31 +02:00
senke
0e72172291 feat(openapi): annotate queue + password-reset handlers + regen
Closes the two annotation gaps that blocked finishing the orval
migration in v1.0.8 :

  - queue_handler.go (5 routes — GetQueue, UpdateQueue, AddQueueItem,
    RemoveQueueItem, ClearQueue) — under @Tags Queue with @Security
    BearerAuth, @Param body/path, @Success/@Failure on the standard
    APIResponse envelope.
  - queue_session_handler.go (5 routes — CreateSession, GetSession,
    DeleteSession, AddToSession, RemoveFromSession). GetSession is
    public (no @Security tag) since the share-token URL is meant for
    join-via-link from outside the auth wall.
  - password_reset_handler.go (2 routes — RequestPasswordReset and
    ResetPassword factory functions). Both are public (no @Security)
    since they're the entry-points for users who can't log in. The
    request-side annotation documents the intentional generic 200
    response (anti-enumeration: same body whether the email exists or
    not).

After regen :
  - openapi.yaml gains 7 queue paths (/queue, /queue/items[/{id}],
    /queue/session[/{token}[/items[/{id}]]]) and 2 password paths
    (/auth/password/reset, /auth/password/reset-request). +568 LOC.
  - docs/{docs.go,swagger.json,swagger.yaml} updated identically by
    swag init.
  - apps/web/src/services/generated/queue/queue.ts created (10
    HTTP funcs + matching React Query hooks). model/ index extended
    with the queue + password-reset request/response shapes.

Validates with `swag init` (Swagger 2.0). go build ./... clean. No
runtime behaviour change — annotations are pure metadata read by the
spec generator. The orval regen IS the wiring point for the
follow-up frontend commit (queue.ts migration + authService finish).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 00:55:26 +02:00
senke
9e948d5102 feat(openapi): annotate profile_handler users endpoints (v1.0.8 B-annot)
Some checks failed
Veza CI / Frontend (Web) (push) Failing after 0s
Veza CI / Rust (Stream Server) (push) Failing after 0s
Frontend CI / test (push) Failing after 0s
Security Scan / Secret Scanning (gitleaks) (push) Failing after 0s
Veza CI / Notify on failure (push) Failing after 0s
Veza CI / Backend (Go) (push) Failing after 0s
Fourth batch. Closes the user/profile surface consumed by the
frontend users service. 6 handlers annotated across
internal/handlers/profile_handler.go (now 12/15 annotated).

Handlers annotated:
- SearchUsers            — GET    /users/search
- FollowUser             — POST   /users/{id}/follow
- GetFollowSuggestions   — GET    /users/suggestions
- UnfollowUser           — DELETE /users/{id}/follow
- BlockUser              — POST   /users/{id}/block
- UnblockUser            — DELETE /users/{id}/block

Added a blank `_ "veza-backend-api/internal/models"` import so swaggo
can resolve models.User in doc comments without forcing runtime use
(same pattern as track_hls_handler.go / track_waveform_handler.go).

Spec coverage: /users/* paths now 12 (all frontend-consumed endpoints).
make openapi:  · go build ./...: .

Completes the B-2 backend annotation scope for auth / users / tracks /
playlists — the four services that will migrate to orval in the next
commit. Remaining unannotated handlers (admin, moderation, analytics,
education, cloud, gear, social_group, etc.) are outside the v1.0.8
frontend migration and deferred to v1.0.9.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 01:09:05 +02:00
senke
72c5381c73 feat(openapi): annotate playlist handler gap — 12 endpoints (v1.0.8 B-annot)
Third batch. Fills the playlist_handler.go gap (was 8/24 annotated,
now 20/24). Covers the functionality consumed by the frontend
playlists service: import, favoris, share tokens, collaborators,
analytics, search, recommendations, duplication.

Handlers annotated:
- ImportPlaylist              — POST /playlists/import
- GetFavorisPlaylist          — GET  /playlists/favoris
- GetPlaylistByShareToken     — GET  /playlists/shared/{token}
- SearchPlaylists             — GET  /playlists/search
- GetRecommendations          — GET  /playlists/recommendations
- GetPlaylistStats            — GET  /playlists/{id}/analytics
- AddCollaborator             — POST /playlists/{id}/collaborators
- GetCollaborators            — GET  /playlists/{id}/collaborators
- UpdateCollaboratorPermission — PUT /playlists/{id}/collaborators/{userId}
- RemoveCollaborator          — DELETE /playlists/{id}/collaborators/{userId}
- CreateShareLink             — POST /playlists/{id}/share
- DuplicatePlaylist           — POST /playlists/{id}/duplicate

Not annotated (unrouted, survey false positives): FollowPlaylist,
UnfollowPlaylist — no route references in internal/api/routes_*.go.
Left unannotated to avoid polluting the spec with dead handlers.

Marketplace gap originally planned for this batch is deferred to
v1.0.9: the 13 remaining handlers (UploadProductPreview, reviews,
licenses, sell stats, refund, invoice) don't block the B-2 frontend
migration (auth/users/tracks/playlists only), so they will be done
after v1.0.8 ships. Task #48 updated to reflect.

Spec coverage:
  /playlists/* paths: 5 → 15
  make openapi:  valid
  go build ./...: 

Next: profile_handler.go + auth/handler.go to finish the B-2 spec
surface (users endpoints), then regen orval and migrate 4 services.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 01:04:15 +02:00
senke
3dc0654a52 feat(openapi): annotate track subsystem (social/analytics/search/hls/waveform) — v1.0.8 B-annot
Second batch of the Veza backend OpenAPI annotation campaign. Completes
the track/ handler subtree — 22 more handlers annotated across 5 files —
so the orval-generated frontend client now covers the full track API
surface (stream, download, like, repost, share, search, recommendations,
stats, history, play, waveform, version restore).

Handlers annotated:

- internal/core/track/track_social_handler.go (11):
  LikeTrack, UnlikeTrack, GetTrackLikes, GetUserLikedTracks,
  GetUserRepostedTracks, CreateShare, GetSharedTrack, RevokeShare,
  RepostTrack, UnrepostTrack, GetRepostStatus

- internal/core/track/track_analytics_handler.go (4):
  GetTrackStats, GetTrackHistory, RecordPlay, RestoreVersion

- internal/core/track/track_search_handler.go (3):
  GetRecommendations, GetSuggestedTags, SearchTracks

- internal/core/track/track_hls_handler.go (3):
  HandleStreamCallback (internal), DownloadTrack, StreamTrack
  — both user-facing endpoints document the v1.0.8 P2 302-to-signed-URL
  behavior for S3-backed tracks alongside the local-FS path.

- internal/core/track/track_waveform_handler.go (1): GetWaveform

All comment blocks converge on the established template:
Summary / Description / Tags / Accept/Produce / Security (BearerAuth
when required) / typed Param path|query|body / Success envelope
handlers.APIResponse{data=...} / Failure 400/401/403/404/500 / Router.

track_hls_handler.go + track_waveform_handler.go receive a blank
import of internal/handlers so swaggo's type resolver can locate
handlers.APIResponse without forcing the file to call that package
at runtime.

Spec coverage:
  /tracks/*  paths: 13 → 29
  make openapi:  valid (Swagger 2.0)
  go build ./...: 
  openapi.yaml: +780 lines describing 16 new track endpoints.

Leaves /internal/core/ subsystems still blank: admin, moderation,
analytics/*, auth/handler.go (duplicates routes handled elsewhere),
discover, feed. Batch 2b next will cover playlists + marketplace gap
so the 4 frontend services (auth/users/tracks/playlists) become
fully orval-migratable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 00:58:08 +02:00
senke
2aa2e6cd51 feat(openapi): annotate track CRUD handlers + regen spec (v1.0.8 B-annot)
Some checks failed
Veza CI / Backend (Go) (push) Failing after 0s
Veza CI / Frontend (Web) (push) Failing after 0s
Veza CI / Rust (Stream Server) (push) Failing after 0s
Frontend CI / test (push) Failing after 0s
Security Scan / Secret Scanning (gitleaks) (push) Failing after 0s
Veza CI / Notify on failure (push) Failing after 0s
First batch of the backend OpenAPI annotation campaign. Adds full
swaggo annotations to the 8 handlers in internal/core/track/track_crud_handler.go
so the resulting openapi.yaml exposes the track CRUD surface to
orval-generated frontend clients.

Handlers annotated (all under @Tags Track):
- ListTracks     — GET    /tracks
- GetTrack       — GET    /tracks/{id}
- UpdateTrack    — PUT    /tracks/{id}                  (Auth, ownership)
- GetLyrics      — GET    /tracks/{id}/lyrics
- UpdateLyrics   — PUT    /tracks/{id}/lyrics           (Auth, ownership)
- DeleteTrack    — DELETE /tracks/{id}                  (Auth, ownership)
- BatchDeleteTracks — POST /tracks/batch/delete         (Auth)
- BatchUpdateTracks — POST /tracks/batch/update         (Auth)

Each block follows the established pattern (auth.go + marketplace.go):
Summary / Description / Tags / Accept / Produce / Security when auth-required /
Param (path/query/body) with concrete types / Success envelope typed via
response.APIResponse{data=...} / Failure 400/401/403/404/500 / Router.

make openapi:  valid (Swagger 2.0)
go build ./...: 
openapi.yaml: +490 LOC, 8 new paths exposed under /tracks.

Part of the Option B campaign tracked in
/home/senke/.claude/plans/audit-fonctionnel-wild-hickey.md.
~364 handlers total remain unannotated across 16 files in /internal/core/
and ~55 files in /internal/handlers/. Subsequent commits will annotate
one handler file at a time so each regenerated spec stays bisectable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 00:45:10 +02:00
senke
b47fa21331 feat(v0.12.8): documentation & API publique — rate limiting, scopes, OpenAPI
- API key rate limiting middleware (1000 reads/h, 200 writes/h par clé)
  — tracking séparé read/write, par API key ID (pas par IP)
  — headers X-RateLimit-Limit/Remaining/Reset sur chaque réponse
- API key scope enforcement middleware (read → GET, write → POST/PUT/DELETE)
  — admin scope permet tout, CSRF skip pour API key auth
- OpenAPI spec: ajout securityDefinition ApiKeyAuth (X-API-Key header)
- Swagger annotations: ajout ApiKeyAuth dans cmd/api/main.go
- Wiring dans router.go: middlewares appliqués sur tout le groupe /api/v1
- Tests: 10 tests (5 rate limiter + 5 scope enforcement), tous PASS

Backend existant déjà en place (pré-v0.12.8):
- Swagger UI (gin-swagger + frontend SwaggerUIDoc component)
- API key CRUD (create/list/delete + X-API-Key auth dans AuthMiddleware)
- Developer Dashboard frontend (API keys, webhooks, playground)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 18:44:09 +01:00
senke
7cfd48a82a fix(release): v1.0.1 — Conformité complète ROADMAP checklist
Some checks failed
Backend API CI / test-unit (push) Failing after 0s
Backend API CI / test-integration (push) Failing after 0s
Stream Server CI / test (push) Failing after 0s
- Sécurité: npm 0 CRITICAL, cargo audit 0 vulnérabilités
- OpenAPI: @Param id corrigé pour /tracks/quota/{id}
- Tests: Payment E2E passe, OAuth DATABASE_URL fallback
- Migrations: 000_mark_consolidated.sql
- veza-stream-server: prometheus 0.14, validator 0.19
- docs: SECURITY_SCAN_RC1, V1_SIGNOFF, PROJECT_STATE
2026-03-03 20:17:54 +01:00
senke
72d40990c5 feat(v0.923): API contract tests, OpenAPI generation, CI type sync check
Some checks failed
Backend API CI / test-unit (push) Failing after 0s
Backend API CI / test-integration (push) Failing after 0s
Frontend CI / test (push) Failing after 0s
Storybook Audit / Build & audit Storybook (push) Failing after 0s
2026-02-27 20:23:10 +01:00
senke
f74b020d4b api-contracts: install openapi-generator-cli and create type generation script
- Completed Action 1.1.2.1: Installed @openapitools/openapi-generator-cli
- Completed Action 1.1.2.2: Created generate-types.sh script
- Added swagger annotations to cmd/modern-server/main.go
- Regenerated swagger.yaml with proper info section
- Successfully generated TypeScript types to src/types/generated/

The script generates types from veza-backend-api/openapi.yaml using
typescript-axios generator and creates barrel exports.
2026-01-11 16:30:43 +01:00
senke
e903b3fcd4 api-contracts: audit OpenAPI spec and generate/export to openapi.yaml
- Completed Action 1.1.1.1: Audited existing OpenAPI spec (56 endpoints documented)
- Completed Action 1.1.1.2: Generated swagger.json using swag init
- Completed Action 1.1.1.3: Exported to openapi.yaml (Swagger 2.0 format)
- Created OPENAPI_AUDIT_REPORT.md documenting findings

Note: Spec is in Swagger 2.0 format. Consider upgrading to OpenAPI 3.0 in future.
2026-01-11 16:29:31 +01:00