security: remediate vulnerabilities and issues from codebase audit
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m15s
All checks were successful
Automated Container Build / build-and-push (push) Successful in 1m15s
This commit is contained in:
parent
b60a09196a
commit
fb3f3a3393
15 changed files with 465 additions and 208 deletions
|
|
@ -227,24 +227,32 @@ class ApiClient {
|
|||
});
|
||||
}
|
||||
|
||||
getDownloadUrl(path: string) {
|
||||
const url = `${API_BASE}/api/files/download/?path=${encodeURIComponent(path)}`;
|
||||
return this.accessToken ? `${url}&token=${this.accessToken}` : url;
|
||||
async createDownloadToken(): Promise<string> {
|
||||
const res = await fetch(`${API_BASE}/api/auth/download-token`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.accessToken}`,
|
||||
},
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to fetch download token');
|
||||
const data = await res.json();
|
||||
return data.token;
|
||||
}
|
||||
|
||||
getDownloadFolderUrl(path: string) {
|
||||
const url = `${API_BASE}/api/files/download-folder?path=${encodeURIComponent(path)}`;
|
||||
return this.accessToken ? `${url}&token=${this.accessToken}` : url;
|
||||
getDownloadUrl(path: string, token: string) {
|
||||
return `${API_BASE}/api/files/download/?path=${encodeURIComponent(path)}&token=${token}`;
|
||||
}
|
||||
|
||||
getBulkDownloadUrl() {
|
||||
const url = `${API_BASE}/api/files/download-bulk`;
|
||||
return this.accessToken ? `${url}?token=${this.accessToken}` : url;
|
||||
getDownloadFolderUrl(path: string, token: string) {
|
||||
return `${API_BASE}/api/files/download-folder?path=${encodeURIComponent(path)}&token=${token}`;
|
||||
}
|
||||
|
||||
getThumbnailUrl(checksum: string) {
|
||||
const url = `${API_BASE}/api/files/thumbnail/${encodeURIComponent(checksum)}`;
|
||||
return this.accessToken ? `${url}?token=${this.accessToken}` : url;
|
||||
getBulkDownloadUrl(token: string) {
|
||||
return `${API_BASE}/api/files/download-bulk?token=${token}`;
|
||||
}
|
||||
|
||||
getThumbnailUrl(checksum: string, token: string) {
|
||||
return `${API_BASE}/api/files/thumbnail/${encodeURIComponent(checksum)}?token=${token}`;
|
||||
}
|
||||
|
||||
getStreamHeaders(): Record<string, string> {
|
||||
|
|
@ -379,10 +387,21 @@ class ApiClient {
|
|||
return res.json();
|
||||
}
|
||||
|
||||
getPublicDownloadUrl(id: string, password?: string, path?: string) {
|
||||
async createPublicShareToken(id: string, password?: string) {
|
||||
const res = await fetch(`${API_BASE}/api/public/share/${id}/token`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ password: password || '' }),
|
||||
});
|
||||
if (!res.ok) throw await res.json();
|
||||
const data = await res.json();
|
||||
return data.token;
|
||||
}
|
||||
|
||||
getPublicDownloadUrl(id: string, token: string, path?: string) {
|
||||
let url = `${API_BASE}/api/public/download/${id}`;
|
||||
const params = new URLSearchParams();
|
||||
if (password) params.set('pwd', password);
|
||||
if (token) params.set('token', token);
|
||||
if (path) params.set('path', path);
|
||||
const qs = params.toString();
|
||||
if (qs) {
|
||||
|
|
|
|||
Reference in a new issue