Skip to content

Commit 786a0f2

Browse files
authored
Fix feedback from previous design impl PR (#3079)
Fix feedback
1 parent ff50c38 commit 786a0f2

File tree

5 files changed

+22
-24
lines changed

5 files changed

+22
-24
lines changed

src/frontend/src/lib/components/layout/Footer.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { HTMLAttributes } from "svelte/elements";
33
import { SOURCE_CODE_URL, SUPPORT_URL } from "$lib/config";
44
5-
type Props = HTMLAttributes<HTMLHeadElement>;
5+
type Props = HTMLAttributes<HTMLElement>;
66
77
const { children, class: className, ...props }: Props = $props();
88
</script>

src/frontend/src/lib/components/views/CreateAccount.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
autocorrect="off"
5050
spellcheck="false"
5151
disabled={loading}
52+
error={name.length > 32 ? "Maximum length is 32 characters." : undefined}
5253
/>
5354
</div>
5455
<div class="mt-auto flex flex-col items-stretch gap-3">
@@ -57,7 +58,7 @@
5758
variant="primary"
5859
size="lg"
5960
type="submit"
60-
disabled={name.length === 0 || loading}
61+
disabled={name.length === 0 || name.length > 32 || loading}
6162
>
6263
{#if loading}
6364
<ProgressRing />

src/frontend/src/lib/components/views/CreatePasskey.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
autocorrect="off"
5151
spellcheck="false"
5252
disabled={loading}
53+
error={name.length > 64 ? "Maximum length is 64 characters." : undefined}
5354
/>
5455
</div>
5556
<div class="mt-auto flex flex-col items-stretch gap-3">
@@ -58,7 +59,7 @@
5859
variant="primary"
5960
size="lg"
6061
type="submit"
61-
disabled={name.length === 0 || loading}
62+
disabled={name.length === 0 || name.length > 64 || loading}
6263
>
6364
{#if loading}
6465
<ProgressRing />

src/frontend/src/lib/utils/authentication/passkey.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ export const authenticateWithPasskey = async ({
4242
const passkeyIdentity = DiscoverablePasskeyIdentity.useExisting({
4343
credentialId,
4444
getPublicKey: async (result) => {
45-
console.log("lookup_device_key", result.rawId);
4645
const lookupResult = (
4746
await actor.lookup_device_key(new Uint8Array(result.rawId))
4847
)[0];
4948
if (isNullish(lookupResult)) {
5049
throw new IdentityNotMigratedError();
5150
}
52-
console.log("lookupResult", lookupResult);
5351
identityNumber = lookupResult.anchor_number;
5452
return CosePublicKey.fromDer(new Uint8Array(lookupResult.pubkey));
5553
},

src/frontend/src/lib/utils/discoverablePasskeyIdentity.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,9 @@ export class CosePublicKey implements PublicKey {
7373
* @param credential The credential created previously
7474
*/
7575
function parseCredential(
76-
credential: Credential | null,
77-
): PublicKeyCredentialWithAttachment | null {
78-
const creds = credential as PublicKeyCredentialWithAttachment | null;
79-
80-
if (creds === null) {
81-
return null;
82-
}
76+
credential: Credential,
77+
): PublicKeyCredentialWithAttachment {
78+
const creds = credential as PublicKeyCredentialWithAttachment;
8379

8480
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
8581
// @ts-ignore This type error is probably also in agent-js
@@ -229,24 +225,26 @@ export class DiscoverablePasskeyIdentity extends SignIdentity {
229225
? navigator.credentials.create({
230226
...this.#credentialCreationOptions,
231227
publicKey: {
232-
...this.#credentialCreationOptions!.publicKey,
228+
...this.#credentialCreationOptions.publicKey,
233229
challenge: blob,
234230
},
235231
})
236-
: navigator.credentials.get({
237-
...this.#credentialRequestOptions,
238-
publicKey: {
239-
...this.#credentialRequestOptions!.publicKey,
240-
challenge: blob,
241-
},
242-
}));
232+
: nonNullish(this.#credentialRequestOptions)
233+
? navigator.credentials.get({
234+
...this.#credentialRequestOptions,
235+
publicKey: {
236+
...this.#credentialRequestOptions.publicKey,
237+
challenge: blob,
238+
},
239+
})
240+
: Promise.reject(new Error("Missing credential options")));
241+
242+
if (credential === null) {
243+
throw Error("WebAuthn credential is missing");
244+
}
243245

244246
const result = parseCredential(credential);
245247

246-
if (result === null) {
247-
throw Error("WebAuthn result is missing");
248-
}
249-
250248
if (result.authenticatorAttachment !== null) {
251249
this.#authenticatorAttachment = result.authenticatorAttachment;
252250
}

0 commit comments

Comments
 (0)