Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Handle inactive legacy kit recovery

Neeraj Guptaa36f50f286f9
diff --git a/web/apps/legacy/public/images/legacy-kit/kit-no-longer-active.svg b/web/apps/legacy/public/images/legacy-kit/kit-no-longer-active.svg
new file mode 100644
index 0000000000..2bc9304654
--- /dev/null
+++ b/web/apps/legacy/public/images/legacy-kit/kit-no-longer-active.svg
@@ -0,0 +1,7 @@
+<svg preserveAspectRatio="none" width="100%" height="100%" overflow="visible" style="display: block;" viewBox="0 0 103.266 97.2613" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M102.081 71.053L100.778 81.2846L93.8282 90.0393L81.3751 95.1639C81.3751 95.1639 46.483 95.075 29.543 95.1639C12.603 95.2529 5.2189 89.2919 3.37287 83.8069C2.9472 82.5346 2.6779 81.0488 2.51284 79.5141C1.97424 74.4295 2.61274 68.8288 2.61274 68.8288L28.6743 19.0055L35.1897 8.77398L40.402 4.32548L48.2205 1.65638L58.8622 2.54608L66.8979 9.66368L67.8231 11.2073L93.8282 54.5936L102.081 71.053Z" fill="#666666"/>
+<path d="M67.8267 11.2073C54.3963 2.67508 40.1016 4.48118 32.8782 18.8632C25.7807 32.9916 4.54059 69.892 2.18202 74.6119C1.64341 69.5272 2.61638 68.8288 2.61638 68.8288L28.6779 19.0055L35.1933 8.77398L40.4056 4.32548L48.2241 1.65638L58.8659 2.54608L66.9015 9.66369L67.8267 11.2073Z" fill="#ffffff"/>
+<path d="M33.9317 13.2226C30.7999 18.8634 27.312 24.3039 24.0978 29.9001C18.2817 40.0427 10.8932 54.6783 5.42466 65.1812C4.2823 67.5033 3.58733 70.1235 3.42227 72.717C2.67083 83.4156 11.0757 93.2513 21.6523 93.3402C31.3429 93.3447 63.6853 93.3402 73.884 93.358C75.9516 93.3358 80.0389 93.4114 82.089 93.3269C88.2396 93.011 94.0165 89.3232 97.0614 83.8382C100.189 78.3977 100.471 71.4224 97.6608 65.7862C96.7009 63.8911 94.5942 60.4747 93.504 58.5796C85.3902 44.8337 74.6007 26.3991 66.5173 12.72C59.207 0.166287 40.9161 0.450991 33.9317 13.2226ZM31.2213 11.6657C38.1884 -1.5197 56.1231 -4.02865 66.3305 6.71449C68.4415 8.78304 70.4308 12.4709 71.9554 15.0332C75.0568 20.2735 83.5181 34.5799 86.7323 40.016C89.4123 44.5802 97.7737 58.5841 100.302 62.9569C104.289 69.8432 104.228 78.8514 100.276 85.7422C96.6618 92.326 89.6903 96.7923 82.3149 97.1837C80.1648 97.2683 76.0862 97.2282 73.884 97.2416C64.2369 97.2416 31.8945 97.286 22.786 97.2416C20.649 97.2416 18.4945 97.0369 16.427 96.4408C3.80885 93.0555 -3.47535 78.46 1.66311 66.0887C2.05404 65.1323 2.60133 64.0735 3.09216 63.1838L3.39621 62.6589L13.0694 45.888C16.2402 40.2651 19.4545 34.6733 22.4559 28.9526C25.4443 23.2273 28.159 17.3464 31.2299 11.6657H31.2213Z" fill="#000000"/>
+<path d="M47.4566 58.7663C45.9059 52.4272 45.528 46.0213 45.4629 39.5532C45.4803 33.0806 45.8408 26.6748 47.4566 20.3401C47.9865 18.3605 50.7577 18.3783 51.2746 20.3401C54.0458 31.3991 53.9068 47.6628 51.2746 58.7663C50.7621 60.7637 47.9605 60.7503 47.4566 58.7663Z" fill="#ffffff"/>
+<path d="M49.5245 75.5017C52.6047 75.5017 55.1017 72.9444 55.1017 69.7898C55.1017 66.6352 52.6047 64.0779 49.5245 64.0779C46.4443 64.0779 43.9473 66.6352 43.9473 69.7898C43.9473 72.9444 46.4443 75.5017 49.5245 75.5017Z" fill="#ffffff"/>
+</svg>
diff --git a/web/apps/legacy/src/pages/index.tsx b/web/apps/legacy/src/pages/index.tsx
index d032e070d2..e72ce3ff93 100644
--- a/web/apps/legacy/src/pages/index.tsx
+++ b/web/apps/legacy/src/pages/index.tsx
@@ -59,6 +59,15 @@ const getErrorMessage = (error: unknown) =>
? String(error.message)
: "Something went wrong.";
+const isInactiveLegacyKitError = (error: unknown) => {
+ const message = getErrorMessage(error).toLowerCase();
+ return (
+ message.includes("legacy kit not found") ||
+ (message.includes("http 404") &&
+ message.includes("/legacy-kits/recovery/challenge"))
+ );
+};
+
const parseSlotCode = (rawCode: string): Pick<SheetSlot, "error" | "share"> => {
if (!rawCode.trim()) {
return {};
@@ -136,6 +145,7 @@ const Page: React.FC = () => {
const [session, setSession] = useState<LegacyKitRecoverySession>();
const [isOpening, setIsOpening] = useState(false);
const [isRefreshing, setIsRefreshing] = useState(false);
+ const [isKitInactive, setIsKitInactive] = useState(false);
const [openError, setOpenError] = useState<string>();
const shares = useMemo<[LegacyKitShare, LegacyKitShare] | undefined>(() => {
@@ -237,6 +247,10 @@ const Page: React.FC = () => {
setSession(opened.session);
} catch (error) {
log.error("Legacy kit recovery open failed", error);
+ if (isInactiveLegacyKitError(error)) {
+ setIsKitInactive(true);
+ return;
+ }
setOpenError(getErrorMessage(error));
} finally {
setIsOpening(false);
@@ -253,6 +267,10 @@ const Page: React.FC = () => {
setSession(await refreshLegacyKitRecoverySession(handle));
} catch (error) {
log.error("Legacy kit recovery refresh failed", error);
+ if (isInactiveLegacyKitError(error)) {
+ setIsKitInactive(true);
+ return;
+ }
setOpenError(getErrorMessage(error));
} finally {
setIsRefreshing(false);
@@ -283,6 +301,10 @@ const Page: React.FC = () => {
);
} catch (error) {
log.error("Legacy kit password change failed", error);
+ if (isInactiveLegacyKitError(error)) {
+ setIsKitInactive(true);
+ return;
+ }
setPasswordsFieldError(getErrorMessage(error));
}
},
@@ -292,7 +314,14 @@ const Page: React.FC = () => {
return (
<LegacyShell>
{!hasStarted ? (
- <LandingStep onStart={() => setHasStarted(true)} />
+ <LandingStep
+ onStart={() => {
+ setIsKitInactive(false);
+ setHasStarted(true);
+ }}
+ />
+ ) : isKitInactive ? (
+ <InactiveLegacyKitStep />
) : !session ? (
<UploadStep
slots={slots}
@@ -814,6 +843,51 @@ const ScannedSheetCard: React.FC = () => (
</Box>
);
+const inactiveLegacyKitDescription =
+ "This legacy kit has been deleted by the account owner. These recovery sheets can no longer be used. Contact the account owner for help.";
+
+const InactiveLegacyKitStep: React.FC = () => (
+ <Stack
+ sx={{
+ alignItems: "center",
+ gap: { xs: 2.5, md: 3.5 },
+ maxWidth: { xs: 311, md: 560 },
+ p: { xs: 0, md: 6 },
+ textAlign: "center",
+ width: "100%",
+ }}
+ >
+ <Box
+ component="img"
+ alt=""
+ src="/images/legacy-kit/kit-no-longer-active.svg"
+ sx={{ height: "97.261px", width: "103.266px" }}
+ />
+ <Stack sx={{ alignItems: "center", gap: { xs: 1.5, md: 2 } }}>
+ <Typography
+ component="h1"
+ sx={{
+ fontSize: { xs: 24, md: 32 },
+ fontWeight: 800,
+ lineHeight: { xs: "28px", md: "36px" },
+ }}
+ >
+ Kit no longer active
+ </Typography>
+ <Typography
+ sx={{
+ color: "text.muted",
+ fontSize: { xs: 12, md: 16 },
+ fontWeight: 500,
+ lineHeight: { xs: "16px", md: "20px" },
+ }}
+ >
+ {inactiveLegacyKitDescription}
+ </Typography>
+ </Stack>
+ </Stack>
+);
+
interface WaitingStepProps {
isRefreshing: boolean;
openError?: string;