Deleting passkeys
Deleting a passkey from your vault
Section titled “Deleting a passkey from your vault”Use the @passlock/node library to remove a passkey from your vault:
import { deletePasskey, isDeletedPasskey, isNotFound} from "@passlock/node";
// get these from your development tenancy settingsconst 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 { ...}Deleting a passkey from a device
Section titled “Deleting a passkey from a device”Use the @passlock/client library to remove a passkey from a user’s device:
import { isPasskeyDeletionSupport, deletePasskey } from "@passlock/client";
// get this from your development tenancy settingsconst tenancyId = "myTenancyId";const passkeyId = "myPasskeyId";
if (isPasskeyDeletionSupport()) { deletePasskey(passkeyId, { tenancyId });} else { // tell the user to delete the passkey from their password manager}Backend and frontend deletion
Section titled “Backend and frontend deletion”You can first delete a passkey from your vault, then pass the result to your frontend code…
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))}import { isPasskeyDeletionSupport, deletePasskey } from "@passlock/client";
// result of calling deletePasskey in your backendconst backendDeletionResult = { credentialId: "...", rpId: "..." };
if (isPasskeyDeletionSupport()) { deletePasskey(backendDeletionResult, { tenancyId });}Deletion following a NotFound error
Section titled “Deletion following a NotFound error”If you receive a PasskeyNotFound error, pass that error into the deletePasskey function:
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 }); }}