|
1 | 1 | <script lang="ts"> |
2 | 2 | import { goto } from "$app/navigation"; |
3 | | - import { Hero } from "$lib/fragments"; |
4 | | - import { ButtonAction, Drawer } from "$lib/ui"; |
5 | | - import { getContext, onMount } from "svelte"; |
6 | | - import { GlobalState } from "$lib/global"; |
7 | | - import axios from "axios"; |
8 | | - import { v4 as uuidv4 } from "uuid"; |
9 | 3 | import { |
10 | 4 | PUBLIC_PROVISIONER_URL, |
11 | 5 | PUBLIC_REGISTRY_URL, |
12 | 6 | } from "$env/static/public"; |
| 7 | + import { Hero } from "$lib/fragments"; |
| 8 | + import { GlobalState } from "$lib/global"; |
| 9 | + import { ButtonAction, Drawer } from "$lib/ui"; |
13 | 10 | import { capitalize } from "$lib/utils"; |
| 11 | + import { |
| 12 | + generate, getPublicKey, |
| 13 | + // signPayload, verifySignature |
| 14 | + } from "@auvo/tauri-plugin-crypto-hw-api" |
14 | 15 | import * as falso from "@ngneat/falso"; |
| 16 | + import axios from "axios"; |
| 17 | + import { getContext, onMount } from "svelte"; |
15 | 18 | import { Shadow } from "svelte-loading-spinners"; |
| 19 | + import { v4 as uuidv4 } from "uuid"; |
16 | 20 |
|
17 | 21 | let isPaneOpen = $state(false); |
18 | 22 | let preVerified = $state(false); |
|
41 | 45 | return randomLetters() + randomDigits(); |
42 | 46 | } |
43 | 47 |
|
| 48 | + // IMO, call this function early, check if hardware even supports the app |
| 49 | + // docs: https://github.com/auvoid/tauri-plugin-crypto-hw/blob/48d0b9db7083f9819766e7b3bfd19e39de9a77f3/examples/tauri-app/src/App.svelte#L13 |
| 50 | + async function generateApplicationKeyPair() { |
| 51 | + let res: string | undefined |
| 52 | + try { |
| 53 | + res = await generate("default") |
| 54 | + console.log(res) |
| 55 | + } catch (e) { |
| 56 | + // Put hardware crypto missing error here |
| 57 | + console.log(e) |
| 58 | + } |
| 59 | + return res |
| 60 | + } |
| 61 | +
|
| 62 | + async function getApplicationPublicKey() { |
| 63 | + let res: string | undefined |
| 64 | + try { |
| 65 | + res = await getPublicKey("default") |
| 66 | + console.log(res) |
| 67 | + } catch (e) { |
| 68 | + console.log(e) |
| 69 | + } |
| 70 | + return res // check getPublicKey doc comments (multibase hex format) |
| 71 | + } |
| 72 | +
|
44 | 73 | const handleNext = async () => { |
45 | 74 | //handle next functionlity |
46 | 75 | goto("/verify"); |
|
0 commit comments