Skip to content

Commit

Permalink
Merge pull request #65 from onfido/release-upgrade
Browse files Browse the repository at this point in the history
Refresh onfido-python after onfido-openapi-spec update (01ed1b5)
  • Loading branch information
dvacca-onfido authored Jul 2, 2024
2 parents 1ab7c70 + 28b160d commit eede871
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,19 @@ jobs:
publish:
runs-on: ubuntu-latest
needs: integration-tests
environment: delivery
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_ACTION_ACCESS_TOKEN }}
ref: ${{ github.event.release.tag_name }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Validate release
uses: onfido/onfido-actions/release-check@main
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -86,3 +92,5 @@ jobs:
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Update and commit CHANGELOG.md
uses: onfido/onfido-actions/update-changelog@main
8 changes: 4 additions & 4 deletions .release.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"source": {
"repo_url": "https://github.com/onfido/onfido-openapi-spec",
"short_sha": "a34b6d8",
"long_sha": "a34b6d86714f7f74da2d60a33a76ec3a693d264a",
"version": "v3.0.0"
"short_sha": "01ed1b5",
"long_sha": "01ed1b5fe0f7490bfce54816504a9fec13b33862",
"version": "v3.1.0"
},
"release": "v3.1.0"
"release": "v3.2.0"
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Documentation can be found at <https://documentation.onfido.com>.

This version uses Onfido API v3.6. Refer to our [API versioning guide](https://developers.onfido.com/guide/api-versioning-policy#client-libraries) for details of which client library versions use which versions of the API.

[![PyPI version](https://badge.fury.io/py/onfido-python.svg)](https://badge.fury.io/py/onfido-python)
![Build Status](https://github.com/onfido/onfido-python/actions/workflows/python.yml/badge.svg)

## Installation & Usage

### Requirements
Expand Down
2 changes: 1 addition & 1 deletion onfido/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
""" # noqa: E501


__version__ = "3.1.0"
__version__ = "3.2.0"

# import apis into sdk package
from onfido.api.default_api import DefaultApi
Expand Down
2 changes: 1 addition & 1 deletion onfido/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'onfido-python/3.1.0'
self.user_agent = 'onfido-python/3.2.0'
self.client_side_validation = configuration.client_side_validation

def __enter__(self):
Expand Down
2 changes: 1 addition & 1 deletion onfido/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def to_debug_report(self):
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: v3.6\n"\
"SDK Package Version: 3.1.0".\
"SDK Package Version: 3.2.0".\
format(env=sys.platform, pyversion=sys.version)

def get_host_settings(self):
Expand Down
66 changes: 64 additions & 2 deletions onfido/models/document_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import json

from datetime import date
from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr
from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from onfido.models.document_properties_address_lines import DocumentPropertiesAddressLines
from onfido.models.document_properties_barcode_inner import DocumentPropertiesBarcodeInner
Expand All @@ -36,6 +36,7 @@ class DocumentProperties(BaseModel):
""" # noqa: E501
date_of_birth: Optional[date] = None
date_of_expiry: Optional[date] = None
personal_number: Optional[StrictStr] = None
document_numbers: Optional[List[DocumentPropertiesDocumentNumbersInner]] = None
document_type: Optional[StrictStr] = None
first_name: Optional[StrictStr] = None
Expand All @@ -55,15 +56,60 @@ class DocumentProperties(BaseModel):
widow_name: Optional[StrictStr] = None
alias_name: Optional[StrictStr] = None
issuing_authority: Optional[StrictStr] = None
remarks: Optional[StrictStr] = None
civil_state: Optional[StrictStr] = None
expatriation: Optional[StrictStr] = None
father_name: Optional[StrictStr] = None
mother_name: Optional[StrictStr] = None
religion: Optional[StrictStr] = None
type_of_permit: Optional[StrictStr] = None
version_number: Optional[StrictStr] = None
document_subtype: Optional[StrictStr] = None
profession: Optional[StrictStr] = None
security_document_number: Optional[StrictStr] = None
tax_number: Optional[StrictStr] = None
nist_identity_evidence_strength: Optional[StrictStr] = None
has_issuance_confirmation: Optional[StrictStr] = None
real_id_compliance: Optional[StrictBool] = None
security_tier: Optional[StrictStr] = None
address_lines: Optional[DocumentPropertiesAddressLines] = None
barcode: Optional[List[DocumentPropertiesBarcodeInner]] = None
nfc: Optional[DocumentPropertiesNfc] = None
driving_licence_information: Optional[DocumentPropertiesDrivingLicenceInformation] = None
document_classification: Optional[DocumentPropertiesDocumentClassification] = None
extracted_data: Optional[DocumentPropertiesExtractedData] = None
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = ["date_of_birth", "date_of_expiry", "document_numbers", "document_type", "first_name", "gender", "issuing_country", "last_name", "nationality", "issuing_state", "issuing_date", "categorisation", "mrz_line1", "mrz_line2", "mrz_line3", "address", "place_of_birth", "spouse_name", "widow_name", "alias_name", "issuing_authority", "real_id_compliance", "address_lines", "barcode", "nfc", "driving_licence_information", "document_classification", "extracted_data"]
__properties: ClassVar[List[str]] = ["date_of_birth", "date_of_expiry", "personal_number", "document_numbers", "document_type", "first_name", "gender", "issuing_country", "last_name", "nationality", "issuing_state", "issuing_date", "categorisation", "mrz_line1", "mrz_line2", "mrz_line3", "address", "place_of_birth", "spouse_name", "widow_name", "alias_name", "issuing_authority", "remarks", "civil_state", "expatriation", "father_name", "mother_name", "religion", "type_of_permit", "version_number", "document_subtype", "profession", "security_document_number", "tax_number", "nist_identity_evidence_strength", "has_issuance_confirmation", "real_id_compliance", "security_tier", "address_lines", "barcode", "nfc", "driving_licence_information", "document_classification", "extracted_data"]

@field_validator('nist_identity_evidence_strength')
def nist_identity_evidence_strength_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in set(['superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength']):
raise ValueError("must be one of enum values ('superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength')")
return value

@field_validator('has_issuance_confirmation')
def has_issuance_confirmation_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in set(['true', 'false', 'unspecified']):
raise ValueError("must be one of enum values ('true', 'false', 'unspecified')")
return value

@field_validator('security_tier')
def security_tier_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in set(['tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier']):
raise ValueError("must be one of enum values ('tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier')")
return value

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -154,6 +200,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
_obj = cls.model_validate({
"date_of_birth": obj.get("date_of_birth"),
"date_of_expiry": obj.get("date_of_expiry"),
"personal_number": obj.get("personal_number"),
"document_numbers": [DocumentPropertiesDocumentNumbersInner.from_dict(_item) for _item in obj["document_numbers"]] if obj.get("document_numbers") is not None else None,
"document_type": obj.get("document_type"),
"first_name": obj.get("first_name"),
Expand All @@ -173,7 +220,22 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"widow_name": obj.get("widow_name"),
"alias_name": obj.get("alias_name"),
"issuing_authority": obj.get("issuing_authority"),
"remarks": obj.get("remarks"),
"civil_state": obj.get("civil_state"),
"expatriation": obj.get("expatriation"),
"father_name": obj.get("father_name"),
"mother_name": obj.get("mother_name"),
"religion": obj.get("religion"),
"type_of_permit": obj.get("type_of_permit"),
"version_number": obj.get("version_number"),
"document_subtype": obj.get("document_subtype"),
"profession": obj.get("profession"),
"security_document_number": obj.get("security_document_number"),
"tax_number": obj.get("tax_number"),
"nist_identity_evidence_strength": obj.get("nist_identity_evidence_strength"),
"has_issuance_confirmation": obj.get("has_issuance_confirmation"),
"real_id_compliance": obj.get("real_id_compliance"),
"security_tier": obj.get("security_tier"),
"address_lines": DocumentPropertiesAddressLines.from_dict(obj["address_lines"]) if obj.get("address_lines") is not None else None,
"barcode": [DocumentPropertiesBarcodeInner.from_dict(_item) for _item in obj["barcode"]] if obj.get("barcode") is not None else None,
"nfc": DocumentPropertiesNfc.from_dict(obj["nfc"]) if obj.get("nfc") is not None else None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import json

from datetime import date
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from onfido.models.document_properties_address_lines import DocumentPropertiesAddressLines
from onfido.models.document_properties_barcode_inner import DocumentPropertiesBarcodeInner
Expand All @@ -38,6 +38,7 @@ class DocumentWithDriverVerificationReportAllOfProperties(BaseModel):
""" # noqa: E501
date_of_birth: Optional[date] = None
date_of_expiry: Optional[date] = None
personal_number: Optional[StrictStr] = None
document_numbers: Optional[List[DocumentPropertiesDocumentNumbersInner]] = None
document_type: Optional[StrictStr] = None
first_name: Optional[StrictStr] = None
Expand All @@ -57,7 +58,22 @@ class DocumentWithDriverVerificationReportAllOfProperties(BaseModel):
widow_name: Optional[StrictStr] = None
alias_name: Optional[StrictStr] = None
issuing_authority: Optional[StrictStr] = None
remarks: Optional[StrictStr] = None
civil_state: Optional[StrictStr] = None
expatriation: Optional[StrictStr] = None
father_name: Optional[StrictStr] = None
mother_name: Optional[StrictStr] = None
religion: Optional[StrictStr] = None
type_of_permit: Optional[StrictStr] = None
version_number: Optional[StrictStr] = None
document_subtype: Optional[StrictStr] = None
profession: Optional[StrictStr] = None
security_document_number: Optional[StrictStr] = None
tax_number: Optional[StrictStr] = None
nist_identity_evidence_strength: Optional[StrictStr] = None
has_issuance_confirmation: Optional[StrictStr] = None
real_id_compliance: Optional[StrictBool] = None
security_tier: Optional[StrictStr] = None
address_lines: Optional[DocumentPropertiesAddressLines] = None
barcode: Optional[List[DocumentPropertiesBarcodeInner]] = None
nfc: Optional[DocumentPropertiesNfc] = None
Expand All @@ -71,7 +87,37 @@ class DocumentWithDriverVerificationReportAllOfProperties(BaseModel):
vehicle_class_details: Optional[List[DocumentWithDriverVerificationReportAllOfPropertiesAllOfVehicleClassDetailsInner]] = Field(default=None, description="Detailed classes/categories information")
passenger_vehicle: Optional[DocumentWithDriverVerificationReportAllOfPropertiesAllOfPassengerVehicle] = None
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = ["date_of_birth", "date_of_expiry", "document_numbers", "document_type", "first_name", "gender", "issuing_country", "last_name", "nationality", "issuing_state", "issuing_date", "categorisation", "mrz_line1", "mrz_line2", "mrz_line3", "address", "place_of_birth", "spouse_name", "widow_name", "alias_name", "issuing_authority", "real_id_compliance", "address_lines", "barcode", "nfc", "driving_licence_information", "document_classification", "extracted_data", "drivers_licence", "restricted_licence", "raw_licence_category", "raw_vehicle_classes", "vehicle_class_details", "passenger_vehicle"]
__properties: ClassVar[List[str]] = ["date_of_birth", "date_of_expiry", "personal_number", "document_numbers", "document_type", "first_name", "gender", "issuing_country", "last_name", "nationality", "issuing_state", "issuing_date", "categorisation", "mrz_line1", "mrz_line2", "mrz_line3", "address", "place_of_birth", "spouse_name", "widow_name", "alias_name", "issuing_authority", "remarks", "civil_state", "expatriation", "father_name", "mother_name", "religion", "type_of_permit", "version_number", "document_subtype", "profession", "security_document_number", "tax_number", "nist_identity_evidence_strength", "has_issuance_confirmation", "real_id_compliance", "security_tier", "address_lines", "barcode", "nfc", "driving_licence_information", "document_classification", "extracted_data", "drivers_licence", "restricted_licence", "raw_licence_category", "raw_vehicle_classes", "vehicle_class_details", "passenger_vehicle"]

@field_validator('nist_identity_evidence_strength')
def nist_identity_evidence_strength_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in set(['superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength']):
raise ValueError("must be one of enum values ('superior', 'strong', 'fair', 'weak', 'unacceptable', 'unspecified_identity_evidence_strength')")
return value

@field_validator('has_issuance_confirmation')
def has_issuance_confirmation_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in set(['true', 'false', 'unspecified']):
raise ValueError("must be one of enum values ('true', 'false', 'unspecified')")
return value

@field_validator('security_tier')
def security_tier_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in set(['tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier']):
raise ValueError("must be one of enum values ('tier_1', 'tier_2', 'tier_3', 'tier_4', 'tier_5', 'unspecified_security_tier')")
return value

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -172,6 +218,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
_obj = cls.model_validate({
"date_of_birth": obj.get("date_of_birth"),
"date_of_expiry": obj.get("date_of_expiry"),
"personal_number": obj.get("personal_number"),
"document_numbers": [DocumentPropertiesDocumentNumbersInner.from_dict(_item) for _item in obj["document_numbers"]] if obj.get("document_numbers") is not None else None,
"document_type": obj.get("document_type"),
"first_name": obj.get("first_name"),
Expand All @@ -191,7 +238,22 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"widow_name": obj.get("widow_name"),
"alias_name": obj.get("alias_name"),
"issuing_authority": obj.get("issuing_authority"),
"remarks": obj.get("remarks"),
"civil_state": obj.get("civil_state"),
"expatriation": obj.get("expatriation"),
"father_name": obj.get("father_name"),
"mother_name": obj.get("mother_name"),
"religion": obj.get("religion"),
"type_of_permit": obj.get("type_of_permit"),
"version_number": obj.get("version_number"),
"document_subtype": obj.get("document_subtype"),
"profession": obj.get("profession"),
"security_document_number": obj.get("security_document_number"),
"tax_number": obj.get("tax_number"),
"nist_identity_evidence_strength": obj.get("nist_identity_evidence_strength"),
"has_issuance_confirmation": obj.get("has_issuance_confirmation"),
"real_id_compliance": obj.get("real_id_compliance"),
"security_tier": obj.get("security_tier"),
"address_lines": DocumentPropertiesAddressLines.from_dict(obj["address_lines"]) if obj.get("address_lines") is not None else None,
"barcode": [DocumentPropertiesBarcodeInner.from_dict(_item) for _item in obj["barcode"]] if obj.get("barcode") is not None else None,
"nfc": DocumentPropertiesNfc.from_dict(obj["nfc"]) if obj.get("nfc") is not None else None,
Expand Down
11 changes: 7 additions & 4 deletions onfido/webhook_event_verifier.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import hmac
import hashlib
import json

from .models import WebhookEvent


class OnfidoInvalidSignatureError(Exception):
pass


class WebhookEventVerifier:
def __init__(self, webhook_token):
self.webhook_token = webhook_token

def read_payload(self, raw_event, signature):
# Compute the the actual HMAC signature from the raw request body.
event_signature = hmac.new(key=self.webhook_token.encode("utf-8"),
msg=raw_event.encode("utf-8"),
digestmod=hashlib.sha256).hexdigest()
event_signature = hmac.new(
key=self.webhook_token.encode("utf-8"),
msg=raw_event.encode("utf-8"),
digestmod=hashlib.sha256,
).hexdigest()

# Compare the signatures (prevent against timing attacks).
if not hmac.compare_digest(signature, event_signature):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "onfido-python"
version = "3.1.0"
version = "3.2.0"
description = "Python library for the Onfido API"
authors = ["OpenAPI Generator Community <team@openapitools.org>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools
NAME = "onfido-python"
VERSION = "3.1.0"
VERSION = "3.2.0"
PYTHON_REQUIRES = ">=3.7"
REQUIRES = [
"urllib3 >= 1.25.3, < 2.1.0",
Expand Down

0 comments on commit eede871

Please sign in to comment.