Skip to content

Commit 1492207

Browse files
committed
chore: formatting fixed.
1 parent 324a677 commit 1492207

File tree

3 files changed

+304
-311
lines changed

3 files changed

+304
-311
lines changed

infrastructure/eid-wallet/src/routes/(app)/main/+page.svelte

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
<script lang="ts">
2-
import { goto } from "$app/navigation";
3-
import { Hero, IdentityCard } from "$lib/fragments";
4-
import type { GlobalState } from "$lib/global";
5-
import { Drawer } from "$lib/ui";
6-
import * as Button from "$lib/ui/Button";
7-
import { QrCodeIcon, Settings02Icon } from "@hugeicons/core-free-icons";
8-
import { HugeiconsIcon } from "@hugeicons/svelte";
9-
import {
10-
getCurrent
11-
} from '@tauri-apps/plugin-deep-link'
12-
import { type Snippet, getContext, onMount } from "svelte";
13-
import { onDestroy } from "svelte";
14-
import { Shadow } from "svelte-loading-spinners";
15-
import QrCode from "svelte-qrcode";
2+
import { goto } from "$app/navigation";
3+
import { Hero, IdentityCard } from "$lib/fragments";
4+
import type { GlobalState } from "$lib/global";
5+
import { Drawer } from "$lib/ui";
6+
import * as Button from "$lib/ui/Button";
7+
import { QrCodeIcon, Settings02Icon } from "@hugeicons/core-free-icons";
8+
import { HugeiconsIcon } from "@hugeicons/svelte";
9+
import { getCurrent } from "@tauri-apps/plugin-deep-link";
10+
import { type Snippet, getContext, onMount } from "svelte";
11+
import { onDestroy } from "svelte";
12+
import { Shadow } from "svelte-loading-spinners";
13+
import QrCode from "svelte-qrcode";
1614
1715
let userData: Record<string, unknown> | undefined = $state(undefined);
1816
let greeting: string | undefined = $state(undefined);
@@ -39,7 +37,7 @@ async function retryProfileCreation() {
3937
4038
const globalState = getContext<() => GlobalState>("globalState")();
4139
42-
onMount(() => {
40+
onMount(async () => {
4341
// Load initial data
4442
(async () => {
4543
const userInfo = await globalState.userController.user;
@@ -59,35 +57,14 @@ onMount(() => {
5957
ename = vaultData?.ename;
6058
})();
6159
62-
// Set up a watcher for profile creation status changes
63-
const checkStatus = () => {
64-
profileCreationStatus =
65-
globalState.vaultController.profileCreationStatus;
66-
};
60+
// Set up a watcher for profile creation status changes
61+
const checkStatus = () => {
62+
profileCreationStatus =
63+
globalState.vaultController.profileCreationStatus;
64+
};
6765
68-
// Check status periodically
69-
statusInterval = setInterval(checkStatus, 1000);
70-
71-
const currentHour = new Date().getHours();
72-
greeting =
73-
currentHour > 17
74-
? "Good Evening"
75-
: currentHour > 12
76-
? "Good Afternoon"
77-
: "Good Morning";
78-
});
79-
80-
const urls = await getCurrent()
81-
if (urls && urls.length > 0) {
82-
const url = urls[0]
83-
const [scheme, ...rest] = url.split("://")
84-
const deeplink = rest.join("://")
85-
console.log("URL", scheme, deeplink)
86-
if (scheme !== "w3ds") {
87-
console.error("unsupported url scheme")
88-
}
89-
goto(`/scan-qr?${deeplink}`)
90-
}
66+
// Check status periodically
67+
statusInterval = setInterval(checkStatus, 1000);
9168
9269
const currentHour = new Date().getHours();
9370
greeting =
@@ -98,11 +75,32 @@ onMount(() => {
9875
: "Good Morning";
9976
});
10077
101-
onDestroy(() => {
102-
if (statusInterval) {
103-
clearInterval(statusInterval);
78+
const urls = await getCurrent();
79+
if (urls && urls.length > 0) {
80+
const url = urls[0];
81+
const [scheme, ...rest] = url.split("://");
82+
const deeplink = rest.join("://");
83+
console.log("URL", scheme, deeplink);
84+
if (scheme !== "w3ds") {
85+
console.error("unsupported url scheme");
10486
}
105-
});
87+
goto(`/scan-qr?${deeplink}`);
88+
}
89+
90+
const currentHour = new Date().getHours();
91+
greeting =
92+
currentHour > 17
93+
? "Good Evening"
94+
: currentHour > 12
95+
? "Good Afternoon"
96+
: "Good Morning";
97+
});
98+
99+
onDestroy(() => {
100+
if (statusInterval) {
101+
clearInterval(statusInterval);
102+
}
103+
});
106104
</script>
107105

108106
{#if profileCreationStatus === "loading"}

infrastructure/eid-wallet/src/routes/(app)/scan-qr/+page.svelte

Lines changed: 120 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,132 @@
11
<script lang="ts">
2-
import { goto } from "$app/navigation";
3-
import { page } from "$app/state";
4-
import { PUBLIC_PROVISIONER_URL } from "$env/static/public";
5-
import AppNav from "$lib/fragments/AppNav/AppNav.svelte";
6-
import type { GlobalState } from "$lib/global";
7-
import { Drawer } from "$lib/ui";
8-
import * as Button from "$lib/ui/Button";
9-
import { QrCodeIcon } from "@hugeicons/core-free-icons";
10-
import { HugeiconsIcon } from "@hugeicons/svelte";
11-
import {
12-
Format,
13-
type PermissionState,
14-
type Scanned,
15-
cancel,
16-
checkPermissions,
17-
requestPermissions,
18-
scan,
19-
} from "@tauri-apps/plugin-barcode-scanner";
20-
import axios from "axios";
21-
import { getContext, onDestroy, onMount } from "svelte";
22-
import type { SVGAttributes } from "svelte/elements";
23-
24-
const globalState = getContext<() => GlobalState>("globalState")();
25-
const pathProps: SVGAttributes<SVGPathElement> = {
26-
stroke: "white",
27-
"stroke-width": 7,
28-
"stroke-linecap": "round",
29-
"stroke-linejoin": "round",
30-
};
31-
32-
let platform = $state();
33-
let hostname = $state();
34-
let session = $state();
35-
let codeScannedDrawerOpen = $state(false);
36-
let loggedInDrawerOpen = $state(false);
37-
let scannedData: Scanned | undefined = $state(undefined);
38-
let scanning = false;
39-
let loading = false;
40-
let redirect = $state<string | null>();
41-
let permissions_nullable: PermissionState | null;
42-
43-
async function startScan() {
44-
let permissions = await checkPermissions()
45-
.then((permissions) => {
46-
return permissions;
47-
})
48-
.catch(() => {
49-
return null;
50-
});
51-
52-
if (permissions === "prompt") {
53-
permissions = await requestPermissions();
54-
}
55-
56-
permissions_nullable = permissions;
57-
58-
if (permissions === "granted") {
59-
const formats = [Format.QRCode];
60-
const windowed = true;
61-
if (scanning) return;
62-
scanning = true;
63-
scan({ formats, windowed })
64-
.then((res) => {
65-
scannedData = res;
66-
const url = new URL(res.content);
67-
platform = url.searchParams.get("platform");
68-
const redirectUrl = new URL(
69-
url.searchParams.get("redirect") || "",
70-
);
71-
redirect = url.searchParams.get("redirect");
72-
session = url.searchParams.get("session");
73-
hostname = redirectUrl.hostname;
74-
codeScannedDrawerOpen = true;
75-
})
76-
.catch((error) => {
77-
console.error("Scan error:", error);
78-
})
79-
.finally(() => {
80-
scanning = false;
81-
});
82-
}
83-
}
84-
85-
async function handleAuth() {
86-
const vault = await globalState.vaultController.vault;
87-
if (!vault || !redirect) return;
88-
await axios.post(redirect, { ename: vault.ename, session });
89-
codeScannedDrawerOpen = false;
90-
loggedInDrawerOpen = true;
91-
startScan();
2+
import { goto } from "$app/navigation";
3+
import { page } from "$app/state";
4+
import { PUBLIC_PROVISIONER_URL } from "$env/static/public";
5+
import AppNav from "$lib/fragments/AppNav/AppNav.svelte";
6+
import type { GlobalState } from "$lib/global";
7+
import { Drawer } from "$lib/ui";
8+
import * as Button from "$lib/ui/Button";
9+
import { QrCodeIcon } from "@hugeicons/core-free-icons";
10+
import { HugeiconsIcon } from "@hugeicons/svelte";
11+
import {
12+
Format,
13+
type PermissionState,
14+
type Scanned,
15+
cancel,
16+
checkPermissions,
17+
requestPermissions,
18+
scan,
19+
} from "@tauri-apps/plugin-barcode-scanner";
20+
import axios from "axios";
21+
import { getContext, onDestroy, onMount } from "svelte";
22+
import type { SVGAttributes } from "svelte/elements";
23+
24+
const globalState = getContext<() => GlobalState>("globalState")();
25+
const pathProps: SVGAttributes<SVGPathElement> = {
26+
stroke: "white",
27+
"stroke-width": 7,
28+
"stroke-linecap": "round",
29+
"stroke-linejoin": "round",
30+
};
31+
32+
let platform = $state();
33+
let hostname = $state();
34+
let session = $state();
35+
let codeScannedDrawerOpen = $state(false);
36+
let loggedInDrawerOpen = $state(false);
37+
let scannedData: Scanned | undefined = $state(undefined);
38+
let scanning = false;
39+
let loading = false;
40+
let redirect = $state<string | null>();
41+
let permissions_nullable: PermissionState | null;
42+
43+
async function startScan() {
44+
let permissions = await checkPermissions()
45+
.then((permissions) => {
46+
return permissions;
47+
})
48+
.catch(() => {
49+
return null;
50+
});
51+
52+
if (permissions === "prompt") {
53+
permissions = await requestPermissions();
9254
}
9355
94-
async function cancelScan() {
95-
await cancel();
96-
scanning = false;
97-
}
98-
99-
onMount(async () => {
100-
const [_empty, ...rest] = page.url.search.split("?");
101-
const methodAndParam = rest.join("?");
102-
const [method, ...param] = methodAndParam.split("?");
103-
const data = param.join("?");
104-
const deeplinkMethodSpecifiers = ["auth"];
105-
if (method && !deeplinkMethodSpecifiers.includes(method)) {
106-
console.error("Unknown method specifier");
107-
}
108-
switch (method) {
109-
case "auth": {
110-
const params = new URLSearchParams(data);
111-
platform = params.get("platform");
112-
session = params.get("session");
113-
redirect = params.get("redirect");
114-
if (!redirect || !platform || !session) {
115-
console.error("Bad deeplink!");
116-
break;
117-
}
118-
hostname = new URL(redirect as string).hostname;
56+
permissions_nullable = permissions;
57+
58+
if (permissions === "granted") {
59+
const formats = [Format.QRCode];
60+
const windowed = true;
61+
if (scanning) return;
62+
scanning = true;
63+
scan({ formats, windowed })
64+
.then((res) => {
65+
scannedData = res;
66+
const url = new URL(res.content);
67+
platform = url.searchParams.get("platform");
68+
const redirectUrl = new URL(
69+
url.searchParams.get("redirect") || "",
70+
);
71+
redirect = url.searchParams.get("redirect");
72+
session = url.searchParams.get("session");
73+
hostname = redirectUrl.hostname;
11974
codeScannedDrawerOpen = true;
75+
})
76+
.catch((error) => {
77+
console.error("Scan error:", error);
78+
})
79+
.finally(() => {
12080
scanning = false;
81+
});
82+
}
83+
}
84+
85+
async function handleAuth() {
86+
const vault = await globalState.vaultController.vault;
87+
if (!vault || !redirect) return;
88+
await axios.post(redirect, { ename: vault.ename, session });
89+
codeScannedDrawerOpen = false;
90+
loggedInDrawerOpen = true;
91+
startScan();
92+
}
93+
94+
async function cancelScan() {
95+
await cancel();
96+
scanning = false;
97+
}
98+
99+
onMount(async () => {
100+
const [_empty, ...rest] = page.url.search.split("?");
101+
const methodAndParam = rest.join("?");
102+
const [method, ...param] = methodAndParam.split("?");
103+
const data = param.join("?");
104+
const deeplinkMethodSpecifiers = ["auth"];
105+
if (method && !deeplinkMethodSpecifiers.includes(method)) {
106+
console.error("Unknown method specifier");
107+
}
108+
switch (method) {
109+
case "auth": {
110+
const params = new URLSearchParams(data);
111+
platform = params.get("platform");
112+
session = params.get("session");
113+
redirect = params.get("redirect");
114+
if (!redirect || !platform || !session) {
115+
console.error("Bad deeplink!");
121116
break;
122117
}
118+
hostname = new URL(redirect as string).hostname;
119+
codeScannedDrawerOpen = true;
120+
scanning = false;
121+
break;
123122
}
124-
startScan();
125-
});
123+
}
124+
startScan();
125+
});
126126
127-
onDestroy(async () => {
128-
await cancelScan();
129-
});
127+
onDestroy(async () => {
128+
await cancelScan();
129+
});
130130
</script>
131131

132132
<AppNav title="Scan QR Code" titleClasses="text-white" iconColor="white" />

0 commit comments

Comments
 (0)