usesmileid 12.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- usesmileid-12.0.0/.github/auto-assign.yml +3 -0
- usesmileid-12.0.0/.github/dependabot.yml +16 -0
- usesmileid-12.0.0/.github/workflows/audit.yml +42 -0
- usesmileid-12.0.0/.github/workflows/auto-author-assign.yml +21 -0
- usesmileid-12.0.0/.github/workflows/e2e.yml +49 -0
- usesmileid-12.0.0/.github/workflows/release.yml +86 -0
- usesmileid-12.0.0/.github/workflows/semgrep.yml +146 -0
- usesmileid-12.0.0/.github/workflows/stale.yml +32 -0
- usesmileid-12.0.0/.github/workflows/test.yml +41 -0
- usesmileid-12.0.0/.gitignore +33 -0
- usesmileid-12.0.0/AGENTS.md +30 -0
- usesmileid-12.0.0/CHANGELOG.md +40 -0
- usesmileid-12.0.0/LICENSE +21 -0
- usesmileid-12.0.0/PKG-INFO +387 -0
- usesmileid-12.0.0/README.md +359 -0
- usesmileid-12.0.0/SECURITY.md +30 -0
- usesmileid-12.0.0/example/.gitignore +9 -0
- usesmileid-12.0.0/example/.semgrep.yml +15 -0
- usesmileid-12.0.0/example/AGENTS.md +16 -0
- usesmileid-12.0.0/example/LICENSE +21 -0
- usesmileid-12.0.0/example/README.md +69 -0
- usesmileid-12.0.0/example/pyproject.toml +40 -0
- usesmileid-12.0.0/example/src/smileid_example/__init__.py +1 -0
- usesmileid-12.0.0/example/src/smileid_example/__main__.py +4 -0
- usesmileid-12.0.0/example/src/smileid_example/app.py +206 -0
- usesmileid-12.0.0/example/tests/conftest.py +7 -0
- usesmileid-12.0.0/example/tests/test_app.py +237 -0
- usesmileid-12.0.0/pyproject.toml +64 -0
- usesmileid-12.0.0/tests/__init__.py +1 -0
- usesmileid-12.0.0/tests/conftest.py +102 -0
- usesmileid-12.0.0/tests/test_e2e_sandbox.py +64 -0
- usesmileid-12.0.0/tests/test_errors.py +177 -0
- usesmileid-12.0.0/tests/test_hardening.py +281 -0
- usesmileid-12.0.0/tests/test_multipart_serialization.py +299 -0
- usesmileid-12.0.0/tests/test_polling.py +128 -0
- usesmileid-12.0.0/tests/test_responses.py +196 -0
- usesmileid-12.0.0/tests/test_retries.py +204 -0
- usesmileid-12.0.0/tests/test_token_lifecycle.py +116 -0
- usesmileid-12.0.0/tests/test_validation.py +171 -0
- usesmileid-12.0.0/tests/test_version.py +5 -0
- usesmileid-12.0.0/usesmileid/__init__.py +57 -0
- usesmileid-12.0.0/usesmileid/_version.py +3 -0
- usesmileid-12.0.0/usesmileid/client/__init__.py +10 -0
- usesmileid-12.0.0/usesmileid/client/auth.py +62 -0
- usesmileid-12.0.0/usesmileid/client/client.py +533 -0
- usesmileid-12.0.0/usesmileid/client/config.py +73 -0
- usesmileid-12.0.0/usesmileid/client/transport.py +227 -0
- usesmileid-12.0.0/usesmileid/errors/__init__.py +193 -0
- usesmileid-12.0.0/usesmileid/generated/__init__.py +6 -0
- usesmileid-12.0.0/usesmileid/generated/models.py +139 -0
- usesmileid-12.0.0/usesmileid/generated/operations.py +438 -0
- usesmileid-12.0.0/usesmileid/helpers/__init__.py +18 -0
- usesmileid-12.0.0/usesmileid/helpers/consent.py +50 -0
- usesmileid-12.0.0/usesmileid/helpers/fraud.py +54 -0
- usesmileid-12.0.0/usesmileid/helpers/multipart.py +77 -0
- usesmileid-12.0.0/usesmileid/helpers/polling.py +40 -0
- usesmileid-12.0.0/usesmileid/helpers/user_details.py +54 -0
- usesmileid-12.0.0/usesmileid/py.typed +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: pip
|
|
4
|
+
open-pull-requests-limit: 0
|
|
5
|
+
directory: /
|
|
6
|
+
schedule:
|
|
7
|
+
interval: weekly
|
|
8
|
+
- package-ecosystem: github-actions
|
|
9
|
+
open-pull-requests-limit: 5
|
|
10
|
+
directory: /
|
|
11
|
+
schedule:
|
|
12
|
+
interval: weekly
|
|
13
|
+
groups:
|
|
14
|
+
github-actions:
|
|
15
|
+
patterns:
|
|
16
|
+
- '*'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Security Audit
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
paths:
|
|
6
|
+
- 'pyproject.toml'
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
schedule:
|
|
9
|
+
- cron: '0 9 * * *'
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
security-audit:
|
|
13
|
+
name: Security Audit
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
issues: write
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
20
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
21
|
+
with:
|
|
22
|
+
python-version: '3.12'
|
|
23
|
+
- name: Install package
|
|
24
|
+
run: pip install -e .
|
|
25
|
+
- name: Run pip-audit
|
|
26
|
+
uses: pypa/gh-action-pip-audit@1220774d901786e6f652ae159f7b6bc8fea6d266 # v1.1.0
|
|
27
|
+
with:
|
|
28
|
+
inputs: .
|
|
29
|
+
- name: Create issue on failure
|
|
30
|
+
if: failure() && github.event_name != 'pull_request'
|
|
31
|
+
env:
|
|
32
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
33
|
+
run: |
|
|
34
|
+
EXISTING=$(gh issue list --label "security-audit" --state open --json number --jq 'length' || echo "0")
|
|
35
|
+
if [ "${EXISTING:-0}" -gt 0 ]; then exit 0; fi
|
|
36
|
+
TITLE_DATE=$(date +%Y-%m-%d)
|
|
37
|
+
gh label create "security-audit" --color "D93F0B" --force 2>/dev/null || true
|
|
38
|
+
gh label create "priority:high" --color "B60205" --force 2>/dev/null || true
|
|
39
|
+
gh issue create \
|
|
40
|
+
--title "Security: Python dependency vulnerabilities detected (${TITLE_DATE})" \
|
|
41
|
+
--label "security-audit,priority:high" \
|
|
42
|
+
--body "The daily security audit has detected vulnerabilities. See [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details."
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Not present in the org's other core SDK repos (ruby / js); added here as a
|
|
2
|
+
# standard community-health workflow, following the org's SHA-pinning convention.
|
|
3
|
+
|
|
4
|
+
name: Auto Author Assign
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
pull_request_target:
|
|
8
|
+
types: [opened, reopened]
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
# Adding assignees goes through the issues API; reviewers through pull-requests.
|
|
12
|
+
issues: write
|
|
13
|
+
pull-requests: write
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
assign-author:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: kentaro-m/auto-assign-action@0a2c53d3721e4c5cfcce6afd4014aecc337979f6 # v2.0.2
|
|
20
|
+
with:
|
|
21
|
+
configuration-path: .github/auto-assign.yml
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Live end-to-end test against a real Smile ID environment. Runs on pushes to
|
|
2
|
+
# main and nightly so live-API drift is caught outside the PR loop — fork PRs
|
|
3
|
+
# get no secrets, so this never runs on pull_request.
|
|
4
|
+
|
|
5
|
+
name: E2E Sandbox
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
branches: [main]
|
|
10
|
+
schedule:
|
|
11
|
+
- cron: '23 2 * * *'
|
|
12
|
+
workflow_dispatch:
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
concurrency:
|
|
18
|
+
group: e2e-${{ github.event_name }}-${{ github.ref }}
|
|
19
|
+
cancel-in-progress: true
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
e2e:
|
|
23
|
+
if: github.repository == 'smileidentity/smileid-sdk-python'
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
timeout-minutes: 10
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
28
|
+
with:
|
|
29
|
+
persist-credentials: false
|
|
30
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
31
|
+
with:
|
|
32
|
+
python-version: '3.12'
|
|
33
|
+
- name: Install package
|
|
34
|
+
run: pip install -e ".[dev]"
|
|
35
|
+
- name: Run live sandbox E2E
|
|
36
|
+
env:
|
|
37
|
+
SMILE_PARTNER_ID: ${{ secrets.SMILE_PARTNER_ID }}
|
|
38
|
+
SMILE_API_KEY: ${{ secrets.SMILE_API_KEY }}
|
|
39
|
+
SMILE_BASE_URL: ${{ secrets.SMILE_E2E_BASE_URL }}
|
|
40
|
+
run: |
|
|
41
|
+
set -o pipefail
|
|
42
|
+
python -m pytest tests/test_e2e_sandbox.py -v -ra | tee pytest-output.txt
|
|
43
|
+
# A skip exits 0, so a passing pytest run alone doesn't prove the
|
|
44
|
+
# test executed against real creds. Fail the job unless the summary
|
|
45
|
+
# line shows exactly one passed test.
|
|
46
|
+
if ! grep -qE '(^| )1 passed( |$)' pytest-output.txt; then
|
|
47
|
+
echo "::error::E2E test did not report '1 passed' (skipped or failed) — check SMILE_PARTNER_ID/SMILE_API_KEY secrets."
|
|
48
|
+
exit 1
|
|
49
|
+
fi
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Publishes usesmileid to PyPI when a `vX.Y.Z` tag is pushed. Uses PyPI
|
|
2
|
+
# trusted publishing (OIDC) — no long-lived token stored in this repo.
|
|
3
|
+
|
|
4
|
+
name: Release
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags:
|
|
9
|
+
# vX.Y.Z plus any PEP 440 suffix (v1.2.3rc1, v1.2.3.post1). Keeps a
|
|
10
|
+
# stray tag like `vtest` from starting a publish job at all.
|
|
11
|
+
- 'v[0-9]+.[0-9]+.[0-9]+*'
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
# One publish at a time per tag, so a re-pushed tag can't race itself.
|
|
17
|
+
concurrency:
|
|
18
|
+
group: release-${{ github.ref }}
|
|
19
|
+
cancel-in-progress: false
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
release:
|
|
23
|
+
if: github.repository == 'smileidentity/smileid-sdk-python'
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
environment: pypi
|
|
26
|
+
permissions:
|
|
27
|
+
contents: write
|
|
28
|
+
id-token: write
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
31
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
32
|
+
with:
|
|
33
|
+
python-version: '3.12'
|
|
34
|
+
|
|
35
|
+
- name: Check tag matches package version
|
|
36
|
+
run: |
|
|
37
|
+
TAG_VERSION="${GITHUB_REF_NAME#v}"
|
|
38
|
+
PKG_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
|
|
39
|
+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
|
|
40
|
+
echo "::error::Tag v$TAG_VERSION does not match pyproject.toml version $PKG_VERSION"
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
- name: Install package
|
|
45
|
+
run: pip install -e ".[dev]"
|
|
46
|
+
|
|
47
|
+
- name: Test
|
|
48
|
+
run: pytest
|
|
49
|
+
|
|
50
|
+
- name: Lint
|
|
51
|
+
run: ruff check .
|
|
52
|
+
|
|
53
|
+
- name: Type check
|
|
54
|
+
run: mypy usesmileid
|
|
55
|
+
|
|
56
|
+
- name: Build sdist and wheel
|
|
57
|
+
run: |
|
|
58
|
+
# Clear anything an earlier step left behind, so `twine check` and
|
|
59
|
+
# the publish below only ever see this build's artefacts.
|
|
60
|
+
rm -rf dist build
|
|
61
|
+
pip install build twine
|
|
62
|
+
python -m build
|
|
63
|
+
# Catches broken metadata or an unrenderable README before the
|
|
64
|
+
# upload, which PyPI will not let us replace.
|
|
65
|
+
twine check --strict dist/*
|
|
66
|
+
|
|
67
|
+
- name: Smoke-test built wheel
|
|
68
|
+
run: |
|
|
69
|
+
python -m venv /tmp/wheel-smoke
|
|
70
|
+
/tmp/wheel-smoke/bin/pip install "$(ls dist/*.whl)"
|
|
71
|
+
cd /tmp && /tmp/wheel-smoke/bin/python -c "import usesmileid"
|
|
72
|
+
|
|
73
|
+
- name: Publish to PyPI
|
|
74
|
+
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
|
|
75
|
+
with:
|
|
76
|
+
skip-existing: true
|
|
77
|
+
|
|
78
|
+
- name: Create GitHub release
|
|
79
|
+
env:
|
|
80
|
+
GH_TOKEN: ${{ github.token }}
|
|
81
|
+
run: |
|
|
82
|
+
set -euo pipefail
|
|
83
|
+
if ! gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
|
84
|
+
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
|
|
85
|
+
--verify-tag --generate-notes
|
|
86
|
+
fi
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
name: Semgrep SAST
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
actions: read
|
|
11
|
+
security-events: write
|
|
12
|
+
pull-requests: write
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
semgrep:
|
|
16
|
+
name: Semgrep Security Scan
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
timeout-minutes: 15
|
|
19
|
+
container:
|
|
20
|
+
image: semgrep/semgrep:1.157.0
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
|
|
23
|
+
|
|
24
|
+
- name: Run Semgrep
|
|
25
|
+
continue-on-error: true
|
|
26
|
+
run: semgrep scan --config p/security-audit --sarif -o semgrep.sarif
|
|
27
|
+
|
|
28
|
+
- name: Upload SARIF to GitHub Security
|
|
29
|
+
if: always()
|
|
30
|
+
continue-on-error: true
|
|
31
|
+
uses: github/codeql-action/upload-sarif@5595ccaf912efad79be6eef63a5619ff05969be3 # v4
|
|
32
|
+
with:
|
|
33
|
+
sarif_file: semgrep.sarif
|
|
34
|
+
|
|
35
|
+
- name: Import results into DefectDojo
|
|
36
|
+
if: always()
|
|
37
|
+
continue-on-error: true
|
|
38
|
+
env:
|
|
39
|
+
DEFECTDOJO_URL: ${{ secrets.DEFECTDOJO_URL }}
|
|
40
|
+
DEFECTDOJO_API_TOKEN: ${{ secrets.DEFECTDOJO_API_TOKEN }}
|
|
41
|
+
REPO_NAME: ${{ github.event.repository.name }}
|
|
42
|
+
BRANCH_TAG: ${{ github.head_ref || github.ref_name }}
|
|
43
|
+
run: |
|
|
44
|
+
if [ ! -s semgrep.sarif ]; then
|
|
45
|
+
echo "No semgrep.sarif file found, skipping DefectDojo import"
|
|
46
|
+
exit 0
|
|
47
|
+
fi
|
|
48
|
+
curl -sS -f \
|
|
49
|
+
-H "Authorization: Token ${DEFECTDOJO_API_TOKEN}" \
|
|
50
|
+
-F "scan_type=SARIF" \
|
|
51
|
+
-F "file=@semgrep.sarif" \
|
|
52
|
+
-F "product_type_name=GitHub" \
|
|
53
|
+
-F "product_name=${REPO_NAME}" \
|
|
54
|
+
-F "engagement_name=CI" \
|
|
55
|
+
-F "auto_create_context=true" \
|
|
56
|
+
-F "close_old_findings=true" \
|
|
57
|
+
-F "deduplication_on_engagement=true" \
|
|
58
|
+
-F "commit_hash=${{ github.sha }}" \
|
|
59
|
+
-F "branch_tag=${BRANCH_TAG}" \
|
|
60
|
+
"${DEFECTDOJO_URL}/api/v2/reimport-scan/"
|
|
61
|
+
|
|
62
|
+
- name: Comment findings on PR
|
|
63
|
+
if: github.event_name == 'pull_request' && always()
|
|
64
|
+
env:
|
|
65
|
+
GH_TOKEN: ${{ github.token }}
|
|
66
|
+
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
67
|
+
run: |
|
|
68
|
+
python3 << 'PYEOF'
|
|
69
|
+
import json, os, urllib.request
|
|
70
|
+
|
|
71
|
+
marker = "<!-- semgrep-results -->"
|
|
72
|
+
repo = os.environ.get("GITHUB_REPOSITORY", "")
|
|
73
|
+
pr = os.environ.get("PR_NUMBER", "")
|
|
74
|
+
token = os.environ.get("GH_TOKEN", "")
|
|
75
|
+
api = f"https://api.github.com/repos/{repo}/issues/{pr}/comments"
|
|
76
|
+
headers = {
|
|
77
|
+
"Authorization": f"Bearer {token}",
|
|
78
|
+
"Accept": "application/vnd.github+json",
|
|
79
|
+
"X-GitHub-Api-Version": "2022-11-28",
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
findings = []
|
|
83
|
+
try:
|
|
84
|
+
with open("semgrep.sarif") as f:
|
|
85
|
+
sarif = json.load(f)
|
|
86
|
+
for run in sarif.get("runs", []):
|
|
87
|
+
for result in run.get("results", []):
|
|
88
|
+
rule_id = result.get("ruleId", "unknown")
|
|
89
|
+
message = result.get("message", {}).get("text", "")
|
|
90
|
+
level = result.get("level", "warning")
|
|
91
|
+
for loc in result.get("locations", []):
|
|
92
|
+
phys = loc.get("physicalLocation", {})
|
|
93
|
+
path = phys.get("artifactLocation", {}).get("uri", "?")
|
|
94
|
+
line = phys.get("region", {}).get("startLine", "?")
|
|
95
|
+
findings.append({"rule": rule_id, "message": message,
|
|
96
|
+
"level": level, "file": path, "line": line})
|
|
97
|
+
except (FileNotFoundError, json.JSONDecodeError):
|
|
98
|
+
pass
|
|
99
|
+
|
|
100
|
+
if findings:
|
|
101
|
+
body = f"{marker}\n## 🔍 Semgrep Security Scan Results\n\n"
|
|
102
|
+
body += f"**{len(findings)} finding(s)** detected by "
|
|
103
|
+
body += "[`p/security-audit`](https://semgrep.dev/p/security-audit) ruleset.\n\n"
|
|
104
|
+
body += "| # | Severity | Rule | File | Line | Message |\n"
|
|
105
|
+
body += "|---|----------|------|------|------|---------|\n"
|
|
106
|
+
for i, f in enumerate(findings[:25], 1):
|
|
107
|
+
rule = f["rule"].split(".")[-1] if "." in f["rule"] else f["rule"]
|
|
108
|
+
msg = f["message"].replace("|", "\\|").replace("\n", " ")
|
|
109
|
+
msg = (msg[:80] + "...") if len(msg) > 80 else msg
|
|
110
|
+
body += f'| {i} | {f["level"].upper()} | `{rule}` '
|
|
111
|
+
body += f'| `{f["file"]}` | {f["line"]} | {msg} |\n'
|
|
112
|
+
if len(findings) > 25:
|
|
113
|
+
body += f"\n*... and {len(findings) - 25} more. "
|
|
114
|
+
body += "See full results in workflow logs.*\n"
|
|
115
|
+
body += "\n> ⚠️ These findings are **non-blocking**. "
|
|
116
|
+
body += "Please review and address as appropriate.\n"
|
|
117
|
+
else:
|
|
118
|
+
body = f"{marker}\n## 🔍 Semgrep Security Scan Results\n\n"
|
|
119
|
+
body += "✅ No security findings detected by "
|
|
120
|
+
body += "[`p/security-audit`](https://semgrep.dev/p/security-audit) ruleset.\n"
|
|
121
|
+
|
|
122
|
+
existing_id = None
|
|
123
|
+
try:
|
|
124
|
+
req = urllib.request.Request(api, headers=headers)
|
|
125
|
+
resp = urllib.request.urlopen(req)
|
|
126
|
+
for c in json.loads(resp.read()):
|
|
127
|
+
if marker in c.get("body", ""):
|
|
128
|
+
existing_id = c["id"]
|
|
129
|
+
break
|
|
130
|
+
except Exception:
|
|
131
|
+
pass
|
|
132
|
+
|
|
133
|
+
data = json.dumps({"body": body}).encode()
|
|
134
|
+
if existing_id:
|
|
135
|
+
url = f"https://api.github.com/repos/{repo}/issues/comments/{existing_id}"
|
|
136
|
+
req = urllib.request.Request(url, data=data, headers=headers, method="PATCH")
|
|
137
|
+
else:
|
|
138
|
+
req = urllib.request.Request(api, data=data, headers=headers, method="POST")
|
|
139
|
+
|
|
140
|
+
try:
|
|
141
|
+
urllib.request.urlopen(req)
|
|
142
|
+
action = "Updated" if existing_id else "Posted"
|
|
143
|
+
print(f"{action} comment with {len(findings)} finding(s)")
|
|
144
|
+
except Exception as e:
|
|
145
|
+
print(f"Warning: Could not comment on PR: {e}")
|
|
146
|
+
PYEOF
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Not present in the org's other core SDK repos (ruby / js); added here as a
|
|
2
|
+
# standard community-health workflow, following the org's SHA-pinning convention.
|
|
3
|
+
|
|
4
|
+
name: Mark stale issues and pull requests
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
schedule:
|
|
8
|
+
- cron: '0 1 * * *'
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
issues: write
|
|
13
|
+
pull-requests: write
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
stale:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/stale@4391f3da665fdf50b6810c1a66712fb9ba21aa93 # v11.0.0
|
|
20
|
+
with:
|
|
21
|
+
days-before-stale: 60
|
|
22
|
+
days-before-close: 14
|
|
23
|
+
stale-issue-message: >-
|
|
24
|
+
This issue has been automatically marked as stale because it has had no
|
|
25
|
+
activity for 60 days. It will be closed in 14 days if no further activity occurs.
|
|
26
|
+
stale-pr-message: >-
|
|
27
|
+
This pull request has been automatically marked as stale because it has had no
|
|
28
|
+
activity for 60 days. It will be closed in 14 days if no further activity occurs.
|
|
29
|
+
stale-issue-label: stale
|
|
30
|
+
stale-pr-label: stale
|
|
31
|
+
exempt-issue-labels: pinned,security
|
|
32
|
+
exempt-pr-labels: pinned,security
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# This workflow installs dependencies and runs tests, lint, and type checks
|
|
2
|
+
# across a matrix of supported Python versions.
|
|
3
|
+
|
|
4
|
+
name: Python CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [main]
|
|
9
|
+
pull_request:
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
workflow_call:
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
python-version: ['3.8', '3.12']
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
22
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
23
|
+
with:
|
|
24
|
+
python-version: ${{ matrix.python-version }}
|
|
25
|
+
- name: Install package
|
|
26
|
+
run: pip install -e ".[dev]"
|
|
27
|
+
- name: Test
|
|
28
|
+
run: pytest
|
|
29
|
+
lint:
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
33
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
34
|
+
with:
|
|
35
|
+
python-version: '3.12'
|
|
36
|
+
- name: Install package
|
|
37
|
+
run: pip install -e ".[dev]"
|
|
38
|
+
- name: Lint
|
|
39
|
+
run: ruff check .
|
|
40
|
+
- name: Type check
|
|
41
|
+
run: mypy usesmileid
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Byte-compiled / optimised files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# Test / lint / type-check caches
|
|
18
|
+
.pytest_cache/
|
|
19
|
+
.mypy_cache/
|
|
20
|
+
.ruff_cache/
|
|
21
|
+
.tox/
|
|
22
|
+
.coverage
|
|
23
|
+
.coverage.*
|
|
24
|
+
htmlcov/
|
|
25
|
+
|
|
26
|
+
# Environment files
|
|
27
|
+
.env
|
|
28
|
+
.env.*
|
|
29
|
+
|
|
30
|
+
# Editor / OS
|
|
31
|
+
.vscode/
|
|
32
|
+
.idea/
|
|
33
|
+
.DS_Store
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Agent notes
|
|
2
|
+
|
|
3
|
+
This repository holds Smile ID's V3 server-side SDK for Python (PyPI package and importable module are both `usesmileid`).
|
|
4
|
+
|
|
5
|
+
## Source of truth
|
|
6
|
+
|
|
7
|
+
The API surface (endpoints, request and response shapes) is defined by the OpenAPI specs at [smileidentity/api-reference](https://github.com/smileidentity/api-reference). Treat that repository as authoritative when generating or reviewing client code — do not invent endpoints or fields that aren't described there.
|
|
8
|
+
|
|
9
|
+
## Layout
|
|
10
|
+
|
|
11
|
+
- `usesmileid/generated/` — generator-owned code, produced from the OpenAPI specs. Do not hand-edit files here once the generator is wired up.
|
|
12
|
+
- `usesmileid/client/` — hand-written client code (configuration, auth, transport).
|
|
13
|
+
- `usesmileid/errors/` — hand-written error types.
|
|
14
|
+
- `usesmileid/helpers/` — hand-written convenience helpers.
|
|
15
|
+
|
|
16
|
+
Auth token lifecycle, transport, retries, serialization and errors are hand-written and must survive a future generator run; only `usesmileid/generated/` may be regenerated.
|
|
17
|
+
|
|
18
|
+
All tests are offline (respx mocks) except `tests/test_e2e_sandbox.py`, which reads `SMILE_PARTNER_ID` and `SMILE_API_KEY` from the environment and skips when they are unset. It targets the sandbox unless `SMILE_BASE_URL` is set.
|
|
19
|
+
|
|
20
|
+
## Running tests
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python -m pytest
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Lint with `ruff check .` and type-check with `mypy usesmileid`.
|
|
27
|
+
|
|
28
|
+
## Org-wide conventions
|
|
29
|
+
|
|
30
|
+
Org-wide agent conventions for Smile ID repositories live at [smileidentity/agents](https://github.com/smileidentity/agents) (private repository, internal contributors only).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Security
|
|
10
|
+
|
|
11
|
+
- `base_url` must now be an absolute https URL with no query or fragment,
|
|
12
|
+
validated at construction. There is deliberately no insecure override.
|
|
13
|
+
- `default_callback_url` and per-request `callback_url` values must be https;
|
|
14
|
+
invalid values raise `ValidationError` before any request is sent.
|
|
15
|
+
- `job_id` and `user_id` path parameters are URL-encoded as single path
|
|
16
|
+
segments before interpolation.
|
|
17
|
+
- Multipart part filenames and content types are sanitized against header
|
|
18
|
+
injection (CR, LF, quotes).
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Added `smileid.errors.UnexpectedResponseError`, raised when a success (2xx)
|
|
23
|
+
response body is not a JSON object, with `status_code`, `raw_body` and
|
|
24
|
+
`request_id` populated.
|
|
25
|
+
|
|
26
|
+
- Renamed the PyPI package from `smile-identity-core` to `smileid`, matching
|
|
27
|
+
the importable module.
|
|
28
|
+
- Set the version to 12.0.0, aligning the server SDKs with the V12 mobile
|
|
29
|
+
SDKs.
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- Initial implementation of the V3 SDK: all 14 public operations under
|
|
34
|
+
`client.<resource>.<verb>`, plus `flag_fraud` / `clear_fraud` wrappers.
|
|
35
|
+
- Automatic token management: fetch, thread-safe cache to expiry, one
|
|
36
|
+
refresh-and-retry on 401.
|
|
37
|
+
- Typed error hierarchy under `smileid.errors`.
|
|
38
|
+
- Retry policy for idempotent operations with `Retry-After` support.
|
|
39
|
+
- `verifications.wait_until_complete` polling helper, `Consent` builder and
|
|
40
|
+
client-side validation for user details and fraud reports.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Smile Identity Limited
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|