Skip to content

Commit 3d6d121

Browse files
committed
Update e2e tests
1 parent a449e2c commit 3d6d121

File tree

23 files changed

+550
-431
lines changed

23 files changed

+550
-431
lines changed

src/frontend/src/lib/components/ui/OpenIdItem.svelte

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
import { formatDate, formatRelative, t } from "$lib/stores/locale.store";
1111
1212
interface Props {
13-
credential: OpenIdCredential;
13+
openid: OpenIdCredential;
1414
onUnlink?: () => void;
1515
inUse?: boolean;
1616
}
1717
18-
const { credential, onUnlink, inUse }: Props = $props();
18+
const { openid, onUnlink, inUse }: Props = $props();
1919
20-
const name = $derived(openIdName(credential.iss, credential.metadata));
21-
const email = $derived(getMetadataString(credential.metadata, "email"));
22-
const logo = $derived(openIdLogo(credential.iss, credential.metadata));
20+
const name = $derived(openIdName(openid.iss, openid.metadata));
21+
const email = $derived(getMetadataString(openid.metadata, "email"));
22+
const logo = $derived(openIdLogo(openid.iss, openid.metadata));
2323
const options = $derived(
2424
nonNullish(onUnlink)
2525
? [
@@ -79,10 +79,8 @@
7979
>
8080
<span>{$t`Right now`}</span>
8181
</Tooltip>
82-
{:else if nonNullish(credential.last_usage_timestamp[0])}
83-
{@const date = new Date(
84-
nanosToMillis(credential.last_usage_timestamp[0]),
85-
)}
82+
{:else if nonNullish(openid.last_usage_timestamp[0])}
83+
{@const date = new Date(nanosToMillis(openid.last_usage_timestamp[0]))}
8684
<Tooltip
8785
label={$formatDate(date, {
8886
timeStyle: "short",

src/frontend/src/lib/components/ui/PasskeyItem.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
import { getAuthnMethodAlias } from "$lib/utils/webAuthn";
1212
1313
interface Props {
14-
data: AuthnMethodData;
14+
passkey: AuthnMethodData;
1515
onRename?: () => void;
1616
onRemove?: () => void;
1717
inUse?: boolean;
1818
}
1919
20-
const { data, onRename, onRemove, inUse }: Props = $props();
20+
const { passkey, onRename, onRemove, inUse }: Props = $props();
2121
22-
const alias = $derived(getAuthnMethodAlias(data));
22+
const alias = $derived(getAuthnMethodAlias(passkey));
2323
const options = $derived([
2424
...(nonNullish(onRename)
2525
? [
@@ -86,8 +86,8 @@
8686
>
8787
<span>{$t`Right now`}</span>
8888
</Tooltip>
89-
{:else if nonNullish(data.last_authentication[0])}
90-
{@const date = new Date(nanosToMillis(data.last_authentication[0]))}
89+
{:else if nonNullish(passkey.last_authentication[0])}
90+
{@const date = new Date(nanosToMillis(passkey.last_authentication[0]))}
9191
<Tooltip
9292
label={$formatDate(date, {
9393
timeStyle: "short",

src/frontend/src/lib/components/ui/Select.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
>
7474
<ul class="flex flex-col">
7575
{#each options as option, index}
76-
<li class="contents">
76+
<li class="contents" aria-label={option.label}>
7777
<Button
7878
onclick={() => handleClick(option, index)}
7979
variant="tertiary"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
bind:element={inputRef}
5050
bind:value={name}
5151
inputmode="text"
52-
placeholder={$t`Passkey label`}
52+
placeholder={$t`Passkey name`}
5353
type="text"
5454
autocomplete="off"
5555
autocorrect="off"
@@ -58,7 +58,7 @@
5858
? $t`Maximum length is 32 characters.`
5959
: undefined}
6060
disabled={isSubmitting}
61-
aria-label={$t`Passkey label`}
61+
aria-label={$t`Passkey name`}
6262
/>
6363
</div>
6464
<div class="mt-auto flex flex-col items-stretch gap-3">

src/frontend/src/lib/flows/authFlow.svelte.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,19 @@ export class AuthFlow {
104104
canisterId,
105105
session: get(sessionStore),
106106
});
107-
await authenticationStore.set({ identity, identityNumber });
107+
const authMethod = { passkey: { credentialId } };
108+
await authenticationStore.set({
109+
identity,
110+
identityNumber,
111+
authMethod,
112+
});
108113
const info =
109114
await get(authenticatedStore).actor.get_anchor_info(identityNumber);
110115
if (this.#options.trackLastUsed) {
111116
lastUsedIdentitiesStore.addLastUsedIdentity({
112117
identityNumber,
113118
name: info.name[0],
114-
authMethod: { passkey: { credentialId } },
119+
authMethod,
115120
createdAtMillis: info.created_at.map(nanosToMillis)[0],
116121
});
117122
}
@@ -200,7 +205,11 @@ export class AuthFlow {
200205
// If the call fails, it means the OpenID user does not exist in II.
201206
// In that case, we register them.
202207
authenticationV2Funnel.trigger(AuthenticationV2Events.LoginWithOpenID);
203-
await authenticationStore.set({ identity, identityNumber });
208+
await authenticationStore.set({
209+
identity,
210+
identityNumber,
211+
authMethod: { openid: { iss, sub } },
212+
});
204213
const info =
205214
await get(authenticatedStore).actor.get_anchor_info(identityNumber);
206215
const authnMethod = info.openid_credentials[0]?.find(
@@ -310,7 +319,11 @@ export class AuthFlow {
310319
const identity = await authenticateWithSession({
311320
session: get(sessionStore),
312321
});
313-
await authenticationStore.set({ identity, identityNumber });
322+
await authenticationStore.set({
323+
identity,
324+
identityNumber,
325+
authMethod: { passkey: { credentialId } },
326+
});
314327
if (this.#options.trackLastUsed) {
315328
lastUsedIdentitiesStore.addLastUsedIdentity({
316329
identityNumber,
@@ -403,7 +416,11 @@ export class AuthFlow {
403416
authenticationV2Funnel.trigger(
404417
AuthenticationV2Events.SuccessfulOpenIDRegistration,
405418
);
406-
await authenticationStore.set({ identity, identityNumber });
419+
await authenticationStore.set({
420+
identity,
421+
identityNumber,
422+
authMethod: { openid: { iss, sub } },
423+
});
407424
const metadata: MetadataMapV2 = [];
408425
if (nonNullish(jwtName)) {
409426
metadata.push(["name", { String: jwtName }]);

src/frontend/src/lib/flows/authLastUsedFlow.svelte.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
lastUsedIdentitiesStore,
99
type LastUsedIdentity,
1010
} from "$lib/stores/last-used-identities.store";
11-
import { findConfig, requestJWT } from "$lib/utils/openID";
11+
import { decodeJWT, findConfig, requestJWT } from "$lib/utils/openID";
1212
import { get } from "svelte/store";
1313
import { sessionStore } from "$lib/stores/session.store";
1414
import { isNullish } from "@dfinity/utils";
@@ -40,12 +40,17 @@ export class AuthLastUsedFlow {
4040
const credentialIds = (await this.#identityCredentials.get(
4141
lastUsedIdentity.identityNumber,
4242
)) ?? [lastUsedIdentity.authMethod.passkey.credentialId];
43-
const { identity, identityNumber } = await authenticateWithPasskey({
44-
canisterId,
45-
session: get(sessionStore),
46-
credentialIds,
43+
const { identity, identityNumber, credentialId } =
44+
await authenticateWithPasskey({
45+
canisterId,
46+
session: get(sessionStore),
47+
credentialIds,
48+
});
49+
await authenticationStore.set({
50+
identity,
51+
identityNumber,
52+
authMethod: { passkey: { credentialId } },
4753
});
48-
await authenticationStore.set({ identity, identityNumber });
4954
lastUsedIdentitiesStore.addLastUsedIdentity(lastUsedIdentity);
5055
authenticationV2Funnel.trigger(
5156
AuthenticationV2Events.ContinueAsPasskey,
@@ -74,13 +79,18 @@ export class AuthLastUsedFlow {
7479
mediation: "optional",
7580
loginHint: lastUsedIdentity.authMethod.openid.loginHint,
7681
});
82+
const { iss, sub } = decodeJWT(jwt);
7783
this.systemOverlay = false;
7884
const { identity, identityNumber } = await authenticateWithJWT({
7985
canisterId,
8086
session: get(sessionStore),
8187
jwt,
8288
});
83-
await authenticationStore.set({ identity, identityNumber });
89+
await authenticationStore.set({
90+
identity,
91+
identityNumber,
92+
authMethod: { openid: { iss, sub } },
93+
});
8494
lastUsedIdentitiesStore.addLastUsedIdentity(lastUsedIdentity);
8595
authenticationV2Funnel.addProperties({
8696
provider: config.name,

src/frontend/src/lib/flows/migrationFlow.svelte.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ export class MigrationFlow {
244244
await authenticationStore.set({
245245
identity,
246246
identityNumber,
247+
// Since credential id is missing, we set it to an empty value,
248+
// this will be replaced once a user has completed the migration.
249+
authMethod: { passkey: { credentialId: new Uint8Array() } },
247250
});
248251
upgradeIdentityFunnel.trigger(
249252
UpgradeIdentityEvents.AuthenticationSuccessful,

src/frontend/src/lib/flows/registerAccessMethodFlow.svelte.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,20 @@ export class RegisterAccessMethodFlow {
125125
])
126126
.then(throwCanisterError);
127127
const identity = await authenticateWithSession({ session });
128+
const authMethod = {
129+
passkey: {
130+
credentialId: new Uint8Array(credentialId),
131+
},
132+
};
128133
await authenticationStore.set({
129134
identity,
130135
identityNumber: this.#identityNumber,
136+
authMethod,
131137
});
132138
lastUsedIdentitiesStore.addLastUsedIdentity({
133139
identityNumber: this.#identityNumber,
134140
name,
135-
authMethod: {
136-
passkey: {
137-
credentialId: new Uint8Array(credentialId),
138-
},
139-
},
141+
authMethod,
140142
createdAtMillis: this.#createdAtMillis,
141143
});
142144
return this.#identityNumber;

0 commit comments

Comments
 (0)