|
7 | 7 | import { capitalize } from "$lib/utils"; |
8 | 8 | import Drawer from "$lib/ui/Drawer/Drawer.svelte"; |
9 | 9 | import axios from "axios"; |
10 | | - import { PUBLIC_PROVISIONER_URL } from "$env/static/public"; |
| 10 | + import { v4 as uuidv4 } from "uuid"; |
| 11 | + import { |
| 12 | + PUBLIC_PROVISIONER_URL, |
| 13 | + PUBLIC_REGISTRY_URL, |
| 14 | + } from "$env/static/public"; |
11 | 15 | import { |
12 | 16 | DocFront, |
13 | 17 | verificaitonId, |
|
17 | 21 | } from "./store"; |
18 | 22 | import Passport from "./steps/passport.svelte"; |
19 | 23 | import Selfie from "./steps/selfie.svelte"; |
| 24 | + import { load } from "@tauri-apps/plugin-store"; |
| 25 | + import { Shadow } from "svelte-loading-spinners"; |
20 | 26 |
|
21 | 27 | let globalState: GlobalState | undefined = $state(undefined); |
22 | 28 | let showVeriffModal = $state(false); |
23 | 29 | let person: Record<string, unknown>; |
24 | 30 | let document: Record<string, unknown>; |
| 31 | + let loading = $state(false); |
25 | 32 |
|
26 | 33 | async function handleVerification() { |
27 | 34 | const { data } = await axios.post( |
|
68 | 75 | handleContinue = async () => { |
69 | 76 | if ($status !== "approved") return verifStep.set(0); |
70 | 77 | if (!globalState) throw new Error("Global state is not defined"); |
| 78 | +
|
| 79 | + loading = true; |
71 | 80 | globalState.userController.user = { |
72 | 81 | name: capitalize( |
73 | 82 | person.firstName.value + " " + person.lastName.value, |
|
85 | 94 | ).toDateString(), |
86 | 95 | "Verified On": new Date().toDateString(), |
87 | 96 | }; |
88 | | - console.log(globalState.userController.user); |
89 | | - await goto("/register"); |
| 97 | + const { |
| 98 | + data: { token: registryEntropy }, |
| 99 | + } = await axios.get( |
| 100 | + new URL("/entropy", PUBLIC_REGISTRY_URL).toString(), |
| 101 | + ); |
| 102 | + const { data } = await axios.post( |
| 103 | + new URL("/provision", PUBLIC_PROVISIONER_URL).toString(), |
| 104 | + { |
| 105 | + registryEntropy, |
| 106 | + namespace: uuidv4(), |
| 107 | + verificationId: $verificaitonId, |
| 108 | + }, |
| 109 | + ); |
| 110 | + if (data.success === true) { |
| 111 | + globalState.vaultController.vault = { |
| 112 | + uri: data.uri, |
| 113 | + ename: data.w3id, |
| 114 | + }; |
| 115 | + } |
| 116 | + setTimeout(() => { |
| 117 | + goto("/register"); |
| 118 | + }, 10_000); |
90 | 119 | }; |
91 | 120 | }); |
92 | 121 | </script> |
|
97 | 126 | <section> |
98 | 127 | <Hero |
99 | 128 | title="Verify your account" |
100 | | - subtitle="Get your passport ready. You’ll be directed to a site where you can verify your account in a swift and secure process" |
| 129 | + subtitle="Get your passport ready. You’ll be directed to present |
| 130 | + your passport and take a quick selfie." |
101 | 131 | /> |
102 | 132 | <img class="mx-auto mt-20" src="images/Passport.svg" alt="passport" /> |
103 | 133 | </section> |
|
109 | 139 | <Passport></Passport> |
110 | 140 | {:else if $verifStep === 1} |
111 | 141 | <Selfie></Selfie> |
| 142 | + {:else if loading} |
| 143 | + <div class="my-20"> |
| 144 | + <div |
| 145 | + class="align-center flex w-full flex-col items-center justify-center gap-6" |
| 146 | + > |
| 147 | + <Shadow size={40} color="rgb(142, 82, 255);" /> |
| 148 | + <h3>Generating your eName</h3> |
| 149 | + </div> |
| 150 | + </div> |
112 | 151 | {:else} |
113 | 152 | <div class="flex flex-col gap-6"> |
114 | 153 | {#if $status === "approved"} |
|
0 commit comments