From e42ddaca77f3bb31aca28e221c61d0653ce58a60 Mon Sep 17 00:00:00 2001 From: amathews Date: Tue, 25 Aug 2020 12:33:01 -0400 Subject: [PATCH 1/3] LG-3323 Changes to make sure the right states are showing up on the desktop docauth upload page. Added simple camera detection javascript. --- app/javascript/packages/device/index.js | 12 ++++++++++ app/javascript/packs/upload-step.js | 10 +++++++++ app/views/idv/doc_auth/upload.html.erb | 30 +++++++++++++++++-------- config/locales/doc_auth/en.yml | 7 +++--- config/locales/doc_auth/es.yml | 6 +++-- config/locales/doc_auth/fr.yml | 6 +++-- 6 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 app/javascript/packs/upload-step.js diff --git a/app/javascript/packages/device/index.js b/app/javascript/packages/device/index.js index dbb610cab71..1d2d2f0d48c 100644 --- a/app/javascript/packages/device/index.js +++ b/app/javascript/packages/device/index.js @@ -17,6 +17,18 @@ export function hasMediaAccess() { return 'mediaDevices' in window.navigator; } +/** + * Returns a boolean promise of whether or not the device has a video input device. + * + * @return {Promise} + */ +export async function hasCamera() { + if (hasMediaAccess()) { + const devices = await navigator.mediaDevices.enumerateDevices(); + return devices.some((device) => device.kind === 'videoinput'); + } +} + /** * Returns true if the current device is assumed to be a mobile device where a camera is available, * or false otherwise. This is a rough approximation, using device user agent sniffing and diff --git a/app/javascript/packs/upload-step.js b/app/javascript/packs/upload-step.js new file mode 100644 index 00000000000..ded77b72ba9 --- /dev/null +++ b/app/javascript/packs/upload-step.js @@ -0,0 +1,10 @@ +// app/packs/upload-step.js +import { hasCamera } from '@18f/identity-device'; + +(async () => { + if (await hasCamera()) { + document.getElementById('upload-comp-liveness').classList.add('hidden'); + document.getElementById('upload-comp-liveness-off').classList.remove('hidden'); + document.getElementById('recommended-tag').classList.remove('hidden'); + } +})(); diff --git a/app/views/idv/doc_auth/upload.html.erb b/app/views/idv/doc_auth/upload.html.erb index 579853fbe04..c007fd9b55d 100644 --- a/app/views/idv/doc_auth/upload.html.erb +++ b/app/views/idv/doc_auth/upload.html.erb @@ -12,21 +12,18 @@

<%= t('doc_auth.info.upload_liveness_enabled') %>

-

- <%= t('doc_auth.info.upload_no_image_storage') %> -

<% else %>

<%= t('doc_auth.info.upload') %>

<% end %> -
- <%= link_to t('idv.messages.jurisdiction.no_id'), idv_jurisdiction_errors_no_id_path %> -
+

+ <%= t('doc_auth.info.upload_no_image_storage') %> +

<% if Figaro.env.cac_proofing_enabled == 'true' && desktop_device? %> -
+
<%= t( 'doc_auth.info.use_cac_html', link: link_to( @@ -37,6 +34,10 @@
<% end %> +
+ <%= link_to t('idv.messages.jurisdiction.no_id'), idv_jurisdiction_errors_no_id_path %> +
+
@@ -47,7 +48,8 @@ width: 80, ) %>
-
+
@@ -76,7 +78,8 @@
-
+
'> <%= t('doc_auth.info.upload_from_computer') %>  <%= simple_form_for( :doc_auth, @@ -89,7 +92,16 @@ <% end %>
+
'> + <%= t('doc_auth.info.upload_from_computer') %> + <%= t('doc_auth.info.upload_from_computer_not_allowed') %> +
<%= render 'idv/doc_auth/start_over_or_cancel' %> <%= javascript_pack_tag 'image-preview' %> + +<% unless Figaro.env.document_capture_react_enabled == 'false' %> + <%= javascript_pack_tag 'upload-step' %> +<% end %> diff --git a/config/locales/doc_auth/en.yml b/config/locales/doc_auth/en.yml index f202ecd01a3..ef7344372d1 100644 --- a/config/locales/doc_auth/en.yml +++ b/config/locales/doc_auth/en.yml @@ -75,9 +75,10 @@ en: take_picture: Use the camera on your mobile phone and upload images of your ID. We only use the images to verify your identity. upload: We'll collect information about you by reading your state-issued ID. - We do not store images you upload. We only verify your identity. upload_computer_link: Upload from your computer upload_from_computer: Don't have a phone? + upload_from_computer_not_allowed: Sign in to your login.gov account on any device that has a + camera, like a tablet or computer with a webcam. upload_from_phone: Upload pictures directly from your phone camera upload_image: We only use your ID to verify your identity, and we will not save any images. We accept BMP, PNG, TIFF, and JPG formats. @@ -86,8 +87,8 @@ en: are the owner of the ID. upload_no_image_storage: We do not store images you upload. We only verify your identity. - use_cac_html: "Are you DoD or military? %{link}" - use_cac_link: Use your CAC card instead + use_cac_html: "Do you have a government employee ID? %{link}" + use_cac_link: Use a PIV/CAC instead welcome: We verify your identity to make sure you are you—not someone pretending to be you. Verifying your identity lets you access services that handle sensitive information. diff --git a/config/locales/doc_auth/es.yml b/config/locales/doc_auth/es.yml index aa65b640599..c212ffcf3a9 100644 --- a/config/locales/doc_auth/es.yml +++ b/config/locales/doc_auth/es.yml @@ -81,6 +81,8 @@ es: por el estado. No almacenamos imágenes que cargue. Solo verificamos su identidad. upload_computer_link: Sube desde tu computadora upload_from_computer: "¿No tienes teléfono?" + upload_from_computer_not_allowed: Inicie sesión en su cuenta login.gov en cualquier + dispositivo que tenga una cámara, como una tableta o computadora con una cámara web. upload_from_phone: Sube imágenes directamente desde la cámara de tu teléfono upload_image: Solo utilizamos su ID para verificar su identidad y no guardaremos ninguna imagen. Aceptamos los formatos BMP, PNG, TIFF y JPG. @@ -89,8 +91,8 @@ es: propietario de la identificación. upload_no_image_storage: No almacenamos imágenes que cargue. Solo verificamos su identidad. - use_cac_html: "¿Eres DoD o militar? %{link}" - use_cac_link: Use su tarjeta CAC en su lugar + use_cac_html: "¿Tiene una identificación de empleado del gobierno? %{link}" + use_cac_link: Usa un PIV/CAC en su lugar welcome: Verificamos su identidad para asegurarnos de que usted es usted, y no alguien que pretende ser usted. Verificar su identidad le permite acceder a servicios que manejan información confidencial. diff --git a/config/locales/doc_auth/fr.yml b/config/locales/doc_auth/fr.yml index b1c594e7ffe..1aa57fdaeea 100644 --- a/config/locales/doc_auth/fr.yml +++ b/config/locales/doc_auth/fr.yml @@ -87,6 +87,8 @@ fr: Nous vérifions uniquement votre identité. upload_computer_link: Téléchargez depuis votre ordinateur upload_from_computer: Vous n'avez pas de téléphone? + upload_from_computer_not_allowed: Connectez-vous à votre compte login.gov sur n'importe quel + appareil équipé d'une caméra, comme une tablette ou un ordinateur avec une webcam. upload_from_phone: Téléchargez des images directement depuis l'appareil photo de votre téléphone upload_image: Nous n'utilisons votre identifiant que pour vérifier votre identité, @@ -97,8 +99,8 @@ fr: une photo de vous pour confirmer que vous êtes le propriétaire de la pièce d'identité. upload_no_image_storage: Nous ne stockons pas les images que vous téléchargez. - use_cac_html: "Êtes-vous DoD ou militaire? %{link}" - use_cac_link: Utilisez plutôt votre carte CAC + use_cac_html: "Avez-vous un identifiant d'employé du gouvernement? %{link}" + use_cac_link: Utilisez plutôt un PIV/CAC welcome: Nous vérifions votre identité pour nous assurer que vous êtes bien, et non quelqu'un prétendant être vous. La vérification de votre identité vous permet d'accéder à des services traitant des informations sensibles. From 5cd0c84ff9a0dff4b2ac80cad2c0f5235d9cd41b Mon Sep 17 00:00:00 2001 From: amathews Date: Tue, 25 Aug 2020 12:58:42 -0400 Subject: [PATCH 2/3] LG-3323 Normalize some yaml and fix a problem. --- app/views/idv/doc_auth/upload.html.erb | 2 +- config/locales/doc_auth/en.yml | 6 +++--- config/locales/doc_auth/es.yml | 3 ++- config/locales/doc_auth/fr.yml | 7 ++++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/views/idv/doc_auth/upload.html.erb b/app/views/idv/doc_auth/upload.html.erb index c007fd9b55d..3947c9c110c 100644 --- a/app/views/idv/doc_auth/upload.html.erb +++ b/app/views/idv/doc_auth/upload.html.erb @@ -49,7 +49,7 @@ ) %>
diff --git a/config/locales/doc_auth/en.yml b/config/locales/doc_auth/en.yml index ef7344372d1..eba0482fcb3 100644 --- a/config/locales/doc_auth/en.yml +++ b/config/locales/doc_auth/en.yml @@ -77,8 +77,8 @@ en: upload: We'll collect information about you by reading your state-issued ID. upload_computer_link: Upload from your computer upload_from_computer: Don't have a phone? - upload_from_computer_not_allowed: Sign in to your login.gov account on any device that has a - camera, like a tablet or computer with a webcam. + upload_from_computer_not_allowed: Sign in to your login.gov account on any device + that has a camera, like a tablet or computer with a webcam. upload_from_phone: Upload pictures directly from your phone camera upload_image: We only use your ID to verify your identity, and we will not save any images. We accept BMP, PNG, TIFF, and JPG formats. @@ -87,7 +87,7 @@ en: are the owner of the ID. upload_no_image_storage: We do not store images you upload. We only verify your identity. - use_cac_html: "Do you have a government employee ID? %{link}" + use_cac_html: Do you have a government employee ID? %{link} use_cac_link: Use a PIV/CAC instead welcome: We verify your identity to make sure you are you—not someone pretending to be you. Verifying your identity lets you access services that handle sensitive diff --git a/config/locales/doc_auth/es.yml b/config/locales/doc_auth/es.yml index c212ffcf3a9..5d401129320 100644 --- a/config/locales/doc_auth/es.yml +++ b/config/locales/doc_auth/es.yml @@ -82,7 +82,8 @@ es: upload_computer_link: Sube desde tu computadora upload_from_computer: "¿No tienes teléfono?" upload_from_computer_not_allowed: Inicie sesión en su cuenta login.gov en cualquier - dispositivo que tenga una cámara, como una tableta o computadora con una cámara web. + dispositivo que tenga una cámara, como una tableta o computadora con una cámara + web. upload_from_phone: Sube imágenes directamente desde la cámara de tu teléfono upload_image: Solo utilizamos su ID para verificar su identidad y no guardaremos ninguna imagen. Aceptamos los formatos BMP, PNG, TIFF y JPG. diff --git a/config/locales/doc_auth/fr.yml b/config/locales/doc_auth/fr.yml index 1aa57fdaeea..4b69557e3b6 100644 --- a/config/locales/doc_auth/fr.yml +++ b/config/locales/doc_auth/fr.yml @@ -87,8 +87,9 @@ fr: Nous vérifions uniquement votre identité. upload_computer_link: Téléchargez depuis votre ordinateur upload_from_computer: Vous n'avez pas de téléphone? - upload_from_computer_not_allowed: Connectez-vous à votre compte login.gov sur n'importe quel - appareil équipé d'une caméra, comme une tablette ou un ordinateur avec une webcam. + upload_from_computer_not_allowed: Connectez-vous à votre compte login.gov sur + n'importe quel appareil équipé d'une caméra, comme une tablette ou un ordinateur + avec une webcam. upload_from_phone: Téléchargez des images directement depuis l'appareil photo de votre téléphone upload_image: Nous n'utilisons votre identifiant que pour vérifier votre identité, @@ -99,7 +100,7 @@ fr: une photo de vous pour confirmer que vous êtes le propriétaire de la pièce d'identité. upload_no_image_storage: Nous ne stockons pas les images que vous téléchargez. - use_cac_html: "Avez-vous un identifiant d'employé du gouvernement? %{link}" + use_cac_html: Avez-vous un identifiant d'employé du gouvernement? %{link} use_cac_link: Utilisez plutôt un PIV/CAC welcome: Nous vérifions votre identité pour nous assurer que vous êtes bien, et non quelqu'un prétendant être vous. La vérification de votre identité vous From 1497cb2c41514faffea5b71326ef7341c1094604 Mon Sep 17 00:00:00 2001 From: amathews Date: Tue, 25 Aug 2020 13:30:16 -0400 Subject: [PATCH 3/3] LG-3323 Clean up. --- app/views/idv/doc_auth/upload.html.erb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/views/idv/doc_auth/upload.html.erb b/app/views/idv/doc_auth/upload.html.erb index 3947c9c110c..9347bca0948 100644 --- a/app/views/idv/doc_auth/upload.html.erb +++ b/app/views/idv/doc_auth/upload.html.erb @@ -101,7 +101,4 @@ <%= render 'idv/doc_auth/start_over_or_cancel' %> <%= javascript_pack_tag 'image-preview' %> - -<% unless Figaro.env.document_capture_react_enabled == 'false' %> - <%= javascript_pack_tag 'upload-step' %> -<% end %> +<%= javascript_pack_tag 'upload-step' %>