SDK-2616: .NET - Support configuration for IDV shortened flow - dotnet#543
Conversation
🤖 Claude Code ReviewCode Review FindingsCriticalNone Major
Minor
Nit
|
There was a problem hiding this comment.
Pull request overview
Adds support in the Doc Scan .NET SDK for configuring the IDV “shortened flow” by allowing specific screens to be suppressed via SdkConfig.
Changes:
- Added
suppressed_screenstoSdkConfig(nullable/omitted when unset) and anIsScreenSuppressed(string)helper. - Extended
SdkConfigBuilderwith fluent APIs to set/append suppressed screens and wired it intoBuild(). - Introduced
SuppressedScreenconstants and added unit tests covering builder behavior + JSON serialization/omission.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Yoti.Auth/DocScan/Session/Create/SdkConfig.cs |
Adds SuppressedScreens serialization + helper to check suppression. |
src/Yoti.Auth/DocScan/Session/Create/SdkConfigBuilder.cs |
Adds builder methods for setting/appending suppressed screens and passes through to SdkConfig. |
src/Yoti.Auth/DocScan/Session/Create/SuppressedScreen.cs |
Adds constants for known suppressible screen identifiers. |
test/Yoti.Auth.Tests/DocScan/Session/Create/SdkConfigBuilderTests.cs |
Adds unit tests for suppressed screens behavior and JSON output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public SdkConfigBuilder WithSuppressedScreens(List<string> suppressedScreens) | ||
| { | ||
| _suppressedScreens = suppressedScreens; | ||
| return this; | ||
| } |
There was a problem hiding this comment.
WithSuppressedScreens assigns the provided list directly without validating its contents. If the list contains null/empty/whitespace entries, JSON serialization will include null/invalid identifiers in suppressed_screens, which is likely to cause backend validation errors. Consider validating each element (and optionally de-duplicating) or throwing an InvalidOperationException/ArgumentException when invalid entries are provided.
| if (_suppressedScreens == null) | ||
| _suppressedScreens = new List<string>(); | ||
|
|
||
| _suppressedScreens.Add(suppressedScreen); |
There was a problem hiding this comment.
WithSuppressedScreen will add the provided value even when it is null/empty/whitespace. That can produce a suppressed_screens array containing null in the serialized config, which is likely invalid and may cause session creation to fail. Add input validation (and consider ignoring duplicates) before appending to the list.
| if (_suppressedScreens == null) | |
| _suppressedScreens = new List<string>(); | |
| _suppressedScreens.Add(suppressedScreen); | |
| if (string.IsNullOrWhiteSpace(suppressedScreen)) | |
| return this; | |
| if (_suppressedScreens == null) | |
| _suppressedScreens = new List<string>(); | |
| if (!_suppressedScreens.Contains(suppressedScreen)) | |
| _suppressedScreens.Add(suppressedScreen); |
Summary
Adds support for configuring the IDV shortened flow by allowing callers to suppress individual screens in the Doc Scan SDK config (SDK-2616). Introduces a new
suppressed_screensfield onSdkConfig, fluent builder methods, a constants class for valid screen identifiers, and a helper to check whether a given screen is suppressed.Changes
src/Yoti.Auth/DocScan/Session/Create/SdkConfig.cs: AddedSuppressedScreensproperty serialized assuppressed_screens(omitted when null), a new optional constructor parameter, and anIsScreenSuppressed(string)helper for case-sensitive membership checks.src/Yoti.Auth/DocScan/Session/Create/SdkConfigBuilder.cs: AddedWithSuppressedScreens(List<string>)(bulk set/reset) andWithSuppressedScreen(string)(append single) fluent methods; wired the field intoBuild().src/Yoti.Auth/DocScan/Session/Create/SuppressedScreen.cs: New static class exposing valid screen identifier constants (ID_DOCUMENT_EDUCATION,ID_DOCUMENT_REQUIREMENTS,SUPPLEMENTARY_DOCUMENT_EDUCATION,ZOOM_LIVENESS_EDUCATION,STATIC_LIVENESS_EDUCATION,FACE_CAPTURE_EDUCATION,FLOW_COMPLETION).test/Yoti.Auth.Tests/DocScan/Session/Create/SdkConfigBuilderTests.cs: Added 12 unit tests covering default null behaviour, bulk-set, empty list, null reset, incremental append, constant values,IsScreenSuppressedhappy path / unlisted / null / case sensitivity, JSON array serialization, and JSON omission when null.QA Test Steps
dotnet build src/Yoti.Auth.sln).dotnet test test/Yoti.Auth.Tests/Yoti.Auth.Tests.csproj --filter "FullyQualifiedName~SdkConfigBuilderTests"– verify all 12 newSuppressedScreen*/IsScreenSuppressed*tests pass alongside existing tests.new SdkConfigBuilder().WithSuppressedScreens(new List<string>{ SuppressedScreen.IdDocumentEducation, SuppressedScreen.FlowCompletion }).Build(), serialize withJsonConvert.SerializeObject, and confirm the JSON contains"suppressed_screens":["ID_DOCUMENT_EDUCATION","FLOW_COMPLETION"]..WithSuppressedScreen(SuppressedScreen.ZoomLivenessEducation).WithSuppressedScreen(SuppressedScreen.FaceCaptureEducation), build, and confirm both entries appear inSdkConfig.SuppressedScreensin insertion order.SdkConfigwithout calling either suppression method; confirmSuppressedScreensisnulland the serialized JSON does not contain asuppressed_screenskey (driven byNullValueHandling.Ignore)..WithSuppressedScreens(listOfOne).WithSuppressedScreens(null).Build()– confirmSuppressedScreensisnull..WithSuppressedScreens(new List<string>())– confirm the property is non-null, count 0, and serializes as"suppressed_screens":[].IsScreenSuppressedchecks:truewhen the screen is in the list.falsewhen not in the list.falsewhenSuppressedScreensis null (no NRE).falsefor differing case (e.g."id_document_education").DocScanClient.CreateSessionagainst a sandbox/test environment using a config that suppressesID_DOCUMENT_EDUCATION, launch the Web SDK flow, and confirm that education screen is skipped while all other screens behave as before.SdkConfigpopulating all previously existing fields (AllowedCaptureMethods,PrimaryColour,AllowHandoff,AttemptsConfiguration, etc.) without suppressed screens and confirm serialized output matches the pre-change baseline (no new keys, existing keys unchanged).Notes
stringconstants on a staticSuppressedScreenclass rather than anenum, matching the existing pattern used byDocScanConstantsin this SDK and allowing backend-driven additions without a breaking enum change. Callers can therefore pass arbitrary strings; validation of unknown values is deferred to the backend.SuppressedScreensis serialized withNullValueHandling.Ignore, so the field is omitted entirely when unset – preserving backwards compatibility for existing integrations that do not use the shortened flow.[](not omitted); backend should treat this as "suppress nothing," matching the default behaviour.IsScreenSuppressedperforms a case-sensitive exact-string match, consistent with how the backend compares identifiers. If case-insensitive matching is later required, it can be added without breaking the current contract.suppressedScreensparameter onSdkConfigis optional (= null) and appended at the end of the argument list.Related Jira: SDK-2616
Auto-generated by n8n + Claude CLI