diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 29eb622..31b7ac9 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -50,13 +50,13 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: npm ci - name: Run linter over tests - run: | - npm install prettier - npx prettier -c test/**/*.ts + run: npx prettier -c test/**/*.ts - name: Run integration tests with NPM if: ${{ matrix.node-version == '18.x' && github.repository_owner == 'onfido' && - (github.event_name == 'pull_request' || github.event_name == 'release') }} + (github.event_name == 'pull_request' || + github.event_name == 'release' || + github.event_name == 'workflow_dispatch') }} run: npm test -- -i env: ONFIDO_API_TOKEN: ${{ secrets.ONFIDO_API_TOKEN }} diff --git a/package-lock.json b/package-lock.json index e50ae52..5fefc5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@types/node": "12.11.5 - 12.20.42", "dotenv": "^16.4.5", "jest": "^26.6.3", - "prettier": "^1.18.2", + "prettier": "^3.6.2", "ts-jest": "^26.4.4", "typescript": "^4.0 || ^5.0" } @@ -4569,16 +4569,18 @@ } }, "node_modules/prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz", + "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", "dev": true, - "license": "MIT", "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=4" + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" } }, "node_modules/pretty-format": { diff --git a/package.json b/package.json index 4731c06..0b13d9f 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@faker-js/faker": "^8.4.1", "@types/jest": "^26.0.15", "jest": "^26.6.3", - "prettier": "^1.18.2", + "prettier": "^3.6.2", "ts-jest": "^26.4.4", "dotenv": "^16.4.5", "@types/node": "12.11.5 - 12.20.42", diff --git a/test/classic-webhook-event-verifier.test.ts b/test/classic-webhook-event-verifier.test.ts index 0277291..d42c86c 100644 --- a/test/classic-webhook-event-verifier.test.ts +++ b/test/classic-webhook-event-verifier.test.ts @@ -3,7 +3,7 @@ import { WebhookEventVerifier, WebhookEventType, WebhookEventResourceType, - WebhookEventObjectStatus + WebhookEventObjectStatus, } from "onfido-node"; const webhookToken = "_ABC123abc123ABC123abc123ABC123_"; @@ -19,9 +19,9 @@ const expectedEvent = { id: "check-123", href: "https://api.onfido.com/v3/checks/check-123", status: WebhookEventObjectStatus.Complete, - completed_at_iso8601: "2020-01-01T00:00:00Z" - } - } + completed_at_iso8601: "2020-01-01T00:00:00Z", + }, + }, }; it("returns the event if the signature is valid", () => { @@ -41,7 +41,7 @@ it("allows passing the body as a buffer", () => { expect(event).toEqual(expectedEvent); expect(event.payload.object.href).toEqual( - "https://api.onfido.com/v3/checks/check-123" + "https://api.onfido.com/v3/checks/check-123", ); // Test alternative way to access fields (it also works for additional properties) @@ -53,6 +53,6 @@ it("throws an error if the signature is invalid", () => { "b0082d7481f9f0a2907583dbe1f344d6d4c0d9989df2fd804f98479f60cd760e"; expect(() => verifier.readPayload(rawEvent, signature)).toThrow( - OnfidoInvalidSignatureError + OnfidoInvalidSignatureError, ); }); diff --git a/test/onfido.test.ts b/test/onfido.test.ts index 0a4d25e..cf41b6e 100644 --- a/test/onfido.test.ts +++ b/test/onfido.test.ts @@ -2,7 +2,7 @@ import { Configuration, DefaultApi, Region } from "onfido-node"; it("sets the authorization header from the given token", () => { expect(new Configuration({ apiToken: "api_token" }).apiKey).toBe( - "Token token=api_token" + "Token token=api_token", ); }); @@ -10,44 +10,44 @@ it("contains a user agent header", () => { expect( new Configuration({ apiToken: "api_token" }).baseOptions.headers[ "User-Agent" - ] + ], ).toMatch(/^onfido-node\/\d+\.\d+\.\d+$/); }); it("allows setting the EU region", () => { expect( - new Configuration({ apiToken: "token", region: Region.EU }).basePath + new Configuration({ apiToken: "token", region: Region.EU }).basePath, ).toBe("https://api.eu.onfido.com/v3.6"); }); it("allows setting the US region", () => { expect( - new Configuration({ apiToken: "token", region: Region.US }).basePath + new Configuration({ apiToken: "token", region: Region.US }).basePath, ).toBe("https://api.us.onfido.com/v3.6"); }); it("allows setting the CA region", () => { expect( - new Configuration({ apiToken: "token", region: Region.CA }).basePath + new Configuration({ apiToken: "token", region: Region.CA }).basePath, ).toBe("https://api.ca.onfido.com/v3.6"); }); it("use EU region if region was not provided", () => { expect(new Configuration({ apiToken: "token" }).basePath).toBe( - "https://api.eu.onfido.com/v3.6" + "https://api.eu.onfido.com/v3.6", ); }); it("throws an error for unknown regions", () => { expect( - () => new Configuration({ apiToken: "token", region: "abc" as any }) + () => new Configuration({ apiToken: "token", region: "abc" as any }), ).toThrow("Unknown or missing region 'abc'"); }); it("throws an error if no api token is provided", () => { expect(() => new Configuration()).toThrow("No apiToken provided"); expect(() => new Configuration({ apiToken: "" })).toThrow( - "No apiToken provided" + "No apiToken provided", ); }); @@ -56,8 +56,8 @@ it("allows changing the default timeout", () => { apiToken: "token", region: Region.EU, baseOptions: { - timeout: 123 - } + timeout: 123, + }, }); expect(onfido.baseOptions.timeout).toBe(123); diff --git a/test/resource.test.ts b/test/resource.test.ts index 6332d6e..8921845 100644 --- a/test/resource.test.ts +++ b/test/resource.test.ts @@ -4,8 +4,8 @@ import { AxiosError } from "axios"; const onfido_bad_token = new DefaultApi( new Configuration({ - apiToken: "bad-token" // Use an invalid token - }) + apiToken: "bad-token", // Use an invalid token + }), ); describe("error handling", () => { @@ -16,12 +16,12 @@ describe("error handling", () => { last_name: "Applicant", address: { postcode: "AB12 3AB", - country: "GBR" + country: "GBR", }, location: { ip_address: "127.0.0.1", - country_of_residence: "GBR" - } + country_of_residence: "GBR", + }, }); fail(); // We should never be here } catch (error) { diff --git a/test/resources/addresses.test.ts b/test/resources/addresses.test.ts index 3e58bbb..ea1077b 100644 --- a/test/resources/addresses.test.ts +++ b/test/resources/addresses.test.ts @@ -10,18 +10,18 @@ const exampleAddress: Address = { building_name: "", street: "RAWSON CLOSE", sub_street: "", - town: "SHEFFIELD" + town: "SHEFFIELD", }; const exampleAddress2 = { ...exampleAddress, - building_number: "18" + building_number: "18", }; it("allows picking addresses", async () => { const addresses = await onfido.findAddresses("S2 2DF"); expect(addresses.data.addresses).toEqual( - expect.arrayContaining([exampleAddress, exampleAddress2]) + expect.arrayContaining([exampleAddress, exampleAddress2]), ); }); diff --git a/test/resources/advanced-electronic-signature.test.ts b/test/resources/advanced-electronic-signature.test.ts index c3c84da..61dfa23 100644 --- a/test/resources/advanced-electronic-signature.test.ts +++ b/test/resources/advanced-electronic-signature.test.ts @@ -4,7 +4,7 @@ import { createApplicant, repeatRequestUntilTaskOutputChanges, createWorkflowRunWithCustomInputs, - onfido + onfido, } from "../test-helpers"; import { WorkflowRunBuilder } from "onfido-node"; @@ -22,13 +22,12 @@ it("downloads a signed document file", async () => { custom_data: { doc_result: "clear", face_result: "clear", - transaction_id: "995bf84c-d708-4977-8b88-d4b66bebdaf6" - } + transaction_id: "995bf84c-d708-4977-8b88-d4b66bebdaf6", + }, }; - const workflowRun = await createWorkflowRunWithCustomInputs( - workflowRunBuilder - ); + const workflowRun = + await createWorkflowRunWithCustomInputs(workflowRunBuilder); const taskId = (await onfido.listTasks(workflowRun.data.id)).data[1].id; const output = ( @@ -36,7 +35,7 @@ it("downloads a signed document file", async () => { "findTask", [workflowRun.data.id, taskId], 10, - 3000 + 3000, ) )["output"]; @@ -46,11 +45,11 @@ it("downloads a signed document file", async () => { const signedDocument = await onfido.downloadAesDocument( workflowRun.data.id, - signedDocumentFileId + signedDocumentFileId, ); const receiptDocument = await onfido.downloadAesDocument( workflowRun.data.id, - receiptDocumentFileId + receiptDocumentFileId, ); expect(signedDocument.status).toEqual(200); diff --git a/test/resources/applicants.test.ts b/test/resources/applicants.test.ts index 53e6f1e..e6354b6 100644 --- a/test/resources/applicants.test.ts +++ b/test/resources/applicants.test.ts @@ -5,14 +5,14 @@ import { getExpectedObject, createApplicant, cleanUpApplicants, - sortByApplicantfirst_name + sortByApplicantfirst_name, } from "../test-helpers"; import { exampleApplicant } from "../test-examples"; import { AxiosError, isAxiosError } from "axios"; function getExpectedApplicant(exampleApplicant: Applicant) { return getExpectedObject(exampleApplicant, { - sandbox: true + sandbox: true, }); } @@ -38,7 +38,7 @@ it("finds an applicant", async () => { const lookupApplicant = await onfido.findApplicant(applicant.id); expect(lookupApplicant.data).toMatchObject( - getExpectedApplicant(exampleApplicant) + getExpectedApplicant(exampleApplicant), ); }); @@ -46,11 +46,11 @@ it("updates an applicant", async () => { const modifiedApplicant = { ...exampleApplicant, first_name: "Test2" }; const updatedApplicant = await onfido.updateApplicant(applicant.id, { - first_name: "Test2" + first_name: "Test2", }); expect(updatedApplicant.data).toMatchObject( - getExpectedApplicant(modifiedApplicant) + getExpectedApplicant(modifiedApplicant), ); }); @@ -58,30 +58,30 @@ it("lists an applicant's consents", async () => { const consents = [ { name: ApplicantConsentName.PrivacyNoticesRead, - granted: true + granted: true, }, { name: ApplicantConsentName.SsnVerification, - granted: true + granted: true, }, { name: ApplicantConsentName.PhoneNumberVerification, - granted: true - } + granted: true, + }, ]; const applicant = await createApplicant({ first_name: "Sir Consents", - consents: consents + consents: consents, }); const consentsList = await onfido.findApplicantConsents(applicant.data.id); // sorting to ensure the order is consistent const actualConsentsSorted = consentsList.data.sort((a, b) => - a.name.localeCompare(b.name) + a.name.localeCompare(b.name), ); const expectedConsentsSorted = consents.sort((a, b) => - a.name.localeCompare(b.name) + a.name.localeCompare(b.name), ); expectedConsentsSorted.forEach((expected, index) => { @@ -108,9 +108,9 @@ it("lists applicants", async () => { consents: [ { name: ApplicantConsentName.PrivacyNoticesRead, - granted: true - } - ] + granted: true, + }, + ], }); const applicants = await onfido.listApplicants(1, 20, false); @@ -118,8 +118,8 @@ it("lists applicants", async () => { expect(applicants.data.applicants.sort(sortByApplicantfirst_name)).toEqual( expect.arrayContaining([ getExpectedApplicant(anotherApplicant), - getExpectedApplicant(exampleApplicant) - ]) + getExpectedApplicant(exampleApplicant), + ]), ); }); @@ -134,7 +134,7 @@ it("finds a non existent applicant", async () => { const error_details = error.response?.data.error; expect(isAxiosError(error)).toBe(true); expect(error_details.message).toBe( - "Could not find the following resource: Applicant with id=invalid-applicant-id" + "Could not find the following resource: Applicant with id=invalid-applicant-id", ); expect(error_details.type).toBe("resource_not_found"); } diff --git a/test/resources/autofill.test.ts b/test/resources/autofill.test.ts index ffba1b2..673e398 100644 --- a/test/resources/autofill.test.ts +++ b/test/resources/autofill.test.ts @@ -5,14 +5,14 @@ import { getExpectedObject, createApplicant, cleanUpApplicants, - uploadDocument + uploadDocument, } from "../test-helpers"; const exampleAutofillE2e = { document_id: "21345-xxx", document_classification: { issuing_country: "GBR", - document_type: "driving_licence" + document_type: "driving_licence", }, extracted_data: { date_of_birth: "1976-03-11", @@ -20,8 +20,8 @@ const exampleAutofillE2e = { document_number: "200407512345", first_name: "SARAH", gender: "Female", - last_name: "MORGAN" - } + last_name: "MORGAN", + }, }; let applicant: Applicant; @@ -40,6 +40,6 @@ it("performs autofill", async () => { const result = await onfido.extract({ document_id: document.id }); expect(result.data).toEqual( - getExpectedObject(exampleAutofillE2e, { document_id: document.id }) + getExpectedObject(exampleAutofillE2e, { document_id: document.id }), ); }); diff --git a/test/resources/checks.test.ts b/test/resources/checks.test.ts index 2b366e2..4bd6830 100644 --- a/test/resources/checks.test.ts +++ b/test/resources/checks.test.ts @@ -8,7 +8,7 @@ import { uploadDocument, createWebhook, createCheck, - cleanUpWebhooks + cleanUpWebhooks, } from "../test-helpers"; import { exampleCheck } from "../test-examples"; @@ -16,12 +16,12 @@ function getExpectedCheck(exampleCheck: Check, overrideProperties = {}) { return getExpectedObject(exampleCheck, { applicant_id: expect.stringMatching(/^[0-9a-z-]+$/), results_uri: expect.stringMatching( - /^https\:\/\/dashboard\.onfido\.com\/checks\/[0-9a-z-]+$/ + /^https\:\/\/dashboard\.onfido\.com\/checks\/[0-9a-z-]+$/, ), privacy_notices_read_consent_given: null, report_ids: [ expect.stringMatching(/^[0-9a-z-]+$/), - expect.stringMatching(/^[0-9a-z-]+$/) + expect.stringMatching(/^[0-9a-z-]+$/), ], webhook_ids: expect.arrayContaining([webhook1.id, webhook2.id]), result: expect.anything(), @@ -29,7 +29,7 @@ function getExpectedCheck(exampleCheck: Check, overrideProperties = {}) { version: "3.6", sandbox: true, paused: false, - ...overrideProperties + ...overrideProperties, }); } @@ -55,7 +55,7 @@ afterAll(() => { it("creates a check", async () => { const check = await createCheck(applicant, document, { webhook_ids: [webhook1.id, webhook2.id], - privacy_notices_read_consent_given: true + privacy_notices_read_consent_given: true, }); expect(check.data).toEqual( @@ -63,44 +63,44 @@ it("creates a check", async () => { applicant_id: applicant.id, result: null, status: CheckStatus.InProgress, - privacy_notices_read_consent_given: true - }) + privacy_notices_read_consent_given: true, + }), ); }); it("creates a check for generating a rejected sub-result for document report in the sandbox", async () => { const check = await createCheck(applicant, document, { webhook_ids: [webhook1.id, webhook2.id], - sub_result: "rejected" + sub_result: "rejected", }); expect(check.data).toEqual( getExpectedCheck(exampleCheck, { applicant_id: applicant.id, result: null, - status: CheckStatus.InProgress - }) + status: CheckStatus.InProgress, + }), ); }); it("creates a check for generating a consider result for a report in the sandbox", async () => { const check = await createCheck(applicant, document, { webhook_ids: [webhook1.id, webhook2.id], - consider: ["identity_enhanced"] + consider: ["identity_enhanced"], }); expect(check.data).toEqual( getExpectedCheck(exampleCheck, { applicant_id: applicant.id, result: null, - status: CheckStatus.InProgress - }) + status: CheckStatus.InProgress, + }), ); }); it("finds a check", async () => { const check = await createCheck(applicant, document, { - webhook_ids: [webhook1.id, webhook2.id] + webhook_ids: [webhook1.id, webhook2.id], }); const lookupCheck = (await onfido.findCheck(check.data.id)).data; @@ -110,17 +110,17 @@ it("finds a check", async () => { getExpectedCheck(exampleCheck, { applicant_id: applicant.id, status: lookupCheck.status, - result: lookupCheck.result - }) + result: lookupCheck.result, + }), ); }); it("lists checks", async () => { await createCheck(applicant, document, { - webhook_ids: [webhook1.id, webhook2.id] + webhook_ids: [webhook1.id, webhook2.id], }); await createCheck(applicant, document, { - webhook_ids: [webhook1.id, webhook2.id] + webhook_ids: [webhook1.id, webhook2.id], }); const checks = (await onfido.listChecks(applicant.id)).data.checks; @@ -129,18 +129,18 @@ it("lists checks", async () => { expect(checks).toEqual([ getExpectedCheck(exampleCheck, { status: checks[0].status, - result: checks[0].result + result: checks[0].result, }), getExpectedCheck(exampleCheck, { status: checks[1].status, - result: checks[1].result - }) + result: checks[1].result, + }), ]); }); it("resumes a check", async () => { const check = await createCheck(applicant, document, { - webhook_ids: [webhook1.id, webhook2.id] + webhook_ids: [webhook1.id, webhook2.id], }); expect((await onfido.resumeCheck(check.data.id)).status).toEqual(204); @@ -148,7 +148,7 @@ it("resumes a check", async () => { it("downloads a check", async () => { const check = await createCheck(applicant, document, { - webhook_ids: [webhook1.id, webhook2.id] + webhook_ids: [webhook1.id, webhook2.id], }); const file = await onfido.downloadCheck(check.data.id); diff --git a/test/resources/documents.test.ts b/test/resources/documents.test.ts index 4c51d30..c788fe8 100644 --- a/test/resources/documents.test.ts +++ b/test/resources/documents.test.ts @@ -6,19 +6,19 @@ import { createApplicant, cleanUpApplicants, uploadDocument, - sortByDocumentType + sortByDocumentType, } from "../test-helpers"; import { exampleDocument } from "../test-examples"; import { AxiosError } from "axios"; function getExpectedDocument( exampleDocument: Document, - overrideProperties = {} + overrideProperties = {}, ) { return getExpectedObject(exampleDocument, { applicant_id: applicant.id, download_href: expect.stringMatching(/^\/.+/), - ...overrideProperties + ...overrideProperties, }); } @@ -43,7 +43,7 @@ it("uploads a document", async () => { it("uploads a document with location", async () => { document = ( await uploadDocument(applicant, DocumentTypes.DrivingLicence, { - country_of_residence: "FRA" + country_of_residence: "FRA", }) ).data; }); @@ -74,12 +74,12 @@ it("lists documents", async () => { expect(documents).toEqual([ getExpectedDocument(exampleDocument, { id: document.id, - type: "driving_licence" + type: "driving_licence", }), getExpectedDocument(exampleDocument, { id: anotherDocument.id, - type: "passport" - }) + type: "passport", + }), ]); }); @@ -89,7 +89,7 @@ it("downloads an NFC face", async () => { applicant, DocumentTypes.Passport, {}, - "test/media/nfc_data.json" + "test/media/nfc_data.json", ) ).data; diff --git a/test/resources/id-photos.test.ts b/test/resources/id-photos.test.ts index e6937f0..cc37517 100644 --- a/test/resources/id-photos.test.ts +++ b/test/resources/id-photos.test.ts @@ -5,7 +5,7 @@ import { getExpectedObject, createApplicant, cleanUpApplicants, - uploadIdPhoto + uploadIdPhoto, } from "../test-helpers"; const exampleIdPhoto: IdPhoto = { @@ -15,15 +15,15 @@ const exampleIdPhoto: IdPhoto = { download_href: "/v3.6/live_photos/123-abc/download", file_name: "7e255271-9662-42c7-a997-ab27b645ad15.png", file_type: "image/png", - file_size: 395_856 + file_size: 395_856, }; function getExpectedIdPhoto(uploadedIdPhoto: IdPhoto) { return getExpectedObject(uploadedIdPhoto, { download_href: expect.stringMatching( - /^\/v3.6\/id_photos\/[0-9a-z-]+\/download$/ + /^\/v3.6\/id_photos\/[0-9a-z-]+\/download$/, ), - file_name: expect.stringMatching(/^[0-9a-f-]+\.png$/) + file_name: expect.stringMatching(/^[0-9a-f-]+\.png$/), }); } @@ -69,6 +69,6 @@ it("lists id photos", async () => { expect(idPhotos.data.id_photos).toEqual([ getExpectedIdPhoto(exampleIdPhoto), - getExpectedIdPhoto(exampleIdPhoto) + getExpectedIdPhoto(exampleIdPhoto), ]); }); diff --git a/test/resources/live-photos.test.ts b/test/resources/live-photos.test.ts index bd172f5..0abd076 100644 --- a/test/resources/live-photos.test.ts +++ b/test/resources/live-photos.test.ts @@ -5,7 +5,7 @@ import { getExpectedObject, createApplicant, cleanUpApplicants, - uploadLivePhoto + uploadLivePhoto, } from "../test-helpers"; const exampleLivePhoto: LivePhoto = { @@ -15,14 +15,14 @@ const exampleLivePhoto: LivePhoto = { download_href: "/v3.6/live_photos/123-abc/download", file_name: "sample_photo.png", file_type: "image/png", - file_size: 395_856 + file_size: 395_856, }; function getExpectedLivePhoto(exampleLivePhoto: LivePhoto) { return getExpectedObject(exampleLivePhoto, { download_href: expect.stringMatching( - /^\/v3.6\/live_photos\/[0-9a-z-]+\/download$/ - ) + /^\/v3.6\/live_photos\/[0-9a-z-]+\/download$/, + ), }); } @@ -74,6 +74,6 @@ it("lists live photos", async () => { expect(livePhotos.data.live_photos).toEqual([ getExpectedLivePhoto(exampleLivePhoto), - getExpectedLivePhoto(exampleLivePhoto) + getExpectedLivePhoto(exampleLivePhoto), ]); }); diff --git a/test/resources/live-videos.test.ts b/test/resources/live-videos.test.ts index 3844ebf..2fda965 100644 --- a/test/resources/live-videos.test.ts +++ b/test/resources/live-videos.test.ts @@ -4,7 +4,7 @@ import { onfido, getExpectedObject, sampleapplicant_id, - sortByLiveVideoId + sortByLiveVideoId, } from "../test-helpers"; const sampleLiveVideoId1 = @@ -19,21 +19,21 @@ const exampleLiveVideo: LiveVideo = { download_href: "https://api.onfido.com/v3.6/live_videos/123-abc/download", file_name: "video.mov", file_type: "video/quicktime", - file_size: 165_093 + file_size: 165_093, }; function getExpectedLiveVideo( exampleLivePhoto: LiveVideo, liveVideoId: string, - challenge: any | Array = null + challenge: any | Array = null, ) { return getExpectedObject(exampleLivePhoto, { id: liveVideoId, languages: null, challenge: challenge, download_href: expect.stringMatching( - /^\/v3.6\/live_videos\/[0-9a-z-]+\/download$/ - ) + /^\/v3.6\/live_videos\/[0-9a-z-]+\/download$/, + ), }); } @@ -61,8 +61,8 @@ it("finds a live video", async () => { getExpectedLiveVideo( exampleLiveVideo, sampleLiveVideoId1, - expect.anything() - ) + expect.anything(), + ), ); }); @@ -72,6 +72,6 @@ it("lists live videos", async () => { expect(liveVideos.sort(sortByLiveVideoId)).toEqual([ getExpectedLiveVideo(exampleLiveVideo, sampleLiveVideoId1), - getExpectedLiveVideo(exampleLiveVideo, sampleLiveVideoId2) + getExpectedLiveVideo(exampleLiveVideo, sampleLiveVideoId2), ]); }); diff --git a/test/resources/motion-captures.test.ts b/test/resources/motion-captures.test.ts index fe2dcc6..d5de1ca 100644 --- a/test/resources/motion-captures.test.ts +++ b/test/resources/motion-captures.test.ts @@ -4,7 +4,7 @@ import { getExpectedObject, onfido, sampleapplicant_id, - sortByMotionCaptureId + sortByMotionCaptureId, } from "../test-helpers"; const sampleId1 = process.env.ONFIDO_SAMPLE_MOTION_ID_1; @@ -17,19 +17,19 @@ const exampleMotionCapture: MotionCapture = { download_href: "https://api.onfido.com/v3.6/motion_captures/id/download", file_name: "id.mp4", file_type: "video/mp4", - file_size: 2_720_276 + file_size: 2_720_276, }; function getExpectedMotionCapture( example: MotionCapture, - exampleId: string + exampleId: string, ): MotionCapture { return getExpectedObject(example, { id: exampleId, file_name: exampleId + ".mp4", download_href: expect.stringMatching( - /^\/v3\.6\/motion_captures\/[0-9a-z-]+\/download$/ - ) + /^\/v3\.6\/motion_captures\/[0-9a-z-]+\/download$/, + ), }); } @@ -54,7 +54,7 @@ it("finds a motion capture", async () => { const motionCapture = (await onfido.findMotionCapture(sampleId1)).data; expect(motionCapture).toEqual( - getExpectedMotionCapture(exampleMotionCapture, sampleId1) + getExpectedMotionCapture(exampleMotionCapture, sampleId1), ); }); @@ -64,6 +64,6 @@ it("lists motion captures", async () => { expect(motionCaptures.sort(sortByMotionCaptureId)).toEqual([ getExpectedMotionCapture(exampleMotionCapture, sampleId2), - getExpectedMotionCapture(exampleMotionCapture, sampleId1) + getExpectedMotionCapture(exampleMotionCapture, sampleId1), ]); }); diff --git a/test/resources/qualified-electronic-signature.test.ts b/test/resources/qualified-electronic-signature.test.ts index 6c3f1c4..c468a42 100644 --- a/test/resources/qualified-electronic-signature.test.ts +++ b/test/resources/qualified-electronic-signature.test.ts @@ -5,7 +5,7 @@ import { repeatRequestUntilTaskOutputChanges, createWorkflowRunWithCustomInputs, onfido, - sleep + sleep, } from "../test-helpers"; import { WorkflowRunBuilder } from "onfido-node"; @@ -35,13 +35,12 @@ it("downloads a signed document file", async () => { document_number: "Example string", document_to_sign_url: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", - document_type: "driving_licence" - } + document_type: "driving_licence", + }, }; - const workflowRun = await createWorkflowRunWithCustomInputs( - workflowRunBuilder - ); + const workflowRun = + await createWorkflowRunWithCustomInputs(workflowRunBuilder); const taskId = (await onfido.listTasks(workflowRun.data.id)).data[1].id; const output = ( @@ -49,7 +48,7 @@ it("downloads a signed document file", async () => { "findTask", [workflowRun.data.id, taskId], 10, - 3000 + 3000, ) )["output"]; diff --git a/test/resources/report-schemas.test.ts b/test/resources/report-schemas.test.ts index 56e934a..75db9f0 100644 --- a/test/resources/report-schemas.test.ts +++ b/test/resources/report-schemas.test.ts @@ -9,11 +9,11 @@ import { FacialSimilarityPhotoReport, Report, ReportConfigurationFacialSimilarityUseCaseEnum, - ReportName + ReportName, } from "onfido-node"; import { exampleDocumentReport, - exampleFacialSimilarityPhotoReport + exampleFacialSimilarityPhotoReport, } from "../test-examples"; import { cleanUpApplicants, @@ -23,7 +23,7 @@ import { getExpectedFacialSimilarityPhotoReport, repeatRequestUntilStatusChanges, uploadDocument, - uploadLivePhoto + uploadLivePhoto, } from "../test-helpers"; let applicant: Applicant; @@ -42,14 +42,14 @@ it("schema of document report should be valid", async () => { const check: Check = ( await createCheck(applicant, document, { webhook_ids: [], - report_names: ["document"] + report_names: ["document"], }) ).data; const report: Report = await repeatRequestUntilStatusChanges( "findReport", [check.report_ids[0]], - "complete" + "complete", ); expect(report).toEqual(getExpectedDocumentReport(exampleDocumentReport)); @@ -58,7 +58,7 @@ it("schema of document report should be valid", async () => { const document_report = report as DocumentReport; expect( - document_report.breakdown.data_comparison.breakdown.issuing_country.result + document_report.breakdown.data_comparison.breakdown.issuing_country.result, ).toEqual("clear"); expect(document_report.properties.date_of_birth).toEqual("1990-01-01"); expect(document_report.properties.document_subtype).toBeUndefined(); @@ -73,26 +73,26 @@ it("schema of facial similarity photo report should be valid", async () => { report_configuration: { facial_similarity_photo_fully_auto: { use_case: - ReportConfigurationFacialSimilarityUseCaseEnum.Reverification - } - } + ReportConfigurationFacialSimilarityUseCaseEnum.Reverification, + }, + }, }) ).data; const report: Report = await repeatRequestUntilStatusChanges( "findReport", [check.report_ids[0]], - "complete" + "complete", ); expect(report).toEqual( getExpectedFacialSimilarityPhotoReport(exampleFacialSimilarityPhotoReport, { live_photos: [ { - id: (report as FacialSimilarityPhotoReport).live_photos[0].id - } - ] - }) + id: (report as FacialSimilarityPhotoReport).live_photos[0].id, + }, + ], + }), ); }, 30000); @@ -100,26 +100,26 @@ it("schema of document with address information report should be valid", async ( await uploadLivePhoto(applicant); const check: Check = ( await createCheck(applicant, document, { - report_names: [ReportName.DocumentWithAddressInformation] + report_names: [ReportName.DocumentWithAddressInformation], }) ).data; const report: Report = await repeatRequestUntilStatusChanges( "findReport", [check.report_ids[0]], - "complete" + "complete", ); const document_report = report as DocumentWithAddressInformationReport; expect(document_report).toEqual( getExpectedDocumentReport(exampleDocumentReport, { - name: "document_with_address_information" - }) + name: "document_with_address_information", + }), ); expect(document_report.properties.barcode[0].document_type).toEqual( - "driving_licence" + "driving_licence", ); }, 30000); @@ -127,20 +127,20 @@ it("schema of document with driving license information report should be valid", await uploadLivePhoto(applicant); const check: Check = ( await createCheck(applicant, document, { - report_names: [ReportName.DocumentWithDrivingLicenceInformation] + report_names: [ReportName.DocumentWithDrivingLicenceInformation], }) ).data; const report: Report = await repeatRequestUntilStatusChanges( "findReport", [check.report_ids[0]], - "complete" + "complete", ); const document_report = report as DocumentWithDrivingLicenceInformationReport; expect(document_report.name).toEqual( - "document_with_driving_licence_information" + "document_with_driving_licence_information", ); expect(document_report.properties.driving_licence_information).not.toBeNull(); }, 30000); @@ -149,14 +149,14 @@ it("schema of device intelligence report should be valid", async () => { await uploadLivePhoto(applicant); const check: Check = ( await createCheck(applicant, document, { - report_names: [ReportName.DeviceIntelligence] + report_names: [ReportName.DeviceIntelligence], }) ).data; const report: Report = await repeatRequestUntilStatusChanges( "findReport", [check.report_ids[0]], - "complete" + "complete", ); const device_intelligence = report as DeviceIntelligenceReport; diff --git a/test/resources/reports.test.ts b/test/resources/reports.test.ts index c6c5a2e..10ed803 100644 --- a/test/resources/reports.test.ts +++ b/test/resources/reports.test.ts @@ -7,7 +7,7 @@ import { uploadDocument, createCheck, sortByReportName, - repeatRequestUntilStatusChanges + repeatRequestUntilStatusChanges, } from "../test-helpers"; function getExpectedReport(exampleReport: Report, overrideProperties = {}) { @@ -17,7 +17,7 @@ function getExpectedReport(exampleReport: Report, overrideProperties = {}) { breakdown: expect.anything(), properties: expect.anything(), status: expect.anything(), - ...overrideProperties + ...overrideProperties, }); } @@ -40,14 +40,14 @@ const exampleReport: Report = { result: "clear", sub_result: "clear", documents: [{ id: "document-id" }], - check_id: "aa111111-1111-1111-1111-111111111111" + check_id: "aa111111-1111-1111-1111-111111111111", }; it("finds a report", async () => { const report: Report = await repeatRequestUntilStatusChanges( "findReport", [check.report_ids[1]], - "complete" + "complete", ); expect(report).toEqual(getExpectedReport(exampleReport)); @@ -55,7 +55,7 @@ it("finds a report", async () => { it("lists reports", async () => { const reports = (await onfido.listReports(check.id)).data.reports.sort( - sortByReportName + sortByReportName, ); // Providing actual result and sub_result as parameter as they might change overtime @@ -63,17 +63,17 @@ it("lists reports", async () => { getExpectedReport(exampleReport, { name: "document", result: reports[0].result, - sub_result: reports[0].sub_result + sub_result: reports[0].sub_result, }), getExpectedReport(exampleReport, { name: "identity_enhanced", result: reports[1].result, - sub_result: reports[1].sub_result - }) + sub_result: reports[1].sub_result, + }), ]); - expect(reports.find(report => report.name === "document").name).toEqual( - "document" + expect(reports.find((report) => report.name === "document").name).toEqual( + "document", ); }); diff --git a/test/resources/sdk-tokens.test.ts b/test/resources/sdk-tokens.test.ts index 327765f..596da32 100644 --- a/test/resources/sdk-tokens.test.ts +++ b/test/resources/sdk-tokens.test.ts @@ -15,10 +15,10 @@ afterAll(() => { it("generates an sdk token", async () => { const sdkToken = await onfido.generateSdkToken({ applicant_id: applicant.id, - referrer: "https://*.example.com/*" + referrer: "https://*.example.com/*", }); expect(sdkToken.data.token).toEqual( - expect.stringMatching(/^[0-9a-zA-Z\._-]+$/) + expect.stringMatching(/^[0-9a-zA-Z\._-]+$/), ); }); diff --git a/test/resources/signing-documents.test.ts b/test/resources/signing-documents.test.ts index 17bf9c1..8b7fbcd 100644 --- a/test/resources/signing-documents.test.ts +++ b/test/resources/signing-documents.test.ts @@ -5,7 +5,7 @@ import { onfido, createApplicant, cleanUpApplicants, - uploadSigningDocument + uploadSigningDocument, } from "../test-helpers"; const nonExistingId = "00000000-0000-0000-0000-000000000000"; @@ -51,16 +51,15 @@ it("finds a signing document", async () => { }); it("lists signing documents", async () => { - const documents = ( - await onfido.listSigningDocuments(applicant.id) - ).data.signing_documents; + const documents = (await onfido.listSigningDocuments(applicant.id)).data + .signing_documents; - expect(documents.some(doc => doc.id === signingDocument.id)).toBeTruthy(); + expect(documents.some((doc) => doc.id === signingDocument.id)).toBeTruthy(); }); it("throws an error when uploading a signing document with null params", async () => { await expect( - onfido.uploadSigningDocument(undefined as any, undefined as any) + onfido.uploadSigningDocument(undefined as any, undefined as any), ).rejects.toThrow(/Required parameter applicantId/); }); diff --git a/test/resources/tasks.test.ts b/test/resources/tasks.test.ts index ca46976..5508f7c 100644 --- a/test/resources/tasks.test.ts +++ b/test/resources/tasks.test.ts @@ -9,7 +9,7 @@ import { completeTask, createWorkflowRun, getExpectedObject, - onfido + onfido, } from "../test-helpers"; function getExpectedTask(exampleTask: Task, overrideProperties = {}) { @@ -19,7 +19,7 @@ function getExpectedTask(exampleTask: Task, overrideProperties = {}) { workflow_run_id: expect.stringMatching(/^[0-9a-z-]+$/), created_at: expect.anything(), updated_at: expect.anything(), - ...overrideProperties + ...overrideProperties, }); } @@ -41,7 +41,7 @@ it("lists tasks", async () => { expect(tasks.data).toEqual([ getExpectedTask(exampleTask), - getExpectedTask(exampleTask) + getExpectedTask(exampleTask), ]); }); @@ -53,21 +53,21 @@ it("finds a task", async () => { expect(task.data).toEqual( getExpectedTask(exampleTask, { input: expect.anything(), - output: expect.anything() - }) + output: expect.anything(), + }), ); }); it("completes a task", async () => { const taskId = (await onfido.listTasks(workflowRunId)).data.filter( - task => task.id !== "start" + (task) => task.id !== "start", )[0].id; const completedTask = await completeTask(workflowRunId, taskId, { data: { first_name: faker.person.firstName(), - last_name: faker.person.lastName() - } + last_name: faker.person.lastName(), + }, }); expect(completedTask.status).toEqual(200); expect(completedTask.data).toEqual({}); diff --git a/test/resources/watchlist-monitor.test.ts b/test/resources/watchlist-monitor.test.ts index 334d10e..e268cfd 100644 --- a/test/resources/watchlist-monitor.test.ts +++ b/test/resources/watchlist-monitor.test.ts @@ -2,7 +2,7 @@ import { Applicant, WatchlistMonitor, WatchlistMonitorMatch, - WatchlistMonitorReportNameEnum + WatchlistMonitorReportNameEnum, } from "onfido-node"; import { exampleWatchlistMonitor } from "../test-examples"; @@ -12,12 +12,12 @@ import { createApplicant, createWatchlistMonitor, getExpectedObject, - onfido + onfido, } from "../test-helpers"; function getExpectedWatchlistMonitor( exampleWatchlistMonitor: WatchlistMonitor, - overrideProperties = {} + overrideProperties = {}, ) { return getExpectedObject(exampleWatchlistMonitor, { applicant_id: expect.stringMatching(/^[0-9a-z-]+$/), @@ -27,7 +27,7 @@ function getExpectedWatchlistMonitor( tags: expect.anything(), is_sandbox: expect.anything(), created_at: expect.anything(), - ...overrideProperties + ...overrideProperties, }); } @@ -45,17 +45,17 @@ it("creates a watchlist standard monitor", async () => { const watchlistMonitor: WatchlistMonitor = ( await createWatchlistMonitor( applicant, - WatchlistMonitorReportNameEnum.Standard + WatchlistMonitorReportNameEnum.Standard, ) ).data; expect(watchlistMonitor).toEqual( - getExpectedWatchlistMonitor(exampleWatchlistMonitor) + getExpectedWatchlistMonitor(exampleWatchlistMonitor), ); expect(watchlistMonitor.applicant_id).toEqual(applicant.id); expect(watchlistMonitor.report_name).toEqual( - WatchlistMonitorReportNameEnum.Standard + WatchlistMonitorReportNameEnum.Standard, ); }); @@ -65,12 +65,12 @@ it("creates a watchlist AML monitor", async () => { ).data; expect(watchlistMonitor).toEqual( - getExpectedWatchlistMonitor(exampleWatchlistMonitor) + getExpectedWatchlistMonitor(exampleWatchlistMonitor), ); expect(watchlistMonitor.applicant_id).toEqual(applicant.id); expect(watchlistMonitor.report_name).toEqual( - WatchlistMonitorReportNameEnum.Aml + WatchlistMonitorReportNameEnum.Aml, ); }); @@ -78,7 +78,7 @@ it("finds a watchlist monitor", async () => { const watchlistMonitor: WatchlistMonitor = ( await createWatchlistMonitor( applicant, - WatchlistMonitorReportNameEnum.Standard + WatchlistMonitorReportNameEnum.Standard, ) ).data; @@ -87,7 +87,7 @@ it("finds a watchlist monitor", async () => { ).data; expect(lookupWatchlistMonitor).toEqual( - getExpectedWatchlistMonitor(exampleWatchlistMonitor) + getExpectedWatchlistMonitor(exampleWatchlistMonitor), ); expect(lookupWatchlistMonitor.id).toEqual(watchlistMonitor.id); }); @@ -95,7 +95,7 @@ it("finds a watchlist monitor", async () => { it("lists watchlist monitors", async () => { await createWatchlistMonitor( applicant, - WatchlistMonitorReportNameEnum.Standard + WatchlistMonitorReportNameEnum.Standard, ); const watchlistMonitorsList: WatchlistMonitor[] = ( @@ -104,8 +104,8 @@ it("lists watchlist monitors", async () => { expect(watchlistMonitorsList).toEqual( expect.arrayContaining([ - getExpectedWatchlistMonitor(exampleWatchlistMonitor) - ]) + getExpectedWatchlistMonitor(exampleWatchlistMonitor), + ]), ); }); @@ -113,12 +113,12 @@ it("deletes a watchlist monitor", async () => { const watchlistMonitor: WatchlistMonitor = ( await createWatchlistMonitor( applicant, - WatchlistMonitorReportNameEnum.Standard + WatchlistMonitorReportNameEnum.Standard, ) ).data; const deleteResponse = await onfido.deleteWatchlistMonitor( - watchlistMonitor.id + watchlistMonitor.id, ); expect(deleteResponse.status).toEqual(204); }); @@ -127,7 +127,7 @@ it("lists watchlist monitor matches", async () => { const watchlistMonitor: WatchlistMonitor = ( await createWatchlistMonitor( applicant, - WatchlistMonitorReportNameEnum.Standard + WatchlistMonitorReportNameEnum.Standard, ) ).data; @@ -142,12 +142,12 @@ it("forces report creation", async () => { const watchlistMonitor: WatchlistMonitor = ( await createWatchlistMonitor( applicant, - WatchlistMonitorReportNameEnum.Standard + WatchlistMonitorReportNameEnum.Standard, ) ).data; const response = await onfido.forceReportCreationFromWatchlistMonitor( - watchlistMonitor.id + watchlistMonitor.id, ); expect(response.status).toEqual(201); diff --git a/test/resources/webhooks.test.ts b/test/resources/webhooks.test.ts index 7abdb81..978a627 100644 --- a/test/resources/webhooks.test.ts +++ b/test/resources/webhooks.test.ts @@ -4,13 +4,13 @@ import { onfido, getExpectedObject, cleanUpWebhooks, - createWebhook + createWebhook, } from "../test-helpers"; import { exampleWebhook } from "../test-examples"; function getExpectedWebhook(exampleWebhook: Webhook) { return getExpectedObject(exampleWebhook, { - token: expect.stringMatching(/^[0-9a-zA-Z_-]+$/) + token: expect.stringMatching(/^[0-9a-zA-Z_-]+$/), }); } @@ -38,11 +38,11 @@ it("updates a webhook", async () => { var patchedWebhook = { ...exampleWebhook, enabled: false }; const updatedWebhook = await onfido.updateWebhook(webhook.id, { - enabled: false + enabled: false, }); expect(updatedWebhook.data).toEqual( - getExpectedWebhook({ ...exampleWebhook, enabled: false }) + getExpectedWebhook({ ...exampleWebhook, enabled: false }), ); }); @@ -59,7 +59,7 @@ it("lists webhooks", async () => { expect(webhooks.data.webhooks).toEqual( expect.arrayContaining([ getExpectedWebhook(exampleWebhook), - getExpectedWebhook(exampleWebhook) - ]) + getExpectedWebhook(exampleWebhook), + ]), ); }); diff --git a/test/resources/workflow-runs-outputs.test.ts b/test/resources/workflow-runs-outputs.test.ts index 1c9959e..14375f8 100644 --- a/test/resources/workflow-runs-outputs.test.ts +++ b/test/resources/workflow-runs-outputs.test.ts @@ -5,7 +5,7 @@ import { exampleWorkflowRun, exampleWorkflowRunOutputDocumentReport, exampleWorkflowRunOutputFacialSimilarityReport, - exampleWorkflowRunOutputProfileDataCapture + exampleWorkflowRunOutputProfileDataCapture, } from "../test-examples"; import { cleanUpApplicants, @@ -16,12 +16,12 @@ import { onfido, repeatRequestUntilStatusChanges, uploadDocument, - uploadLivePhoto + uploadLivePhoto, } from "../test-helpers"; function getExpectedWorkflowRun( exampleWorkflowRun: WorkflowRun, - overrideProperties = {} + overrideProperties = {}, ) { return getExpectedObject(exampleWorkflowRun, { applicant_id: expect.stringMatching(/^[0-9a-z-]+$/), @@ -38,13 +38,13 @@ function getExpectedWorkflowRun( link: expect.anything(), created_at: expect.anything(), updated_at: expect.anything(), - ...overrideProperties + ...overrideProperties, }); } function getExpectedWorkflowRunOutput( exampleWorkflowRunOutput: object, - expectedObject = {} + expectedObject = {}, ) { return getExpectedObject(exampleWorkflowRunOutput, expectedObject); } @@ -66,7 +66,7 @@ describe("workflow runs outputs", () => { .id; const taskId = (await onfido.listTasks(workflowRunId)).data.filter( - task => task.id !== "start" + (task) => task.id !== "start", )[0].id; const taskData = { @@ -74,10 +74,7 @@ describe("workflow runs outputs", () => { first_name: faker.person.firstName(), last_name: faker.person.lastName(), // birthdate().toISOString() yields 1977-07-10T01:37:30.719Z format, discard the time - dob: faker.date - .birthdate() - .toISOString() - .split("T")[0], + dob: faker.date.birthdate().toISOString().split("T")[0], email: faker.internet.email(), phone_number: faker.helpers.fromRegExp(/[\+]3519[1236][0-9]{7}/), nationality: faker.location.countryCode("alpha-3"), @@ -88,18 +85,18 @@ describe("workflow runs outputs", () => { line2: faker.location.street(), line3: faker.location.street(), town: faker.location.city(), - postcode: faker.location.zipCode() - } + postcode: faker.location.zipCode(), + }, }; await completeTask(workflowRunId, taskId, { - data: taskData + data: taskData, }); const workflowRun = await onfido.findWorkflowRun(workflowRunId); expect(workflowRun.data).toEqual( - getExpectedWorkflowRun(exampleWorkflowRun) + getExpectedWorkflowRun(exampleWorkflowRun), ); // workflow run has configured as output the result of the @@ -112,7 +109,7 @@ describe("workflow runs outputs", () => { line2: expect.stringMatching(/^[0-9A-Za-z\s'-]+$/), line3: expect.stringMatching(/^[0-9A-Za-z\s'-]+$/), postcode: expect.stringMatching(/^[0-9A-Za-z\s-]+$/), - town: expect.stringMatching(/^[A-Za-z\s\.-]+$/) + town: expect.stringMatching(/^[A-Za-z\s\.-]+$/), }, country_residence: expect.stringMatching(/^[A-Z]{3}$/), dob: expect.stringMatching(/^[0-9-]+$/), @@ -121,8 +118,8 @@ describe("workflow runs outputs", () => { last_name: expect.stringMatching(/^[A-Za-z\s-]+$/), nationality: expect.stringMatching(/^[A-Z]{3}$/), phone_number: expect.stringMatching(/^\+[0-9]+$/), - phone_number_consent_granted: expect.anything() - }) + phone_number_consent_granted: expect.anything(), + }), ); }); @@ -133,37 +130,37 @@ describe("workflow runs outputs", () => { const profileDataCaptureTaskId = ( await onfido.listTasks(workflowRunId) - ).data.filter(task => task.id.includes("profile"))[0].id; + ).data.filter((task) => task.id.includes("profile"))[0].id; await completeTask(workflowRunId, profileDataCaptureTaskId, { data: { first_name: faker.person.firstName(), - last_name: faker.person.lastName() - } + last_name: faker.person.lastName(), + }, }); const documentCaptureTaskId = ( await onfido.listTasks(workflowRunId) - ).data.filter(task => task.id.includes("document_photo"))[0].id; + ).data.filter((task) => task.id.includes("document_photo"))[0].id; const documentId = (await uploadDocument(applicant)).data.id; await completeTask(workflowRunId, documentCaptureTaskId, { - data: [{ id: documentId }] + data: [{ id: documentId }], }); const photoCaptureTaskId = ( await onfido.listTasks(workflowRunId) - ).data.filter(task => task.id.includes("face_photo"))[0].id; + ).data.filter((task) => task.id.includes("face_photo"))[0].id; const photoId = (await uploadLivePhoto(applicant)).data.id; await completeTask(workflowRunId, photoCaptureTaskId, { - data: [{ id: photoId }] + data: [{ id: photoId }], }); const workflowRun = await repeatRequestUntilStatusChanges( "findWorkflowRun", [workflowRunId], - "approved" + "approved", ); expect(workflowRun).toEqual(getExpectedWorkflowRun(exampleWorkflowRun)); @@ -177,8 +174,8 @@ describe("workflow runs outputs", () => { status: expect.stringMatching(/^[a-z]+$/), result: expect.stringMatching(/^[a-z]+$/), sub_result: expect.stringMatching(/^[a-z]+$/), - uuid: expect.stringMatching(/^[0-9A-Za-z-]+$/) - }) + uuid: expect.stringMatching(/^[0-9A-Za-z-]+$/), + }), ); expect(workflowRun.output["selfie"]).toEqual( @@ -190,9 +187,9 @@ describe("workflow runs outputs", () => { status: expect.stringMatching(/^[a-z]+$/), result: expect.stringMatching(/^[a-z]+$/), sub_result: null, - uuid: expect.stringMatching(/^[0-9A-Za-z-]+$/) - } - ) + uuid: expect.stringMatching(/^[0-9A-Za-z-]+$/), + }, + ), ); }, 30000); }); diff --git a/test/resources/workflow-runs.test.ts b/test/resources/workflow-runs.test.ts index 3352704..f4cbe31 100644 --- a/test/resources/workflow-runs.test.ts +++ b/test/resources/workflow-runs.test.ts @@ -2,7 +2,7 @@ import { Applicant, TimelineFileReference, WorkflowRun, - WorkflowRunBuilder + WorkflowRunBuilder, } from "onfido-node"; import { exampleWorkflowRun } from "../test-examples"; @@ -15,12 +15,12 @@ import { getExpectedObject, onfido, repeatRequestUntilHttpCodeChanges, - repeatRequestUntilStatusChanges + repeatRequestUntilStatusChanges, } from "../test-helpers"; function getExpectedWorkflowRun( exampleWorkflowRun: WorkflowRun, - overrideProperties = {} + overrideProperties = {}, ) { return getExpectedObject(exampleWorkflowRun, { applicant_id: expect.stringMatching(/^[0-9a-z-]+$/), @@ -37,7 +37,7 @@ function getExpectedWorkflowRun( link: expect.anything(), created_at: expect.anything(), updated_at: expect.anything(), - ...overrideProperties + ...overrideProperties, }); } @@ -64,15 +64,14 @@ it("creates a workflow run with custom inputs", async () => { const workflowRunBuilder: WorkflowRunBuilder = { applicant_id: applicant.id, workflow_id: workflow_id_with_custom_inputs, - custom_data: { age: 18, is_employed: false } + custom_data: { age: 18, is_employed: false }, }; - const workflowRunWithCustomInputs = await createWorkflowRunWithCustomInputs( - workflowRunBuilder - ); + const workflowRunWithCustomInputs = + await createWorkflowRunWithCustomInputs(workflowRunBuilder); expect(workflowRunWithCustomInputs.data).toEqual( - getExpectedWorkflowRun(exampleWorkflowRun) + getExpectedWorkflowRun(exampleWorkflowRun), ); }); @@ -83,7 +82,7 @@ it("finds a workflow run", async () => { // Providing actual status and result as parameter since they might have changed overtime expect(lookupworkflowRun.data).toEqual( - getExpectedWorkflowRun(exampleWorkflowRun) + getExpectedWorkflowRun(exampleWorkflowRun), ); }); @@ -96,8 +95,8 @@ it("lists workflow runs", async () => { expect(workflowRuns.data).toEqual( expect.arrayContaining([ getExpectedWorkflowRun(exampleWorkflowRun), - getExpectedWorkflowRun(exampleWorkflowRun) - ]) + getExpectedWorkflowRun(exampleWorkflowRun), + ]), ); }); @@ -118,7 +117,7 @@ it("generates a timeline file", async () => { await repeatRequestUntilStatusChanges( "findWorkflowRun", [workflowRunId], - "approved" + "approved", ); const timelineFileData: TimelineFileReference = ( @@ -135,7 +134,7 @@ it("downloads a timeline file", async () => { await repeatRequestUntilStatusChanges( "findWorkflowRun", [workflowRunId], - "approved" + "approved", ); const timelineFileId = (await onfido.createTimelineFile(workflowRunId)).data @@ -143,7 +142,7 @@ it("downloads a timeline file", async () => { const file = await repeatRequestUntilHttpCodeChanges("findTimelineFile", [ workflowRunId, - timelineFileId + timelineFileId, ]); expect(file.status).toEqual(200); @@ -158,12 +157,12 @@ it("downloads an evidence folder", async () => { await repeatRequestUntilStatusChanges( "findWorkflowRun", [workflowRunId], - "approved" + "approved", ); const file = await repeatRequestUntilHttpCodeChanges( "downloadEvidenceFolder", - [workflowRunId] + [workflowRunId], ); expect(file.status).toEqual(200); diff --git a/test/studio-webhook-event-verifier.test.ts b/test/studio-webhook-event-verifier.test.ts index 8a15a15..60ddf6d 100644 --- a/test/studio-webhook-event-verifier.test.ts +++ b/test/studio-webhook-event-verifier.test.ts @@ -5,7 +5,7 @@ import { WebhookEventVerifier, WebhookEventType, WebhookEventResourceType, - WebhookEventObjectStatus + WebhookEventObjectStatus, } from "onfido-node"; const webhookToken = "YKOC6mkBxi6yK2zlUIrLMvsJMFEZObP5"; @@ -19,13 +19,12 @@ const expectedEvent = { resource_type: WebhookEventResourceType.WorkflowTask, object: { id: "profile_1eb92", - href: - "https://api.eu.onfido.com/v3.6/workflow_runs/bc77c6e5-753a-4580-96a6-aaed3e5a8d19/tasks/profile_1eb92", + href: "https://api.eu.onfido.com/v3.6/workflow_runs/bc77c6e5-753a-4580-96a6-aaed3e5a8d19/tasks/profile_1eb92", status: WebhookEventObjectStatus.Started, started_at_iso8601: "2024-07-10T12:49:09Z", task_def_id: "profile_data", task_spec_id: "profile_1eb92", - workflow_run_id: "bc77c6e5-753a-4580-96a6-aaed3e5a8d19" + workflow_run_id: "bc77c6e5-753a-4580-96a6-aaed3e5a8d19", }, resource: { created_at: "2024-07-10T12:49:09Z", @@ -35,9 +34,9 @@ const expectedEvent = { task_def_id: "profile_data", task_def_version: null, updated_at: "2024-07-10T12:49:09Z", - workflow_run_id: "bc77c6e5-753a-4580-96a6-aaed3e5a8d19" - } - } + workflow_run_id: "bc77c6e5-753a-4580-96a6-aaed3e5a8d19", + }, + }, }; it("returns the event if the signature is valid", () => { @@ -57,7 +56,7 @@ it("allows passing the body as a buffer", () => { expect(event).toEqual(expectedEvent); expect(event.payload.object.href).toEqual( - "https://api.eu.onfido.com/v3.6/workflow_runs/bc77c6e5-753a-4580-96a6-aaed3e5a8d19/tasks/profile_1eb92" + "https://api.eu.onfido.com/v3.6/workflow_runs/bc77c6e5-753a-4580-96a6-aaed3e5a8d19/tasks/profile_1eb92", ); // Test alternative way to access fields (it also works for additional properties) @@ -69,7 +68,7 @@ it("throws an error if the signature is invalid", () => { "c95a5b785484f6fa1bc25f381b5595d66bf85cb442eefb06aa007802ee6a4dfb"; expect(() => verifier.readPayload(rawEvent, signature)).toThrow( - OnfidoInvalidSignatureError + OnfidoInvalidSignatureError, ); }); @@ -79,7 +78,7 @@ it("allows deconding a webhook studio payload with object in output", () => { const rawEventFromFile = readFileSync( "test/media/studio_webhook_event_with_object_in_output.json", - "utf8" + "utf8", ); const event = verifier.readPayload(Buffer.from(rawEventFromFile), signature); @@ -91,13 +90,13 @@ it("allows deconding a webhook studio payload with object in output", () => { document_numbers: [ { type: "document_number", - value: "999999999" - } + value: "999999999", + }, ], document_type: "passport", first_name: "Jane", issuing_country: "GBR", - last_name: "Doe" + last_name: "Doe", }); }); @@ -107,7 +106,7 @@ it("allows deconding a webhook studio payload with list in output", () => { const rawEventFromFile = readFileSync( "test/media/studio_webhook_event_with_list_in_output.json", - "utf8" + "utf8", ); const event = verifier.readPayload(Buffer.from(rawEventFromFile), signature); @@ -116,7 +115,7 @@ it("allows deconding a webhook studio payload with list in output", () => { { checksum_sha256: "hiwV2PLmeQZzeySPGGwVL48sxVXcyfpXy9LDl1u3lWU=", id: "7af75a3a-ba34-4aa5-9e3e-096c9f56256b", - type: "document_photo" - } + type: "document_photo", + }, ]); }); diff --git a/test/test-examples.ts b/test/test-examples.ts index 19a44f5..822cc48 100644 --- a/test/test-examples.ts +++ b/test/test-examples.ts @@ -7,7 +7,7 @@ import { Task, WatchlistMonitor, Webhook, - WorkflowRun + WorkflowRun, } from "onfido-node"; export const exampleApplicant: Applicant = { @@ -32,13 +32,13 @@ export const exampleApplicant: Applicant = { state: null, line1: null, line2: null, - line3: null + line3: null, }, phone_number: "351911111111", location: { ip_address: "127.0.0.1", - country_of_residence: "GBR" - } + country_of_residence: "GBR", + }, }; export const exampleCheck: Check = { @@ -56,7 +56,7 @@ export const exampleCheck: Check = { redirect_uri: null, results_uri: "https://dashboard.onfido.com/checks/123-abc", // privacy_notices_read_consent_given: true, - webhook_ids: ["webhook-123"] + webhook_ids: ["webhook-123"], }; export const exampleDocument: Document = { @@ -70,7 +70,7 @@ export const exampleDocument: Document = { file_size: 361_771, type: "driving_licence", side: null, - issuing_country: null + issuing_country: null, }; export const exampleWebhook: Webhook = { @@ -86,7 +86,7 @@ export const exampleWebhook: Webhook = { oauth_server_url: null, oauth_server_client_id: null, oauth_server_client_secret: null, - oauth_server_scope: null + oauth_server_scope: null, }; export const exampleWorkflowRun: WorkflowRun = { @@ -102,7 +102,7 @@ export const exampleWorkflowRun: WorkflowRun = { link: null, created_at: "2022-06-28T15:39:42Z", updated_at: "2022-06-28T15:39:42Z", - tags: [] + tags: [], }; export const exampleWorkflowRunOutputProfileDataCapture: object = { @@ -112,7 +112,7 @@ export const exampleWorkflowRunOutputProfileDataCapture: object = { line2: "Reichel Mall", line3: "Sherwood Drives", postcode: "38074", - town: "Keeblerview" + town: "Keeblerview", }, country_residence: "TTO", dob: "1976-08-31", @@ -121,7 +121,7 @@ export const exampleWorkflowRunOutputProfileDataCapture: object = { last_name: "Kihn", nationality: "SWZ", phone_number: "+351930983797", - phone_number_consent_granted: true + phone_number_consent_granted: true, }; export const exampleWorkflowRunOutputDocumentReport: object = { @@ -130,202 +130,202 @@ export const exampleWorkflowRunOutputDocumentReport: object = { breakdown: { minimum_accepted_age: { properties: {}, - result: "clear" - } + result: "clear", + }, }, - result: "clear" + result: "clear", }, compromised_document: { breakdown: { document_database: { properties: {}, - result: "clear" + result: "clear", }, repeat_attempts: { properties: {}, - result: "clear" - } + result: "clear", + }, }, - result: "clear" + result: "clear", }, data_comparison: { breakdown: { date_of_birth: { properties: {}, - result: "clear" + result: "clear", }, date_of_expiry: { properties: {}, - result: "clear" + result: "clear", }, document_numbers: { properties: {}, - result: "clear" + result: "clear", }, document_type: { properties: {}, - result: "clear" + result: "clear", }, first_name: { properties: {}, - result: "clear" + result: "clear", }, gender: { properties: {}, - result: "clear" + result: "clear", }, issuing_country: { properties: {}, - result: "clear" + result: "clear", }, last_name: { properties: {}, - result: "clear" - } + result: "clear", + }, }, - result: "clear" + result: "clear", }, data_consistency: { breakdown: { date_of_birth: { properties: {}, - result: "clear" + result: "clear", }, date_of_expiry: { properties: {}, - result: "clear" + result: "clear", }, document_numbers: { properties: {}, - result: "clear" + result: "clear", }, document_type: { properties: {}, - result: "clear" + result: "clear", }, first_name: { properties: {}, - result: "clear" + result: "clear", }, gender: { properties: {}, - result: "clear" + result: "clear", }, issuing_country: { properties: {}, - result: "clear" + result: "clear", }, last_name: { properties: {}, - result: "clear" + result: "clear", }, multiple_data_sources_present: { properties: {}, - result: "clear" + result: "clear", }, nationality: { properties: {}, - result: "clear" - } + result: "clear", + }, }, - result: "clear" + result: "clear", }, data_validation: { breakdown: { date_of_birth: { properties: {}, - result: "clear" + result: "clear", }, document_expiration: { properties: {}, - result: "clear" + result: "clear", }, document_numbers: { properties: {}, - result: "clear" + result: "clear", }, expiry_date: { properties: {}, - result: "clear" + result: "clear", }, gender: { properties: {}, - result: "clear" + result: "clear", }, mrz: { properties: {}, - result: "clear" - } + result: "clear", + }, }, - result: "clear" + result: "clear", }, image_integrity: { breakdown: { colour_picture: { properties: {}, - result: "clear" + result: "clear", }, conclusive_document_quality: { properties: {}, - result: "clear" + result: "clear", }, image_quality: { properties: {}, - result: "clear" + result: "clear", }, supported_document: { properties: {}, - result: "clear" - } + result: "clear", + }, }, - result: "clear" + result: "clear", }, police_record: { breakdown: { "document_has_not_been_recorded_as_lost,_stolen_or_compromised": { properties: {}, - result: "clear" - } + result: "clear", + }, }, - result: "clear" + result: "clear", }, visual_authenticity: { breakdown: { digital_tampering: { properties: {}, - result: "clear" + result: "clear", }, face_detection: { properties: {}, - result: "clear" + result: "clear", }, fonts: { properties: {}, - result: "clear" + result: "clear", }, original_document_present: { properties: {}, - result: "clear" + result: "clear", }, other: { properties: {}, - result: "clear" + result: "clear", }, picture_face_integrity: { properties: {}, - result: "clear" + result: "clear", }, security_features: { properties: {}, - result: "clear" + result: "clear", }, template: { properties: {}, - result: "clear" - } + result: "clear", + }, }, - result: "clear" - } + result: "clear", + }, }, properties: { date_of_birth: "1990-01-01", @@ -334,25 +334,25 @@ export const exampleWorkflowRunOutputDocumentReport: object = { document_numbers: [ { type: "document_number", - value: "999999999" - } + value: "999999999", + }, ], document_type: "passport", first_name: "Broderick", issuing_country: "GBR", - last_name: "Altenwerth" + last_name: "Altenwerth", }, repeat_attempts: { attempts_clear_rate: 0, attempts_count: 1, repeat_attempts: [], report_id: "00000000-0000-0000-0000-000000000000", - unique_mismatches_count: 0 + unique_mismatches_count: 0, }, result: "clear", status: "complete", sub_result: "clear", - uuid: "9d2d7ca9-73c6-4dc8-9185-7bcc62f8a1c5" + uuid: "9d2d7ca9-73c6-4dc8-9185-7bcc62f8a1c5", }; export const exampleWorkflowRunOutputFacialSimilarityReport: object = { @@ -362,50 +362,50 @@ export const exampleWorkflowRunOutputFacialSimilarityReport: object = { face_match: { properties: { document_id: "0925205f-1af3-4874-8d14-f2d2a81fb75d", - score: 0.6512 + score: 0.6512, }, - result: "clear" - } + result: "clear", + }, }, - result: "clear" + result: "clear", }, image_integrity: { breakdown: { face_detected: { properties: {}, - result: "clear" + result: "clear", }, source_integrity: { properties: {}, - result: "clear" - } + result: "clear", + }, }, - result: "clear" + result: "clear", }, visual_authenticity: { breakdown: { spoofing_detection: { properties: { - score: 0.9512 + score: 0.9512, }, - result: "clear" - } + result: "clear", + }, }, - result: "clear" - } + result: "clear", + }, }, properties: {}, result: "clear", status: "complete", sub_result: null, - uuid: "9cb47ea9-bc41-4e98-8005-51de3d8174b7" + uuid: "9cb47ea9-bc41-4e98-8005-51de3d8174b7", }; export const exampleTask: Task = { id: "abc-123", task_def_id: "task_123", created_at: "2022-06-28T15:39:42Z", - updated_at: "2022-07-28T15:40:42Z" + updated_at: "2022-07-28T15:40:42Z", }; export const exampleDocumentReport: DocumentReport = { @@ -413,8 +413,8 @@ export const exampleDocumentReport: DocumentReport = { created_at: "2024-04-26T11:27:05Z", documents: [ { - id: "dcfa6ae8-4e37-4717-a72b-b6510d24396e" - } + id: "dcfa6ae8-4e37-4717-a72b-b6510d24396e", + }, ], href: "/v3.6/reports/ebc7a6b9-d8b2-4ceb-8940-9c8cd70f2b51", id: "ebc7a6b9-d8b2-4ceb-8940-9c8cd70f2b51", @@ -425,15 +425,15 @@ export const exampleDocumentReport: DocumentReport = { document_numbers: [ { type: "document_number", - value: "999999999" - } + value: "999999999", + }, ], document_type: "passport", first_name: "laboris nulla", gender: null, issuing_country: "GBR", last_name: "elit", - nationality: null + nationality: null, }, result: "clear", status: "complete", @@ -444,196 +444,196 @@ export const exampleDocumentReport: DocumentReport = { breakdown: { gender: { result: "clear", - properties: {} + properties: {}, }, date_of_birth: { result: "clear", - properties: {} + properties: {}, }, document_numbers: { result: "clear", - properties: {} + properties: {}, }, document_expiration: { result: "clear", - properties: {} + properties: {}, }, expiry_date: { result: "clear", - properties: {} + properties: {}, }, mrz: { result: "clear", - properties: {} - } - } + properties: {}, + }, + }, }, visual_authenticity: { result: "clear", breakdown: { fonts: { result: "clear", - properties: {} + properties: {}, }, picture_face_integrity: { result: "clear", - properties: {} + properties: {}, }, template: { result: "clear", - properties: {} + properties: {}, }, security_features: { result: "clear", - properties: {} + properties: {}, }, original_document_present: { result: "clear", - properties: {} + properties: {}, }, digital_tampering: { result: "clear", - properties: {} + properties: {}, }, other: { result: "clear", - properties: {} + properties: {}, }, face_detection: { result: "clear", - properties: {} - } - } + properties: {}, + }, + }, }, compromised_document: { result: "clear", breakdown: { document_database: { result: "clear", - properties: {} + properties: {}, }, repeat_attempts: { result: "clear", - properties: {} - } - } + properties: {}, + }, + }, }, data_consistency: { result: "clear", breakdown: { date_of_expiry: { result: "clear", - properties: {} + properties: {}, }, document_numbers: { result: "clear", - properties: {} + properties: {}, }, issuing_country: { result: "clear", - properties: {} + properties: {}, }, document_type: { result: "clear", - properties: {} + properties: {}, }, date_of_birth: { result: "clear", - properties: {} + properties: {}, }, gender: { result: "clear", - properties: {} + properties: {}, }, multiple_data_sources_present: { result: "clear", - properties: {} + properties: {}, }, first_name: { result: "clear", - properties: {} + properties: {}, }, last_name: { result: "clear", - properties: {} + properties: {}, }, nationality: { result: "clear", - properties: {} - } - } + properties: {}, + }, + }, }, data_comparison: { result: "clear", breakdown: { issuing_country: { result: "clear", - properties: {} + properties: {}, }, gender: { result: "clear", - properties: {} + properties: {}, }, date_of_expiry: { result: "clear", - properties: {} + properties: {}, }, last_name: { result: "clear", - properties: {} + properties: {}, }, document_type: { result: "clear", - properties: {} + properties: {}, }, document_numbers: { result: "clear", - properties: {} + properties: {}, }, first_name: { result: "clear", - properties: {} + properties: {}, }, date_of_birth: { result: "clear", - properties: {} - } - } + properties: {}, + }, + }, }, image_integrity: { result: "clear", breakdown: { image_quality: { result: "clear", - properties: {} + properties: {}, }, conclusive_document_quality: { result: "clear", - properties: {} + properties: {}, }, supported_document: { result: "clear", - properties: {} + properties: {}, }, colour_picture: { result: "clear", - properties: {} - } - } + properties: {}, + }, + }, }, police_record: { - result: "clear" + result: "clear", }, age_validation: { result: "clear", breakdown: { minimum_accepted_age: { result: "clear", - properties: {} - } - } - } - } + properties: {}, + }, + }, + }, + }, }; export const exampleFacialSimilarityPhotoReport: FacialSimilarityPhotoReport = { @@ -641,8 +641,8 @@ export const exampleFacialSimilarityPhotoReport: FacialSimilarityPhotoReport = { created_at: "2024-04-30T13:31:43Z", documents: [ { - id: "83bab412-6253-4a2b-9a91-658a864e379f" - } + id: "83bab412-6253-4a2b-9a91-658a864e379f", + }, ], href: "/v3.6/reports/c39c01da-a6d4-4921-a3c5-72d78eb51236", id: "c39c01da-a6d4-4921-a3c5-72d78eb51236", @@ -661,23 +661,23 @@ export const exampleFacialSimilarityPhotoReport: FacialSimilarityPhotoReport = { spoofing_detection: { result: "clear", properties: { - score: 0.9512 - } - } - } + score: 0.9512, + }, + }, + }, }, image_integrity: { result: "clear", breakdown: { source_integrity: { result: "clear", - properties: {} + properties: {}, }, face_detected: { result: "clear", - properties: {} - } - } + properties: {}, + }, + }, }, face_comparison: { result: "clear", @@ -686,12 +686,12 @@ export const exampleFacialSimilarityPhotoReport: FacialSimilarityPhotoReport = { result: "clear", properties: { score: 0.6512, - document_id: "83bab412-6253-4a2b-9a91-658a864e379f" - } - } - } - } - } + document_id: "83bab412-6253-4a2b-9a91-658a864e379f", + }, + }, + }, + }, + }, }; export const exampleWatchlistMonitor: WatchlistMonitor = { @@ -701,5 +701,5 @@ export const exampleWatchlistMonitor: WatchlistMonitor = { deleted_at: null, tags: [], is_sandbox: true, - created_at: "2022-06-28T15:39:42Z" + created_at: "2022-06-28T15:39:42Z", }; diff --git a/test/test-helpers.ts b/test/test-helpers.ts index d18984f..07cc3d5 100644 --- a/test/test-helpers.ts +++ b/test/test-helpers.ts @@ -17,14 +17,14 @@ import { Report, WatchlistMonitorReportNameEnum, WorkflowRunBuilder, - DocumentTypes + DocumentTypes, } from "onfido-node"; export const onfido = new DefaultApi( new Configuration({ apiToken: process.env.ONFIDO_API_TOKEN, - baseOptions: { timeout: 60_000 } - }) + baseOptions: { timeout: 60_000 }, + }), ); jest.setTimeout(60_000); @@ -53,15 +53,15 @@ export async function createApplicant(overrideProperties = {}) { last_name: "Applicant", address: { postcode: "AB12 3AB", - country: "GBR" + country: "GBR", }, location: { ip_address: "127.0.0.1", - country_of_residence: "GBR" + country_of_residence: "GBR", }, email: "first.last@gmail.com", phone_number: "351911111111", - ...overrideProperties + ...overrideProperties, }); } @@ -73,7 +73,7 @@ export async function cleanUpApplicants() { const applicants = await onfido.listApplicants(1, 20, false); - applicants.data.applicants.forEach(async function(applicant) { + applicants.data.applicants.forEach(async function (applicant) { try { if (applicant.id != sampleapplicant_id) { await onfido.deleteApplicant(applicant.id); @@ -94,7 +94,7 @@ export async function uploadDocument( applicant: Applicant, documentType: DocumentTypes = DocumentTypes.DrivingLicence, location?: LocationBuilder, - filePath: string = "test/media/sample_driving_licence.png" + filePath: string = "test/media/sample_driving_licence.png", ) { let fileTransfer = new FileTransfer(filePath); @@ -106,20 +106,20 @@ export async function uploadDocument( undefined, undefined, undefined, - location + location, ); } export async function uploadLivePhoto( applicant: Applicant, - advancedValidation?: boolean + advancedValidation?: boolean, ) { let buffer = readFileSync("test/media/sample_photo.png"); return onfido.uploadLivePhoto( applicant.id, new FileTransfer(buffer, "sample_photo.png"), - advancedValidation + advancedValidation, ); } @@ -131,7 +131,7 @@ export async function uploadIdPhoto(applicant: Applicant) { export async function uploadSigningDocument( applicant: Applicant, - filePath: string = "test/media/sample_signing_document.pdf" + filePath: string = "test/media/sample_signing_document.pdf", ) { const fileTransfer = new FileTransfer(filePath); @@ -141,14 +141,14 @@ export async function uploadSigningDocument( export async function createWebhook() { return onfido.createWebhook({ url: "https://example.com", - events: ["check.completed", "report.completed"] + events: ["check.completed", "report.completed"], }); } export async function cleanUpWebhooks() { const webhooks = await onfido.listWebhooks(); - webhooks.data.webhooks.forEach(async function(webhook) { + webhooks.data.webhooks.forEach(async function (webhook) { expect((await onfido.deleteWebhook(webhook.id)).status).toEqual(204); }); } @@ -156,23 +156,23 @@ export async function cleanUpWebhooks() { export async function createCheck( applicant: Applicant, document: Document, - overrideProperties = {} + overrideProperties = {}, ) { return onfido.createCheck({ applicant_id: applicant.id, report_names: ["document", "identity_enhanced"], document_ids: [document.id], - ...overrideProperties + ...overrideProperties, }); } export async function createWatchlistMonitor( applicant: Applicant, - reportName: WatchlistMonitorReportNameEnum + reportName: WatchlistMonitorReportNameEnum, ) { return onfido.createWatchlistMonitor({ applicant_id: applicant.id, - report_name: reportName + report_name: reportName, }); } @@ -229,12 +229,12 @@ export function sortByReportName(a: Report, b: Report) { export function createWorkflowRun(applicant: Applicant, workflow_id: string) { return onfido.createWorkflowRun({ applicant_id: applicant.id, - workflow_id: workflow_id + workflow_id: workflow_id, }); } export function createWorkflowRunWithCustomInputs( - workflowRunBuilder: WorkflowRunBuilder + workflowRunBuilder: WorkflowRunBuilder, ) { return onfido.createWorkflowRun(workflowRunBuilder); } @@ -242,18 +242,18 @@ export function createWorkflowRunWithCustomInputs( export function completeTask( workflowRunId: string, taskId: string, - taskData: CompleteTaskBuilder + taskData: CompleteTaskBuilder, ) { return onfido.completeTask(workflowRunId, taskId, taskData); } export async function sleep(msec: number) { - return new Promise(resolve => setTimeout(resolve, msec)); + return new Promise((resolve) => setTimeout(resolve, msec)); } export function getExpectedDocumentReport( exampleReport: DocumentReport, - overrideProperties = {} + overrideProperties = {}, ) { return getExpectedObject(exampleReport, { check_id: expect.stringMatching(/^[0-9a-z-]+$/), @@ -261,13 +261,13 @@ export function getExpectedDocumentReport( breakdown: expect.anything(), properties: expect.anything(), status: expect.anything(), - ...overrideProperties + ...overrideProperties, }); } export function getExpectedFacialSimilarityPhotoReport( exampleReport: FacialSimilarityPhotoReport, - overrideProperties = {} + overrideProperties = {}, ) { return getExpectedObject(exampleReport, { check_id: expect.stringMatching(/^[0-9a-z-]+$/), @@ -275,7 +275,7 @@ export function getExpectedFacialSimilarityPhotoReport( breakdown: expect.anything(), properties: expect.anything(), status: expect.anything(), - ...overrideProperties + ...overrideProperties, }); } @@ -284,7 +284,7 @@ export async function repeatRequestUntilStatusChanges( params: any[], expectedStatus: string, maxRetries = 15, - sleepTime = 1000 + sleepTime = 1000, ): Promise { let instance = (await onfido[fn](...params)).data; let iteration = 0; @@ -305,7 +305,7 @@ export async function repeatRequestUntilTaskOutputChanges( fn: string, params: any[], maxRetries = 15, - sleepTime = 1000 + sleepTime = 1000, ): Promise { let instance = (await onfido[fn](...params)).data; let iteration = 0; @@ -326,7 +326,7 @@ export async function repeatRequestUntilHttpCodeChanges( fn: string, params: any[], maxRetries: number = 15, - sleepTime: number = 1000 + sleepTime: number = 1000, ): Promise { let iteration = 0; let instance: any;