aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/canaries/canaries.ts
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-02-27 16:51:14 +0100
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-02-27 16:51:14 +0100
commit291e5b0cc2d5f1c510775e8e17d6b78659e56f24 (patch)
tree08934a545f8b4a2aa554f48db33f1e7d74848809 /src/routes/canaries/canaries.ts
parent08c8330012f57d5de28bc63a2be60b62ea1078c6 (diff)
downloadmem-estrogen-zone-291e5b0cc2d5f1c510775e8e17d6b78659e56f24.tar.gz
mem-estrogen-zone-291e5b0cc2d5f1c510775e8e17d6b78659e56f24.tar.bz2
mem-estrogen-zone-291e5b0cc2d5f1c510775e8e17d6b78659e56f24.tar.lz
mem-estrogen-zone-291e5b0cc2d5f1c510775e8e17d6b78659e56f24.zip

feat: new canary, move to /~mem/ on estrogen.zone

Diffstat (limited to 'src/routes/canaries/canaries.ts')
-rw-r--r--src/routes/canaries/canaries.ts107
1 files changed, 55 insertions, 52 deletions
diff --git a/src/routes/canaries/canaries.ts b/src/routes/canaries/canaries.ts
index 692abc2..dab2e68 100644
--- a/src/routes/canaries/canaries.ts
+++ b/src/routes/canaries/canaries.ts
@@ -1,25 +1,25 @@
-import { browser } from "$app/environment";
-import { validateSignature } from "./keystore";
+import { browser } from '$app/environment';
+import { base } from '$app/paths';
+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
+ name: string;
+ description: string;
+ signer: string;
+ url: string;
+ keyIdentifier: string;
+ contentType: string;
+ upstream?: string;
}
-export interface Canary extends CanaryInterface { }
+export interface Canary extends CanaryInterface {}
type _PreCanaryInterfaceEntries = {
- [T in keyof CanaryInterface]: [T, CanaryInterface[T]]
-}
-type CanaryInterfaceEntry = _PreCanaryInterfaceEntries[keyof _PreCanaryInterfaceEntries]
+ [T in keyof CanaryInterface]: [T, CanaryInterface[T]];
+};
+type CanaryInterfaceEntry =
+ _PreCanaryInterfaceEntries[keyof _PreCanaryInterfaceEntries];
export class Canary {
- public constructor(
- canary: CanaryInterface
- ) {
+ public constructor(canary: CanaryInterface) {
const entries = Object.entries(canary) as CanaryInterfaceEntry[];
for (const a of entries) {
// @ts-ignore we know the value will match in type
@@ -29,19 +29,22 @@ export class Canary {
}
public forceContentType = false;
public async getRawText() {
- if (!browser) throw new Error('This should only be done in a browser.')
- const res = await fetch(this.url)
+ if (!browser) throw new Error('This should only be done in a browser.');
+ const res = await fetch(this.url);
if (res.ok) {
- if (!this.forceContentType) this.contentType = res.headers.get('Content-Type') || this.contentType
- const text = await res.text()
- return text
+ if (!this.forceContentType)
+ this.contentType = res.headers.get('Content-Type') || this.contentType;
+ const text = await res.text();
+ return text;
} else {
throw new Error(`Fetching canary failed with code ${res.status} (${res.statusText}):
-${await res.text().catch(e => `Unknown (Unable to get text, ${JSON.stringify(e)})`)}`)
+${await res.text().catch((e) => `Unknown (Unable to get text, ${JSON.stringify(e)})`)}`);
}
}
- public async getValidatedText(rawText: string | Promise<string> = this.getRawText()) {
- return await validateSignature(await rawText, this.keyIdentifier)
+ public async getValidatedText(
+ rawText: string | Promise<string> = this.getRawText(),
+ ) {
+ return await validateSignature(await rawText, this.keyIdentifier);
}
/** Returns downloadable data url if signature passes, otherwise returns null */
public async getUrl(rawText: string | Promise<string> = this.getRawText()) {
@@ -54,34 +57,34 @@ ${await res.text().catch(e => `Unknown (Unable to get text, ${JSON.stringify(e)}
return null;
}
return {
- stripped: URL.createObjectURL(new Blob([stripped], {
- type: this.contentType,
- })),
- signed: URL.createObjectURL(new Blob([t], {
- type: this.contentType,
- })),
- }
+ stripped: URL.createObjectURL(
+ new Blob([stripped], {
+ type: this.contentType,
+ }),
+ ),
+ signed: URL.createObjectURL(
+ new Blob([t], {
+ type: this.contentType,
+ }),
+ ),
+ };
}
}
-new Canary(
- {
- 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({
+ name: 'estrogen.zone',
+ description: 'Services hosted around estrogen.zone and yuridick.gay',
+ signer: 'memdmp',
+ url: base + '/canaries/memdmp:estrogen.zone',
+ keyIdentifier: 'memdmp',
+ contentType: 'text/plain; charset=utf-8',
+});
-new Canary(
- {
- 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'
- }
-);
+new Canary({
+ name: 'kyun.host',
+ description: 'The VPS provider "kyun.host"',
+ signer: 'napatha',
+ url: base + '/canaries/napatha:kyun.host',
+ keyIdentifier: 'napatha',
+ contentType: 'text/plain; charset=utf-8',
+ upstream: 'https://files.kyun.host/canary.txt',
+});