added python static liveness check#425
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for Static Liveness Check functionality to the Yoti Python SDK, enabling identity verification using a single static image instead of the existing ZOOM liveness method that requires multiple frames and facemap data.
Key Changes
- Added
StaticLivenessResourceResponseandImageResponseclasses to handle static liveness resource retrieval - Extended
RequestedLivenessCheckBuilderwithfor_static_liveness()andwith_manual_check_never()methods for session creation - Updated
ResourceContainerto parse and filter static liveness resources alongside existing ZOOM resources
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| yoti_python_sdk/doc_scan/constants.py | Added STATIC constant for the new liveness type |
| yoti_python_sdk/doc_scan/session/create/check/liveness.py | Extended configuration and builder to support STATIC liveness type with optional manual_check parameter |
| yoti_python_sdk/doc_scan/session/retrieve/static_liveness_resource_response.py | New class to represent static liveness resources with image data |
| yoti_python_sdk/doc_scan/session/retrieve/image_response.py | New class to wrap image data containing media information for static liveness |
| yoti_python_sdk/doc_scan/session/retrieve/resource_container.py | Updated to parse STATIC type and added filter property for static liveness resources |
| yoti_python_sdk/tests/doc_scan/session/create/check/test_liveness_check.py | Added comprehensive tests for static liveness check creation and JSON serialization |
| yoti_python_sdk/tests/doc_scan/session/retrieve/test_static_liveness_resource.py | New test file covering static liveness resource parsing and media ID retrieval |
| examples/doc_scan/templates/success.html | Added UI section to display static liveness resources with collapsible accordion layout matching ZOOM liveness pattern |
Comments suppressed due to low confidence (2)
yoti_python_sdk/doc_scan/session/retrieve/static_liveness_resource_response.py:4
- Import of 'ResourceResponse' is not used.
from .resource_response import ResourceResponse
yoti_python_sdk/tests/doc_scan/session/retrieve/test_static_liveness_resource.py:2
- Import of 'json' is not used.
import json
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nikhilPank
left a comment
There was a problem hiding this comment.
Looks good and it works locally.
There are a few cleanup recommendations from Copilot which could be implemented
…urce_response.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…veness_resource.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@mehmet-yoti I've opened a new pull request, #426, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
* Python library updates * added python static liveness check (#425) * update version files
* Python library updates * added python static liveness check (#425) * update version files
* Python library updates * added python static liveness check (#425) * update version files
* SDK-2267:updated refs * SDK-2267:version update * Release/2.14.3 (#420) Python library updates * Release/2.14.4 (#423) * SDK-2648 updated version of protobuf * Update version to 2.14.4 * SDK-2648: Update protobuf to 4.21.12+ * Remove accidentally committed virtual environment files from Flask example * Update doc_scan example requirements for protobuf 4.21.12 and SDK v2.14.4 * Update Flask example requirements for protobuf 4.21.12 and SDK v2.14.4 * updated versions in examples * Fix GitHub Actions workflow to install local SDK before example requirements * Release/2.14.5 (#436) * Python library updates * added python static liveness check (#425) * update version files * updated protobuf error * fix: update example requirements to be compatible with SDK cryptography>=42.0.0 doc_scan/requirements.txt pinned cryptography==41.0.7 which conflicts with the SDK's install_requires (cryptography>=42.0.0), breaking the CI examples job. Updated both example requirements files and clarified the headers to reflect that they contain SDK-inherited range constraints. * fix: sync cryptography constraint and prevent local SDK override in CI - requirements.in: cryptography>=41.0.7 -> >=42.0.0 to match setup.py, remove leading blank line - tests.yaml: reinstall local SDK after AML/Django examples, which pin yoti==2.14.0 from PyPI and would otherwise override the editable install - flask/doc_scan requirements.txt: clarify # via yoti (installed separately) annotations since yoti is no longer in requirements.in



Static Liveness Check Implementation
Overview
This implementation adds support for Static Liveness Check to the Yoti Python SDK, enabling identity verification using a single static image instead of the ZOOM liveness method which requires multiple frames and facemap data.
Features Added
1. Session Creation (Request Side)
Create STATIC Liveness Check
Generated JSON:
{ "type": "LIVENESS", "config": { "liveness_type": "STATIC", "manual_check": "NEVER", "max_retries": 3 } }2. Session Retrieval (Response Side)
Access STATIC Liveness Resources
3. Media Content Retrieval
Download STATIC Liveness Image
Run Tests
Example Application
The Flask example application (
examples/doc_scan/) now displays Static Liveness resources on the success page:Backward Compatibility
✅ Fully backward compatible - All existing code using ZOOM liveness continues to work without any changes:
Acceptance Criteria
All three acceptance criteria have been met:
✅ Add support for requesting a liveness check type STATIC
for_static_liveness()builder methodmanual_checkparameter (defaults to"NEVER")✅ Add support for retrieving the updated liveness check response
StaticLivenessResourceResponseclassstatic_liveness_resourcesfilter property✅ Ensure that the SDKs support retrieving the media for the STATIC liveness check
resource.image.media.idget_media_content()method works seamlesslyFor Existing Implementations
No changes required! Your existing ZOOM liveness code will continue to work. You can optionally add STATIC liveness support: