feat: isPasskeyRecoveryEnabled in service

This commit is contained in:
httpjamesm 2024-03-11 13:03:15 -04:00
parent 00f45ef39d
commit 1d4f92c39b
No known key found for this signature in database

View file

@ -0,0 +1,24 @@
import HTTPService from "@ente/shared/network/HTTPService";
import { getToken } from "@ente/shared/storage/localStorage/helpers"
import { logError } from "@ente/shared/sentry";
import { CustomError } from "@ente/shared/error";
export const isPasskeyRecoveryEnabled = async () => {
try {
const token = getToken();
const resp = await HTTPService.get("/users/two-factor/recovery-status", {}, {
"X-Auth-Token": token,
});
if (typeof resp.data === "undefined") {
throw Error(CustomError.REQUEST_FAILED);
}
return resp.isPasskeyRecoveryEnabled as boolean;
} catch (e) {
logError(e, "failed to get passkey recovery status");
throw e
}
}