Skip to main content

File-backed key provider for Swarmauri

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_keyprovider_file


Swarmauri File Key Provider

FileKeyProvider is a file-backed implementation of the KeyProviderBase interface. It persists each key beneath a keys/<kid>/v<version>/ directory, captures metadata in meta.json, and exports public material in PEM or JWK form. The provider supports the same lifecycle semantics as the in-memory providers, but every operation is durable on disk.

Highlights

  • Generate symmetric AES-256-GCM keys and asymmetric Ed25519, X25519, RSA (OAEP/PSS), or ECDSA (P-256) key material.
  • Import existing keys while preserving private material when allowed by the selected ExportPolicy.
  • Rotate versions in-place, destroy versions or entire keys, and list historical versions stored on disk.
  • Publish public material as individual JWKs or aggregate JWKS documents and expose HKDF and random byte helpers.

Installation

Choose the tool that matches your workflow:

# pip
pip install swarmauri_keyprovider_file

# Poetry
poetry add swarmauri_keyprovider_file

# uv
uv add swarmauri_keyprovider_file

Usage

import asyncio
from tempfile import TemporaryDirectory

from swarmauri_keyprovider_file import FileKeyProvider
from swarmauri_core.key_providers.types import (
    ExportPolicy,
    KeyAlg,
    KeyClass,
    KeySpec,
)
from swarmauri_core.crypto.types import KeyUse


async def run_example() -> str:
    with TemporaryDirectory() as tmp:
        provider = FileKeyProvider(tmp)
        spec = KeySpec(
            klass=KeyClass.symmetric,
            alg=KeyAlg.AES256_GCM,
            uses=(KeyUse.ENCRYPT,),
            export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
        )
        created = await provider.create_key(spec)
        provider2 = FileKeyProvider(tmp)
        loaded = await provider2.get_key(created.kid, include_secret=True)
        print(f"Loaded key: {loaded.kid}")


asyncio.run(run_example())

FileKeyProvider is asynchronous—every lifecycle method returns a KeyRef. Use include_secret=True when retrieving keys that allow private material export so symmetric key bytes are loaded from disk.

Entry Point

The provider registers under the swarmauri.key_providers entry point as FileKeyProvider.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

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

swarmauri_keyprovider_file-0.2.1.dev9.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

swarmauri_keyprovider_file-0.2.1.dev9-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_keyprovider_file-0.2.1.dev9.tar.gz.

File metadata

  • Download URL: swarmauri_keyprovider_file-0.2.1.dev9.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_keyprovider_file-0.2.1.dev9.tar.gz
Algorithm Hash digest
SHA256 8739d94ae9fe5ddc5a34236e36a38d00a518a1a27650e3d45505125cfa4762bc
MD5 d0edf319db7eee6882fe2d22099201c1
BLAKE2b-256 5097ba4dc49bf52095c778ec7d8c1b35842b953a704ddf97f1f96a720dc0a300

See more details on using hashes here.

File details

Details for the file swarmauri_keyprovider_file-0.2.1.dev9-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_keyprovider_file-0.2.1.dev9-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_keyprovider_file-0.2.1.dev9-py3-none-any.whl
Algorithm Hash digest
SHA256 1bc5d29c589e2452a1cc8f23444107791fb51ed6036096febbf93765df8ec1bb
MD5 422af141249366361c23d56ff0b1e8f4
BLAKE2b-256 50cdbf1d4cf8ca43cbcf1c1628b31c067885aa8d316c3884a052651571284508

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