Follow-up to a7609ff for the whole frontend: all 30 API helpers in
src/lib now pass path values through encodeURIComponent, so an id taken
from the URL can never leave its own path segment and make the page call
another endpoint with the viewer's token.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
20 lines
676 B
TypeScript
20 lines
676 B
TypeScript
import { apiFetch, apiFetchBlob } from "@/lib/auth/api-client";
|
|
|
|
export type QrEntityType =
|
|
| "colonies"
|
|
| "apiaries"
|
|
| "queens"
|
|
| "honey-batches"
|
|
| "storage-containers"
|
|
| "bottling-batches";
|
|
|
|
export async function fetchQrCodeSvg(entityType: QrEntityType, id: string): Promise<Blob> {
|
|
const { blob } = await apiFetchBlob(`/qr/${encodeURIComponent(entityType)}/${encodeURIComponent(id)}.svg`, `${entityType}.svg`);
|
|
return blob;
|
|
}
|
|
|
|
export async function fetchQrLink(entityType: QrEntityType, id: string): Promise<string> {
|
|
const { url } = await apiFetch<{ url: string }>(`/qr/${encodeURIComponent(entityType)}/${encodeURIComponent(id)}/link`);
|
|
return url;
|
|
}
|