Skip to content

Commit

Permalink
Merge pull request #255 from getyoti/release/2.13.0
Browse files Browse the repository at this point in the history
Release 2.13.0
  • Loading branch information
davidgrayston authored Oct 21, 2020
2 parents a29fb7f + 5931a55 commit 2e003b7
Show file tree
Hide file tree
Showing 58 changed files with 917 additions and 221 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- pip install -r requirements.txt
- pip install -e .[dev]
script:
- py.test -v
- pytest -v
- <<: *test
python: "3.4"
- <<: *test
Expand Down
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ How to manage users
1) [Running the examples](#running-the-examples) -
How to retrieve a Yoti profile using the token

1) [Running the tests](#running-the-tests) -
Running tests for SDK example

1) [API Coverage](#api-coverage) -
Attributes defined

Expand Down Expand Up @@ -196,14 +193,6 @@ To run the Flask or Django container:
* [Profile - Flask](examples/yoti_example_flask)
* [Doc Scan](examples/doc_scan)

## Running the Tests

Running the tests is done by the following process, ensuring you are using Python 3.0+:

1. Install dependencies: `pip install -r requirements.txt`
1. Install the SDK and development dependencies: `pip install .[dev]`
1. Execute in the main project dir: `py.test`

## API Coverage

* Activity Details
Expand Down
2 changes: 1 addition & 1 deletion examples/doc_scan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
1. Rename the [.env.example](.env.example) file to `.env` and fill in the required configuration values
1. Install the dependencies with `pip install -r requirements.txt`
1. Start the server `flask run --cert=adhoc`
1. Visit `https://localhost:5000`
1. Visit `https://localhost:5000`
58 changes: 33 additions & 25 deletions examples/doc_scan/app.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import base64
from io import BytesIO

import yoti_python_sdk
from filetype import filetype
from flask import Flask, Response, render_template, request, send_file, session
from flask import Flask, Response, render_template, request, session
from yoti_python_sdk.doc_scan import (
DocScanClient,
RequestedDocumentAuthenticityCheckBuilder,
RequestedFaceMatchCheckBuilder,
RequestedIDDocumentComparisonCheckBuilder,
RequestedLivenessCheckBuilder,
RequestedTextExtractionTaskBuilder,
SdkConfigBuilder,
SessionSpecBuilder,
)
from yoti_python_sdk.doc_scan.exception import DocScanException
from yoti_python_sdk.doc_scan.session.create.filter import (
RequiredIdDocumentBuilder,
DocumentRestrictionBuilder,
DocumentRestrictionsFilterBuilder,
)

from .settings import YOTI_APP_BASE_URL, YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH

Expand Down Expand Up @@ -48,26 +50,49 @@ def create_session():
.with_client_session_token_ttl(600)
.with_resources_ttl(90000)
.with_user_tracking_id("some-user-tracking-id")
.with_requested_check(RequestedDocumentAuthenticityCheckBuilder().build())
.with_requested_check(
RequestedDocumentAuthenticityCheckBuilder()
.with_manual_check_never()
.build()
)
.with_requested_check(
RequestedLivenessCheckBuilder()
.for_zoom_liveness()
.with_max_retries(1)
.build()
)
.with_requested_check(
RequestedFaceMatchCheckBuilder().with_manual_check_fallback().build()
RequestedFaceMatchCheckBuilder().with_manual_check_never().build()
)
.with_requested_check(RequestedIDDocumentComparisonCheckBuilder().build())
.with_requested_task(
RequestedTextExtractionTaskBuilder().with_manual_check_always().build()
RequestedTextExtractionTaskBuilder()
.with_manual_check_never()
.with_chip_data_desired()
.build()
)
.with_sdk_config(sdk_config)
.with_required_document(build_required_id_document_restriction("PASSPORT"))
.with_required_document(
build_required_id_document_restriction("DRIVING_LICENCE")
)
.build()
)

return doc_scan_client.create_session(session_spec)


def build_required_id_document_restriction(document_type):
document_restriction = (
DocumentRestrictionBuilder().with_document_types([document_type]).build()
)

filter_builder = DocumentRestrictionsFilterBuilder().for_whitelist()
filter_builder.with_document_restriction(document_restriction)

return RequiredIdDocumentBuilder().with_filter(filter_builder.build()).build()


@app.route("/")
def index():
try:
Expand Down Expand Up @@ -118,8 +143,6 @@ def media():

doc_scan_client = DocScanClient(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH)

base64_req = request.args.get("base64", "0")

session_id = session.get("doc_scan_session_id", None)
if session_id is None:
return Response("No session ID available", status=404)
Expand All @@ -129,21 +152,6 @@ def media():
except DocScanException as e:
return render_template("error.html", error=e.text)

if base64_req == "1" and retrieved_media.mime_type == "application/octet-stream":
decoded = base64.b64decode(retrieved_media.content)
info = filetype.guess(decoded)

buffer = BytesIO()
buffer.write(decoded)
buffer.seek(0)

return send_file(
buffer,
attachment_filename="media." + info.extension,
mimetype=info.mime,
as_attachment=True,
)

return Response(
retrieved_media.content, content_type=retrieved_media.mime_type, status=200
)
Expand Down
144 changes: 89 additions & 55 deletions examples/doc_scan/templates/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ <h1>Get Session Result</h1>
<td>User Tracking ID</td>
<td>{{ session_result.user_tracking_id }}</td>
</tr>
{% if session_result.biometric_consent_timestamp is not none %}
<tr>
<td>Biometric Consent Timestamp</td>
<td>{{ session_result.biometric_consent_timestamp }}</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
Expand Down Expand Up @@ -134,6 +140,29 @@ <h3 class="mb-0">
</div>
</div>
{% endif %}

{% if session_result.id_document_comparison_checks|length > 0 %}
<div class="card">
<div class="card-header" id="comparison-checks">
<h3 class="mb-0">
<button aria-controls="collapse-comparison-checks" aria-expanded="true" class="btn btn-link"
data-target="#collapse-comparison-checks" data-toggle="collapse"
type="button">
ID Document Comparison Checks
</button>
</h3>
</div>
<div aria-labelledby="comparison-checks" class="collapse" id="collapse-comparison-checks">
<div class="card-body">
{% for check in session_result.id_document_comparison_checks %}
{% with check=check %}
{% include "partials/check.html" %}
{% endwith %}
{% endfor %}
</div>
</div>
</div>
{% endif %}
</div>
</div>
</div>
Expand All @@ -149,7 +178,7 @@ <h2>ID Documents</h2>

{% with doc_num=0 %}
{% for document in session_result.resources.id_documents %}
{% set doc_num = loop.index + 1 %}
{% set doc_num = loop.index %}
<div class="row pt-4">
<div class="col">

Expand Down Expand Up @@ -193,6 +222,26 @@ <h5>Media</h5>
</div>
</div>
{% endif %}

{% if document.document_id_photo is not none %}
<div class="card">
<div class="card-header" id="document-id-photo-{{ doc_num }}">
<h4 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapse-document-id-photo-{{ doc_num }}" aria-expanded="true" aria-controls="collapse-document-id-photo-{{ doc_num }}">
Document ID Photo
</button>
</h4>
</div>
<div id="collapse-document-id-photo-{{ doc_num }}" class="collapse" aria-labelledby="document-id-photo-{{ doc_num }}">
<div class="card-body">
{% if document.document_fields.media is not none %}
<img class="card-img-top" src="/media?mediaId={{ document.document_id_photo.media.id }}" />
{% endif %}
</div>
</div>
</div>
{% endif %}

{% if document.text_extraction_tasks|length > 0 %}
<div class="card">
<div class="card-header" id="text-extraction-tasks-{{ doc_num }}">
Expand Down Expand Up @@ -256,36 +305,54 @@ <h5>Generated Media</h5>
{% endif %}

{% if document.pages|length > 0 %}
{% with page_num=0 %}
{% for page in document.pages %}
{% set page_num = loop.index %}
<div class="card">
<div class="card-header" id="document-pages-{{ doc_num }}">
<div class="card-header" id="document-pages-{{ doc_num }}-{{ page_num }}">
<h4 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse"
data-target="#collapse-document-pages-{{ doc_num }}"
data-target="#collapse-document-pages-{{ doc_num }}-{{ page_num }}"
aria-expanded="true"
aria-controls="collapse-document-pages-{{ doc_num }}">
Pages
aria-controls="collapse-document-pages-{{ doc_num }}-{{ page_num }}">
Page {{ page_num }}
</button>
</h4>
</div>
<div id="collapse-document-pages-{{ doc_num }}" class="collapse"
aria-labelledby="document-pages-{{ doc_num }}">
<div class="card-body">
<div class="card-group">
{% for page in document.pages %}
{% if page.media is not none %}
<div class="card" style="width: 18rem;">
<img class="card-img-top"
src="/media?mediaId={{ page.media.id }}"/>
<div class="card-body">
<p>Method: {{ page.capture_method }}</p>
</div>
<div id="collapse-document-pages-{{ doc_num }}-{{ page_num }}" class="collapse"
aria-labelledby="document-pages-{{ doc_num }}-{{ page_num }}">

<div class="card-group">
{% if page.media is not none %}
<div class="card" style="width: 18rem;">
<img class="card-img-top"
src="/media?mediaId={{ page.media.id }}"/>
<div class="card-body">
<p>Method: {{ page.capture_method }}</p>
</div>
</div>
{% endif %}
</div>

{% if page.frames|length > 0 %}
<div class="card-group">
{% for frame in page.frames %}
{% if frame.media is not none %}
<div class="card">
<img class="card-img-top" src="/media?mediaId={{ frame.media.id }}" />
<div class="card-body">
<h5 class="card-title">Frame</h5>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}

</div>
</div>
{% endfor %}
{% endwith %}
{% endif %}
</div>
</div>
Expand All @@ -303,7 +370,7 @@ <h2>Zoom Liveness Resources</h2>

{% with liveness_num=0 %}
{% for liveness in session_result.resources.zoom_liveness_resources %}
{% set liveness_num = loop.index + 1 %}
{% set liveness_num = loop.index %}
<div class="row pt-4">
<div class="col">
<table class="table table-striped table-light">
Expand All @@ -317,39 +384,6 @@ <h2>Zoom Liveness Resources</h2>

<div class="accordion mt-3">

{% if liveness.facemap is not none %}
<div class="card">
<div class="card-header" id="liveness-{{ liveness_num }}-facemap">
<h3 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse"
data-target="#collapse-liveness-{{ liveness_num }}-facemap" aria-expanded="true"
aria-controls="collapse-liveness-{{ liveness_num }}-facemap">
Face Map
</button>
</h3>
</div>
<div id="collapse-liveness-{{ liveness_num }}-facemap" class="collapse" aria-labelledby="liveness-{{ liveness_num }}-facemap">
<div class="card-body">
{% if liveness.facemap.media is not none %}
<h4>Media</h4>
<table class="table table-striped">
<tbody>
<tr>
<td>ID</td>
<td>
<a href="/media?mediaId={{ liveness.facemap.media.id }}&base64=1">
{{ liveness.facemap.media.id }}
</a>
</td>
</tr>
</tbody>
</table>
{% endif %}
</div>
</div>
</div>
{% endif %}

{% if liveness.frames|length > 0 %}
<div class="card">
<div class="card-header" id="liveness-{{ liveness_num }}-frames">
Expand Down Expand Up @@ -383,4 +417,4 @@ <h5 class="card-title">Frame</h5>
{% endfor %}
{% endwith %}
</div>
{% include "layout/footer.html" %}
{% include "layout/footer.html" %}
10 changes: 5 additions & 5 deletions examples/yoti_example_django/yoti_example/static/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
font-size: 40px;
font-weight: 700;
line-height: 1.2;

margin: 0;
margin-top: 0;
margin-bottom: 80px;

text-align: center;

Expand All @@ -45,8 +45,8 @@
}

#yoti-share-button {
width: 130px;
height: 50px;
width: 250px;
height: 45px;
}

.yoti-login-or-separator {
Expand All @@ -56,7 +56,7 @@
font-weight: bold;
line-height: 1.5;
text-align: center;
margin-bottom: 30px;
margin-top: 30px;
}

.yoti-login-dialog {
Expand Down
Loading

0 comments on commit 2e003b7

Please sign in to comment.