From 2d5fc31cef4b3f5928fca7c6e0b2a0391541f210 Mon Sep 17 00:00:00 2001
From: memdmp <memdmp@estrogen.zone>
Date: Wed, 22 Jan 2025 22:11:40 +0100
Subject: fix: better handling

---
 src/routes/canaries/Canary.svelte | 38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)

(limited to 'src/routes/canaries/Canary.svelte')

diff --git a/src/routes/canaries/Canary.svelte b/src/routes/canaries/Canary.svelte
index 284ed9f..50031ed 100644
--- a/src/routes/canaries/Canary.svelte
+++ b/src/routes/canaries/Canary.svelte
@@ -25,7 +25,9 @@
   $effect(() => {
     (async (canary) => {
       rawText = await canary.getRawText();
-    })(canary);
+    })(canary).catch((e) => {
+      failedFetch = true;
+    });
   });
   $effect(() => {
     (async (canary) => {
@@ -59,33 +61,43 @@
   </div>
   <div class="bottom">
     <div class="mt-2">
-      {#if url}
-        <span class="opacity-70">Get Canary:</span>
+      <span class="opacity-70">Get Canary:</span>
+      {#if canary.upstream}
         <a
           class="opacity-90 hover:underline text-blue-400 hover:text-blue-300"
-          href={url.signed}
+          href={canary.upstream}
         >
-          Signed
+          Upstream
         </a>
+      {/if}
+      {#if status !== "failed_sigcheck" && status !== "failed_fetch"}
         <a
           class="opacity-90 hover:underline text-blue-400 hover:text-blue-300"
-          href={url.stripped}
+          href={url?.signed ?? canary.url}
         >
-          Stripped
+          Signed
         </a>
-      {:else if status === "failed_fetch"}
-        <span class="opacity-70">Get Canary:</span>
+      {:else}
+        <a
+          class="opacity-90 hover:underline text-red-400 hover:text-red-300"
+          href={url?.signed ?? canary.url}
+        >
+          Signed, {status === "failed_sigcheck"
+            ? "bad signature"
+            : "unreachable"}
+        </a>
+      {/if}
+      {#if url}
         <a
           class="opacity-90 hover:underline text-blue-400 hover:text-blue-300"
-          href={canary.url}
+          href={url.stripped}
         >
-          Signed
+          Stripped
         </a>
+      {:else}
         <span class="opacity-70 text-blue-400 grayscale cursor-not-allowed">
           Stripped
         </span>
-      {:else}
-        No URL yet
       {/if}
     </div>
   </div>
-- 
cgit v1.2.3

