Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ plugins:
- 'lib/rspec/formatters/user_flow_formatter.rb'
eslint:
enabled: true
channel: eslint-6
config:
extensions:
- .js
Expand Down
78 changes: 39 additions & 39 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
{
'extends': 'airbnb',
'parser': 'babel-eslint',
'env': {
'browser': true,
'commonjs': true,
'es6': true,
'mocha': true
"extends": "airbnb",
"parser": "babel-eslint",
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"mocha": true
},
'globals': {
'$': true,
'__DEV__': true,
'assert': true,
'chai': true,
'sinon': true,
'expect': true,
'fixture': true
"globals": {
"$": true,
"__DEV__": true,
"assert": true,
"chai": true,
"sinon": true,
"expect": true,
"fixture": true
},
'rules': {
'jsx-a11y/img-has-alt': 'off',
'func-names': 0,
'space-before-function-paren': 0,
'prefer-arrow-callback': 0,
'import/prefer-default-export': 'off',
'import/extensions': ['off', 'never'],
'no-param-reassign': ['off', 'never'],
"rules": {
"jsx-a11y/img-has-alt": "off",
"func-names": 0,
"space-before-function-paren": 0,
"prefer-arrow-callback": 0,
"import/prefer-default-export": "off",
"import/extensions": ["off", "never"],
"no-param-reassign": ["off", "never"]
},
'parserOptions': {
'ecmaVersion': 6,
'sourceType': 'module'
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
'settings': {
'import/core-modules': [
'app/components/index',
'app/utils/index',
'app/pw-toggle',
'app/form-validation',
'app/form-field-format',
'app/radio-btn',
'app/print-personal-key',
'app/utils/ms-formatter',
'app/phone-internationalization',
'app/i18n-dropdown',
],
"settings": {
"import/core-modules": [
"app/components/index",
"app/utils/index",
"app/pw-toggle",
"app/form-validation",
"app/form-field-format",
"app/radio-btn",
"app/print-personal-key",
"app/utils/ms-formatter",
"app/phone-internationalization",
"app/i18n-dropdown"
]
}
}
7 changes: 3 additions & 4 deletions app/javascript/app/acuant/document_capture_dom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-cycle
import { documentCaptureFallbackModeEnabled } from './document_capture_fallback';

// Fallback form elements
Expand All @@ -16,11 +17,9 @@ export const acuantSdkPreviewImage = () => document.querySelector('#acuant-sdk-p
export const acuantSdkFallbackText = () => document.querySelector('#acuant-fallback-text');
export const acuantSdkFallbackLink = () => document.querySelector('#acuant-fallback-link');

export const fetchSdkInitializationCredentials = () =>
document.querySelector('meta[name="acuant-sdk-initialization-creds"]').content;
export const fetchSdkInitializationCredentials = () => document.querySelector('meta[name="acuant-sdk-initialization-creds"]').content;

export const fetchSdkInitializationEndpoint = () =>
document.querySelector('meta[name="acuant-sdk-initialization-endpoint"]').content;
export const fetchSdkInitializationEndpoint = () => document.querySelector('meta[name="acuant-sdk-initialization-endpoint"]').content;

const hideAcuantSdkContainers = () => {
acuantSdkUploadForm().classList.add('hidden');
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/app/acuant/document_capture_fallback.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-cycle
import {
showAcuantSdkFallbackText,
addClickEventListenerToAcuantFallbackLink,
Expand All @@ -9,9 +10,9 @@ export const enableDocumentCaptureFallbackMode = () => {
acauntDocumentCaptureFallbackEnabled();
};

export const documentCaptureFallbackModeEnabled = () =>
window.isDocumentCaptureFallbackModeEnabled === true;

export const documentCaptureFallbackModeEnabled = () => (
window.isDocumentCaptureFallbackModeEnabled === true
);

export const documentCaptureFallbackLinkClicked = (event) => {
event.preventDefault();
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/app/acuant/selfie_capture.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { acuantSdkPreviewImage, imageDataUrlInput, imageFileInput, showAcuantSdkContainer }
import {
acuantSdkPreviewImage, imageDataUrlInput, imageFileInput, showAcuantSdkContainer,
}
from './document_capture_dom';

const {
Expand Down
1 change: 0 additions & 1 deletion app/javascript/app/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ function checkbox() {
}
}


document.addEventListener('DOMContentLoaded', checkbox);
4 changes: 2 additions & 2 deletions app/javascript/app/components/focus-trap-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function FocusTrapProxy() {

return {
activate() {
focusables.forEach(trap => trap.deactivate());
focusables.forEach((trap) => trap.deactivate());

activated.push(ownTrap);

Expand All @@ -32,7 +32,7 @@ function FocusTrapProxy() {
return false;
}

activated = activated.filter(activatedTrap => activatedTrap !== ownTrap);
activated = activated.filter((activatedTrap) => activatedTrap !== ownTrap);

if (activated.length) {
activated[activated.length - 1].activate();
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/app/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import modal from './modal';
import Accordion from './accordion';

window.LoginGov = (window.LoginGov || {});
const LoginGov = window.LoginGov;
const { LoginGov } = window;
const trapModal = modal(focusTrapProxy);

LoginGov.Modal = trapModal;
Expand Down
1 change: 0 additions & 1 deletion app/javascript/app/components/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ function modal(focusTrap) {
};
}


export default modal;
4 changes: 2 additions & 2 deletions app/javascript/app/form-validation.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'classlist.js';

const I18n = window.LoginGov.I18n;
const { I18n } = window.LoginGov;

document.addEventListener('DOMContentLoaded', () => {
const forms = document.querySelectorAll('form');

function addListenerMulti(el, events, fn) {
events.split(' ').forEach(e => el.addEventListener(e, fn, false));
events.split(' ').forEach((e) => el.addEventListener(e, fn, false));
}

if (forms.length !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/app/i18n-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ document.addEventListener('DOMContentLoaded', () => {
const desktopDropdown = document.querySelector('.i18n-desktop-dropdown');

function addListenerMulti(el, s, fn) {
s.split(' ').forEach(e => el.addEventListener(e, fn, false));
s.split(' ').forEach((e) => el.addEventListener(e, fn, false));
}

function toggleAriaExpanded(element) {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/app/phone-internationalization.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const INTERNATIONAL_CODE_REGEX = /^\+(\d+) |^1 /;

const I18n = window.LoginGov.I18n;
const { I18n } = window.LoginGov;

const selectedInternationCodeOption = () => {
const dropdown = document.querySelector('[data-international-phone-form] .international-code');
Expand Down
3 changes: 1 addition & 2 deletions app/javascript/app/pw-toggle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const I18n = window.LoginGov.I18n;
const { I18n } = window.LoginGov;

function togglePw() {
const inputs = document.querySelectorAll('input[type="password"]');
Expand Down Expand Up @@ -27,5 +27,4 @@ function togglePw() {
}
}


document.addEventListener('DOMContentLoaded', togglePw);
1 change: 0 additions & 1 deletion app/javascript/app/radio-btn.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ function highlightRadioBtn() {
}
}


document.addEventListener('DOMContentLoaded', highlightRadioBtn);
4 changes: 2 additions & 2 deletions app/javascript/app/utils/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Events {

const handlersForEvent = this.handlers[eventName] || [];

if (!handlersForEvent.filter(obj => obj.handler === handler).length) {
if (!handlersForEvent.filter((obj) => obj.handler === handler).length) {
handlersForEvent.push({ handler, context });
}

Expand All @@ -26,7 +26,7 @@ class Events {
this.handlers[eventName].length = 0;
} else {
const handlers = this.handlers[eventName] || [];
this.handlers[eventName] = handlers.filter(obj => obj.handler !== handler);
this.handlers[eventName] = handlers.filter((obj) => obj.handler !== handler);
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/app/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import msFormatter from './ms-formatter';
import enableBannerToggling from './toggle-banner';

window.LoginGov = (window.LoginGov || {});
const LoginGov = window.LoginGov;
const documentElement = window.document.documentElement;
const { LoginGov } = window;
const { documentElement } = window.document;

documentElement.className = documentElement.className.replace(/no-js/, '');

Expand Down
16 changes: 9 additions & 7 deletions app/javascript/app/webauthn.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const base64ToArrayBuffer = (base64) => {
const bytes = Uint8Array.from(window.atob(base64).split('').map(char => char.charCodeAt(0)));
const bytes = Uint8Array.from(window.atob(base64).split('').map((char) => char.charCodeAt(0)));
return bytes.buffer;
};

const arrayBufferToBase64 = (arrayBuffer) => {
const buffer = new Uint8Array(arrayBuffer);
const binaryString = Array.from(buffer).map(byte => String.fromCharCode(byte)).join('');
const binaryString = Array.from(buffer).map((byte) => String.fromCharCode(byte)).join('');
return window.btoa(binaryString);
};

const longToByteArray = long => new Uint8Array(8).map(() => {
const longToByteArray = (long) => new Uint8Array(8).map(() => {
const byte = long & 0xff; // eslint-disable-line no-bitwise
long = (long - byte) / 256;
return byte;
Expand All @@ -19,7 +19,7 @@ const extractCredentials = (credentials) => {
if (!credentials) { // empty string check
return [];
}
return credentials.split(',').map(credential => ({
return credentials.split(',').map((credential) => ({
type: 'public-key',
id: base64ToArrayBuffer(credential),
}));
Expand All @@ -32,7 +32,9 @@ const isWebAuthnEnabled = () => {
return false;
};

const enrollWebauthnDevice = ({ userId, userEmail, userChallenge, excludeCredentials }) => {
const enrollWebauthnDevice = ({
userId, userEmail, userChallenge, excludeCredentials,
}) => {
const createOptions = {
publicKey: {
challenge: new Uint8Array(JSON.parse(userChallenge)),
Expand Down Expand Up @@ -85,7 +87,7 @@ const enrollWebauthnDevice = ({ userId, userEmail, userChallenge, excludeCredent
},
};

return navigator.credentials.create(createOptions).then(newCred => ({
return navigator.credentials.create(createOptions).then((newCred) => ({
webauthnId: arrayBufferToBase64(newCred.rawId),
webauthnPublicKey: newCred.id,
attestationObject: arrayBufferToBase64(newCred.response.attestationObject),
Expand All @@ -103,7 +105,7 @@ const verifyWebauthnDevice = ({ userChallenge, credentialIds }) => {
},
};

return navigator.credentials.get(getOptions).then(newCred => ({
return navigator.credentials.get(getOptions).then((newCred) => ({
credentialId: arrayBufferToBase64(newCred.rawId),
authenticatorData: arrayBufferToBase64(newCred.response.authenticatorData),
clientDataJSON: arrayBufferToBase64(newCred.response.clientDataJSON),
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/doc-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function docAuth() {
player.style.display = 'none';
canvas.style.display = 'inline-block';
captureButton.innerHTML = 'X';
player.srcObject.getVideoTracks().forEach(track => track.stop());
player.srcObject.getVideoTracks().forEach((track) => track.stop());
player.srcObject = null;
}

Expand Down
6 changes: 2 additions & 4 deletions app/javascript/packs/doc_capture_polling.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ const DOC_CAPTURE_TIMEOUT = 1000 * 60 * 25; // 25 minutes
const DOC_CAPTURE_POLL_INTERVAL = 5000;
const MAX_DOC_CAPTURE_POLL_ATTEMPTS = Math.floor(DOC_CAPTURE_TIMEOUT / DOC_CAPTURE_POLL_INTERVAL);

const docCaptureContinueButtonForm = () =>
document.querySelector('.doc_capture_continue_button_form');
const docCaptureContinueButtonForm = () => document.querySelector('.doc_capture_continue_button_form');

const docCaptureContinueInstructions = () =>
document.querySelector('#doc_capture_continue_instructions');
const docCaptureContinueInstructions = () => document.querySelector('#doc_capture_continue_instructions');

const handleMaxPollAttempts = () => {
// Unhide the continue buttons so the user can continue manually
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packs/image-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function imagePreview() {
$('#doc_auth_image').on('change', function(event) {
$('.simple_form .alert-error').hide();
$('.simple_form .alert-notice').hide();
const files = event.target.files;
const { files } = event.target;
const image = files[0];
const reader = new FileReader();
reader.onload = function(file) {
Expand Down
8 changes: 4 additions & 4 deletions app/javascript/packs/pw-strength.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import zxcvbn from 'zxcvbn';

const I18n = window.LoginGov.I18n;
const { I18n } = window.LoginGov;

// zxcvbn returns a strength score from 0 to 4
// we map those scores to:
Expand Down Expand Up @@ -46,7 +46,7 @@ function getFeedback(z) {
if (!warning && !suggestions.length) return ' ';
if (warning) return lookup(warning);

return `${suggestions.map(s => lookup(s)).join('')}`;
return `${suggestions.map((s) => lookup(s)).join('')}`;
}

function disableSubmit(submitEl, length = 0, score = 0) {
Expand All @@ -60,7 +60,7 @@ function disableSubmit(submitEl, length = 0, score = 0) {
}

function analyzePw() {
const userAgent = window.navigator.userAgent;
const { userAgent } = window.navigator;
const input = document.querySelector(
'#password_form_password, #reset_password_form_password, #update_user_password_form_password',
);
Expand All @@ -69,7 +69,7 @@ function analyzePw() {
const pwFeedback = document.getElementById('pw-strength-feedback');
const submit = document.querySelector('input[type="submit"]');
const forbiddenPasswordsElement = document.querySelector('[data-forbidden-passwords]');
const forbiddenPasswords = forbiddenPasswordsElement.dataset.forbiddenPasswords;
const { forbiddenPasswords } = forbiddenPasswordsElement.dataset;

disableSubmit(submit);

Expand Down
1 change: 0 additions & 1 deletion app/javascript/packs/verify-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ function verifyModal() {
}
}


document.addEventListener('DOMContentLoaded', verifyModal);
2 changes: 1 addition & 1 deletion app/javascript/packs/webauthn-setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const WebAuthn = require('../app/webauthn');

function webauthn() {
if (location.href.indexOf('?error=') === -1 && !WebAuthn.isWebAuthnEnabled()) {
if (window.location.href.indexOf('?error=') === -1 && !WebAuthn.isWebAuthnEnabled()) {
window.location.href = '/webauthn_setup?error=NotSupportedError';
}
const continueButton = document.getElementById('continue-button');
Expand Down
Loading