Skip to main content

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.

Metadata

Release files for swarmauri_keyprovider_file 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swarmauri_keyprovider_file 0.2.0
File Size Uploaded
swarmauri_keyprovider_file-0.2.0.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swarmauri_keyprovider_file 0.2.0
File Interpreter ABI Platform
swarmauri_keyprovider_file-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.2 kB

Release files / swarmauri_keyprovider_file-0.2.0.tar.gz

Download URL swarmauri_keyprovider_file-0.2.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5476bb24100ce9d814c296b77892b6824d23a280431560b89e5c746e7e648bdd
BLAKE2b-256 checksum
How to use checksums
6a6944e0ef0d7a860f0aa7a85d6ffe91cfe21a2f62813d71edc5e1711b7d483a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","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}

Release files / swarmauri_keyprovider_file-0.2.0-py3-none-any.whl

Download URL swarmauri_keyprovider_file-0.2.0-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b42bcd393a76f9d5bf4e10473a7f57354d3a5e86f28341f9f6d5c673515e15c8
BLAKE2b-256 checksum
How to use checksums
214be8e0c08007b113e94a4dba57e734da5ff7284052490bd61c23ec5eac9b25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","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}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page