diff options
feat: upstream links
Diffstat (limited to 'src/routes/canaries/canaries.ts')
-rw-r--r-- | src/routes/canaries/canaries.ts | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/src/routes/canaries/canaries.ts b/src/routes/canaries/canaries.ts index d28baab..692abc2 100644 --- a/src/routes/canaries/canaries.ts +++ b/src/routes/canaries/canaries.ts @@ -2,15 +2,29 @@ import { browser } from "$app/environment"; import { validateSignature } from "./keystore"; export const canaries: Canary[] = []; +export interface CanaryInterface { + name: string, + description: string, + signer: string, + url: string, + keyIdentifier: string, + contentType: string, + upstream?: string +} +export interface Canary extends CanaryInterface { } +type _PreCanaryInterfaceEntries = { + [T in keyof CanaryInterface]: [T, CanaryInterface[T]] +} +type CanaryInterfaceEntry = _PreCanaryInterfaceEntries[keyof _PreCanaryInterfaceEntries] export class Canary { public constructor( - public name: string, - public description: string, - public signer: string, - public url: string, - public keyIdentifier: string, - public contentType: string = 'text/plain', + canary: CanaryInterface ) { + const entries = Object.entries(canary) as CanaryInterfaceEntry[]; + for (const a of entries) { + // @ts-ignore we know the value will match in type + this[a[0]] = a[1]; + } canaries.push(this); } public forceContentType = false; @@ -50,20 +64,24 @@ ${await res.text().catch(e => `Unknown (Unable to get text, ${JSON.stringify(e)} } } new Canary( - 'estrogen.zone', - 'Services hosted around estrogen.zone and yuridick.gay', - 'memdmp', - '/canaries/memdmp:estrogen.zone', - 'memdmp', - 'text/plain; charset=utf-8' + { + name: 'estrogen.zone', + description: 'Services hosted around estrogen.zone and yuridick.gay', + signer: 'memdmp', + url: '/canaries/memdmp:estrogen.zone', + keyIdentifier: 'memdmp', + contentType: 'text/plain; charset=utf-8' + } ); new Canary( - 'kyun.host', - 'The VPS provider "kyun.host"', - 'napatha', - '/canaries/napatha:kyun.host', - // 'https://files.kyun.host/canary.txt', - 'napatha', - 'text/plain; charset=utf-8' + { + name: 'kyun.host', + description: 'The VPS provider "kyun.host"', + signer: 'napatha', + url: '/canaries/napatha:kyun.host', + keyIdentifier: 'napatha', + contentType: 'text/plain; charset=utf-8', + upstream: 'https://files.kyun.host/canary.txt' + } ); |