Skip to content

Deleting passkeys

Use the @passlock/node library to remove a passkey from your vault:

backend/passkeys.ts
import {
deletePasskey,
isDeletedPasskey,
isNotFound
} from "@passlock/node";
// get these from your development tenancy settings
const tenancyId = "myTenancyId";
const apiKey = "myApiKey";
const result = await deletePasskey(passkeyId, { tenancyId, apiKey });
if (isDeletedPasskey(result)) {
// success
} else if (isNotFound(result)) {
// passkey not found in the vault
} else {
...
}

Use the @passlock/client library to remove a passkey from a user’s device:

frontend/passkeys.ts
import { isPasskeyDeletionSupport, deletePasskey } from "@passlock/client";
// get this from your development tenancy settings
const tenancyId = "myTenancyId";
const passkeyId = "myPasskeyId";
if (isPasskeyDeletionSupport()) {
deletePasskey(passkeyId, { tenancyId });
} else {
// tell the user to delete the passkey from their password manager
}

You can first delete a passkey from your vault, then pass the result to your frontend code…

backend/passkeys.ts
import {
deletePasskey,
isDeletedPasskey,
} from "@passlock/node";
const result = await deletePasskey(passkeyId, { tenancyId, apiKey });
if (isDeletedPasskey(result)) {
// send the result to your frontend
res.send(JSON.stringify(result))
}
frontend/passkeys.ts
import { isPasskeyDeletionSupport, deletePasskey } from "@passlock/client";
// result of calling deletePasskey in your backend
const backendDeletionResult = { credentialId: "...", rpId: "..." };
if (isPasskeyDeletionSupport()) {
deletePasskey(backendDeletionResult, { tenancyId });
}

If you receive a PasskeyNotFound error, pass that error into the deletePasskey function:

frontend/login.ts
import {
authenticatePasskey,
deletePasskey,
isPasskeyNotFound,
isPasskeyDeletionSupport,
} from "@passlock/client";
const result = await authenticatePasskey({ ... });
if (isPasskeyNotFound(result) && isPasskeyDeletionSupport()) {
if (confirm("Passkey invalid, remove it?")) {
await deletePasskey(result, { tenancyId });
}
}