Skip to content

Add optional createdAt property to last used identities#3414

Merged
lmuntaner merged 9 commits intomainfrom
lm-created-at-timestamp-last-used-identity
Oct 19, 2025
Merged

Add optional createdAt property to last used identities#3414
lmuntaner merged 9 commits intomainfrom
lm-created-at-timestamp-last-used-identity

Conversation

@lmuntaner
Copy link
Copy Markdown
Contributor

@lmuntaner lmuntaner commented Oct 14, 2025

Motivation

We want to add when the identity was created in the identity switcher.

In this PR, I add a new property to the data stored in local storage that is then used in the identity switcher.

Changes

  • Added an optional created_at field to the AuthnMethodSessionInfo type in the backend interface and ensured it is populated from the anchor's creation time.
  • Updated AuthFlow and RegisterAccessMethodFlow classes to extract, convert (using the new nanosToMillis utility), and pass createdAtMillis when handling identity and authentication method information.
  • For legacy identities or flows where created_at is not available, set createdAtMillis to undefined.
  • Extended the LastUsedIdentity type and the lastUsedIdentitiesStore to include the optional createdAtMillis field and updated the store's API accordingly.
  • Added a new nanosToMillis utility function for converting nanosecond timestamps to milliseconds.

Tests

  • Tested locally that the new property is added to the local storage with the right units. See screenshot attached.
  • Updated tests for lastUsedIdentitiesStore and lastUsedIdentityStore to include checks for the new createdAtMillis property, ensuring correct behavior and coverage.

@lmuntaner lmuntaner requested a review from Copilot October 14, 2025 10:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an optional createdAtMillis property to the last used identities feature, enabling the identity switcher to display when each identity was created.

Key changes:

  • New utility function to extract creation time from identity info
  • Updated last used identity store to include optional creation timestamp
  • Modified authentication flows to pass creation time when available

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/frontend/src/lib/utils/identityInfo.ts New utility function to convert identity creation time to milliseconds
src/frontend/src/lib/utils/identityInfo.test.ts Test coverage for the new utility function
src/frontend/src/lib/stores/last-used-identities.store.ts Added optional createdAtMillis property to store types
src/frontend/src/lib/stores/last-used-identities.store.test.ts Updated tests to include the new property
src/frontend/src/lib/flows/registerAccessMethodFlow.svelte.ts Extract and pass creation time from identity info
src/frontend/src/lib/flows/migrationFlow.svelte.ts Set undefined for legacy identities without creation time
src/frontend/src/lib/flows/authFlow.svelte.ts Pass creation time for existing identities or current time for new ones

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lmuntaner lmuntaner marked this pull request as ready for review October 14, 2025 13:18
@lmuntaner lmuntaner requested a review from sea-snake October 14, 2025 13:26
@lmuntaner lmuntaner force-pushed the lm-created-at-timestamp-last-used-identity branch from 0d9f34c to 43d0f98 Compare October 17, 2025 06:44
Copy link
Copy Markdown
Contributor

@sea-snake sea-snake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread src/internet_identity/src/main.rs Outdated
@lmuntaner lmuntaner added this pull request to the merge queue Oct 19, 2025
Merged via the queue into main with commit a3afef3 Oct 19, 2025
76 checks passed
@lmuntaner lmuntaner deleted the lm-created-at-timestamp-last-used-identity branch October 19, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants