(params: {
encryptQueryParam: string
aesKey: string
cdnBaseUrl: string
})
| 56 | } |
| 57 | |
| 58 | export async function downloadAndDecrypt(params: { |
| 59 | encryptQueryParam: string |
| 60 | aesKey: string |
| 61 | cdnBaseUrl: string |
| 62 | }): Promise<Buffer> { |
| 63 | const url = buildCdnDownloadUrl(params.encryptQueryParam, params.cdnBaseUrl) |
| 64 | const response = await fetch(url) |
| 65 | if (!response.ok) { |
| 66 | throw new Error(`CDN download failed: HTTP ${response.status}`) |
| 67 | } |
| 68 | const ciphertext = Buffer.from(await response.arrayBuffer()) |
| 69 | return decryptAesEcb(ciphertext, parseAesKey(params.aesKey)) |
| 70 | } |
| 71 | |
| 72 | export interface UploadedFileInfo { |
| 73 | encryptQueryParam: string |
no test coverage detected