stream-fusion-better/stream_fusion/web/api/peer/schemas.py
LimeDrive 0aba81abb2 feat(peer): add authenticated peer-to-peer cache sharing
Introduces a secure peer-to-peer cache sharing system using HMAC-SHA256 request signatures and Fernet (AES-128-CBC) response encryption.

- New peer_keys table for per-peer credential management (key_id, secret)
- New /api/peer/check endpoint returns encrypted debrid availability data
- New /api/peer/items endpoint returns encrypted torrent metadata
- Rate limiting per peer key with configurable limits and windows
- Admin UI for creating, viewing, revoking, and deleting peer keys
- Peer cache enrichment integrated into BaseDebrid L2.5 lookup pipeline
- StremThruDebrid override with cross-service PG L2 check + peer cache
- Removed old /api/share/cache endpoint (replaced by /api/peer/*)
- Added cryptography package dependency

BREAKING CHANGE: The /api/share/cache endpoint has been removed and replaced with /api/peer/check. Clients must update to use HMAC authentication with X-Peer-Key-Id, X-Peer-Timestamp, and X-Peer-Signature headers.
2026-03-28 05:07:40 +01:00

47 lines
1.3 KiB
Python

from typing import Optional
from pydantic import BaseModel, Field
SUPPORTED_SERVICES = {"realdebrid", "alldebrid", "torbox"}
# ── Data endpoints ────────────────────────────────────────────────────────────
class PeerCacheRequest(BaseModel):
hashes: list[str] = Field(
...,
min_length=1,
max_length=200,
description="Info-hashes to look up (max 200 per request)",
)
service: str = Field(
...,
description="Debrid service identifier: realdebrid | alldebrid | torbox",
)
class PeerCacheResponse(BaseModel):
payload: str = Field(
description=(
"Fernet-encrypted JSON. Decrypted shape: "
'{"service": str, "debrid_cache": {hash: cached_data_dict}}'
)
)
class PeerItemsRequest(BaseModel):
hashes: list[str] = Field(
...,
min_length=1,
max_length=200,
description="Info-hashes to look up (max 200 per request)",
)
class PeerItemsResponse(BaseModel):
payload: str = Field(
description=(
"Fernet-encrypted JSON. Decrypted shape: "
'{"torrent_items": {hash: torrent_item_dict}}'
)
)