Skip to main content

Python SDK for licensefoundry — issuance, verification, and CoMP-shaped translation of W3C Verifiable Credentials.

Reason this release was yanked:

Renamed fields rubric_version/rubric_url to framework_version/framework_url in 0.3.0

Project description

licensefoundry

Python SDK for licensefoundry — issuance, verification, and CoMP-shaped translation of W3C Verifiable Credentials (JWT-VC encoded, Ed25519-signed).

Built in: Phase 5 of /docs/path-c-rebuild-plan.md.

Install

pip install licensefoundry

Requires Python ≥ 3.10.

Quick start

import os
from licensefoundry import (
    LicenseFoundryClient,
    IssueCredentialRequest,
    Rights,
    TrainGrant,
    TrainScope,
    CommercialGrant,
    CredentialScope,
    Attribution,
    CapabilityNotEnabledError,
)

with LicenseFoundryClient(
    base_url="https://api.licensefoundry.com",
    api_key=os.environ["LICENSEFOUNDRY_API_KEY"],
    # Production verifiers MUST list only their production issuer DID
    accepted_issuers=["did:web:licensefoundry.com"],
) as lf:
    try:
        cred = lf.issuer.issue_credential(IssueCredentialRequest(
            asset_id="...",
            rights=Rights(
                train=TrainGrant(granted=True, scope=TrainScope(model_family="open-source")),
                commercial=CommercialGrant(granted=True),
            ),
            scope=CredentialScope(
                audience="single_product",
                product_id="my-rag",
                jurisdiction=["US"],
                attribution=Attribution(required=True),
            ),
        ))
        print(cred.credential_jwt)
    except CapabilityNotEnabledError as e:
        show_upgrade_modal(plan=e.required_plan, url=e.upgrade_url)

    # Verify offline (uses cached JWKS + Status List 2021)
    result = lf.verifier.verify(some_jwt)
    if not result.valid:
        print("invalid:", result.errors)

Public surface

Module Use for
lf.issuer register_asset, issue_credential, revoke_credential, status
lf.verifier Offline verification with cached JWKS and Status List 2021
licensefoundry.comp from_credential(vc), satisfies(vc, function=, ause=, ...)

The customer-facing API uses canonical Path C field names (train, rag, embed, display, eval, derive, commercial). CoMP terminology (function, subfn, ause, licensedur, etc.) is opt-in via licensefoundry.comp.

Typed errors

Per /docs/auth-access-flows.md §4.5, HTTP failures surface as typed exceptions:

Exception When
AuthError 401 — bad/missing API key
CapabilityNotEnabledError 402 with error: capability_not_enabled — upgrade needed
ScopeDeniedError 403 — API key scope rejects this action
NotFoundError 404
ConflictError 409 — e.g. asset not yet anchored
ValidationError 422
RateLimitedError 429 — carries retry_after
ServerError 5xx
NetworkError request failure / timeout
VerificationError raised by verifier.verify_or_raise()

Verification

Verifier performs offline verification per /docs/credential-format.md §7:

  1. Parse JWT
  2. Resolve issuer (cached did:web → JWKS)
  3. EdDSA signature verification (via cryptography)
  4. Temporal validity
  5. @context and issuer accepted-list checks
  6. Revocation via Status List 2021 bitstring (cached)

Per /docs/billing-model.md §2, offline verification is free — no metering event. Online verification (calling the issuer's /v1/credentials/verify endpoint) is metered.

Specs that govern this SDK

Develop

pip install -e ".[dev]"
pytest
ruff check .
mypy src

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

licensefoundry-0.2.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

licensefoundry-0.2.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file licensefoundry-0.2.0.tar.gz.

File metadata

  • Download URL: licensefoundry-0.2.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for licensefoundry-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2fa5c4975ebf3638a54177884d642784583f480a089293087893eb4283e21037
MD5 beaf24529764fd6ca754f7133da2fe09
BLAKE2b-256 f0a70875e0c2f189ea3497d559e68ba2f304ec008a67298a8e37e39d0b7b297b

See more details on using hashes here.

File details

Details for the file licensefoundry-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: licensefoundry-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for licensefoundry-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4deb520f9af2806eecd60b6273bc0de58f8c48dc149c0a3380175b42bdd1ca36
MD5 79855556b290b311841b241683386ef1
BLAKE2b-256 98db192ce1917419a5fc90a857b63642984b82ba2f5fb593cb3feb2389c3cd98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page