diff --git a/packages/login/src/utils/actions.ts b/packages/login/src/utils/actions.ts index a9b277df7f..126d3004b0 100644 --- a/packages/login/src/utils/actions.ts +++ b/packages/login/src/utils/actions.ts @@ -46,7 +46,11 @@ import { TVersionBuild, } from "@docspace/shared/api/settings/types"; import { Encoder } from "@docspace/shared/utils/encoder"; -import { TTfaSecretKeyAndQR } from "@/types"; +import { + TConfirmLinkParams, + TConfirmLinkResult, + TTfaSecretKeyAndQR, +} from "@/types"; import { TScope } from "@docspace/shared/utils/oauth/types"; import { transformToClientProps } from "@docspace/shared/utils/oauth"; @@ -369,3 +373,20 @@ export async function getTfaSecretKeyAndQR(confirmKey: string | null = null) { return tfaSecretKeyAndQR.response as TTfaSecretKeyAndQR; } + +export async function checkConfirmLink(data: TConfirmLinkParams) { + const [checkConfirmLink] = createRequest( + [`/authentication/confirm`], + [["Content-Type", "application/json"]], + "POST", + JSON.stringify(data), + ); + + const response = await fetch(checkConfirmLink); + + if (!response.ok) throw new Error(response.statusText); + + const result = await response.json(); + + return result.response as TConfirmLinkResult; +}