@okta/okta-signin-widget
Version:
The Okta Sign-In Widget
135 lines (121 loc) • 4.29 kB
JavaScript
/* eslint complexity: [2, 25] */
import { AUTHENTICATOR_KEY, FORMS } from './RemediationConstants';
const FORMNAME_CLASSNAME_MAPPINGS = {
[ ]: {
[ ]: 'primary-auth',
[ ]: 'primary-auth'
},
[ ]: {
[ ]: 'forgot-password',
},
[ ]: {
[ ]: 'registration',
},
[ ]: {
[ ]: 'mfa-verify-passcode',
[ ]: 'mfa-verify-password',
sms: 'mfa-verify-passcode',
voice: 'mfa-verify-passcode',
[ ]: 'mfa-verify-question',
[ ]: 'mfa-verify-webauthn',
[ ]: 'mfa-verify-totp',
[ ]: 'mfa-verify-totp',
[ ]: 'mfa-verify',
[ ]: 'mfa-verify',
[ ]: 'mfa-verify-duo',
[ ]: 'mfa-verify',
[ ]: 'mfa-verify',
[ ]: 'mfa-verify',
},
[ ]: {
[ ]: 'mfa-verify',
[ ]: 'mfa-verify',
},
[ ]: {
[ ]: 'mfa-verify',
[ ]: 'mfa-verify',
},
[ ]: {
[ ]: 'enroll-email',
[ ]: 'enroll-password',
sms: 'enroll-sms',
voice: 'enroll-call',
[ ]: 'enroll-question',
[ ]: 'enroll-webauthn',
[ ]: 'enroll-onprem',
[ ]: 'enroll-rsa',
[ ]: 'enroll-duo',
[ ]: 'enroll-symantec',
[ ]: 'enroll-yubikey',
},
[ ]: {
'select-authenticator-enroll': 'enroll-choices'
},
[ ]: {
[ ]: 'forgot-password'
},
[ ]: {
[ ]: 'password-expired'
},
[ ]: {
[ ]: 'custom-password-expired'
},
[ ]: {
[ ]: 'custom-password-expiry-warning'
},
[ ]: {
[ ]: 'forgot-password'
},
[ ]: {
[ ]: 'admin-consent-required',
},
[ ]: {
[ ]: 'consent-required',
}
};
const getV1ClassName = (formName, authenticatorKey, methodType, isPasswordRecoveryFlow) => {
// if password reset flow from identifier page with recoveryAuthenticator add forgot-password class
if (isPasswordRecoveryFlow && formName === FORMS.IDENTIFY) {
return 'forgot-password';
} else {
let key = formName;
if (authenticatorKey === AUTHENTICATOR_KEY.PHONE) {
// Both sms and call have same type phone
// currentAuthenticatorEnrollment is during verify and currentAuthenticator during enroll flows
key = `${methodType}`;
}
else if (authenticatorKey) {
key = `${authenticatorKey}`;
}
if (FORMNAME_CLASSNAME_MAPPINGS[formName] && FORMNAME_CLASSNAME_MAPPINGS[formName][key]) {
return FORMNAME_CLASSNAME_MAPPINGS[formName][key];
} else {
return null;
}
}
};
const getClassNameMapping = (formName, authenticatorKey, methodType, isPasswordRecoveryFlow) => {
// 1. Generates V2 class name
// If we have a type which is authenticatorType/methodType use that to generate a V2 className
// Otherwise just use formName
let v2ClassName = formName;
if (authenticatorKey) {
v2ClassName = v2ClassName + '--' + authenticatorKey;
}
// 2. do a lookup for any V1 classNames and concat
let v1ClassName = getV1ClassName(
formName,
authenticatorKey,
methodType,
isPasswordRecoveryFlow,
);
const result = [v2ClassName];
if (v1ClassName) {
result.push(v1ClassName);
}
return result;
};
export {
getClassNameMapping,
getV1ClassName
};