Skip to content

Releases: getyoti/yoti-python-sdk

v2.14.5

16 Dec 15:13
eab6d64

Choose a tag to compare

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

from yoti_python_sdk.doc_scan import RequestedLivenessCheckBuilder

# Build a STATIC liveness check
liveness_check = (
    RequestedLivenessCheckBuilder()
    .for_static_liveness()
    .with_max_retries(3)
    .with_manual_check_never()
    .build()
)

Generated JSON:

{
  "type": "LIVENESS",
  "config": {
    "liveness_type": "STATIC",
    "manual_check": "NEVER",
    "max_retries": 3
  }
}

2. Session Retrieval (Response Side)

Access STATIC Liveness Resources

from yoti_python_sdk.doc_scan import DocScanClient

client = DocScanClient(sdk_id, key_file_path)
session_result = client.get_session(session_id)

# Get all STATIC liveness resources
static_resources = session_result.resources.static_liveness_resources

for resource in static_resources:
    print(f"Resource ID: {resource.id}")
    print(f"Liveness Type: {resource.liveness_type}")
    
    # Access the image and media
    if resource.image and resource.image.media:
        media_id = resource.image.media.id
        media_type = resource.image.media.type
        created = resource.image.media.created
        
        print(f"Media ID: {media_id}")
        print(f"Media Type: {media_type}")

3. Media Content Retrieval

Download STATIC Liveness Image

# Get the first STATIC liveness resource
static_liveness = session_result.resources.static_liveness_resources[0]

# Extract media ID
media_id = static_liveness.image.media.id

# Retrieve the actual image content
media_content = client.get_media_content(session_id, media_id)

# Access the image bytes and MIME type
image_bytes = media_content.content
mime_type = media_content.mime_type  # e.g., "image/jpeg" or "image/png"

# Save to file
with open(f"liveness_image.{mime_type.split('/')[-1]}", "wb") as f:
    f.write(image_bytes)

Run Tests

# Run STATIC liveness tests only
pytest yoti_python_sdk/tests/doc_scan/session/create/check/test_liveness_check.py -v
pytest yoti_python_sdk/tests/doc_scan/session/retrieve/test_static_liveness_resource.py -v

# Run all doc_scan tests
pytest yoti_python_sdk/tests/doc_scan/ -v

Example Application

The Flask example application (examples/doc_scan/) now displays Static Liveness resources on the success page:

  • Shows resource ID and liveness type
  • Displays the static liveness image
  • Provides media ID for reference
  • Uses collapsible accordion UI similar to ZOOM liveness

Backward Compatibility

Fully backward compatible - All existing code using ZOOM liveness continues to work without any changes:

# Existing ZOOM liveness code still works
zoom_check = RequestedLivenessCheckBuilder().for_zoom_liveness().build()
zoom_resources = session_result.resources.zoom_liveness_resources

# New STATIC liveness code
static_check = RequestedLivenessCheckBuilder().for_static_liveness().build()
static_resources = session_result.resources.static_liveness_resources

Acceptance Criteria

All three acceptance criteria have been met:

  1. Add support for requesting a liveness check type STATIC

    • Implemented via for_static_liveness() builder method
    • Supports manual_check parameter (defaults to "NEVER")
  2. Add support for retrieving the updated liveness check response

    • Created StaticLivenessResourceResponse class
    • Added static_liveness_resources filter property
    • Parses image and media objects correctly
  3. Ensure that the SDKs support retrieving the media for the STATIC liveness check

    • Media ID accessible via resource.image.media.id
    • Existing get_media_content() method works seamlessly
    • Example application displays the image

For Existing Implementations

No changes required! Your existing ZOOM liveness code will continue to work. You can optionally add STATIC liveness support:

# Add STATIC liveness alongside existing ZOOM liveness
session_spec = (
    SessionSpecBuilder()
    .with_requested_check(
        RequestedLivenessCheckBuilder()
        .for_zoom_liveness()  # Existing
        .with_max_retries(1)
        .build()
    )
    .with_requested_check(
        RequestedLivenessCheckBuilder()
        .for_static_liveness()  # New
        .with_max_retries(3)
        .with_manual_check_never()
        .build()
    )
    # ... other configuration
    .build()
)

v2.14.4

08 Aug 15:12
3b2454e

Choose a tag to compare

Updated

** Updated protobuf dependency from 3.20.3 to >=4.21.12 for improved compatibility and security
** Reorganized protobuf modules to original API structure
** Dependency Updates:** All relevant libraries have been updated to ensure compatibility with Python 3.12.
** Updated GitHub Actions workflows for faster CI execution
** Enhanced example applications with updated dependency requirements
** Improved backward compatibility while supporting modern protobuf versions

v2.14.3

03 Jul 14:11
af34005

Choose a tag to compare

Added

Python 3.12 Support: The project supports Python 3.12.
Dependency Updates: All relevant libraries have been updated to ensure compatibility with Python 3.12.

v2.14.2

23 Feb 14:21
6fe15da

Choose a tag to compare

Changed

  • Update to protobuf==4.21.12
  • Set protobuf==3.20.1 in setup.py

v2.14.1

21 Jun 13:09
8f019e3

Choose a tag to compare

Security

  • Update to pytz==2022.1

Changed

  • Set protobuf==3.13.0 in setup.py

Removed

  • Support for Python 2.7

v2.14.0

16 Nov 16:13
eff67c4

Choose a tag to compare

Added

  • Supplementary document support (Doc Scan)
  • DynamicPolicyBuilder().with_document_images()
  • accept_self_asserted option can now be passed to DynamicPolicyBuilder methods

Fixed

  • DocScanClient.get_media_content() will now return None for 204 no content responses (Doc Scan)

v2.13.0

21 Oct 12:59
2e003b7

Choose a tag to compare

Doc Scan

Added

  • Support for ID document comparison checks
  • Ability to block the collection of biometric consent
  • Allow the configuration of the manual_check value for requested Document Authenticity checks
  • Add support for chip data
    • RequestedTextExtractionTaskBuilder().with_chip_data_desired()
    • RequestedTextExtractionTaskBuilder().with_chip_data_ignore()
    • IdDocumentResourceResponse property: document_id_photo
  • Add support for document page frames

Fixed

  • RequestedDocumentAuthenticityCheckBuilder.build() is no longer static. Python 2 implementations must change this to RequestedDocumentAuthenticityCheckBuilder().build()

v2.12.2

18 Jun 16:44
da0828a

Choose a tag to compare

Fixed

Set pytest version to >=4.6.0 to prevent clashes with upstream dependencies requiring pytest >= 4.6.0

v2.12.1

09 Jun 11:55
03ba5ee

Choose a tag to compare

Fixed

  • Update Attribute Issuance Expiry Date format to be milliseconds, not microseconds

v2.12.0

18 May 12:02
d4ed035

Choose a tag to compare

Added

  • yoti_python_sdk.doc_scan
    • session.create.filter - Contains builders and objects used for specifying required documents during session creation (see snippets below)
    • DocScanClient
      • get_supported_documents() - retrieve all currently supported documents

Creating a required document

document_restriction = (DocumentRestrictionBuilder()
                            .with_document_types(["PASSPORT", "DRIVING_LICENCE"])
                            .with_country_codes(["GBR"])
                            .build())

document_filter = (DocumentRestrictionsFilterBuilder()
                       .for_whitelist()
                       .with_document_restriction(document_restriction)
                       .build())

required_id_document = (RequiredIdDocumentBuilder()
                            .with_filter(document_filter)
                            .build())