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.dev24.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.dev24.tar.gz.

File metadata

  • Download URL: swarmauri_keyprovider_file-0.2.1.dev24.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.dev24.tar.gz
Algorithm Hash digest
SHA256 fc68cc6bd76819b78421ca1e59dfbcc9008feb615d048c27784119286c3d696a
MD5 09969eb667c4b0d2dbf525c2569a786d
BLAKE2b-256 7e258ec3e44d0d00d20a238b8ea428326b762a8388ab456e8cf1b0abdeb2b915

See more details on using hashes here.

File details

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

File metadata

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

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