diff --git a/components/Button.tsx b/components/Button.tsx new file mode 100644 index 0000000..6b532f6 --- /dev/null +++ b/components/Button.tsx @@ -0,0 +1,9 @@ +import { JSX } from 'preact' + +export function Button( + { variant, ...props }: + & { variant: 'primary' | 'secondary' | 'tertiary' } + & JSX.ButtonHTMLAttributes, +) { + return +} diff --git a/components/Input.tsx b/components/Input.tsx new file mode 100644 index 0000000..14c1dc1 --- /dev/null +++ b/components/Input.tsx @@ -0,0 +1,42 @@ +import { useSignal, useSignalEffect } from '@preact/signals' +import { JSX } from 'preact' + +export function Input( + { label, name, ...props }: + & { label: string; name: string } + & JSX.InputHTMLAttributes, +) { + if (props.type === 'password') { + const password = useSignal('') + const hash = useSignal('') + const salt = crypto.randomUUID() + + useSignalEffect(() => { + crypto.subtle.digest( + 'SHA-256', + new TextEncoder().encode(salt + password.value), + ).then((digest) => hash.value = new TextDecoder().decode(digest)) + }) + + return ( + + ) + } + + return ( + + ) +} diff --git a/deno.json b/deno.json index 80ae286..d81f34d 100644 --- a/deno.json +++ b/deno.json @@ -48,8 +48,6 @@ "@std/json": "jsr:@std/json@^1.0.1", "@std/streams": "jsr:@std/streams@^0.224.5", "preact": "npm:preact@^10.24.2", - "@univoq/": "https://deno.land/x/univoq@0.2.0/", - "univoq": "https://deno.land/x/univoq@0.2.0/mod.ts", "web-push": "npm:web-push@^3.6.7" }, "compilerOptions": { diff --git a/islands/LoginForm.tsx b/islands/LoginForm.tsx index 4fa0837..efaa69c 100644 --- a/islands/LoginForm.tsx +++ b/islands/LoginForm.tsx @@ -1,11 +1,12 @@ import { requestApi } from ':src/utils.ts' import { startAuthentication } from '@simplewebauthn/browser' import { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types' -import { Button, Input } from 'univoq' import type { WebAuthnLoginFinishPayload, WebAuthnLoginStartPayload, } from '../routes/api/webauthn/login/[step].ts' +import { Button } from ':components/Button.tsx' +import { Input } from ':components/Input.tsx' export default function LoginForm() { return ( @@ -28,7 +29,7 @@ export default function LoginForm() { type='checkbox' checked /> - + ) } diff --git a/islands/PassKeyRegister.tsx b/islands/PassKeyRegister.tsx index e6d0aa5..41867a2 100644 --- a/islands/PassKeyRegister.tsx +++ b/islands/PassKeyRegister.tsx @@ -1,11 +1,12 @@ import { requestApi } from ':src/utils.ts' import { startRegistration } from '@simplewebauthn/browser' import { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types' -import { Button, Input } from 'univoq' import type { WebAuthnRegisterFinishPayload, WebAuthnRegisterStartPayload, } from '../routes/api/webauthn/register/[step].ts' +import { Button } from ':components/Button.tsx' +import { Input } from ':components/Input.tsx' function isWebAuthnSupported(): boolean { return 'credentials' in navigator @@ -16,7 +17,6 @@ function RegisterForm({ disabled }: { disabled?: boolean }) {