diff --git a/package-lock.json b/package-lock.json index 305b267..304ceb7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2751,8 +2751,8 @@ } }, "@unumid/id-verification-types": { - "version": "git+ssh://git@github.com/UnumID/id-verification-types.git#372f3ad606476690828035c8cd88434ab2498be6", - "from": "git+ssh://git@github.com/UnumID/id-verification-types.git#v1.0.0", + "version": "git+ssh://git@github.com/UnumID/id-verification-types.git#df2d9e495fbb450ec5213f1dd627caeec39e0802", + "from": "git+ssh://git@github.com/UnumID/id-verification-types.git#v1.0.1", "dev": true }, "@unumid/types": { diff --git a/package.json b/package.json index 5be5355..9ae13a5 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "@types/validator": "^13.1.3", "@typescript-eslint/eslint-plugin": "^4.15.2", "@typescript-eslint/parser": "^4.15.2", - "@unumid/id-verification-types": "git+ssh://git@github.com/UnumID/id-verification-types#v1.0.0", + "@unumid/id-verification-types": "git+ssh://git@github.com/UnumID/id-verification-types#v1.0.1", "eslint": "^7.20.0", "eslint-config-semistandard": "^16.0.0", "eslint-config-standard": "^16.0.3", diff --git a/src/components/Register.tsx b/src/components/Register.tsx index e202226..4252461 100644 --- a/src/components/Register.tsx +++ b/src/components/Register.tsx @@ -18,37 +18,9 @@ import { v1 } from 'uuid'; import { backendClient } from '../feathers'; import { config } from '../config'; import { useSearchParams } from 'react-router-dom'; -import { HvDocScanData } from '../types'; - -import { KYCData as _KYCData, HvClientResponse } from '@unumid/id-verification-types'; - -// export interface HVDetails { -// dateOfBirth: string; -// firstName: string; -// fullName: string; -// // eslint-disable-next-line camelcase -// id_back_imagePath: string; -// idNumber: string; -// lastName: string; -// middleName: string; -// } - -// export interface HvResult { -// status: string; -// transactionId: string; -// details: HVDetails; -// } - -// interface KYCData extends Omit<_KYCData, 'docImage' | 'fullFaceImage'> { -// docImage?: string; -// fullFaceImage?: string; -// } - -// interface HvDocScanResult { -// status: string; -// } - -// types for global variables added by the hyperverge sdk + +import { KYCData as _KYCData, HvClientResponse, HyperVergeResponse } from '@unumid/id-verification-types'; + declare global { interface Window { HyperKycConfig?: any; @@ -75,51 +47,6 @@ const makeHvHandler = (callback: (data: HvClientResponse) => void) => (HyperKycR break; } - // const hvDocScanData: HvDocScanData = HyperKycResult.Success.data; - // const docCountryId = hvDocScanData.selectedCountryId; - - // const faceMatchData = hvDocScanData.faceMatchData.responseResult.result.details.match; - // const faceMatch = faceMatchData.value; - // const faceMatchConfidence = faceMatchData.confidence; - - // const faceData = hvDocScanData.faceData; - // // const fullFaceImage = faceData.fullFaceImagePath; - // const liveFace = faceData.responseResult.result.details.liveFace.value; - // const liveFaceConfidence = faceData.responseResult.result.details.liveFace.confidence; - - // const docData = hvDocScanData.docListData[0]; - // // const docImage = docData.docImagePath; - // const docType = docData.documentId; - // const { address, dateOfBirth, fullName, gender } = docData.responseResult.result.details[0].fieldsExtracted; - // debugger; - // /** - // * Reformat the DOB from the HV document scan. - // * dateOfBirthday was taking the format MM-DD-YYYY from HV, but as of 6/23 was updated to dD-mM-YYYY. - // * and Prove needs it in the format YYYY-MM-DD, so just turning it in that here - // */ - // const proveDob = dateOfBirth.value.split('-'); - - // // loop through the split data array and ensure all values have at least 2 digits - // for (let i = 0; i < proveDob.length; i++) { - // if (proveDob[i].length < 2) { - // proveDob[i] = '0' + proveDob[i]; - // } - // } - - // // shift values to fit desired format; this was working when HV was returning in format MM-DD-YYYY - // // const hold = proveDob[2]; - // // proveDob[2] = proveDob[1]; - // // proveDob[1] = proveDob[0]; - // // proveDob[0] = hold; - - // // shift values to fit desired format; having to deal with new format of DD-MM-YYYY - // const hold = proveDob[2]; - // proveDob[2] = proveDob[0]; - // proveDob[0] = hold; - - // // now should be in YYYY-MM-DD format - // const dob = proveDob.join('-'); - debugger; // eslint-disable-next-line node/no-callback-literal callback( @@ -223,14 +150,14 @@ const Register: FC = () => { * calls the hvService to persist the data on a user entity for credential issuance later. * the service creates a user and returns the userCode for linking to the prove prefill data */ - const sendHvDocScanData = async (data: HvClientResponse): Promise => { + const sendHvDocScanData = async (data: HvClientResponse): Promise => { // TODO add auth with backend const hvService = backendClient.service('hyperVerge'); const response = await hvService.create(data); // TODO ensure success response - return response.userCode; + return response; }; /** @@ -262,30 +189,18 @@ const Register: FC = () => { const responseAuth = await hyperVergeAuthService.create({}); const accessToken = responseAuth.result.token; - // hyperverge document scan setup - // const defaultDocumentId = 'dl'; - // const defaultCountryId = 'usa'; - - // setting to undefined to force selection by the user - const defaultDocumentId = undefined; - const defaultCountryId = undefined; - const transactionId = `${v1()}`; - const documentHv = new window.Document(true, defaultCountryId, defaultDocumentId); - const face = new window.Face(); - // const workflow = [documentHv, face]; - // const workflowId = 'global_workflow'; - const workflowId = 'USA_DL_Workflow'; + const workflowId = 'global_workflow'; + // const workflowId = 'USA_DL_Workflow'; const hyperKycConfig = new window.HyperKycConfig(accessToken, workflowId, transactionId); - // const hyperKycConfig = new window.HyperKycConfig(accessToken, workflow, transactionId, defaultCountryId); const callback = async (data: HvClientResponse) => { - const userCode = await sendHvDocScanData(data); + const { userCode, dob } = await sendHvDocScanData(data); debugger; if (config.proveEnabled) { // kick off Prove InstantLink sms - // sendProveSms(userCode, data.dob); + sendProveSms(userCode, dob); } else { // redirect to the deeplink router with the userCode and issuer did redirectToDeeplinkRouter(userCode, config.hvIssuerDid);