@clerk/shared
Version:
Internal package utils used by the Clerk SDKs
19 lines (17 loc) • 1.11 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
//#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
exports.PASSWORD_CONFIRMATION_NOTICE_TTL = PASSWORD_CONFIRMATION_NOTICE_TTL;
exports.PASSWORD_CONFIRMATION_SESSION_ENDED_PARAM = PASSWORD_CONFIRMATION_SESSION_ENDED_PARAM;
exports.isPasswordConfirmationError = isPasswordConfirmationError;
exports.isPasswordConfirmationNotice = isPasswordConfirmationNotice;
//# sourceMappingURL=passwordConfirmation.js.map