Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-altcha for openSUSE:Factory 
checked in at 2026-11-21 21:46:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-altcha (Old)
 and      /work/SRC/openSUSE:Factory/.python-altcha.new.1340718 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-altcha"

Sat Nov 21 21:46:58 2026 rev:10 rq:1399546 version:2.4.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-altcha/python-altcha.changes      
2026-10-26 10:01:14.575835010 +0100
+++ /work/SRC/openSUSE:Factory/.python-altcha.new.1340718/python-altcha.changes 
2026-11-21 21:48:50.341276730 +0100
@@ -1,0 +2,20 @@
+Fri Nov 20 20:33:42 UTC 2026 - Dirk Müller <[email protected]>
+
+- update to 2.4.0:
+  * `verify_server` supports Sentinel v2's `POST
+    /v2/verify/signature`. Pass the ID and secret of a `restricted`
+    or `full` API key as `api_key` and `secret`: they are sent as
+    HTTP Basic credentials and `secret` is left out of the body.
+    `api_key` without `secret` raises `ValueError`.
+  * `ServerSignaturePayload` carries the optional `apiKey` and
+    `id` fields (`api_key`, `id`) and keeps them in `to_dict`,
+    so a payload object passed to `verify_server` still names
+    its signing key.
+  * `verify_server` no longer retries `4xx` responses (e.g.
+    `401`/`403` for missing or wrong credentials, `429`); they
+    return `verified=False` at once.
+  * `verify_server` returns `reason='INVALID_RESPONSE'` (after
+    retrying) instead of raising when a `2xx` response body is not
+    a JSON object.
+
+-------------------------------------------------------------------

Old:
----
  altcha-2.3.0.tar.gz

New:
----
  altcha-2.4.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-altcha.spec ++++++
--- /var/tmp/diff_new_pack.GzQIRS/_old  2026-11-21 21:48:50.973303222 +0100
+++ /var/tmp/diff_new_pack.GzQIRS/_new  2026-11-21 21:48:50.975303306 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           python-altcha
-Version:        2.3.0
+Version:        2.4.0
 Release:        0
 Summary:        A library for creating and verifying challenges for ALTCHA
 License:        MIT

++++++ altcha-2.3.0.tar.gz -> altcha-2.4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/altcha-2.3.0/CHANGELOG.md 
new/altcha-2.4.0/CHANGELOG.md
--- old/altcha-2.3.0/CHANGELOG.md       2026-10-04 03:20:47.962978000 +0200
+++ new/altcha-2.4.0/CHANGELOG.md       2026-11-17 08:07:10.526710700 +0100
@@ -4,6 +4,31 @@
 
 The format is based on [Keep a 
Changelog](https://keepachangelog.com/en/1.1.0/).
 
+## [2.4.0] - 2026-11-17
+
+### Added
+
+- `verify_server` supports Sentinel v2's `POST /v2/verify/signature`. Pass the 
ID and
+  secret of a `restricted` or `full` API key as `api_key` and `secret`: they 
are sent as
+  HTTP Basic credentials and `secret` is left out of the body. `api_key` 
without `secret`
+  raises `ValueError`. Sentinel v1 (`/v1/verify/signature`) works as before 
when `api_key`
+  is omitted.
+- `ServerSignaturePayload` carries the optional `apiKey` and `id` fields 
(`api_key`, `id`)
+  and keeps them in `to_dict`, so a payload object passed to `verify_server` 
still names
+  its signing key.
+
+### Changed
+
+- `verify_server` no longer retries `4xx` responses (e.g. `401`/`403` for 
missing or wrong
+  credentials, `429`); they return `verified=False` at once. For error 
responses, `reason`
+  is the body's `code`, else its `error`, else `HTTP_<status>`; `5xx` 
responses that
+  exhaust the retries report it too (was always `HTTP_<status>`).
+
+### Fixed
+
+- `verify_server` returns `reason='INVALID_RESPONSE'` (after retrying) instead 
of raising
+  when a `2xx` response body is not a JSON object.
+
 ## [2.3.0] - 2026-10-04
 
 Aligns the v2 API (`altcha.v2`) with the reference JavaScript implementation
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/altcha-2.3.0/PKG-INFO new/altcha-2.4.0/PKG-INFO
--- old/altcha-2.3.0/PKG-INFO   2026-10-04 03:20:50.362951500 +0200
+++ new/altcha-2.4.0/PKG-INFO   2026-11-17 08:07:18.635947700 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.4
 Name: altcha
-Version: 2.3.0
+Version: 2.4.0
 Summary: A library for creating and verifying challenges for ALTCHA.
 Home-page: https://github.com/altcha-org/altcha-lib-py
 Author: Daniel Regeci
@@ -254,17 +254,99 @@
 
 #### `verify_fields_hash(form_data, fields, fields_hash, algorithm) → bool`
 
-Verifies the hash of specific form fields.
+Verifies the hash of specific form fields: the hex hash (`algorithm`, e.g. 
`'SHA-256'`) of
+the values of `fields` in `form_data`, joined with `\n`, must equal 
`fields_hash`.
 
-#### `verify_server_signature(payload, hmac_key) → (bool, 
ServerSignatureVerificationData | None, str | None)`
+#### `verify_server_signature(payload, hmac_secret, *, hmac_algorithm) → 
VerifyServerSignatureResult`
 
-Verifies an ALTCHA server signature.
+Verifies an ALTCHA server signature locally, e.g. the `payload` of Sentinel's
+`POST /v2/verify` (or `/v1/verify`) response, with the secret of the API key 
that signed
+it. Sentinel v1 and v2 sign the same way, so this works for both. To have 
Sentinel check
+the payload instead, use `verify_server` (below).
 
-#### `verify_server(payload, url, secret, *, headers, timeout, retries, 
retry_delay, retry_backoff, http_post) → VerifyServerResult`
+```python
+from altcha import verify_fields_hash, verify_server_signature
+
+result = verify_server_signature(payload, API_KEY_SECRET)
+
+if result.verified:
+    data = result.verification_data
+    # Detect tampering with the submitted form fields
+    if data.get("fields") and not verify_fields_hash(
+        form_data, data["fields"], data["fieldsHash"], "SHA-256"
+    ):
+        ...
+```
+
+| Parameter | Type | Default | Description |
+|---|---|---|---|
+| `payload` | `str` \| `ServerSignaturePayload` | — | Base64-encoded JSON 
string or `ServerSignaturePayload` object. Its `algorithm` (hash of 
`verificationData`) must be `'SHA-1'`, `'SHA-256'`, `'SHA-384'` or `'SHA-512'`. 
|
+| `hmac_secret` | `str` \| `bytes` | — | Secret used to verify the HMAC 
signature (the API key secret for Sentinel). Raises `ValueError` if empty. |
+| `hmac_algorithm` | `str` | `'SHA-256'` | HMAC digest algorithm. |
+
+Returns `VerifyServerSignatureResult` with fields:
 
-Verifies a payload remotely via the ALTCHA Sentinel `/v1/verify/signature` 
API, instead of
+| Field | Type | Description |
+|---|---|---|
+| `verified` | `bool` | `True` if the signature is valid, the payload has not 
expired, and `verified` is `true` in both the payload and the signed 
verification data. |
+| `expired` | `bool` | `True` if the signed `expire` is in the past. |
+| `invalid_signature` | `bool` | `True` if the signature does not match, or 
the payload is malformed. |
+| `invalid_solution` | `bool` | `True` if `verified` is not `true` in the 
payload or in the signed verification data. |
+| `time` | `float` | Time taken for verification in milliseconds. |
+| `verification_data` | `dict \| None` | The signed verification data, parsed 
with `parse_verification_data`; `None` unless `verified`. |
+
+`parse_verification_data(data)` turns the URL-encoded verification data into a 
flat dict:
+
+- Keys stay as signed, e.g. `data["challenge.algorithm"]` and 
`data["device.edk"]`
+  (`verify_server` returns these nested instead).
+- `'true'`/`'false'` become `bool`, all-digit values `int` (including e.g. a
+  `params.zip` of `01234`, which becomes `1234`), and `digits.digits` values 
`float`.
+- `fields` and `reasons` become lists.
+- Keys with empty values are left out.
+
+Unlike Sentinel v2's `/v2/verify/signature` (via `verify_server`), local 
verification does
+not prevent reuse: a valid payload verifies again until `expire`. Reject 
repeated `id`s
+yourself if that matters.
+
+#### `verify_server(payload, url, secret, *, api_key, headers, timeout, 
retries, retry_delay, retry_backoff, http_post) → VerifyServerResult`
+
+Verifies a payload remotely via the ALTCHA Sentinel verify signature API, 
instead of
 checking the HMAC signature locally. Avoids managing the HMAC secret on your 
server, at the
-cost of a network round-trip.
+cost of a network round-trip. Both Sentinel v2 (`POST /v2/verify/signature`) 
and Sentinel v1
+(`POST /v1/verify/signature`) are supported; they differ in how the request is 
authenticated.
+
+##### Sentinel v2
+
+```python
+from altcha import verify_server
+
+result = verify_server(
+    payload,  # the payload received from POST /v2/verify
+    url="https://sentinel.example.com/v2/verify/signature";,
+    api_key=SENTINEL_API_KEY,  # id of a restricted or full API key (key_...)
+    secret=SENTINEL_API_KEY_SECRET,  # its secret (sec_...)
+    timeout=10,
+    retries=2,
+)
+
+if result.verified:
+    ...
+```
+
+- `api_key` and `secret` are the ID and secret of a `restricted` or `full` API 
key of the
+  account that owns the payload's (public) API key. They are sent as
+  `Authorization: Basic base64(api_key:secret)`; an `Authorization` header in 
`headers` is
+  replaced. `api_key` without `secret` raises `ValueError` before any request 
is sent.
+- The request body is `{"payload": ...}`; `secret` is not sent in the body 
(Sentinel v2
+  rejects it).
+- Without credentials, Sentinel v2 answers `401` and `reason` is 
`'API_KEY_REQUIRED'`. A
+  payload signed by a key of another account gets 
`reason='API_KEY_NOT_ALLOWED'`.
+- `verification_data` is the signed verification data as a nested dict, with 
keys split on
+  `.`: `result.verification_data["challenge"]["algorithm"]` (v1's 
`challengeAlgorithm`),
+  `result.verification_data["device"]["edk"]`. `fields` and `reasons` are 
lists; `id`,
+  `fieldsHash`, `device.edk` and `params.*` stay strings.
+
+##### Sentinel v1
 
 ```python
 from altcha import verify_server
@@ -281,11 +363,20 @@
     ...
 ```
 
+- `/v1/verify/signature` takes no credentials: omit `api_key`. `secret` (the 
payload's API
+  key secret) is optional and sent in the body as `{"payload": ..., "secret": 
...}`; Sentinel
+  answers `reason='WRONG_API_KEY_SECRET'` when it is not the payload key's 
secret.
+- This also applies to the `/v1/verify/signature` alias Sentinel v2 serves with
+  `[server] v1_compat = true`.
+
+##### Parameters
+
 | Parameter | Type | Default | Description |
 |---|---|---|---|
 | `payload` | `str` \| `ServerSignaturePayload` \| `dict` | — | The payload to 
verify. |
-| `url` | `str` | — | Full URL of the Sentinel `/v1/verify/signature` 
endpoint. |
-| `secret` | `str` | `None` | API key secret, checked against the payload's 
API key. |
+| `url` | `str` | — | Full URL of the Sentinel endpoint: 
`/v2/verify/signature` (v2) or `/v1/verify/signature` (v1). |
+| `secret` | `str` | `None` | v2: secret of `api_key`, required with it. v1: 
API key secret sent in the body and checked against the payload's API key. |
+| `api_key` | `str` | `None` | v2 only: ID of a `restricted` or `full` API 
key, sent with `secret` as HTTP Basic credentials. |
 | `headers` | `dict` | `None` | Additional headers to send with the request. |
 | `timeout` | `float` | `10` | Per-attempt request timeout in seconds. |
 | `retries` | `int` | `0` | Number of retry attempts after the first try. |
@@ -293,14 +384,22 @@
 | `retry_backoff` | `str` | `'exponential'` | `'fixed'` or `'exponential'` 
backoff. |
 | `http_post` | callable | stdlib `urllib` | Transport override: `(url, body, 
headers, timeout) -> (status, body)`. |
 
+##### Errors and retries
+
+Failures never raise; they return `verified=False` with a `reason`. `4xx` 
responses (bad
+payload, missing or wrong credentials, rate limit) are definitive and returned 
at once.
+Network errors, other error statuses (e.g. `5xx`) and invalid response bodies 
are retried up
+to `retries` times. For an error response, `reason` is the `code` of 
Sentinel's error body
+(v2: `{"code", "error", "statusCode"}`), else its `error` (v1), else 
`'HTTP_<status>'`.
+
 Returns `VerifyServerResult` with fields:
 
 | Field | Type | Description |
 |---|---|---|
 | `verified` | `bool` | `True` if Sentinel confirmed the payload is valid. |
-| `reason` | `str \| None` | Failure reason, if any. |
+| `reason` | `str \| None` | Why verification failed: Sentinel's `reason` 
(e.g. `'PAYLOAD_ALREADY_USED'`, `'INVALID_PAYLOAD'`, `'API_KEY_NOT_ALLOWED'` 
(v2), `'WRONG_API_KEY_SECRET'` (v1)), the error code of an HTTP error response, 
`'INVALID_RESPONSE'`, or a network error message. |
 | `api_key` | `str \| None` | The API key associated with the payload, if 
returned. |
-| `verification_data` | `dict \| None` | Parsed verification data, if 
returned. |
+| `verification_data` | `dict \| None` | Verification data returned by 
Sentinel (nested dict), if returned. |
 
 ---
 
@@ -323,6 +422,12 @@
 | `expires` | `datetime` | `None` | Optional expiration time. |
 | `params` | `dict` | `None` | Optional URL-encoded query parameters appended 
to the salt. |
 
+#### `verify_server_signature_v1(payload, hmac_key) → (bool, 
ServerSignatureVerificationData | None, str | None)`
+
+Verifies a server signature with the v1 API. Returns `(verified, data, 
error)`, where `data`
+exposes the known fields (`classification`, `expire`, `fields`, `fieldsHash`, 
`score`, …)
+as attributes. Prefer `verify_server_signature`.
+
 #### `verify_solution_v1(payload, hmac_secret, check_expires) → (bool, str | 
None)`
 
 Verifies a v1 solution payload.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/altcha-2.3.0/README.md new/altcha-2.4.0/README.md
--- old/altcha-2.3.0/README.md  2026-10-04 03:20:47.962997000 +0200
+++ new/altcha-2.4.0/README.md  2026-11-17 08:07:10.526710700 +0100
@@ -231,17 +231,99 @@
 
 #### `verify_fields_hash(form_data, fields, fields_hash, algorithm) → bool`
 
-Verifies the hash of specific form fields.
+Verifies the hash of specific form fields: the hex hash (`algorithm`, e.g. 
`'SHA-256'`) of
+the values of `fields` in `form_data`, joined with `\n`, must equal 
`fields_hash`.
 
-#### `verify_server_signature(payload, hmac_key) → (bool, 
ServerSignatureVerificationData | None, str | None)`
+#### `verify_server_signature(payload, hmac_secret, *, hmac_algorithm) → 
VerifyServerSignatureResult`
 
-Verifies an ALTCHA server signature.
+Verifies an ALTCHA server signature locally, e.g. the `payload` of Sentinel's
+`POST /v2/verify` (or `/v1/verify`) response, with the secret of the API key 
that signed
+it. Sentinel v1 and v2 sign the same way, so this works for both. To have 
Sentinel check
+the payload instead, use `verify_server` (below).
 
-#### `verify_server(payload, url, secret, *, headers, timeout, retries, 
retry_delay, retry_backoff, http_post) → VerifyServerResult`
+```python
+from altcha import verify_fields_hash, verify_server_signature
+
+result = verify_server_signature(payload, API_KEY_SECRET)
+
+if result.verified:
+    data = result.verification_data
+    # Detect tampering with the submitted form fields
+    if data.get("fields") and not verify_fields_hash(
+        form_data, data["fields"], data["fieldsHash"], "SHA-256"
+    ):
+        ...
+```
+
+| Parameter | Type | Default | Description |
+|---|---|---|---|
+| `payload` | `str` \| `ServerSignaturePayload` | — | Base64-encoded JSON 
string or `ServerSignaturePayload` object. Its `algorithm` (hash of 
`verificationData`) must be `'SHA-1'`, `'SHA-256'`, `'SHA-384'` or `'SHA-512'`. 
|
+| `hmac_secret` | `str` \| `bytes` | — | Secret used to verify the HMAC 
signature (the API key secret for Sentinel). Raises `ValueError` if empty. |
+| `hmac_algorithm` | `str` | `'SHA-256'` | HMAC digest algorithm. |
+
+Returns `VerifyServerSignatureResult` with fields:
 
-Verifies a payload remotely via the ALTCHA Sentinel `/v1/verify/signature` 
API, instead of
+| Field | Type | Description |
+|---|---|---|
+| `verified` | `bool` | `True` if the signature is valid, the payload has not 
expired, and `verified` is `true` in both the payload and the signed 
verification data. |
+| `expired` | `bool` | `True` if the signed `expire` is in the past. |
+| `invalid_signature` | `bool` | `True` if the signature does not match, or 
the payload is malformed. |
+| `invalid_solution` | `bool` | `True` if `verified` is not `true` in the 
payload or in the signed verification data. |
+| `time` | `float` | Time taken for verification in milliseconds. |
+| `verification_data` | `dict \| None` | The signed verification data, parsed 
with `parse_verification_data`; `None` unless `verified`. |
+
+`parse_verification_data(data)` turns the URL-encoded verification data into a 
flat dict:
+
+- Keys stay as signed, e.g. `data["challenge.algorithm"]` and 
`data["device.edk"]`
+  (`verify_server` returns these nested instead).
+- `'true'`/`'false'` become `bool`, all-digit values `int` (including e.g. a
+  `params.zip` of `01234`, which becomes `1234`), and `digits.digits` values 
`float`.
+- `fields` and `reasons` become lists.
+- Keys with empty values are left out.
+
+Unlike Sentinel v2's `/v2/verify/signature` (via `verify_server`), local 
verification does
+not prevent reuse: a valid payload verifies again until `expire`. Reject 
repeated `id`s
+yourself if that matters.
+
+#### `verify_server(payload, url, secret, *, api_key, headers, timeout, 
retries, retry_delay, retry_backoff, http_post) → VerifyServerResult`
+
+Verifies a payload remotely via the ALTCHA Sentinel verify signature API, 
instead of
 checking the HMAC signature locally. Avoids managing the HMAC secret on your 
server, at the
-cost of a network round-trip.
+cost of a network round-trip. Both Sentinel v2 (`POST /v2/verify/signature`) 
and Sentinel v1
+(`POST /v1/verify/signature`) are supported; they differ in how the request is 
authenticated.
+
+##### Sentinel v2
+
+```python
+from altcha import verify_server
+
+result = verify_server(
+    payload,  # the payload received from POST /v2/verify
+    url="https://sentinel.example.com/v2/verify/signature";,
+    api_key=SENTINEL_API_KEY,  # id of a restricted or full API key (key_...)
+    secret=SENTINEL_API_KEY_SECRET,  # its secret (sec_...)
+    timeout=10,
+    retries=2,
+)
+
+if result.verified:
+    ...
+```
+
+- `api_key` and `secret` are the ID and secret of a `restricted` or `full` API 
key of the
+  account that owns the payload's (public) API key. They are sent as
+  `Authorization: Basic base64(api_key:secret)`; an `Authorization` header in 
`headers` is
+  replaced. `api_key` without `secret` raises `ValueError` before any request 
is sent.
+- The request body is `{"payload": ...}`; `secret` is not sent in the body 
(Sentinel v2
+  rejects it).
+- Without credentials, Sentinel v2 answers `401` and `reason` is 
`'API_KEY_REQUIRED'`. A
+  payload signed by a key of another account gets 
`reason='API_KEY_NOT_ALLOWED'`.
+- `verification_data` is the signed verification data as a nested dict, with 
keys split on
+  `.`: `result.verification_data["challenge"]["algorithm"]` (v1's 
`challengeAlgorithm`),
+  `result.verification_data["device"]["edk"]`. `fields` and `reasons` are 
lists; `id`,
+  `fieldsHash`, `device.edk` and `params.*` stay strings.
+
+##### Sentinel v1
 
 ```python
 from altcha import verify_server
@@ -258,11 +340,20 @@
     ...
 ```
 
+- `/v1/verify/signature` takes no credentials: omit `api_key`. `secret` (the 
payload's API
+  key secret) is optional and sent in the body as `{"payload": ..., "secret": 
...}`; Sentinel
+  answers `reason='WRONG_API_KEY_SECRET'` when it is not the payload key's 
secret.
+- This also applies to the `/v1/verify/signature` alias Sentinel v2 serves with
+  `[server] v1_compat = true`.
+
+##### Parameters
+
 | Parameter | Type | Default | Description |
 |---|---|---|---|
 | `payload` | `str` \| `ServerSignaturePayload` \| `dict` | — | The payload to 
verify. |
-| `url` | `str` | — | Full URL of the Sentinel `/v1/verify/signature` 
endpoint. |
-| `secret` | `str` | `None` | API key secret, checked against the payload's 
API key. |
+| `url` | `str` | — | Full URL of the Sentinel endpoint: 
`/v2/verify/signature` (v2) or `/v1/verify/signature` (v1). |
+| `secret` | `str` | `None` | v2: secret of `api_key`, required with it. v1: 
API key secret sent in the body and checked against the payload's API key. |
+| `api_key` | `str` | `None` | v2 only: ID of a `restricted` or `full` API 
key, sent with `secret` as HTTP Basic credentials. |
 | `headers` | `dict` | `None` | Additional headers to send with the request. |
 | `timeout` | `float` | `10` | Per-attempt request timeout in seconds. |
 | `retries` | `int` | `0` | Number of retry attempts after the first try. |
@@ -270,14 +361,22 @@
 | `retry_backoff` | `str` | `'exponential'` | `'fixed'` or `'exponential'` 
backoff. |
 | `http_post` | callable | stdlib `urllib` | Transport override: `(url, body, 
headers, timeout) -> (status, body)`. |
 
+##### Errors and retries
+
+Failures never raise; they return `verified=False` with a `reason`. `4xx` 
responses (bad
+payload, missing or wrong credentials, rate limit) are definitive and returned 
at once.
+Network errors, other error statuses (e.g. `5xx`) and invalid response bodies 
are retried up
+to `retries` times. For an error response, `reason` is the `code` of 
Sentinel's error body
+(v2: `{"code", "error", "statusCode"}`), else its `error` (v1), else 
`'HTTP_<status>'`.
+
 Returns `VerifyServerResult` with fields:
 
 | Field | Type | Description |
 |---|---|---|
 | `verified` | `bool` | `True` if Sentinel confirmed the payload is valid. |
-| `reason` | `str \| None` | Failure reason, if any. |
+| `reason` | `str \| None` | Why verification failed: Sentinel's `reason` 
(e.g. `'PAYLOAD_ALREADY_USED'`, `'INVALID_PAYLOAD'`, `'API_KEY_NOT_ALLOWED'` 
(v2), `'WRONG_API_KEY_SECRET'` (v1)), the error code of an HTTP error response, 
`'INVALID_RESPONSE'`, or a network error message. |
 | `api_key` | `str \| None` | The API key associated with the payload, if 
returned. |
-| `verification_data` | `dict \| None` | Parsed verification data, if 
returned. |
+| `verification_data` | `dict \| None` | Verification data returned by 
Sentinel (nested dict), if returned. |
 
 ---
 
@@ -300,6 +399,12 @@
 | `expires` | `datetime` | `None` | Optional expiration time. |
 | `params` | `dict` | `None` | Optional URL-encoded query parameters appended 
to the salt. |
 
+#### `verify_server_signature_v1(payload, hmac_key) → (bool, 
ServerSignatureVerificationData | None, str | None)`
+
+Verifies a server signature with the v1 API. Returns `(verified, data, 
error)`, where `data`
+exposes the known fields (`classification`, `expire`, `fields`, `fieldsHash`, 
`score`, …)
+as attributes. Prefer `verify_server_signature`.
+
 #### `verify_solution_v1(payload, hmac_secret, check_expires) → (bool, str | 
None)`
 
 Verifies a v1 solution payload.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/altcha-2.3.0/altcha/v2.py 
new/altcha-2.4.0/altcha/v2.py
--- old/altcha-2.3.0/altcha/v2.py       2026-10-04 03:20:47.963458800 +0200
+++ new/altcha-2.4.0/altcha/v2.py       2026-11-17 08:07:10.527087200 +0100
@@ -895,6 +895,9 @@
         signature: HMAC signature of the hashed verification data.
         verification_data: URL-encoded query string of verification attributes.
         verified: Whether the server marked the payload as verified.
+        api_key: ID of the API key that signed the payload (Sentinel's 
``apiKey``),
+            if present. Not covered by the signature.
+        id: Payload ID (Sentinel's ``id``), if present. Not covered by the 
signature.
     """
 
     def __init__(
@@ -903,19 +906,28 @@
         signature: str,
         verification_data: str,
         verified: bool,
+        api_key: str | None = None,
+        id: str | None = None,
     ):
         self.algorithm = algorithm
         self.signature = signature
         self.verification_data = verification_data
         self.verified = verified
+        self.api_key = api_key
+        self.id = id
 
     def to_dict(self) -> dict:
-        return {
+        d: dict = {
             "algorithm": self.algorithm,
             "signature": self.signature,
             "verificationData": self.verification_data,
             "verified": self.verified,
         }
+        if self.api_key is not None:
+            d["apiKey"] = self.api_key
+        if self.id is not None:
+            d["id"] = self.id
+        return d
 
     @classmethod
     def from_dict(cls, d: dict) -> ServerSignaturePayload:
@@ -924,6 +936,8 @@
             signature=d["signature"],
             verification_data=d["verificationData"],
             verified=bool(d.get("verified", False)),
+            api_key=d.get("apiKey"),
+            id=d.get("id"),
         )
 
     @classmethod
@@ -1106,9 +1120,14 @@
 
     Attributes:
         verified: ``True`` if Sentinel confirmed the payload is valid.
-        reason: Failure reason (e.g. an error code or exception message), if 
any.
+        reason: Why verification failed, if it did: Sentinel's ``reason`` (e.g.
+            ``'PAYLOAD_ALREADY_USED'``, ``'INVALID_PAYLOAD'``, 
``'API_KEY_NOT_ALLOWED'``
+            (v2) or ``'WRONG_API_KEY_SECRET'`` (v1)), the ``code`` (else 
``error``) of an
+            HTTP error response (e.g. ``'API_KEY_REQUIRED'``), 
``'HTTP_<status>'``,
+            ``'INVALID_RESPONSE'`` or a network error message.
         api_key: The API key associated with the payload, if returned.
-        verification_data: Parsed verification data, if returned.
+        verification_data: The verification data returned by Sentinel, as a 
nested
+            dict (``{'challenge': {'algorithm': ...}}``), if returned.
     """
 
     def __init__(
@@ -1150,11 +1169,34 @@
     time.sleep(wait)
 
 
+def _decode_json(body: bytes) -> object:
+    """Decode a JSON response body, or return ``None`` if it is not valid 
JSON."""
+    try:
+        return json.loads(body.decode())
+    except (ValueError, RecursionError):
+        return None
+
+
+def _error_reason(status: int, body: bytes) -> str:
+    """
+    The ``code`` of a Sentinel error body (v2: ``{code, error, statusCode}``), 
else its
+    ``error`` (v1 sends only ``error``), else ``'HTTP_<status>'``.
+    """
+    data = _decode_json(body)
+    if isinstance(data, dict):
+        for key in ("code", "error"):
+            value = data.get(key)
+            if isinstance(value, str) and value:
+                return value
+    return f"HTTP_{status}"
+
+
 def verify_server(
     payload: str | ServerSignaturePayload | dict,
     url: str,
     secret: str | None = None,
     *,
+    api_key: str | None = None,
     headers: dict[str, str] | None = None,
     timeout: float = 10.0,
     retries: int = 0,
@@ -1164,20 +1206,39 @@
     | None = None,
 ) -> VerifyServerResult:
     """
-    Verify a payload remotely via the ALTCHA Sentinel ``/v1/verify/signature`` 
API.
+    Verify a payload remotely via the ALTCHA Sentinel verify signature API.
 
     Instead of verifying the HMAC signature locally (see 
:func:`verify_server_signature`),
     this POSTs the payload to Sentinel and trusts its response. Avoids 
managing the HMAC
     secret on your server, at the cost of a network round-trip.
 
+    Supports both Sentinel versions; they differ in how the request is 
authenticated:
+
+    - Sentinel v2 (``/v2/verify/signature``): pass *api_key* and *secret*, the 
ID and
+      secret of a ``restricted`` or ``full`` API key of the account that owns 
the
+      payload's API key. They are sent as HTTP Basic credentials, and nothing 
else
+      besides the payload is sent in the body.
+    - Sentinel v1 (``/v1/verify/signature``, also the ``/v1`` alias Sentinel 
v2 serves
+      with ``v1_compat``): omit *api_key*. *secret* is optional and sent in 
the body;
+      Sentinel checks it against the payload's API key.
+
     Args:
-        payload: The payload to verify, as received from ``POST /v1/verify`` — 
a base64
-            string, a :class:`ServerSignaturePayload`, or an already-decoded 
dict.
-        url: Full URL of the Sentinel ``/v1/verify/signature`` endpoint.
-        secret: API key secret. If given, Sentinel checks it against the 
payload's API key.
-        headers: Additional headers to send with the request.
+        payload: The payload to verify, as received from ``POST /v2/verify`` 
(or
+            ``/v1/verify``) — a base64 string, a 
:class:`ServerSignaturePayload`, or an
+            already-decoded dict.
+        url: Full URL of the Sentinel ``/v2/verify/signature`` or
+            ``/v1/verify/signature`` endpoint.
+        secret: API key secret. With *api_key* (Sentinel v2), the secret of 
that key,
+            sent as the Basic password; required. Without *api_key* (Sentinel 
v1),
+            optional and sent as ``secret`` in the body.
+        api_key: Sentinel v2: ID (``key_…``) of a ``restricted`` or ``full`` 
API key,
+            sent with *secret* as ``Authorization: Basic 
base64(api_key:secret)``.
+        headers: Additional headers to send with the request. An 
``Authorization``
+            header is replaced when *api_key* is set.
         timeout: Per-attempt request timeout in seconds. Defaults to ``10``.
-        retries: Number of retry attempts after the first try. Defaults to 
``0``.
+        retries: Number of retry attempts after the first try. Network errors, 
non-4xx
+            error statuses and invalid response bodies are retried; 4xx 
responses are
+            not. Defaults to ``0``.
         retry_delay: Base delay in seconds between retries. Defaults to 
``0.3``.
         retry_backoff: ``'fixed'`` or ``'exponential'`` backoff applied to 
*retry_delay*.
         http_post: Transport override — ``(url, body, headers, timeout) -> 
(status, body)``.
@@ -1188,18 +1249,31 @@
         A :class:`VerifyServerResult` describing the outcome. Failures (HTTP 
errors, network
         errors, or a negative Sentinel verdict) are reported via 
``verified=False`` with a
         ``reason``, never raised as exceptions.
+
+    Raises:
+        ValueError: If *api_key* is set without *secret*.
     """
+    if api_key and not secret:
+        raise ValueError("secret is required when api_key is set")
+
     if isinstance(payload, ServerSignaturePayload):
         payload_value: str | dict = payload.to_dict()
     else:
         payload_value = payload
 
     body: dict = {"payload": payload_value}
-    if secret is not None:
+    # Sentinel v2 rejects `secret` in the body (400); only Sentinel v1 reads 
it.
+    if not api_key and secret is not None:
         body["secret"] = secret
     data = json.dumps(body).encode()
 
     req_headers = {"Content-Type": "application/json", **(headers or {})}
+    if api_key:
+        credentials = base64.b64encode(f"{api_key}:{secret}".encode()).decode()
+        req_headers = {
+            k: v for k, v in req_headers.items() if k.lower() != 
"authorization"
+        }
+        req_headers["Authorization"] = f"Basic {credentials}"
     post = http_post or _default_http_post
 
     attempts = retries + 1
@@ -1207,27 +1281,22 @@
         try:
             status, resp_body = post(url, data, req_headers, timeout)
         except Exception as e:  # noqa: BLE001 -- custom transports may raise 
anything
-            if attempt >= attempts - 1:
-                return VerifyServerResult(
-                    verified=False, reason=str(e) or type(e).__name__
-                )
-            _sleep_backoff(attempt, retry_delay, retry_backoff)
-            continue
-
-        if status == 400:
-            try:
-                err_data = json.loads(resp_body.decode())
-            except ValueError:
-                err_data = None
-            reason = (err_data or {}).get("error") or f"HTTP_{status}"
-            return VerifyServerResult(verified=False, reason=reason)
-
-        if not (200 <= status < 300):
-            if attempt >= attempts - 1:
-                return VerifyServerResult(verified=False, 
reason=f"HTTP_{status}")
-            _sleep_backoff(attempt, retry_delay, retry_backoff)
-            continue
+            reason = str(e) or type(e).__name__
+        else:
+            if 200 <= status < 300:
+                resp_data = _decode_json(resp_body)
+                if isinstance(resp_data, dict):
+                    return VerifyServerResult.from_dict(resp_data)
+                reason = "INVALID_RESPONSE"
+            else:
+                reason = _error_reason(status, resp_body)
+                # A 4xx (bad payload, missing or wrong credentials, rate 
limit) fails
+                # the same way again.
+                if 400 <= status < 500:
+                    return VerifyServerResult(verified=False, reason=reason)
 
-        return VerifyServerResult.from_dict(json.loads(resp_body.decode()))
+        if attempt >= attempts - 1:
+            return VerifyServerResult(verified=False, reason=reason)
+        _sleep_backoff(attempt, retry_delay, retry_backoff)
 
     return VerifyServerResult(verified=False, reason="NETWORK_ERROR")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/altcha-2.3.0/altcha.egg-info/PKG-INFO 
new/altcha-2.4.0/altcha.egg-info/PKG-INFO
--- old/altcha-2.3.0/altcha.egg-info/PKG-INFO   2026-10-04 03:20:50.350898700 
+0200
+++ new/altcha-2.4.0/altcha.egg-info/PKG-INFO   2026-11-17 08:07:18.627549000 
+0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.4
 Name: altcha
-Version: 2.3.0
+Version: 2.4.0
 Summary: A library for creating and verifying challenges for ALTCHA.
 Home-page: https://github.com/altcha-org/altcha-lib-py
 Author: Daniel Regeci
@@ -254,17 +254,99 @@
 
 #### `verify_fields_hash(form_data, fields, fields_hash, algorithm) → bool`
 
-Verifies the hash of specific form fields.
+Verifies the hash of specific form fields: the hex hash (`algorithm`, e.g. 
`'SHA-256'`) of
+the values of `fields` in `form_data`, joined with `\n`, must equal 
`fields_hash`.
 
-#### `verify_server_signature(payload, hmac_key) → (bool, 
ServerSignatureVerificationData | None, str | None)`
+#### `verify_server_signature(payload, hmac_secret, *, hmac_algorithm) → 
VerifyServerSignatureResult`
 
-Verifies an ALTCHA server signature.
+Verifies an ALTCHA server signature locally, e.g. the `payload` of Sentinel's
+`POST /v2/verify` (or `/v1/verify`) response, with the secret of the API key 
that signed
+it. Sentinel v1 and v2 sign the same way, so this works for both. To have 
Sentinel check
+the payload instead, use `verify_server` (below).
 
-#### `verify_server(payload, url, secret, *, headers, timeout, retries, 
retry_delay, retry_backoff, http_post) → VerifyServerResult`
+```python
+from altcha import verify_fields_hash, verify_server_signature
+
+result = verify_server_signature(payload, API_KEY_SECRET)
+
+if result.verified:
+    data = result.verification_data
+    # Detect tampering with the submitted form fields
+    if data.get("fields") and not verify_fields_hash(
+        form_data, data["fields"], data["fieldsHash"], "SHA-256"
+    ):
+        ...
+```
+
+| Parameter | Type | Default | Description |
+|---|---|---|---|
+| `payload` | `str` \| `ServerSignaturePayload` | — | Base64-encoded JSON 
string or `ServerSignaturePayload` object. Its `algorithm` (hash of 
`verificationData`) must be `'SHA-1'`, `'SHA-256'`, `'SHA-384'` or `'SHA-512'`. 
|
+| `hmac_secret` | `str` \| `bytes` | — | Secret used to verify the HMAC 
signature (the API key secret for Sentinel). Raises `ValueError` if empty. |
+| `hmac_algorithm` | `str` | `'SHA-256'` | HMAC digest algorithm. |
+
+Returns `VerifyServerSignatureResult` with fields:
 
-Verifies a payload remotely via the ALTCHA Sentinel `/v1/verify/signature` 
API, instead of
+| Field | Type | Description |
+|---|---|---|
+| `verified` | `bool` | `True` if the signature is valid, the payload has not 
expired, and `verified` is `true` in both the payload and the signed 
verification data. |
+| `expired` | `bool` | `True` if the signed `expire` is in the past. |
+| `invalid_signature` | `bool` | `True` if the signature does not match, or 
the payload is malformed. |
+| `invalid_solution` | `bool` | `True` if `verified` is not `true` in the 
payload or in the signed verification data. |
+| `time` | `float` | Time taken for verification in milliseconds. |
+| `verification_data` | `dict \| None` | The signed verification data, parsed 
with `parse_verification_data`; `None` unless `verified`. |
+
+`parse_verification_data(data)` turns the URL-encoded verification data into a 
flat dict:
+
+- Keys stay as signed, e.g. `data["challenge.algorithm"]` and 
`data["device.edk"]`
+  (`verify_server` returns these nested instead).
+- `'true'`/`'false'` become `bool`, all-digit values `int` (including e.g. a
+  `params.zip` of `01234`, which becomes `1234`), and `digits.digits` values 
`float`.
+- `fields` and `reasons` become lists.
+- Keys with empty values are left out.
+
+Unlike Sentinel v2's `/v2/verify/signature` (via `verify_server`), local 
verification does
+not prevent reuse: a valid payload verifies again until `expire`. Reject 
repeated `id`s
+yourself if that matters.
+
+#### `verify_server(payload, url, secret, *, api_key, headers, timeout, 
retries, retry_delay, retry_backoff, http_post) → VerifyServerResult`
+
+Verifies a payload remotely via the ALTCHA Sentinel verify signature API, 
instead of
 checking the HMAC signature locally. Avoids managing the HMAC secret on your 
server, at the
-cost of a network round-trip.
+cost of a network round-trip. Both Sentinel v2 (`POST /v2/verify/signature`) 
and Sentinel v1
+(`POST /v1/verify/signature`) are supported; they differ in how the request is 
authenticated.
+
+##### Sentinel v2
+
+```python
+from altcha import verify_server
+
+result = verify_server(
+    payload,  # the payload received from POST /v2/verify
+    url="https://sentinel.example.com/v2/verify/signature";,
+    api_key=SENTINEL_API_KEY,  # id of a restricted or full API key (key_...)
+    secret=SENTINEL_API_KEY_SECRET,  # its secret (sec_...)
+    timeout=10,
+    retries=2,
+)
+
+if result.verified:
+    ...
+```
+
+- `api_key` and `secret` are the ID and secret of a `restricted` or `full` API 
key of the
+  account that owns the payload's (public) API key. They are sent as
+  `Authorization: Basic base64(api_key:secret)`; an `Authorization` header in 
`headers` is
+  replaced. `api_key` without `secret` raises `ValueError` before any request 
is sent.
+- The request body is `{"payload": ...}`; `secret` is not sent in the body 
(Sentinel v2
+  rejects it).
+- Without credentials, Sentinel v2 answers `401` and `reason` is 
`'API_KEY_REQUIRED'`. A
+  payload signed by a key of another account gets 
`reason='API_KEY_NOT_ALLOWED'`.
+- `verification_data` is the signed verification data as a nested dict, with 
keys split on
+  `.`: `result.verification_data["challenge"]["algorithm"]` (v1's 
`challengeAlgorithm`),
+  `result.verification_data["device"]["edk"]`. `fields` and `reasons` are 
lists; `id`,
+  `fieldsHash`, `device.edk` and `params.*` stay strings.
+
+##### Sentinel v1
 
 ```python
 from altcha import verify_server
@@ -281,11 +363,20 @@
     ...
 ```
 
+- `/v1/verify/signature` takes no credentials: omit `api_key`. `secret` (the 
payload's API
+  key secret) is optional and sent in the body as `{"payload": ..., "secret": 
...}`; Sentinel
+  answers `reason='WRONG_API_KEY_SECRET'` when it is not the payload key's 
secret.
+- This also applies to the `/v1/verify/signature` alias Sentinel v2 serves with
+  `[server] v1_compat = true`.
+
+##### Parameters
+
 | Parameter | Type | Default | Description |
 |---|---|---|---|
 | `payload` | `str` \| `ServerSignaturePayload` \| `dict` | — | The payload to 
verify. |
-| `url` | `str` | — | Full URL of the Sentinel `/v1/verify/signature` 
endpoint. |
-| `secret` | `str` | `None` | API key secret, checked against the payload's 
API key. |
+| `url` | `str` | — | Full URL of the Sentinel endpoint: 
`/v2/verify/signature` (v2) or `/v1/verify/signature` (v1). |
+| `secret` | `str` | `None` | v2: secret of `api_key`, required with it. v1: 
API key secret sent in the body and checked against the payload's API key. |
+| `api_key` | `str` | `None` | v2 only: ID of a `restricted` or `full` API 
key, sent with `secret` as HTTP Basic credentials. |
 | `headers` | `dict` | `None` | Additional headers to send with the request. |
 | `timeout` | `float` | `10` | Per-attempt request timeout in seconds. |
 | `retries` | `int` | `0` | Number of retry attempts after the first try. |
@@ -293,14 +384,22 @@
 | `retry_backoff` | `str` | `'exponential'` | `'fixed'` or `'exponential'` 
backoff. |
 | `http_post` | callable | stdlib `urllib` | Transport override: `(url, body, 
headers, timeout) -> (status, body)`. |
 
+##### Errors and retries
+
+Failures never raise; they return `verified=False` with a `reason`. `4xx` 
responses (bad
+payload, missing or wrong credentials, rate limit) are definitive and returned 
at once.
+Network errors, other error statuses (e.g. `5xx`) and invalid response bodies 
are retried up
+to `retries` times. For an error response, `reason` is the `code` of 
Sentinel's error body
+(v2: `{"code", "error", "statusCode"}`), else its `error` (v1), else 
`'HTTP_<status>'`.
+
 Returns `VerifyServerResult` with fields:
 
 | Field | Type | Description |
 |---|---|---|
 | `verified` | `bool` | `True` if Sentinel confirmed the payload is valid. |
-| `reason` | `str \| None` | Failure reason, if any. |
+| `reason` | `str \| None` | Why verification failed: Sentinel's `reason` 
(e.g. `'PAYLOAD_ALREADY_USED'`, `'INVALID_PAYLOAD'`, `'API_KEY_NOT_ALLOWED'` 
(v2), `'WRONG_API_KEY_SECRET'` (v1)), the error code of an HTTP error response, 
`'INVALID_RESPONSE'`, or a network error message. |
 | `api_key` | `str \| None` | The API key associated with the payload, if 
returned. |
-| `verification_data` | `dict \| None` | Parsed verification data, if 
returned. |
+| `verification_data` | `dict \| None` | Verification data returned by 
Sentinel (nested dict), if returned. |
 
 ---
 
@@ -323,6 +422,12 @@
 | `expires` | `datetime` | `None` | Optional expiration time. |
 | `params` | `dict` | `None` | Optional URL-encoded query parameters appended 
to the salt. |
 
+#### `verify_server_signature_v1(payload, hmac_key) → (bool, 
ServerSignatureVerificationData | None, str | None)`
+
+Verifies a server signature with the v1 API. Returns `(verified, data, 
error)`, where `data`
+exposes the known fields (`classification`, `expire`, `fields`, `fieldsHash`, 
`score`, …)
+as attributes. Prefer `verify_server_signature`.
+
 #### `verify_solution_v1(payload, hmac_secret, check_expires) → (bool, str | 
None)`
 
 Verifies a v1 solution payload.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/altcha-2.3.0/setup.py new/altcha-2.4.0/setup.py
--- old/altcha-2.3.0/setup.py   2026-10-04 03:20:47.963458800 +0200
+++ new/altcha-2.4.0/setup.py   2026-11-17 08:07:10.527087200 +0100
@@ -7,7 +7,7 @@
 
 setup(
     name="altcha",
-    version="2.3.0",
+    version="2.4.0",
     description="A library for creating and verifying challenges for ALTCHA.",
     long_description=Path("README.md").read_text(encoding="utf-8"),
     long_description_content_type="text/markdown",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/altcha-2.3.0/tests/test_altcha_v2.py 
new/altcha-2.4.0/tests/test_altcha_v2.py
--- old/altcha-2.3.0/tests/test_altcha_v2.py    2026-10-04 03:20:47.963991900 
+0200
+++ new/altcha-2.4.0/tests/test_altcha_v2.py    2026-11-17 08:07:10.527551000 
+0100
@@ -882,6 +882,7 @@
 
 class TestVerifyServer(unittest.TestCase):
     URL = "https://sentinel.example.com/v1/verify/signature";
+    URL_V2 = "https://sentinel.example.com/v2/verify/signature";
 
     def setUp(self):
         self._sleep_calls: list[float] = []
@@ -914,14 +915,106 @@
         calls = []
 
         def post(url, data, headers, timeout):
-            calls.append(data)
+            calls.append((data, headers))
             return 200, json.dumps({"verified": True}).encode()
 
         verify_server("payload", self.URL, secret="sec_123", http_post=post)
         self.assertEqual(
-            json.loads(calls[0]), {"payload": "payload", "secret": "sec_123"}
+            json.loads(calls[0][0]), {"payload": "payload", "secret": 
"sec_123"}
+        )
+        self.assertNotIn("Authorization", calls[0][1])
+
+    def test_v2_api_key_sent_as_basic_auth_without_body_secret(self):
+        calls = []
+
+        def post(url, data, headers, timeout):
+            calls.append((url, data, headers))
+            return 200, json.dumps({"verified": True}).encode()
+
+        verify_server(
+            "payload",
+            self.URL_V2,
+            secret="sec_123",
+            api_key="key_restricted",
+            headers={"authorization": "Bearer other", "X-Extra": "1"},
+            http_post=post,
+        )
+        url, data, headers = calls[0]
+        self.assertEqual(url, self.URL_V2)
+        self.assertEqual(json.loads(data), {"payload": "payload"})
+        self.assertEqual(
+            headers,
+            {
+                "Content-Type": "application/json",
+                "X-Extra": "1",
+                "Authorization": "Basic "
+                + base64.b64encode(b"key_restricted:sec_123").decode(),
+            },
         )
 
+    def test_v2_api_key_without_secret_raises(self):
+        def post(url, data, headers, timeout):
+            raise AssertionError("no request expected")
+
+        for secret in (None, ""):
+            with self.subTest(secret=secret), self.assertRaises(ValueError):
+                verify_server(
+                    "payload",
+                    self.URL_V2,
+                    secret=secret,
+                    api_key="key_restricted",
+                    http_post=post,
+                )
+
+    def test_4xx_is_terminal_with_error_code(self):
+        for status in (400, 401, 403, 429):
+            calls = []
+
+            def post(url, data, headers, timeout, status=status, calls=calls):
+                calls.append(1)
+                body = {"code": "API_KEY_REQUIRED", "error": "API key 
required."}
+                return status, json.dumps({**body, "statusCode": 
status}).encode()
+
+            with self.subTest(status=status):
+                result = verify_server(
+                    "payload", self.URL_V2, retries=3, http_post=post
+                )
+                self.assertFalse(result.verified)
+                self.assertEqual(result.reason, "API_KEY_REQUIRED")
+                self.assertEqual(len(calls), 1)
+
+    def test_5xx_retried_then_fails_with_error_code(self):
+        calls = []
+
+        def post(url, data, headers, timeout):
+            calls.append(1)
+            return 503, json.dumps({"code": "UNAVAILABLE", "error": 
"x"}).encode()
+
+        result = verify_server("payload", self.URL_V2, retries=2, 
http_post=post)
+        self.assertFalse(result.verified)
+        self.assertEqual(result.reason, "UNAVAILABLE")
+        self.assertEqual(len(calls), 3)
+
+    def test_error_without_json_body_reports_status(self):
+        def post(url, data, headers, timeout):
+            return 502, b"Bad Gateway"
+
+        result = verify_server("payload", self.URL_V2, http_post=post)
+        self.assertFalse(result.verified)
+        self.assertEqual(result.reason, "HTTP_502")
+
+    def test_invalid_success_body_retried(self):
+        responses = [b"<html>", b"[]", json.dumps({"verified": True}).encode()]
+
+        def post(url, data, headers, timeout):
+            return 200, responses.pop(0)
+
+        result = verify_server("payload", self.URL_V2, retries=1, 
http_post=post)
+        self.assertFalse(result.verified)
+        self.assertEqual(result.reason, "INVALID_RESPONSE")
+        result = verify_server("payload", self.URL_V2, http_post=post)
+        self.assertTrue(result.verified)
+
     def test_secret_omitted_when_not_given(self):
         calls = []
 
@@ -975,6 +1068,8 @@
             signature="sig",
             verification_data="verified=true",
             verified=True,
+            api_key="key_1",
+            id="543713f0",
         )
         calls = []
 
@@ -991,8 +1086,13 @@
                 "signature": "sig",
                 "verificationData": "verified=true",
                 "verified": True,
+                "apiKey": "key_1",
+                "id": "543713f0",
             },
         )
+        self.assertEqual(
+            ServerSignaturePayload.from_dict(sent["payload"]).api_key, "key_1"
+        )
 
     def test_fixed_backoff(self):
         def post(url, data, headers, timeout):

Reply via email to