()
| 480 | } |
| 481 | |
| 482 | function getEncryptingHostConfig(): { |
| 483 | key: string; |
| 484 | urlStyle: EncryptingHostUrlStyle; |
| 485 | domains: string[]; |
| 486 | title: string; |
| 487 | color: string; |
| 488 | fakelink: string; |
| 489 | } { |
| 490 | const { |
| 491 | encryptingHostKey, |
| 492 | encryptingHostUrlStyle, |
| 493 | encryptingHostDomains, |
| 494 | encryptingHostTitle, |
| 495 | encryptingHostColor, |
| 496 | encryptingHostFakelink |
| 497 | } = settings.store as { |
| 498 | encryptingHostKey?: string; |
| 499 | encryptingHostUrlStyle?: string; |
| 500 | encryptingHostDomains?: string; |
| 501 | encryptingHostTitle?: string; |
| 502 | encryptingHostColor?: string; |
| 503 | encryptingHostFakelink?: string; |
| 504 | }; |
| 505 | |
| 506 | const key = encryptingHostKey?.trim() || ""; |
| 507 | if (!key) { |
| 508 | throw new Error("Encrypting.host API key is required"); |
| 509 | } |
| 510 | |
| 511 | const style = encryptingHostUrlStyle || "query"; |
| 512 | if (style !== "query" && style !== "param" && style !== "fakelink" && style !== "embed") { |
| 513 | throw new Error("Invalid Encrypting.host URL style"); |
| 514 | } |
| 515 | |
| 516 | const domainsRaw = encryptingHostDomains?.trim() || "[\"offensive\"]"; |
| 517 | |
| 518 | return { |
| 519 | key, |
| 520 | urlStyle: style, |
| 521 | domains: parseEncryptingHostDomains(domainsRaw), |
| 522 | title: encryptingHostTitle?.trim() || "", |
| 523 | color: encryptingHostColor?.trim() || "", |
| 524 | fakelink: encryptingHostFakelink?.trim() || "" |
| 525 | }; |
| 526 | } |
| 527 | |
| 528 | async function uploadToEncryptingHost(fileBlob: Blob, filename: string): Promise<string> { |
| 529 | const config = getEncryptingHostConfig(); |
no test coverage detected