{ "version": 3, "sources": ["../../src/modern/features/password-indicator/index.js", "../../src/modern/features/password-indicator/reducers.js", "../../src/modern/redux/reducers/passwords.js", "../../src/modern/redux/actions/passwords.js", "../../src/modern/features/password-indicator/Password.js", "../../src/modern/components/form/PasswordIndicator.js", "../../src/modern/components/form/styles.js"], "sourcesContent": ["import * as React from 'react'\nimport * as ReactDOM from 'react-dom/client'\nimport { Provider } from 'react-redux'\nimport { createStore, applyMiddleware } from 'redux'\nimport { thunk } from 'redux-thunk'\n\nimport { callAPIMiddleware } from '$redux/middleware/callAPI'\nimport langMiddleware from '$redux/middleware/langMiddleware'\n\nimport reducers from './reducers'\nimport Password from './Password'\n\nconst container = document.createElement('div')\n\nconst findParentField = (element) => {\n if (element.classList.contains('field-input')) {\n return element\n }\n\n if (element === document) {\n return null\n }\n\n return findParentField(element.parentNode)\n}\n\nwindow.addEventListener('js:location:loaded', (event) => {\n const passwordInput = document.getElementById('id_new_password1')\n const field = passwordInput && findParentField(passwordInput)\n const changePasswordForm = document.querySelector('#settings-content form')\n const resetPasswordForm = document.querySelector('#settings form')\n const form = changePasswordForm || resetPasswordForm\n\n if (passwordInput && field) {\n const store = createStore(reducers, {}, applyMiddleware(thunk, callAPIMiddleware, langMiddleware))\n\n field.appendChild(container)\n\n const root = ReactDOM.createRoot(container)\n root.render(\n \n \n ,\n container\n )\n }\n})\n", "import { combineReducers } from 'redux'\n\nimport passwords from '$redux/reducers/passwords'\n\nexport default combineReducers({ passwords })\n", "import zxcvbn from 'zxcvbn'\n\nimport * as ActionTypes from '../actions/passwords'\n\nconst initialState = {\n score: '',\n passwordSuggestions: []\n}\n\nconst passwords = (state = initialState, action) => {\n switch (action.type) {\n case ActionTypes.GET_PASSWORD_SCORE_SUCCESS: {\n const { feedback } = zxcvbn(action.password)\n const { warning, suggestions } = feedback\n const score = action.response.score || ''\n const passwordSuggestions = [...(warning ? [warning] : []), ...suggestions]\n\n return {\n ...state,\n score,\n suggestions: passwordSuggestions\n }\n }\n\n default:\n return state\n }\n}\n\nexport default passwords\n", "import { api } from '$utils/apiRequester'\n\nexport const GET_PASSWORD_SCORE_REQUEST = 'GET_PASSWORD_SCORE_REQUEST'\nexport const GET_PASSWORD_SCORE_SUCCESS = 'GET_PASSWORD_SCORE_SUCCESS'\nexport const GET_PASSWORD_SCORE_FAILURE = 'GET_PASSWORD_SCORE_FAILURE'\n\nexport const getPasswordScore = password => ({\n types: [GET_PASSWORD_SCORE_REQUEST, GET_PASSWORD_SCORE_SUCCESS, GET_PASSWORD_SCORE_FAILURE],\n promise: () => api('ulule').post('/passwords/score', { body: { password } }),\n password\n})\n", "import React from 'react'\nimport PropTypes from 'prop-types'\nimport { connect } from 'react-redux'\n\nimport PasswordIndicator from '$components/form/PasswordIndicator'\nimport { getPasswordScore } from '$redux/actions/passwords'\n\nclass Password extends React.Component {\n constructor(props) {\n super(props)\n\n this.state = {\n password: props.passwordInput.value\n }\n }\n\n componentDidMount() {\n const { form, passwordInput } = this.props\n\n passwordInput.addEventListener('input', this.handlePasswordChange)\n form.addEventListener('submit', this.handleSubmit)\n }\n\n componentWillUnmount() {\n const { form, passwordInput } = this.props\n\n passwordInput.removeEventListener('input', this.handlePasswordChange)\n form.removeEventListener('submit', this.handleSubmit)\n }\n\n handleSubmit = event => {\n event.preventDefault()\n\n const { form, score } = this.props\n const passwordInvalid = score === 'worst' || score === 'bad'\n\n if (!passwordInvalid) {\n // get submit method from a new form instance\n // as it is overriden by input with name=\"submit\"\n document.createElement('form').submit.call(form)\n }\n }\n\n handlePasswordChange = () => {\n const { passwordInput } = this.props\n\n this.setState({ password: passwordInput.value })\n }\n\n render() {\n const { password } = this.state\n const { getPasswordScore, score, suggestions } = this.props\n\n return (\n \n )\n }\n}\n\nPassword.propTypes = {\n form: PropTypes.object,\n passwordInput: PropTypes.object.isRequired\n}\n\nconst mapStateToProps = (state, ownProps) => ({\n score: state.passwords.score,\n suggestions: state.passwords.suggestions\n})\n\nconst mapDispatchToProps = { getPasswordScore }\n\nexport default connect(\n mapStateToProps,\n mapDispatchToProps\n)(Password)\n", "import React from 'react'\nimport PropTypes from 'prop-types'\nimport { t } from '@ulule/localize'\n\nimport * as S from './styles'\n\nclass PasswordIndicator extends React.Component {\n constructor(props) {\n super(props)\n\n this.initializeTranslations()\n }\n\n initializeTranslations = () => {\n this.strength = {\n worst: `\uD83D\uDEAB ${t('Worst')}`,\n bad: `\uD83D\uDC4E ${t('Bad')}`,\n weak: `\uD83D\uDE10 ${t('Weak')}`,\n good: `\uD83D\uDE0A ${t('Good')}`,\n strong: `\uD83E\uDD17 ${t('Strong')}`\n }\n\n this.message = {\n worst: t('Risky.'),\n bad: t('Still too weak.'),\n weak: t('Ok but still a bit too weak.'),\n good: t('Your password is secure.'),\n strong: t('Your password is very secure, you are unhackable.')\n }\n\n this.suggestions = [\n t('Use a few words, avoid common phrases'),\n t('No need for symbols, digits, or uppercase letters'),\n t('Add another word or two. Uncommon words are better.'),\n t('Straight rows of keys are easy to guess'),\n t('Short keyboard patterns are easy to guess'),\n t('Use a longer keyboard pattern with more turns'),\n t('Repeats like \"aaa\" are easy to guess'),\n t('Repeats like \"abcabcabc\" are only slightly harder to guess than \"abc\"'),\n t('Avoid repeated words and characters'),\n t('Sequences like abc or 6543 are easy to guess'),\n t('Avoid sequences'),\n t('Recent years are easy to guess'),\n t('Avoid recent years'),\n t('Avoid years that are associated with you'),\n t('Dates are often easy to guess'),\n t('Avoid dates and years that are associated with you'),\n t('This is a top-10 common password'),\n t('This is a top-100 common password'),\n t('This is a very common password'),\n t('This is similar to a commonly used password'),\n t('A word by itself is easy to guess'),\n t('Names and surnames by themselves are easy to guess'),\n t('Common names and surnames are easy to guess'),\n t(`Capitalization doesn't help very much`),\n t('All-uppercase is almost as easy to guess as all-lowercase'),\n t(`Reversed words aren't much harder to guess`),\n t(`Predictable substitutions like '@' instead of 'a' don't help very much`)\n ]\n }\n\n componentDidUpdate(prevProps) {\n const { password, getPasswordScore } = this.props\n const { password: prevPassword } = prevProps\n\n if (password !== '' && password !== prevPassword) {\n getPasswordScore(password)\n }\n }\n\n getLocalized = value => {\n const localized = value && t(value)\n const period = value && localized.slice(-1) === '.' ? '' : '.'\n return value ? `${localized}${period}` : value\n }\n\n render() {\n const { password, score, suggestions } = this.props\n const strength = this.strength[score]\n const localizedSuggestions = suggestions ? suggestions.map(this.getLocalized) : []\n const message = [this.message[score], ...localizedSuggestions].join(' ')\n\n return (\n \n {password && (\n \n {strength} {message}\n \n )}\n \n )\n }\n}\n\nPasswordIndicator.propTypes = {\n getPasswordScore: PropTypes.func.isRequired,\n password: PropTypes.string,\n score: PropTypes.string,\n suggestions: PropTypes.arrayOf(PropTypes.string)\n}\n\nexport default PasswordIndicator\n", "import styled from 'styled-components'\nimport { COLORS } from '@ulule/owl-kit-components'\n\nconst colorByScore = {\n worst: COLORS.SECONDARY_RED,\n bad: COLORS.SECONDARY_RED,\n weak: COLORS.SECONDARY_PURPLE,\n good: COLORS.SECONDARY_PURPLE,\n strong: COLORS.PRIMARY_BLUE\n}\n\nexport const PasswordIndicator = styled.div`\n font-size: 13px;\n`\n\nexport const PasswordStrength = styled.span`\n color: ${props => colorByScore[props.score]};\n`\n"], "mappings": "0gBAAAA,IAAAC,IAAA,IAAAC,EAAuB,SACvBC,EAA0B,SCD1BC,IAAAC,ICAAC,IAAAC,IAAA,IAAAC,EAAmB,SCAnBC,IAAAC,IAEO,IAAMC,GAA6B,6BAC7BC,EAA6B,6BAC7BC,GAA6B,6BAE7BC,EAAmBC,IAAa,CAC3C,MAAO,CAACJ,GAA4BC,EAA4BC,EAA0B,EAC1F,QAAS,IAAMG,EAAI,OAAO,EAAE,KAAK,mBAAoB,CAAE,KAAM,CAAE,SAAAD,CAAS,CAAE,CAAC,EAC3E,SAAAA,CACF,GDNA,IAAME,GAAe,CACnB,MAAO,GACP,oBAAqB,CAAC,CACxB,EAEMC,GAAY,CAACC,EAAQF,GAAcG,IAAW,CAClD,OAAQA,EAAO,KAAM,CACnB,KAAiBC,EAA4B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H,EAAO,YAAAI,CAAY,EAAI,KAAK,MAEtD,OACE,EAAAT,QAAA,cAACU,EAAA,CACC,iBAAkBF,EAClB,SAAUD,EACV,MAAOF,EACP,YAAaI,EACf,CAEJ,CACF,EAEAV,EAAS,UAAY,CACnB,KAAM,EAAAY,QAAU,OAChB,cAAe,EAAAA,QAAU,OAAO,UAClC,EAEA,IAAMC,GAAkB,CAACC,EAAOC,KAAc,CAC5C,MAAOD,EAAM,UAAU,MACvB,YAAaA,EAAM,UAAU,WAC/B,GAEME,GAAqB,CAAE,iBAAAP,CAAiB,EAEvCQ,EAAQC,EACbL,GACAG,EACF,EAAEhB,CAAQ,EJnEV,IAAMmB,EAAY,SAAS,cAAc,KAAK,EAExCC,EAAmBC,GACnBA,EAAQ,UAAU,SAAS,aAAa,EACnCA,EAGLA,IAAY,SACP,KAGFD,EAAgBC,EAAQ,UAAU,EAG3C,OAAO,iBAAiB,qBAAuBC,GAAU,CACvD,IAAMC,EAAgB,SAAS,eAAe,kBAAkB,EAC1DC,EAAQD,GAAiBH,EAAgBG,CAAa,EACtDE,EAAqB,SAAS,cAAc,wBAAwB,EACpEC,EAAoB,SAAS,cAAc,gBAAgB,EAC3DC,EAAOF,GAAsBC,EAEnC,GAAIH,GAAiBC,EAAO,CAC1B,IAAMI,EAAQC,EAAYC,EAAU,CAAC,EAAGC,EAAgBC,EAAOC,EAAmBC,CAAc,CAAC,EAEjGV,EAAM,YAAYL,CAAS,EAEL,aAAWA,CAAS,EACrC,OACH,gBAACgB,EAAA,CAAS,MAAOP,GACf,gBAACQ,EAAA,CAAS,KAAMT,EAAM,cAAeJ,EAAe,CACtD,EACAJ,CACF,CACF,CACF,CAAC", "names": ["init_define_process_env", "init_sentry_release_injection_stub", "React", "ReactDOM", "init_define_process_env", "init_sentry_release_injection_stub", "init_define_process_env", "init_sentry_release_injection_stub", "import_zxcvbn", "init_define_process_env", "init_sentry_release_injection_stub", "GET_PASSWORD_SCORE_REQUEST", "GET_PASSWORD_SCORE_SUCCESS", "GET_PASSWORD_SCORE_FAILURE", "getPasswordScore", "password", "api", "initialState", "passwords", "state", "action", "GET_PASSWORD_SCORE_SUCCESS", "feedback", "zxcvbn", "warning", "suggestions", "score", "passwordSuggestions", "__spreadProps", "__spreadValues", "passwords_default", "reducers_default", "combineReducers", "passwords_default", "init_define_process_env", "init_sentry_release_injection_stub", "import_react", "import_prop_types", "init_define_process_env", "init_sentry_release_injection_stub", "import_react", "import_prop_types", "import_localize", "init_define_process_env", "init_sentry_release_injection_stub", "colorByScore", "colors_exports", "_a", "PasswordIndicator", "src_default", "__template", "_b", "PasswordStrength", "props", "PasswordIndicator", "React", "props", "__publicField", "value", "localized", "period", "prevProps", "password", "getPasswordScore", "prevPassword", "score", "suggestions", "strength", "localizedSuggestions", "message", "PasswordStrength", "PropTypes", "PasswordIndicator_default", "Password", "React", "props", "__publicField", "event", "form", "score", "passwordInput", "password", "getPasswordScore", "suggestions", "PasswordIndicator_default", "PropTypes", "mapStateToProps", "state", "ownProps", "mapDispatchToProps", "Password_default", "connect_default", "container", "findParentField", "element", "event", "passwordInput", "field", "changePasswordForm", "resetPasswordForm", "form", "store", "createStore", "reducers_default", "applyMiddleware", "thunk", "callAPIMiddleware", "langMiddleware_default", "Provider_default", "Password_default"] }