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.dev14.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.

File details

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

File metadata

  • Download URL: swarmauri_keyprovider_file-0.2.1.dev14.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.dev14.tar.gz
Algorithm Hash digest
SHA256 6883f51c6e8c17c8bd92abcda8a41ad1bda8dad92ad7900bf5879b862656751d
MD5 93d2f4d19b6948b1f2e43d86cfae6f90
BLAKE2b-256 fb27aca5ad95c3a6ddf8260b0adee4d4acd30337f15ebd64557c528a7ef61639

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_keyprovider_file-0.2.1.dev14-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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.dev14-py3-none-any.whl
Algorithm Hash digest
SHA256 fabe856ad1028fc8af8ff80f5f37a521822e4a6bb8fd5550630e3ddad21dc96f
MD5 ce2de44b741a0ba63d3c3c32875b391e
BLAKE2b-256 13b17eb4b7da7e0585dcb7c3db45638d9ae4411c31a6a09df0856a31bc7133a9

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