From c92c45ce37f3eb27d4bab996ea70c633f47b56d9 Mon Sep 17 00:00:00 2001 From: Maxwell Weru Date: Thu, 14 Jul 2022 15:21:41 +0300 Subject: [PATCH] Identity Verification fixes (#99) * Rename liveness to video * Split IdentityVerificationReport.cs into multiple files * Added IdentityVerificationReportVideo.Document * Added Type to IdentityVerification and IdentityVerificationCreateRequest * Rename checks to options * Rename LiveCapture to Live * Added IdentityVerificationOptionsForSelfie and IdentityVerificationOptionsForVideo * Update README.md --- README.md | 10 +- ...AbstractIdentityVerificationReportCheck.cs | 16 ++ .../IdentityVerificationConsent.cs | 22 ++ .../IdentityVerificationReport.cs | 207 +----------------- .../IdentityVerificationReportDocument.cs | 86 ++++++++ .../IdentityVerificationReportError.cs | 16 ++ .../IdentityVerificationReportIdNumber.cs | 40 ++++ .../IdentityVerificationReportSelfie.cs | 15 ++ .../IdentityVerificationReportVideo.cs | 20 ++ .../IdentityVerification.cs | 7 +- .../IdentityVerificationChecks.cs | 36 --- .../IdentityVerificationCreateRequest.cs | 7 +- .../IdentityVerificationOptions.cs | 77 +++++++ 13 files changed, 313 insertions(+), 246 deletions(-) create mode 100644 src/FaluSdk/IdentityVerificationReports/AbstractIdentityVerificationReportCheck.cs create mode 100644 src/FaluSdk/IdentityVerificationReports/IdentityVerificationConsent.cs create mode 100644 src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportDocument.cs create mode 100644 src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportError.cs create mode 100644 src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportIdNumber.cs create mode 100644 src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportSelfie.cs create mode 100644 src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportVideo.cs delete mode 100644 src/FaluSdk/IdentityVerifications/IdentityVerificationChecks.cs create mode 100644 src/FaluSdk/IdentityVerifications/IdentityVerificationOptions.cs diff --git a/README.md b/README.md index 28ab25a9..39611cca 100644 --- a/README.md +++ b/README.md @@ -141,13 +141,15 @@ FaluClient client; // omitted for brevity var request = new IdentityVerificationCreateRequest { - Checks = new IdentityVerificationChecks + Type = "document", // can also be "id_number" or "document_and_selfie" or "document_and_video" + Options = new IdentityVerificationOptions { - Document = new IdentityVerificationChecksForDocument + Document = new IdentityVerificationOptionsForDocument { - LiveCapture = true, - } + Live = true, + }, }, + ReturnUrl = "https://my-app.com/verify/waiting?userId=123456", }; var response = await client.IdentityVerifications.CreateAsync(request); response.EnsureSuccess(); // might throw an exception (FaluException) diff --git a/src/FaluSdk/IdentityVerificationReports/AbstractIdentityVerificationReportCheck.cs b/src/FaluSdk/IdentityVerificationReports/AbstractIdentityVerificationReportCheck.cs new file mode 100644 index 00000000..b37b5e79 --- /dev/null +++ b/src/FaluSdk/IdentityVerificationReports/AbstractIdentityVerificationReportCheck.cs @@ -0,0 +1,16 @@ +namespace Falu.IdentityVerificationReports; + +/// +public abstract class AbstractIdentityVerificationReportCheck +{ + /// + /// Details on the verification error. + /// Present when not verified. + /// + public IdentityVerificationReportError? Error { get; set; } + + /// + /// Whether the check resulted in a successful verification. + /// + public bool Verified { get; set; } +} diff --git a/src/FaluSdk/IdentityVerificationReports/IdentityVerificationConsent.cs b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationConsent.cs new file mode 100644 index 00000000..de0e3fab --- /dev/null +++ b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationConsent.cs @@ -0,0 +1,22 @@ +namespace Falu.IdentityVerificationReports; + +/// +public class IdentityVerificationConsent +{ + /// + /// The timestamp marking when the user gave consent for the identity verification to be done. + /// + public DateTimeOffset Date { get; set; } + + /// + /// The IP address from which the user gave consent for the identity verification to be done. + /// + /// ::ffff:127.0.0.1 + public string? IP { get; set; } + + /// + /// The user agent of the browser from which the user gave consent for the identity verification to be done. + /// + /// Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 + public string? UserAgent { get; set; } +} diff --git a/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReport.cs b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReport.cs index 1d5d6ca0..4c7c0f17 100644 --- a/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReport.cs +++ b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReport.cs @@ -18,7 +18,7 @@ public class IdentityVerificationReport : IHasId, IHasCreated, IHasUpdated, IHas /// /// The checks that initiated this report. /// - public IdentityVerificationChecks? Checks { get; set; } + public IdentityVerificationOptions? Options { get; set; } /// /// Details on the user’s acceptance of the Services Agreement. @@ -41,9 +41,9 @@ public class IdentityVerificationReport : IHasId, IHasCreated, IHasUpdated, IHas public IdentityVerificationReportSelfie? Selfie { get; set; } /// - /// Result from a liveness check. + /// Result from a video check. /// - public IdentityVerificationReportLiveness? Liveness { get; set; } + public IdentityVerificationReportVideo? Video { get; set; } /// public string? Workspace { get; set; } @@ -54,204 +54,3 @@ public class IdentityVerificationReport : IHasId, IHasCreated, IHasUpdated, IHas /// public string? Etag { get; set; } } - -/// -public class IdentityVerificationConsent -{ - /// - /// The timestamp marking when the user gave consent for the identity verification to be done. - /// - public DateTimeOffset Date { get; set; } - - /// - /// The IP address from which the user gave consent for the identity verification to be done. - /// - /// ::ffff:127.0.0.1 - public string? IP { get; set; } - - /// - /// The user agent of the browser from which the user gave consent for the identity verification to be done. - /// - /// Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 - public string? UserAgent { get; set; } -} - -/// -public class IdentityVerificationReportIdNumber : AbstractIdentityVerificationReportCheck -{ - /// - /// Type of ID number. - /// - public string? IdNumberType { get; set; } - - /// - /// Identification number. - /// - public string? IdNumber { get; set; } - - /// - /// The first name. - /// - public string? FirstName { get; set; } - - /// - /// The last name. - /// - public string? LastName { get; set; } - - /// - /// The date of birth. - /// - public DateTimeOffset? Birthday { get; set; } - - /// - /// The other names. - /// - public List? OtherNames { get; set; } - - /// - /// The sex as it should appear on the document - /// - public string? Sex { get; set; } -} - -/// -public class IdentityVerificationReportDocument : AbstractIdentityVerificationReportCheck -{ - /// - /// Expiry date of the document. - /// - public DateTimeOffset? Expiry { get; set; } - - /// - /// Issued date of the document. - /// - public DateTimeOffset? Issued { get; set; } - - /// - /// Three-letter ISO country code, - /// in lowercase, which issued the document. - /// - /// ken - public string? Issuer { get; set; } - - /// - /// Three-letter ISO country code, - /// in lowercase, where the entity issued the document originates from. - /// - /// ken - public string? Nationality { get; set; } - - /// - /// Type of the document. - /// - public string? Type { get; set; } - - /// - /// Sub type for the document - /// - public string? SubType { get; set; } - - /// - /// Document identification number. - /// - public string? Number { get; set; } - - /// - /// Personal number - /// - public string? PersonalNumber { get; set; } - - /// - /// First name as it appears in the document. - /// - public string? FirstName { get; set; } - - /// - /// Last name as it appears in the document. - /// - public string? LastName { get; set; } - - /// - /// Other names as they appear in the document. - /// - public List? OtherNames { get; set; } - - /// - /// Sex as it appears on the document - /// - public string? Sex { get; set; } - - /// - /// Date of birth as it appears in the document. - /// - public DateTimeOffset? Birthday { get; set; } - - /// - /// Address as it appears in the document. - /// - public PhysicalAddress? Address { get; set; } - - /// - /// Unique identifiers of the files containing images for this document. - /// - public List Files { get; set; } = new List(); -} - -/// -public class IdentityVerificationReportSelfie : AbstractIdentityVerificationReportCheck -{ - /// - /// Identifier of the file holding the image of the identity document used in this check. - /// - public string? Document { get; set; } - - /// - /// Identifier of the file holding the image of the selfie used in this check. - /// - public string? Selfie { get; set; } -} - -/// -public class IdentityVerificationReportLiveness : AbstractIdentityVerificationReportCheck -{ - /// - /// Identifier of the file holding the video used in this check. - /// - public string? Video { get; set; } - - /// - /// Identifier of the file holding the image of the potrait used in this check. - /// - public string? Portrait { get; set; } -} - -/// -public abstract class AbstractIdentityVerificationReportCheck -{ - /// - /// Details on the verification error. - /// Present when not verified. - /// - public IdentityVerificationReportError? Error { get; set; } - - /// - /// Whether the check resulted in a successful verification. - /// - public bool Verified { get; set; } -} - -/// -public class IdentityVerificationReportError -{ - /// - /// A short machine-readable string giving the reason for the verification failure. - /// - public string? Code { get; set; } - - /// - /// A human-readable message giving the reason for the failure. - /// These message can be shown to your user. - /// - public string? Description { get; set; } -} diff --git a/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportDocument.cs b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportDocument.cs new file mode 100644 index 00000000..420a9729 --- /dev/null +++ b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportDocument.cs @@ -0,0 +1,86 @@ +using Falu.Core; + +namespace Falu.IdentityVerificationReports; + +/// +public class IdentityVerificationReportDocument : AbstractIdentityVerificationReportCheck +{ + /// + /// Expiry date of the document. + /// + public DateTimeOffset? Expiry { get; set; } + + /// + /// Issued date of the document. + /// + public DateTimeOffset? Issued { get; set; } + + /// + /// Three-letter ISO country code, + /// in lowercase, which issued the document. + /// + /// ken + public string? Issuer { get; set; } + + /// + /// Three-letter ISO country code, + /// in lowercase, where the entity issued the document originates from. + /// + /// ken + public string? Nationality { get; set; } + + /// + /// Type of the document. + /// + public string? Type { get; set; } + + /// + /// Sub type for the document + /// + public string? SubType { get; set; } + + /// + /// Document identification number. + /// + public string? Number { get; set; } + + /// + /// Personal number + /// + public string? PersonalNumber { get; set; } + + /// + /// First name as it appears in the document. + /// + public string? FirstName { get; set; } + + /// + /// Last name as it appears in the document. + /// + public string? LastName { get; set; } + + /// + /// Other names as they appear in the document. + /// + public List? OtherNames { get; set; } + + /// + /// Sex as it appears on the document + /// + public string? Sex { get; set; } + + /// + /// Date of birth as it appears in the document. + /// + public DateTimeOffset? Birthday { get; set; } + + /// + /// Address as it appears in the document. + /// + public PhysicalAddress? Address { get; set; } + + /// + /// Unique identifiers of the files containing images for this document. + /// + public List Files { get; set; } = new List(); +} diff --git a/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportError.cs b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportError.cs new file mode 100644 index 00000000..5f582158 --- /dev/null +++ b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportError.cs @@ -0,0 +1,16 @@ +namespace Falu.IdentityVerificationReports; + +/// +public class IdentityVerificationReportError +{ + /// + /// A short machine-readable string giving the reason for the verification failure. + /// + public string? Code { get; set; } + + /// + /// A human-readable message giving the reason for the failure. + /// These message can be shown to your user. + /// + public string? Description { get; set; } +} diff --git a/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportIdNumber.cs b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportIdNumber.cs new file mode 100644 index 00000000..6d78957a --- /dev/null +++ b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportIdNumber.cs @@ -0,0 +1,40 @@ +namespace Falu.IdentityVerificationReports; + +/// +public class IdentityVerificationReportIdNumber : AbstractIdentityVerificationReportCheck +{ + /// + /// Type of ID number. + /// + public string? IdNumberType { get; set; } + + /// + /// Identification number. + /// + public string? IdNumber { get; set; } + + /// + /// The first name. + /// + public string? FirstName { get; set; } + + /// + /// The last name. + /// + public string? LastName { get; set; } + + /// + /// The date of birth. + /// + public DateTimeOffset? Birthday { get; set; } + + /// + /// The other names. + /// + public List? OtherNames { get; set; } + + /// + /// The sex as it should appear on the document + /// + public string? Sex { get; set; } +} diff --git a/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportSelfie.cs b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportSelfie.cs new file mode 100644 index 00000000..2a35b56c --- /dev/null +++ b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportSelfie.cs @@ -0,0 +1,15 @@ +namespace Falu.IdentityVerificationReports; + +/// +public class IdentityVerificationReportSelfie : AbstractIdentityVerificationReportCheck +{ + /// + /// Identifier of the file holding the image of the identity document used in this check. + /// + public string? Document { get; set; } + + /// + /// Identifier of the file holding the image of the selfie used in this check. + /// + public string? Selfie { get; set; } +} diff --git a/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportVideo.cs b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportVideo.cs new file mode 100644 index 00000000..8c7be7a8 --- /dev/null +++ b/src/FaluSdk/IdentityVerificationReports/IdentityVerificationReportVideo.cs @@ -0,0 +1,20 @@ +namespace Falu.IdentityVerificationReports; + +/// +public class IdentityVerificationReportVideo : AbstractIdentityVerificationReportCheck +{ + /// + /// Identifier of the file holding the image of the identity document used in this check. + /// + public string? Document { get; set; } + + /// + /// Identifier of the file holding the video used in this check. + /// + public string? Video { get; set; } + + /// + /// Identifier of the file holding the image of the potrait used in this check. + /// + public string? Portrait { get; set; } +} diff --git a/src/FaluSdk/IdentityVerifications/IdentityVerification.cs b/src/FaluSdk/IdentityVerifications/IdentityVerification.cs index 2de2b3bc..81a19c1a 100644 --- a/src/FaluSdk/IdentityVerifications/IdentityVerification.cs +++ b/src/FaluSdk/IdentityVerifications/IdentityVerification.cs @@ -22,10 +22,15 @@ public class IdentityVerification : IdentityVerificationPatchModel, IHasId, IHas /// public string? Status { get; set; } + /// + /// The type of verification check to be performed. + /// + public string? Type { get; set; } + /// /// A set of verification checks to be performed. /// - public IdentityVerificationChecks? Checks { get; set; } + public IdentityVerificationOptions? Options { get; set; } /// /// The short-lived client secret used by front-end libraries to show a verification modal inside your app. diff --git a/src/FaluSdk/IdentityVerifications/IdentityVerificationChecks.cs b/src/FaluSdk/IdentityVerifications/IdentityVerificationChecks.cs deleted file mode 100644 index 232c8cb4..00000000 --- a/src/FaluSdk/IdentityVerifications/IdentityVerificationChecks.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Falu.IdentityVerifications; - -/// -public class IdentityVerificationChecks -{ - /// - /// Options for the id number check. - /// - public IdentityVerificationChecksForIdNumber? IdNumber { get; set; } - - /// - /// Options for the document check. - /// - public IdentityVerificationChecksForDocument? Document { get; set; } -} - -/// -public class IdentityVerificationChecksForIdNumber -{ - // intentionally left blank -} - -/// -public class IdentityVerificationChecksForDocument -{ - /// - /// Disable image uploads, identity document images have to be captured using the device's camera. - /// - public bool LiveCapture { get; set; } - - /// - /// The allowed identity document types. - /// If a user uploads a document which isn't one of the allowed types, it will be rejected. - /// - public List? Allowed { get; set; } -} diff --git a/src/FaluSdk/IdentityVerifications/IdentityVerificationCreateRequest.cs b/src/FaluSdk/IdentityVerifications/IdentityVerificationCreateRequest.cs index 821c93ee..8b65ecb1 100644 --- a/src/FaluSdk/IdentityVerifications/IdentityVerificationCreateRequest.cs +++ b/src/FaluSdk/IdentityVerifications/IdentityVerificationCreateRequest.cs @@ -5,10 +5,15 @@ /// public class IdentityVerificationCreateRequest : IdentityVerificationPatchModel { + /// + /// The type of verification check to be performed. + /// + public string? Type { get; set; } + /// /// A set of verification checks to be performed. /// - public IdentityVerificationChecks? Checks { get; set; } + public IdentityVerificationOptions? Options { get; set; } /// /// The URL the user will be redirected to upon completing the verification flow. diff --git a/src/FaluSdk/IdentityVerifications/IdentityVerificationOptions.cs b/src/FaluSdk/IdentityVerifications/IdentityVerificationOptions.cs new file mode 100644 index 00000000..64b89804 --- /dev/null +++ b/src/FaluSdk/IdentityVerifications/IdentityVerificationOptions.cs @@ -0,0 +1,77 @@ +namespace Falu.IdentityVerifications; + +/// +public class IdentityVerificationOptions +{ + /// + /// Options for the id number check. + /// + public IdentityVerificationOptionsForIdNumber? IdNumber { get; set; } + + /// + /// Options for the document check. + /// + public IdentityVerificationOptionsForDocument? Document { get; set; } + + /// + /// Options for the selfie check. + /// + public IdentityVerificationOptionsForSelfie? Selfie { get; set; } + + /// + /// Options for the video check. + /// + public IdentityVerificationOptionsForVideo? Video { get; set; } +} + +/// +public class IdentityVerificationOptionsForIdNumber +{ + // intentionally left blank +} + +/// +public class IdentityVerificationOptionsForDocument +{ + /// + /// Disable image uploads, identity document images have to be captured using the device's camera. + /// + public bool Live { get; set; } + + /// + /// The allowed identity document types. + /// If a user uploads a document which isn't one of the allowed types, it will be rejected. + /// + public List? Allowed { get; set; } +} + +/// +public class IdentityVerificationOptionsForSelfie +{ + /// + /// Disable image uploads, selfie images have to be captured using the device's camera. + /// + public bool Live { get; set; } +} + +/// +public class IdentityVerificationOptionsForVideo +{ + /// + /// Disable uploads, videos have to be captured using the device's camera. + /// + public bool Live { get; set; } + + /// + /// Face poses to be performed in the video recording. + /// It is recommended to leave this field unassigned for the server to + /// generate random values per verification for security purposes. + /// + public List? Poses { get; set; } + + /// + /// Numerical phrase to be recited in the video recording. + /// When not provided, the server generates a random one. + /// + public int? Recital { get; set; } +}