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
9 changes: 5 additions & 4 deletions app/controllers/concerns/idv/document_capture_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ def validation_requirements_met?
def document_type_mismatch?
# Reject passports when feature is disabled but user submitted a passport
return true if !IdentityConfig.store.doc_auth_passports_enabled &&
submitted_id_type == 'passport'
submitted_id_type == Idp::Constants::DocumentTypes::PASSPORT

# Reject when user requested passport flow but submitted a different document type
return true if document_capture_session.passport_requested? &&
submitted_id_type != 'passport'
submitted_id_type != Idp::Constants::DocumentTypes::PASSPORT

# Reject when user didn't request passport flow but submitted a passport
return true if !document_capture_session.passport_requested? &&
submitted_id_type == 'passport'
submitted_id_type == Idp::Constants::DocumentTypes::PASSPORT

false
end
Expand All @@ -175,7 +175,8 @@ def submitted_id_type
end

def id_type_requested
document_capture_session.passport_requested? ? 'passport' : 'state_id'
document_capture_session.passport_requested? ? Idp::Constants::DocumentTypes::PASSPORT :
Idp::Constants::DocumentTypes::STATE_ID_CARD
end

def track_document_issuing_state(user, state)
Expand Down
3 changes: 2 additions & 1 deletion app/forms/idv/api_image_upload_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ def document_type
return nil if document_capture_session.nil?

@document_type ||= passport_requested? \
? 'Passport' : 'DriversLicense'
? DocAuth::LexisNexis::DocumentTypes::PASSPORT :
DocAuth::LexisNexis::DocumentTypes::DRIVERS_LICENSE
end

def validate_pii_from_doc(client_response)
Expand Down
6 changes: 3 additions & 3 deletions app/forms/idv/choose_id_type_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ def submit(params)
end

def chosen_id_type_valid?
return true if DocAuth::Response::ID_TYPE_SLUGS.value? @chosen_id_type
return true if Idp::Constants::DocumentTypes::SUPPORTED_ID_TYPES.include?(@chosen_id_type)
errors.add(
:chosen_id_type,
:invalid,
message: "
`choose_id_type` #{@chosen_id_type} is invalid,
expected one of #{DocAuth::Response::ID_TYPE_SLUGS.values}
`chosen_id_type` #{@chosen_id_type} is invalid,
expected one of #{Idp::Constants::DocumentTypes::SUPPORTED_ID_TYPES}
",
)
false
Expand Down
7 changes: 3 additions & 4 deletions app/forms/idv/doc_pii_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def submit

def self.pii_like_keypaths(document_type:)
keypaths = [[:pii]]
document_attrs = document_type&.downcase&.include?('passport') ?
document_attrs = document_type&.downcase&.include?(Idp::Constants::DocumentTypes::PASSPORT) ?
DocPiiPassport.pii_like_keypaths :
DocPiiStateId.pii_like_keypaths

Expand Down Expand Up @@ -76,7 +76,6 @@ def self.present_error(existing_errors)

PII_ERROR_KEYS = %i[name dob address1 state zipcode jurisdiction state_id_number
dob_min_age].freeze
STATE_ID_TYPES = ['drivers_license', 'state_id_card', 'identification_card'].freeze

attr_reader :pii_from_doc

Expand All @@ -103,10 +102,10 @@ def dob_valid?

def id_doc_type_valid?
case id_doc_type
when *STATE_ID_TYPES
when *Idp::Constants::DocumentTypes::STATE_ID_TYPES
state_id_validation = DocPiiStateId.new(pii: pii_from_doc)
state_id_validation.valid? || errors.merge!(state_id_validation.errors)
when 'passport', 'passport_card'
when *Idp::Constants::DocumentTypes::PASSPORT_TYPES
passport_validation = DocPiiPassport.new(pii: pii_from_doc)
passport_validation.valid? || errors.merge!(passport_validation.errors)
else
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/packages/document-capture/context/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const UploadContext = createContext({
statusPollInterval: undefined as number | undefined,
isMockClient: false,
flowPath: 'standard' as FlowPath,
idType: 'state_id',
idType: 'state_id_card',
formData: {} as Record<string, any>,
submitAttempts: 0,
});
Expand Down Expand Up @@ -175,7 +175,7 @@ interface UploadContextProviderProps {
flowPath: FlowPath;

/**
* The ID type, one of "state_id" or "passport".
* The ID type, one of "state_id_card" or "passport".
*/
idType: string;

Expand Down
2 changes: 1 addition & 1 deletion app/jobs/socure_docv_results_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def validate_mrz(doc_pii_response)

def document_type
@document_type ||= document_capture_session.passport_requested? \
? 'Passport' : 'DriversLicense'
? DocAuth::Socure::DocumentTypes::PASSPORT : DocAuth::Socure::DocumentTypes::DRIVERS_LICENSE
end

def user_uuid
Expand Down
4 changes: 2 additions & 2 deletions app/services/doc_auth/classification_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def doc_side_class_ok?(classification_info, doc_side)
!side_type.present? ||
(
IdentityConfig.store.doc_auth_passports_enabled ?
DocAuth::Response::ID_TYPE_SLUGS.key?(side_type) :
DocAuth::Response::STATE_ID_TYPE_SLUGS.key?(side_type)
DocAuth::DocumentClassifications::ALL_CLASSIFICATIONS.include?(side_type) :
DocAuth::DocumentClassifications::STATE_ID_CLASSIFICATIONS.include?(side_type)
) ||
side_type == 'Unknown'
end
Expand Down
21 changes: 21 additions & 0 deletions app/services/doc_auth/document_classifications.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module DocAuth::DocumentClassifications
PASSPORT = 'Passport'
IDENTIFICATION_CARD = 'Identification Card'
DRIVERS_LICENSE = 'Drivers License'

ALL_CLASSIFICATIONS = [PASSPORT, IDENTIFICATION_CARD, DRIVERS_LICENSE].freeze
STATE_ID_CLASSIFICATIONS = [IDENTIFICATION_CARD, DRIVERS_LICENSE].freeze

CLASSIFICATION_TO_DOCUMENT_TYPE = {
PASSPORT => Idp::Constants::DocumentTypes::PASSPORT,
DRIVERS_LICENSE => Idp::Constants::DocumentTypes::DRIVERS_LICENSE,
IDENTIFICATION_CARD => Idp::Constants::DocumentTypes::IDENTIFICATION_CARD,
}.freeze

STATE_ID_CLASSIFICATION_TO_DOCUMENT_TYPE = {
DRIVERS_LICENSE => Idp::Constants::DocumentTypes::DRIVERS_LICENSE,
IDENTIFICATION_CARD => Idp::Constants::DocumentTypes::IDENTIFICATION_CARD,
}.freeze
end
7 changes: 2 additions & 5 deletions app/services/doc_auth/error_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def handle(response_info)
end

class IdTypeErrorHandler < ErrorHandler
SUPPORTED_ID_CLASSNAME = ['Identification Card', 'Drivers License', 'Passport'].freeze
ACCEPTED_ISSUER_TYPES = [DocAuth::LexisNexis::IssuerTypes::STATE_OR_PROVINCE.name,
DocAuth::LexisNexis::IssuerTypes::COUNTRY.name,
DocAuth::LexisNexis::IssuerTypes::UNKNOWN.name].freeze
Expand All @@ -24,15 +23,15 @@ def get_id_type_errors(classification_info)
error_result = ErrorResult.new
both_side_ok = true
document_type = classification_info.with_indifferent_access.dig('Front', 'ClassName')
is_passport = document_type == 'Passport'
is_passport = document_type == DocAuth::DocumentClassifications::PASSPORT
sides = is_passport ? ['Front'] : ['Front', 'Back']
sides.each do |side|
side_class = classification_info.with_indifferent_access.dig(side, 'ClassName')
side_country = classification_info.with_indifferent_access.dig(side, 'CountryCode')
side_issuer_type = classification_info.with_indifferent_access.dig(side, 'IssuerType')

side_ok = !side_class.present? ||
SUPPORTED_ID_CLASSNAME.include?(side_class) ||
DocAuth::DocumentClassifications::ALL_CLASSIFICATIONS.include?(side_class) ||
side_class == 'Unknown'
country_ok = !side_country.present? || supported_country_codes.include?(side_country)
issuer_type_ok = !side_issuer_type.present? ||
Expand Down Expand Up @@ -294,8 +293,6 @@ class ErrorGenerator
'Visible Photo Characteristics': { type: FRONT, msg_key: Errors::VISIBLE_PHOTO_CHECK },
}.freeze

SUPPORTED_ID_CLASSNAME = ['Identification Card', 'Drivers License', 'Passport'].freeze

def initialize(config)
@config = config
end
Expand Down
8 changes: 4 additions & 4 deletions app/services/doc_auth/lexis_nexis/doc_pii_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def read_pii(true_id_product)
doc_issue_type: id_doc_issue_type,
)

if id_doc_type == 'drivers_license' || id_doc_type == 'state_id_card'
if Idp::Constants::DocumentTypes::SUPPORTED_STATE_ID_TYPES.include?(id_doc_type)
generate_state_id_pii
elsif id_doc_type == 'passport' || id_doc_type == 'passport_card'
elsif Idp::Constants::DocumentTypes::PASSPORT_TYPES.include?(id_doc_type)
generate_passport_pii
end
end
Expand Down Expand Up @@ -185,9 +185,9 @@ def generate_passport_pii

def determine_id_doc_type(doc_class_name:, doc_issue_type:)
val = if IdentityConfig.store.doc_auth_passports_enabled
DocAuth::Response::ID_TYPE_SLUGS[doc_class_name]
DocumentClassifications::CLASSIFICATION_TO_DOCUMENT_TYPE[doc_class_name]
else
DocAuth::Response::STATE_ID_TYPE_SLUGS[doc_class_name]
DocumentClassifications::STATE_ID_CLASSIFICATION_TO_DOCUMENT_TYPE[doc_class_name]
end

# If the DocIssueType is 'Passport Card',
Expand Down
6 changes: 6 additions & 0 deletions app/services/doc_auth/lexis_nexis/document_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module DocAuth::LexisNexis::DocumentTypes
PASSPORT = 'Passport'
DRIVERS_LICENSE = 'DriversLicense'
end
4 changes: 2 additions & 2 deletions app/services/doc_auth/lexis_nexis/requests/true_id_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def body
def id_front_image
# TrueID front_image required whether driver's license or passport
case document_type
when 'Passport'
when DocumentTypes::PASSPORT
passport_image
else
front_image
Expand Down Expand Up @@ -109,7 +109,7 @@ def acuant_sdk_source?
end

def back_image_required?
document_type == 'DriversLicense'
document_type == DocumentTypes::DRIVERS_LICENSE
end

def encode(image)
Expand Down
10 changes: 6 additions & 4 deletions app/services/doc_auth/lexis_nexis/responses/true_id_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,20 @@ def parsed_response_body
end

def id_doc_type_expected?
expected_id_type = passport_requested ? ['passport'] :
['drivers_license', 'state_id_card']
expected_id_types = passport_requested ?
Idp::Constants::DocumentTypes::SUPPORTED_PASSPORT_TYPES :
Idp::Constants::DocumentTypes::SUPPORTED_STATE_ID_TYPES

expected_id_type.include?(id_type)
expected_id_types.include?(id_type)
end

def id_type
pii_from_doc&.id_doc_type
end

def passport_pii?
@passport_pii ||= ['passport', 'passport_card'].include?(id_type)
@passport_pii ||=
Idp::Constants::DocumentTypes::PASSPORT_TYPES.include?(id_type)
end

def transaction_status
Expand Down
2 changes: 1 addition & 1 deletion app/services/doc_auth/mock/doc_auth_mock_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def post_images(
return mocked_response_for_method(__method__) if method_mocked?(__method__)

instance_id = SecureRandom.uuid
if document_type == 'Passport'
if document_type == DocAuth::LexisNexis::DocumentTypes::PASSPORT
passport_image_response = post_passport_image(
image: passport_image,
instance_id: instance_id,
Expand Down
11 changes: 0 additions & 11 deletions app/services/doc_auth/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ class Response
:selfie_live, :selfie_quality_good
attr_accessor :vendor_errors

ID_TYPE_SLUGS = {
'Identification Card' => 'state_id_card',
'Drivers License' => 'drivers_license',
'Passport' => 'passport',
}.freeze

STATE_ID_TYPE_SLUGS = {
'Identification Card' => 'state_id_card',
'Drivers License' => 'drivers_license',
}.freeze

def initialize(
success:,
errors: {},
Expand Down
6 changes: 6 additions & 0 deletions app/services/doc_auth/socure/document_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

module DocAuth::Socure::DocumentTypes
PASSPORT = 'Passport'
DRIVERS_LICENSE = 'DriversLicense'
end
5 changes: 4 additions & 1 deletion app/services/doc_auth/socure/requests/document_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class DocumentRequest < DocAuth::Socure::Request
attr_reader :customer_user_id, :redirect_url, :language,
:liveness_checking_required, :passport_requested

PASSPORT_DOCUMENT_TYPE = 'passport'
DRIVERS_LICENSE_DOCUMENT_TYPE = 'license'

def initialize(
customer_user_id:,
redirect_url:,
Expand Down Expand Up @@ -76,7 +79,7 @@ def use_case_key
end

def document_type
passport_requested ? 'passport' : 'license'
passport_requested ? PASSPORT_DOCUMENT_TYPE : DRIVERS_LICENSE_DOCUMENT_TYPE
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def error_messages
end

def read_pii
if id_doc_type == 'passport'
if id_doc_type == Idp::Constants::DocumentTypes::PASSPORT
return Pii::Passport.new(
first_name: get_data(DATA_PATHS[:first_name]),
middle_name: get_data(DATA_PATHS[:middle_name]),
Expand Down Expand Up @@ -235,14 +235,14 @@ def parse_date(date_string)

def id_type_supported?
if passports_enabled?
DocAuth::Response::ID_TYPE_SLUGS.key?(document_id_type)
DocAuth::DocumentClassifications::ALL_CLASSIFICATIONS.include?(document_id_type)
else
DocAuth::Response::STATE_ID_TYPE_SLUGS.key?(document_id_type)
DocAuth::DocumentClassifications::STATE_ID_CLASSIFICATIONS.include?(document_id_type)
end
end

def id_type_expected?
if id_doc_type == 'passport'
if id_doc_type == Idp::Constants::DocumentTypes::PASSPORT
passport_requested
else
!passport_requested
Expand Down
2 changes: 1 addition & 1 deletion app/services/proofing/resolution/progressive_proofer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def process_state_id(
end

def passport_applicant?(applicant_pii)
applicant_pii[:id_doc_type] == 'passport'
applicant_pii[:id_doc_type] == Idp::Constants::DocumentTypes::PASSPORT
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions lib/idp/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ module Vendors
SOURCE_CHECK = [AAMVA, AAMVA_UNSUPPORTED_JURISDICTION, STATE_ID_MOCK].freeze
end

module DocumentTypes
PASSPORT = 'passport'
PASSPORT_CARD = 'passport_card'
DRIVERS_LICENSE = 'drivers_license'
STATE_ID_CARD = 'state_id_card'
IDENTIFICATION_CARD = 'identification_card'

SUPPORTED_PASSPORT_TYPES = [PASSPORT].freeze
SUPPORTED_STATE_ID_TYPES = [DRIVERS_LICENSE, STATE_ID_CARD].freeze
SUPPORTED_ID_TYPES = [*SUPPORTED_PASSPORT_TYPES, *SUPPORTED_STATE_ID_TYPES].freeze
PASSPORT_TYPES = [PASSPORT, PASSPORT_CARD].freeze
STATE_ID_TYPES = [DRIVERS_LICENSE, STATE_ID_CARD, IDENTIFICATION_CARD].freeze
end

# US State and Territory codes are
# taken from the FIPS standard, which
# can be found at:
Expand Down
Loading