-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sdk 2242 digital identity share v2 #415
Open
mehmet-yoti
wants to merge
12
commits into
development
Choose a base branch
from
SDK-2242-DigitalIdentity-Share-V2
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c556aef
SDK-2267:updated refs
mehmet-yoti f4368e3
SDK-2267:updated refs
mehmet-yoti 683a073
SDK-2242 added, create session, qrcode, and retrive session,receipt
mehmet-yoti 53cd367
SDK-2242 removed local test protobuf
mehmet-yoti 171bb0c
SDK-2242 added missing files
mehmet-yoti e92d211
Updated github actions
mehmet-yoti bd31f91
Updated github actions
mehmet-yoti 2cd58c4
Updated github actions
mehmet-yoti 8a1ac33
SDK-2242-removed-files
mehmet-yoti cc485cf
Updated referenced libraries
mehmet-yoti 9a8008c
Updated referenced libraries
mehmet-yoti df96b8f
removed unneccessary folder
mehmet-yoti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Required Keys | ||
YOTI_CLIENT_SDK_ID=yourClientSdkId | ||
YOTI_KEY_FILE_PATH=yourKeyFilePath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Yoti Share v2 Python Example | ||
|
||
## Running the example project | ||
|
||
1. Rename the [.env.example](.env.example) file to `.env` and fill in the required configuration values | ||
2. Add your SDK ID to the [templates/index.html](templates/index.html) file | ||
3. Create a virtual environment with `python3 -m venv .venv` | ||
4. Active the environment `. .venv/bin/activate` | ||
5. Install the dependencies with `pip install -r requirements.txt` | ||
6. Start the server `flask run --port 8000` | ||
7. Visit `http://127.0.0.1:8000` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import json, requests | ||
from flask import Flask, Response, request, render_template | ||
|
||
|
||
from cryptography.fernet import base64 | ||
|
||
from settings import YOTI_API_URL, YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH | ||
|
||
from yoti_python_sdk.digital_identity import ( | ||
DigitalIdentityClient | ||
) | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/") | ||
def index(): | ||
return render_template("index.html") | ||
|
||
@app.route("/sessions") | ||
def sessions(): | ||
session_config = { | ||
"policy": { | ||
"wanted": [ | ||
{ | ||
"name": "date_of_birth", | ||
"derivation": "age_over:18", | ||
"optional": "false" | ||
} | ||
, | ||
{ | ||
"name": "full_name" | ||
}, | ||
{ | ||
"name": "email_address" | ||
}, | ||
{ | ||
"name": "phone_number" | ||
}, | ||
{ | ||
"name": "selfie" | ||
}, | ||
{ | ||
"name": "date_of_birth", | ||
"derivation": "age_over:18" | ||
}, | ||
{ | ||
"name": "nationality" | ||
}, | ||
{ | ||
"name": "gender" | ||
}, | ||
{ | ||
"name": "document_details" | ||
}, | ||
{ | ||
"name": "document_images" | ||
}], | ||
"wanted_auth_types": [], | ||
"wanted_remember_me": "false", | ||
}, | ||
"extensions": [], | ||
"subject": { | ||
"subject_id": "some_subject_id_string" | ||
}, # Optional reference to a user ID | ||
"notification": { | ||
"url": "https://webhook.site/818dc66b-e18b-4767-92c5-47c7af21629c", | ||
"method": "POST", | ||
"headers": {}, | ||
"verifyTls": "true" | ||
}, | ||
"redirectUri": "/profile" # Mandatory redirect URI but not required for Non-browser flows | ||
} | ||
|
||
digital_identity_client = DigitalIdentityClient(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH, YOTI_API_URL) | ||
|
||
share_session_result = digital_identity_client.create_share_session(session_config) | ||
|
||
session_id = share_session_result.id | ||
|
||
# create_qr_code_result = create_share_qr_code(share_session_result.id) | ||
# get_share_session_result = get_share_session(share_session_result.id) | ||
# get_qr_code_result = get_share_qr_code(create_qr_code_result.id) | ||
|
||
# Return Session ID JSON | ||
return json.dumps({"session_id": session_id}) | ||
|
||
@app.route("/create-qr-code") | ||
def create_qr_code(): | ||
# Get query params - sessionId | ||
session_id = request.args.get('sessionId') | ||
digital_identity_client = DigitalIdentityClient(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH, YOTI_API_URL) | ||
|
||
# Create QR Code | ||
create_qr_code_result = digital_identity_client.create_share_qr_code(session_id) | ||
|
||
# Return QR Code ID and URI JSON | ||
return json.dumps({"qr_code_id": create_qr_code_result.id, "qr_code_uri": create_qr_code_result.uri}) | ||
|
||
@app.route("/render-qr-code") | ||
def render_qr_code(): | ||
# Get query params - qrCodeUri | ||
qr_code_uri = request.args.get('qrCodeUri') | ||
# Make a POST request to the API to create a QR Code image | ||
url = "https://api.yoti.com/api/v1/qrcodes/image" | ||
payload = { "url": str(qr_code_uri) } | ||
headers = { | ||
"Accept": "image/png", | ||
"Content-Type": "application/json" | ||
} | ||
|
||
response = requests.request("POST", url, json=payload, headers=headers) | ||
|
||
# Return QR Code Image as PNG | ||
return Response(response.content, mimetype='image/png') | ||
|
||
@app.route("/profile") | ||
def profile(): | ||
# Get query params - receiptId | ||
receipt_id = request.args.get('receiptId') | ||
digital_identity_client = DigitalIdentityClient(YOTI_CLIENT_SDK_ID, YOTI_KEY_FILE_PATH, YOTI_API_URL) | ||
|
||
share_receipt = digital_identity_client.get_share_receipt(receipt_id) | ||
age_over_verification = share_receipt.userContent.profile.find_age_over_verification(18) | ||
selfie = share_receipt.userContent.profile.selfie.value | ||
attribute_list = share_receipt.userContent.profile.attributes | ||
full_name = share_receipt.userContent.profile.full_name.value | ||
data = base64.b64encode(selfie).decode("utf-8") | ||
selfie_image = "data:{0};base64,{1}".format("image/jpeg", data) | ||
age_verified = age_over_verification.result | ||
|
||
return render_template("profile.html", age_verified=age_verified, selfie=selfie, full_name=full_name, selfie_image=selfie_image, attribute_list = attribute_list) | ||
|
||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", ssl_context="adhoc") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
flask>=3.0.1 | ||
python-dotenv>=1.0.1 | ||
yoti>=2.15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.11 | ||
# by the following command: | ||
# | ||
# pip-compile --output-file=requirements.txt requirements.in | ||
# | ||
asn1==2.2.0 | ||
# via yoti | ||
blinker==1.7.0 | ||
# via flask | ||
certifi==2023.11.17 | ||
# via requests | ||
cffi==1.16.0 | ||
# via cryptography | ||
charset-normalizer==3.3.2 | ||
# via requests | ||
click==8.1.7 | ||
# via flask | ||
cryptography==42.0.1 | ||
# via | ||
# pyopenssl | ||
# yoti | ||
deprecated==1.2.10 | ||
# via yoti | ||
flask==3.0.1 | ||
# via -r requirements.in | ||
future==0.18.3 | ||
# via yoti | ||
idna==3.6 | ||
# via requests | ||
iso8601==0.1.13 | ||
# via yoti | ||
itsdangerous==2.1.2 | ||
# via flask | ||
jinja2==3.1.3 | ||
# via flask | ||
markupsafe==2.1.4 | ||
# via | ||
# jinja2 | ||
# werkzeug | ||
protobuf==3.20.1 | ||
# via yoti | ||
pycparser==2.21 | ||
# via cffi | ||
pyopenssl==24.0.0 | ||
# via yoti | ||
python-dotenv==1.0.1 | ||
# via -r requirements.in | ||
pytz==2022.1 | ||
# via yoti | ||
requests==2.31.0 | ||
# via yoti | ||
urllib3==2.1.0 | ||
# via requests | ||
werkzeug==3.0.1 | ||
# via flask | ||
wrapt==1.16.0 | ||
# via deprecated | ||
yoti==2.15 | ||
# via -r requirements.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from os import environ | ||
from os.path import dirname, join | ||
|
||
from dotenv import load_dotenv | ||
|
||
dotenv_path = join(dirname(__file__), ".env") | ||
load_dotenv(dotenv_path) | ||
|
||
YOTI_CLIENT_SDK_ID = environ.get("YOTI_CLIENT_SDK_ID", None) | ||
YOTI_KEY_FILE_PATH = environ.get("YOTI_KEY_FILE_PATH", None) | ||
YOTI_API_URL = environ.get("YOTI_API_URL", "https://api.yoti.com/share") | ||
|
||
if YOTI_CLIENT_SDK_ID is None or YOTI_KEY_FILE_PATH is None: | ||
raise ValueError("YOTI_CLIENT_SDK_ID or YOTI_KEY_FILE_PATH is None") | ||
|
||
YOTI_APP_BASE_URL = environ.get("YOTI_APP_BASE_URL", "https://127.0.0.1:8000") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
examples/digitalidentity/static/assets/icons/chevron-down-grey.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to change URL to
https://example.com/webhook-url
.