feat(public-share): Oeffentliche Share-Zugriffsseite fuer externe Besucher + SPA-Links im DMS-ShareDialog — Modul 13/16 des UI-Backlogs

This commit is contained in:
Agent Zero
2026-09-15 23:16:30 +02:00
parent 7097e28578
commit 00f8f100d7
7 changed files with 452 additions and 2 deletions
+48
View File
@@ -0,0 +1,48 @@
/**
* Public share API client — token-based access to shared files (no auth).
*
* Backend: /api/v1/public/share (permissions plugin, public routes)
* - GET /{token} → share info (file name/size/mime, password flag)
* - POST /{token}/verify → verify password (query param `password`)
* - GET /{token}/download → file download (StreamingResponse — use direct
* navigation, not the JSON api client)
*
* Used by the public /share/:token page for external visitors.
*/
import { apiGet, apiPost } from '@/api/client';
export interface PublicShareInfo {
file_name: string;
file_size: number;
mime_type: string;
access_level: string;
requires_password: boolean;
expires_at: string | null;
}
export interface ShareVerifyResult {
valid: boolean;
}
export function fetchPublicShareInfo(token: string): Promise<PublicShareInfo> {
return apiGet<PublicShareInfo>(`/public/share/${encodeURIComponent(token)}`);
}
export function verifyPublicSharePassword(token: string, password: string): Promise<ShareVerifyResult> {
// Backend takes the password as a plain query parameter (public endpoint,
// no auth — see public_routes.py verify_share_password).
return apiPost<ShareVerifyResult>(
`/public/share/${encodeURIComponent(token)}/verify?password=${encodeURIComponent(password)}`,
);
}
/** Direct download URL for the file behind a share token. */
export function publicShareDownloadUrl(token: string): string {
return `/api/v1/public/share/${encodeURIComponent(token)}/download`;
}
/** SPA URL for a share token (shown in the DMS share dialog). */
export function publicSharePageUrl(token: string): string {
return `${window.location.origin}/share/${encodeURIComponent(token)}`;
}