Skip to content

Commit 55e054b

Browse files
committed
fix: lint
1 parent 9b88987 commit 55e054b

File tree

9 files changed

+402
-308
lines changed

9 files changed

+402
-308
lines changed

infrastructure/eid-wallet/src/lib/ui/Toast/Toast.svelte

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
<script lang="ts">
2-
import { onMount } from "svelte";
3-
import type { HTMLAttributes } from "svelte/elements";
2+
import { onMount } from "svelte";
3+
import type { HTMLAttributes } from "svelte/elements";
44
5-
interface IToast extends HTMLAttributes<HTMLElement> {
6-
message: string;
7-
duration?: number;
8-
onClose?: () => void;
9-
}
5+
interface IToast extends HTMLAttributes<HTMLElement> {
6+
message: string;
7+
duration?: number;
8+
onClose?: () => void;
9+
}
1010
11-
const {
12-
message,
13-
duration = 3000,
14-
onClose,
15-
...restProps
16-
}: IToast = $props();
11+
const { message, duration = 3000, onClose, ...restProps }: IToast = $props();
1712
18-
let isVisible = $state(true);
13+
let isVisible = $state(true);
1914
20-
onMount(() => {
21-
const timer = setTimeout(() => {
22-
isVisible = false;
23-
setTimeout(() => {
24-
onClose?.();
25-
}, 300); // Wait for fade out animation
26-
}, duration);
15+
onMount(() => {
16+
const timer = setTimeout(() => {
17+
isVisible = false;
18+
setTimeout(() => {
19+
onClose?.();
20+
}, 300); // Wait for fade out animation
21+
}, duration);
2722
28-
return () => clearTimeout(timer);
29-
});
23+
return () => clearTimeout(timer);
24+
});
3025
</script>
3126

3227
{#if isVisible}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export { default } from "./Toast.svelte";
2-

infrastructure/eid-wallet/src/routes/(app)/scan-qr/scanLogic.ts

Lines changed: 113 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,12 +1153,16 @@ export function createScanLogic({
11531153

11541154
// Ensure globalState is available
11551155
if (!globalState) {
1156-
console.error("GlobalState not available, cannot handle deep link");
1156+
console.error(
1157+
"GlobalState not available, cannot handle deep link",
1158+
);
11571159
return;
11581160
}
11591161

11601162
if (data.type === "auth" && get(codeScannedDrawerOpen)) {
1161-
console.log("Auth request already in progress, ignoring duplicate");
1163+
console.log(
1164+
"Auth request already in progress, ignoring duplicate",
1165+
);
11621166
return;
11631167
}
11641168
if (data.type === "sign" && get(signingDrawerOpen)) {
@@ -1175,23 +1179,23 @@ export function createScanLogic({
11751179
}
11761180

11771181
if (data.type === "auth") {
1178-
console.log("Handling auth deep link");
1182+
console.log("Handling auth deep link");
11791183

1180-
// Close all other modals first
1181-
signingDrawerOpen.set(false);
1182-
loggedInDrawerOpen.set(false);
1183-
isRevealRequest.set(false);
1184+
// Close all other modals first
1185+
signingDrawerOpen.set(false);
1186+
loggedInDrawerOpen.set(false);
1187+
isRevealRequest.set(false);
11841188

1185-
platform.set(data.platform ?? null);
1186-
session.set(data.session ?? null);
1187-
redirect.set(data.redirect ?? null);
1189+
platform.set(data.platform ?? null);
1190+
session.set(data.session ?? null);
1191+
redirect.set(data.redirect ?? null);
11881192

1189-
try {
1190-
hostname.set(new URL(data.redirect || "").hostname);
1191-
} catch (error) {
1192-
console.error("Error parsing redirect URL:", error);
1193-
hostname.set("unknown");
1194-
}
1193+
try {
1194+
hostname.set(new URL(data.redirect || "").hostname);
1195+
} catch (error) {
1196+
console.error("Error parsing redirect URL:", error);
1197+
hostname.set("unknown");
1198+
}
11951199

11961200
isSigningRequest.set(false);
11971201
authError.set(null); // Clear any previous auth errors
@@ -1214,103 +1218,108 @@ export function createScanLogic({
12141218
signingError.set(null); // Clear any previous signing errors
12151219

12161220
try {
1217-
const decodedString = atob(base64Data);
1218-
const parsedSigningData = JSON.parse(
1219-
decodedString,
1220-
) as SigningData;
1221-
console.log("Decoded signing data:", parsedSigningData);
1222-
1223-
if (
1224-
parsedSigningData &&
1225-
parsedSigningData.type === "blind-vote"
1226-
) {
1227-
console.log(
1228-
"🔍 Blind voting request detected in sign deep link",
1229-
);
1230-
1231-
isBlindVotingRequest.set(true);
1232-
selectedBlindVoteOption.set(null);
1233-
signingDrawerOpen.set(true);
1234-
blindVoteError.set(null);
1221+
const decodedString = atob(base64Data);
1222+
const parsedSigningData = JSON.parse(
1223+
decodedString,
1224+
) as SigningData;
1225+
console.log("Decoded signing data:", parsedSigningData);
12351226

1236-
const platformUrlCandidate =
1237-
parsedSigningData?.platformUrl?.trim();
1227+
if (
1228+
parsedSigningData &&
1229+
parsedSigningData.type === "blind-vote"
1230+
) {
1231+
console.log(
1232+
"🔍 Blind voting request detected in sign deep link",
1233+
);
12381234

1239-
if (!platformUrlCandidate) {
1240-
const errorMessage =
1241-
"Missing platform URL in signing data and no PUBLIC_PLATFORM_URL configured.";
1242-
blindVoteError.set(errorMessage);
1243-
throw new Error(errorMessage);
1244-
}
1235+
isBlindVotingRequest.set(true);
1236+
selectedBlindVoteOption.set(null);
1237+
signingDrawerOpen.set(true);
1238+
blindVoteError.set(null);
12451239

1246-
let platformUrl: string;
1247-
try {
1248-
// Validate the URL and normalize trailing slashes for consistent API calls.
1249-
const validatedUrl = new URL(platformUrlCandidate);
1250-
platformUrl = validatedUrl
1251-
.toString()
1252-
.replace(/\/+$/, "");
1253-
} catch (error) {
1254-
const message =
1255-
error instanceof Error
1256-
? error.message
1257-
: String(error);
1258-
const errorMessage = `Invalid platform URL "${platformUrlCandidate}": ${message}`;
1259-
blindVoteError.set(
1260-
"Invalid platform URL in signing request.",
1261-
);
1262-
throw new Error(errorMessage);
1263-
}
1240+
const platformUrlCandidate =
1241+
parsedSigningData?.platformUrl?.trim();
12641242

1265-
signingData.set({
1266-
pollId: parsedSigningData?.pollId,
1267-
sessionId: parsedSigningData?.sessionId,
1268-
platform_url: platformUrl,
1269-
redirect: redirectUri,
1270-
pollDetails: {
1271-
title: "Loading poll details...",
1272-
creatorName: "Loading...",
1273-
options: ["Loading..."],
1274-
},
1275-
});
1243+
if (!platformUrlCandidate) {
1244+
const errorMessage =
1245+
"Missing platform URL in signing data and no PUBLIC_PLATFORM_URL configured.";
1246+
blindVoteError.set(errorMessage);
1247+
throw new Error(errorMessage);
1248+
}
12761249

1277-
try {
1278-
const pollResponse = await fetch(
1279-
`${platformUrl}/api/polls/${get(signingData)?.pollId}`,
1280-
);
1281-
if (pollResponse.ok) {
1282-
const pollDetails = await pollResponse.json();
1283-
signingData.update((prev) =>
1284-
prev
1285-
? {
1286-
...prev,
1287-
pollDetails,
1288-
}
1289-
: prev,
1250+
let platformUrl: string;
1251+
try {
1252+
// Validate the URL and normalize trailing slashes for consistent API calls.
1253+
const validatedUrl = new URL(
1254+
platformUrlCandidate,
12901255
);
1291-
console.log(
1292-
"✅ Poll details fetched:",
1293-
pollDetails,
1256+
platformUrl = validatedUrl
1257+
.toString()
1258+
.replace(/\/+$/, "");
1259+
} catch (error) {
1260+
const message =
1261+
error instanceof Error
1262+
? error.message
1263+
: String(error);
1264+
const errorMessage = `Invalid platform URL "${platformUrlCandidate}": ${message}`;
1265+
blindVoteError.set(
1266+
"Invalid platform URL in signing request.",
12941267
);
1268+
throw new Error(errorMessage);
12951269
}
1296-
} catch (error) {
1297-
console.error(
1298-
"Failed to fetch poll details:",
1299-
error,
1300-
);
1301-
blindVoteError.set("Failed to load poll details");
1270+
1271+
signingData.set({
1272+
pollId: parsedSigningData?.pollId,
1273+
sessionId: parsedSigningData?.sessionId,
1274+
platform_url: platformUrl,
1275+
redirect: redirectUri,
1276+
pollDetails: {
1277+
title: "Loading poll details...",
1278+
creatorName: "Loading...",
1279+
options: ["Loading..."],
1280+
},
1281+
});
1282+
1283+
try {
1284+
const pollResponse = await fetch(
1285+
`${platformUrl}/api/polls/${get(signingData)?.pollId}`,
1286+
);
1287+
if (pollResponse.ok) {
1288+
const pollDetails =
1289+
await pollResponse.json();
1290+
signingData.update((prev) =>
1291+
prev
1292+
? {
1293+
...prev,
1294+
pollDetails,
1295+
}
1296+
: prev,
1297+
);
1298+
console.log(
1299+
"✅ Poll details fetched:",
1300+
pollDetails,
1301+
);
1302+
}
1303+
} catch (error) {
1304+
console.error(
1305+
"Failed to fetch poll details:",
1306+
error,
1307+
);
1308+
blindVoteError.set(
1309+
"Failed to load poll details",
1310+
);
1311+
}
1312+
1313+
return;
13021314
}
13031315

1316+
signingData.set(parsedSigningData);
1317+
isSigningRequest.set(true);
1318+
signingDrawerOpen.set(true);
1319+
} catch (error) {
1320+
console.error("Error decoding signing data:", error);
13041321
return;
13051322
}
1306-
1307-
signingData.set(parsedSigningData);
1308-
isSigningRequest.set(true);
1309-
signingDrawerOpen.set(true);
1310-
} catch (error) {
1311-
console.error("Error decoding signing data:", error);
1312-
return;
1313-
}
13141323
}
13151324
} else if (data.type === "reveal") {
13161325
console.log("Handling reveal deep link");
@@ -1330,7 +1339,9 @@ export function createScanLogic({
13301339
isRevealRequest.set(true);
13311340
} else {
13321341
console.error("Missing pollId in reveal request");
1333-
revealError.set("Invalid reveal request. Poll ID is missing.");
1342+
revealError.set(
1343+
"Invalid reveal request. Poll ID is missing.",
1344+
);
13341345
}
13351346
}
13361347
} catch (error) {

0 commit comments

Comments
 (0)