Skip to content

feat(auth): rename one of the signed-in user's passkeys - #645

Merged
Tr00d merged 1 commit into
masterfrom
feat/auth.passkey.update_passkey
Nov 3, 2026
Merged

Tr00d merged 1 commit into
masterfrom
feat/auth.passkey.update_passkey

Conversation

@Tr00d

@Tr00d Tr00d commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

A signed-in user can rename one of their own passkeys, so they can tell their passkeys apart.

Capability: auth.passkey.update_passkey, Update Passkey. No capability spec exists.

Public API

// IGotrueClient<TUser, TSession>, next to DeletePasskeyAsync
Task<Passkey> RenamePasskeyAsync(Guid passkeyId, string friendlyName, CancellationToken cancellationToken = default);

// IGotrueApi<TUser, TSession>
Task<Passkey> RenamePasskeyAsync(string jwt, Guid passkeyId, string friendlyName, CancellationToken cancellationToken = default);

Passkey moves from Supabase.Gotrue.ListPasskeys to Supabase.Gotrue.Common, because listing and renaming both return it. CreatedAt and LastUsedAt become DateTimeOffset / DateTimeOffset?. Both changes affect unshipped surface only: the type was added in #634 after 8.8.0, and 8.9.0 is held.

var passkeys = await client.ListPasskeysAsync();
var renamed = await client.RenamePasskeyAsync(passkeys[0].Id, "Work laptop");

Behavior

  • Operation: PATCH /passkeys/{passkey_id} with the session's access token, body {"friendly_name":"<name>"}.
  • Inputs: a null or empty friendlyName throws ArgumentException before any request. Whitespace and the 120-character limit are left to the server, which counts runes.
  • Output: the server's updated PasskeyListItem, mapped to Passkey. A success without a body throws GotrueException ("The auth server returned no passkey.").
  • Failures: each is a GotrueException.
    • Reason = Offline when the client is offline. No request is sent.
    • Reason = NoSessionFound when no session or access token is held. No request is sent.
    • 400 validation_failed for a name longer than 120 characters.
    • 404 validation_failed when the user has no passkey with that id.
    • 404 passkey_disabled when passkeys are off.
    • No new FailureHint.Reason.
  • No assurance-level rule: unlike deletion, an aal1 session of a user with MFA can rename (supabase/auth PasskeyUpdate does not call requirePasskeyManagementAAL).
  • State: none. The session is kept. A gotrue.rename_passkey span parents the HTTP span.

Contract source: supabase/auth internal/api/passkey_manage.go (PasskeyUpdate, PasskeyUpdateParams, toPasskeyListItem). The auth openapi.yaml does not describe /passkeys.

Deviations from supabase-js

  • Named RenamePasskeyAsync, the operation's intent (supabase-swift renamePasskey), rather than passkey.update. The endpoint changes only the name.
  • An empty name is rejected before the request; supabase-js sends it and lets the server answer 400.
  • Typed GotrueException instead of { data, error }.

Tests

Tier Class Pins
E2E RenamePasskeyTests Rename returns and stores the new name. Unknown id gives 404. A 121-character name gives validation_failed. An aal1 MFA user can rename.
Contract RenamePasskeyContractTests PATCH path, bearer and apikey. Response mapping, empty success. Server failures. Argument and session checks before the wire. Cancellation, no context capture.
Contract RenamePasskeyApprovalTests Exact body {"friendly_name":"Work laptop"}.
Contract OfflineClientContractTests, ObservabilityContractTests Offline guard; gotrue.rename_passkey parents PATCH /passkeys/{id}.

Changed-line coverage: 100% (21 lines). Mutation: 10/10 tested mutants on changed lines killed, 0 survivors (2 block-removal mutants on async bodies are ignored by Stryker).

Notes

@Tr00d
Tr00d marked this pull request as ready for review November 3, 2026 07:24
@Tr00d
Tr00d merged commit de1b9df into master Nov 3, 2026
6 checks passed
@Tr00d
Tr00d deleted the feat/auth.passkey.update_passkey branch November 3, 2026 07:24
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.

1 participant