Delete a passkey
Your users might want to delete their passkeys. You can do this using the @passlock/browser 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 { Passlock } from "@passlock/server";
// get these from your development tenancy settingsconst tenancyId = "myTenancyId";const apiKey = "myApiKey";const passlock = new Passlock({ tenancyId, apiKey });
const result = await passlock.deletePasskey({ passkeyId });
if (result.success) { // remove the mapping between the passkey and your local user account await unlinkPasskey(passkeyId);
console.log("deleted");} else { console.error(result.error.message);}import { Passlock } from "@passlock/server/unsafe";
// get these from your development tenancy settingsconst tenancyId = "myTenancyId";const apiKey = "myApiKey";const passlock = new Passlock({ tenancyId, apiKey });
const result = await passlock.deletePasskey({ passkeyId });
// remove the mapping between the passkey and your local user accountawait unlinkPasskey(passkeyId);
console.log("passkey deleted");import { deletePasskey } from "@passlock/server";
const result = await deletePasskey({ passkeyId }, { tenancyId, apiKey });
if (result.success) { // remove the mapping between the passkey and your local user account await unlinkPasskey(passkeyId);
console.log("deleted");} else { console.error(result.error.message);}import { deletePasskey } from "@passlock/server/unsafe";
const result = await deletePasskey({ passkeyId }, { tenancyId, apiKey });
// remove the mapping between the passkey and your local user accountawait unlinkPasskey(passkeyId);
console.log("passkey deleted");
Choose your code style
Frontend
Section titled “Frontend”Use the @passlock/browser library to delete the passkey from the user’s device.
import { Passlock } from "@passlock/browser";
// get this from your development tenancy settingsconst tenancyId = "myTenancyId";const passlock = new Passlock({ tenancyId });
const result = await passlock.deletePasskey({ passkeyId }, { tenancyId });
if (result.success) { console.log("deleted");} else { console.error(result.error.message); alert("Please remove your jdoe@example.com passkey");}import { Passlock } from "@passlock/browser/unsafe";
// get this from your development tenancy settingsconst tenancyId = "myTenancyId";const passlock = new Passlock({ tenancyId });
await passlock.deletePasskey({ passkeyId }, { tenancyId });
console.log("passkey deleted");import { deletePasskey } from "@passlock/browser";
// get this from your development tenancy settingsconst tenancyId = "myTenancyId";
const result = await deletePasskey({ passkeyId }, { tenancyId });
if (result.success) { console.log("deleted");} else { console.error(result.error.message); alert("Please remove your jdoe@example.com passkey");}import { deletePasskey } from "@passlock/browser/unsafe";
// get this from your development tenancy settingsconst tenancyId = "myTenancyId";
await deletePasskey({ passkeyId }, { tenancyId });
console.log("passkey deleted");
Choose your code style