Delete a passkey
Your users might want to delete their passkeys. You can do this using the @passlock/client and @passlock/server libraries. For deletion, we flip the order of operations, although strictly this is not required. Delete the passkey in your vault, then delete it from the user’s password manager.
Backend
Section titled “Backend”Use the @passlock/server library to delete the passkey from your vault.
import { deletePasskey } from "@passlock/server";
const result = await deletePasskey({ passkeyId, tenancyId, apiKey });
// remove the mapping between the passkey and your local user accountawait unlinkPasskey(passkeyId);
console.log("passkey deleted");import { deletePasskey, isPasskey } from "@passlock/server/safe";
const result = await deletePasskey({ passkeyId, tenancyId, apiKey });
if (isPasskey(result)) { // remove the mapping between the passkey and your local user account await unlinkPasskey(passkeyId);
console.log("deleted");}Frontend
Section titled “Frontend”Use the @passlock/client library to delete the passkey from the user’s device.
import { deletePasskey } from "@passlock/client";
await deletePasskey({ tenancyId, passkeyId });
console.log("passkey deleted");import { deletePasskey, isDeleteSuccess } from "@passlock/client/safe";
const result = await deletePasskey({ tenancyId, passkeyId });
if (isDeleteSuccess(result)) { console.log("deleted");} else { console.error(result); alert("Please remove your jdoe@example.com passkey");}