Metadata-Version: 2.5
Name: abiz
Version: 2026.1116.1
Summary: Check ABIZ (Agentic Business Record) DNS assertions and signed business records, ABIZ 1.1.
Project-URL: Homepage, https://abizrecord.org
Project-URL: Repository, https://github.com/abiz-org/abiz-python
Project-URL: Issues, https://github.com/abiz-org/abiz-python/issues
Author: ABIZ contributors
Maintainer: ABIZ contributors
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
License-File: src/abiz/data/iso3166.README.md
Keywords: abiz,agents,business record,dns,ed25519,jcs,rfc8785,txt
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: Name Service (DNS)
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: cryptography<51,>=50.0.2
Requires-Dist: dnspython<3,>=2.8.0; python_version < '3.11'
Requires-Dist: dnspython<3,>=2.9.1; python_version >= '3.11'
Requires-Dist: fqdn<2,>=1.6.0
Requires-Dist: idna<4,>=3.20
Requires-Dist: jsonschema<5,>=4.26.0
Requires-Dist: rfc3339-validator<0.2,>=0.1.4
Requires-Dist: rfc3986-validator<0.2,>=0.1.1
Requires-Dist: tzdata>=2026.6; sys_platform == 'win32'
Provides-Extra: test
Requires-Dist: pytest==9.2.0; extra == 'test'
Description-Content-Type: text/markdown

# abiz (Python)

A Python library and command for consumers of ABIZ, the Agentic Business Record. Given a domain, it finds the domain's `_abiz` DNS TXT assertion and fetches the business record the assertion points to. It then checks that record and tells you whether it resolved. It gives the same status and error code as the hosted resolver at `resolve.abizrecord.org`.

It implements **ABIZ 1.1** and passes every case in the shared ABIZ test vectors (format 1).

## Install

```bash
pip install abiz
```

Python 3.10 or later.

## Example

```python
import abiz

result = abiz.resolve("harbourbikes.example.org")   # or abiz.resolve(website="https://www.example.com/about")
if result.ok:
    record = result.record
    print(record["business_name"], record["identity_host"])
else:
    print(result.status, result.code, result.message)    # e.g. not_found missing_txt
    if result.retryable:
        print("Temporary failure: this does not show the record is missing.")
```

From the command line:

```bash
abiz check harbourbikes.example.org
abiz check --website https://www.example.com/about --json
```

The command exits with 0 when the record resolved. It exits with 1 when the record is invalid, missing or in conflict. It exits with 2 when a lookup was unavailable or the input was not a usable domain.

## What is checked

In the order the resolver uses (the first failure decides the code):

1. **Input.** The input is lower-cased, IDN is converted to A-labels and one trailing dot is dropped. A URL, port, credentials or IP literal is refused (`invalid_domain`, `invalid_website`). So is a special-use name (`non_public_domain`). `www.` is never stripped; the apex is only suggested (`try_apex` warning).
2. **DNS.** The library sends one TXT query for `_abiz.<domain>`. NXDOMAIN and NODATA count as absence. A timeout or a failure is reported as `unavailable` and never counts as absence.
3. **Assertion.** Exactly one `v=abiz1` value is allowed (`multiple_txt`). It is read with the ABIZ 1.1 tag-list syntax. `h` must be a host with an optional path. `k` is the business key, if present. `p` is a canonical base64 Ed25519 key.
4. **Well-known file.** `https://<domain>/.well-known/abiz.json` is used only when DNS answered and held no `v=abiz1` value.
5. **Fetch.** The library makes one GET of `https://<h>?format=json` through the fetch guard. It checks every resolved address and refuses private, reserved and special-purpose ranges. It then connects to the checked address, never to the name a second time. TLS is verified for the name. Redirects are not followed, the timeout is 5 s and the body limit is 64 KiB.
6. **Record.** The record must be I-JSON: repeated member names are refused, nesting may be at most 16 deep and there may be at most 5,000 members. It must pass the pinned ABIZ 1.1 JSON Schema (Draft 2020-12, formats asserted) and the semantic checks. Those checks cover safe https URLs, assigned country and region codes, IANA time zones, non-overlapping opening hours, unique ids and ratings within their scale.
7. **Link.** `identity_host` must equal `h`, and `domains` must include the queried domain. `k` and `business_key` must agree with `country` and `registration_number`. `public_key` must equal `p`.
8. **Signature.** The signature must be a valid Ed25519 signature over the RFC 8785 (JCS) form of the record, without its `signature` member.

## What is not checked

- **No company register is consulted.** A resolved record is the publisher's own statement. The library checks that it is well formed and signed with the key that the domain's DNS publishes. The business facts in it are checked for form only. They are not verified against any register or other source.
- **`mcp_server_url` and every other URL in a record are never contacted.** At most two requests are made: the well-known file (only when DNS has no assertion) and the record.
- DNSSEC is not validated. The answer is whatever your configured DNS resolver returns.
- Time zones are checked against the IANA database installed with Python (`zoneinfo`; the `tzdata` package is installed on Windows).

## API

| Function | Returns |
| --- | --- |
| `resolve(domain)` / `resolve(website=...)` | A `Result`. Its fields are `status` (`resolved`, `invalid_input`, `not_found`, `conflict`, `invalid_record` or `unavailable`), `code` (None when resolved), `message`, `retryable`, `details` (path and message, at most 25), `record` (only when resolved), `discovery` (`method` `dns_txt` or `well_known`, `owner`, `dns_value`, `record_url`, `well_known`, `well_known_url`) and `warnings` (`content_type`, `try_apex` with `domain`). `Result.to_dict()` gives the same as plain data. |
| `parse_assertion(value)` | An `Assertion` (`h`, `k`, `p`, `unknown`), or an `AssertionProblem` with `.code` (falsy) |
| `check_record(record_text, domain, assertion, details=None)` | None, or the error code; works offline (`assertion` is a TXT value or an `Assertion`) |
| `verify_signature(record, p)` | None (ok), `public_key_mismatch` or `signature_invalid` |
| `canonicalize(value)` | The RFC 8785 text |
| `sign_record(record, private_key)` | A producer helper. Returns a copy of the record with `public_key` and `signature` set. The key is a `cryptography` Ed25519 private key or its 32-byte seed. |
| `is_assertion`, `is_public_key`, `is_public_address`, `identity_parts`, `normalise_input`, `parse_business_key`, `signing_input`, `public_key_of` | The individual rules the functions above use |

DNS and HTTP are separate, small interfaces. Pass `dns=` (an object with `query_txt(name) -> TxtLookup`) and `fetcher=` (an object with `fetch(url) -> FetchOutcome`) to `resolve` to use DNS-over-HTTPS, a proxy, a cache or test stubs. The defaults are `DnsPythonResolver` (dnspython, 2.5 s) and `GuardedFetcher` (the standard library, with the fetch guard above). `GuardedFetcher(resolve_addresses=...)` takes your own A/AAAA lookup. If you write your own fetcher, it must apply the same guard.

## Conformance

The library passes all of the shared ABIZ test vectors, format 1, for ABIZ 1.1. The vectors cover assertions, public keys, hosts and inputs, addresses, JCS, signing, records checked offline, and whole resolutions against a fake DNS and fetch. It bundles two files and checks each against its SHA-256 at load time:

- `abiz-business-record-v1.1.schema.json`, SHA-256 `3658f17f00c238b8c948fdfb447b509c5d055dd778ebd335495da05c3150ff24`
- `iso3166.json`, SHA-256 `0aa5112c46bc2b3efb254ea9536b3cf2977c73d48149aefcd8bc20df995e5527`

To run the tests from a checkout (the vectors are in `test-vectors/`; set `ABIZ_TEST_VECTORS` to use another copy):

```bash
python -m venv .venv && .venv/bin/pip install --require-hashes -r requirements-lock.txt && .venv/bin/pip install --no-deps -e . && .venv/bin/python -m pytest
```

## Licence

The library is licensed under Apache-2.0; see `LICENSE` and `NOTICE`. Parts are ported from the ABIZ reference validator (`scripts/validate.py`, Apache-2.0). The bundled `iso3166.json` is LGPL-2.1 (Debian iso-codes via pycountry); see `abiz/data/iso3166.README.md`.

Homepage: https://abizrecord.org. Source: https://github.com/abiz-org/abiz-python
