UNPKG

@clerk/shared

Version:

Internal package utils used by the Clerk SDKs

14 lines (13 loc) • 878 B
//#region src/internal/clerk-js/passwordConfirmation.ts const isPasswordConfirmationError = (error) => error?.code === "form_password_incorrect" || error?.code === "form_password_validation_failed"; const PASSWORD_CONFIRMATION_SESSION_ENDED_PARAM = "__clerk_password_confirmation_session_ended"; const PASSWORD_CONFIRMATION_NOTICE_TTL = 300 * 1e3; const isPasswordConfirmationNotice = (value, publishableKey) => { if (typeof value !== "string" || !value.startsWith(`${publishableKey}:`)) return false; const issuedAt = Number(value.slice(publishableKey.length + 1)); const age = Date.now() - issuedAt; return Number.isFinite(issuedAt) && age >= 0 && age < 3e5; }; //#endregion export { PASSWORD_CONFIRMATION_NOTICE_TTL, PASSWORD_CONFIRMATION_SESSION_ENDED_PARAM, isPasswordConfirmationError, isPasswordConfirmationNotice }; //# sourceMappingURL=passwordConfirmation.mjs.map