swarmauri_keyprovider_local 0.2.0.dev4__tar.gz → 0.2.1.dev9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swarmauri_keyprovider_local-0.2.1.dev9/PKG-INFO +135 -0
- swarmauri_keyprovider_local-0.2.1.dev9/README.md +108 -0
- {swarmauri_keyprovider_local-0.2.0.dev4 → swarmauri_keyprovider_local-0.2.1.dev9}/pyproject.toml +14 -2
- {swarmauri_keyprovider_local-0.2.0.dev4 → swarmauri_keyprovider_local-0.2.1.dev9}/swarmauri_keyprovider_local/LocalKeyProvider.py +31 -4
- {swarmauri_keyprovider_local-0.2.0.dev4 → swarmauri_keyprovider_local-0.2.1.dev9}/swarmauri_keyprovider_local/examples/README.md +1 -1
- {swarmauri_keyprovider_local-0.2.0.dev4 → swarmauri_keyprovider_local-0.2.1.dev9}/swarmauri_keyprovider_local/examples/basic_usage.py +1 -1
- swarmauri_keyprovider_local-0.2.0.dev4/PKG-INFO +0 -64
- swarmauri_keyprovider_local-0.2.0.dev4/README.md +0 -41
- {swarmauri_keyprovider_local-0.2.0.dev4 → swarmauri_keyprovider_local-0.2.1.dev9}/LICENSE +0 -0
- {swarmauri_keyprovider_local-0.2.0.dev4 → swarmauri_keyprovider_local-0.2.1.dev9}/swarmauri_keyprovider_local/__init__.py +0 -0
- {swarmauri_keyprovider_local-0.2.0.dev4 → swarmauri_keyprovider_local-0.2.1.dev9}/swarmauri_keyprovider_local/examples/__init__.py +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_keyprovider_local
|
|
3
|
+
Version: 0.2.1.dev9
|
|
4
|
+
Summary: In-memory key provider for development and testing
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: swarmauri,sdk,standards,keyprovider,local,key-management
|
|
8
|
+
Author: Jacob Stewart
|
|
9
|
+
Author-email: jacob@swarmauri.com
|
|
10
|
+
Requires-Python: >=3.10,<3.13
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Development Status :: 3 - Alpha
|
|
18
|
+
Classifier: Topic :: Security :: Cryptography
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: Programming Language :: Python
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
23
|
+
Requires-Dist: cryptography
|
|
24
|
+
Requires-Dist: swarmauri_base
|
|
25
|
+
Requires-Dist: swarmauri_core
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_local/"><img src="https://img.shields.io/pypi/dm/swarmauri_keyprovider_local" alt="PyPI - Downloads"/></a>
|
|
32
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_keyprovider_local/"><img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_keyprovider_local.svg"/></a>
|
|
33
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_local/"><img src="https://img.shields.io/pypi/pyversions/swarmauri_keyprovider_local" alt="PyPI - Python Version"/></a>
|
|
34
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_local/"><img src="https://img.shields.io/pypi/l/swarmauri_keyprovider_local" alt="PyPI - License"/></a>
|
|
35
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_local/"><img src="https://img.shields.io/pypi/v/swarmauri_keyprovider_local?label=swarmauri_keyprovider_local&color=green" alt="PyPI - swarmauri_keyprovider_local"/></a>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
# Swarmauri Local Key Provider
|
|
39
|
+
|
|
40
|
+
Provides a pure in-memory implementation of the `KeyProviderBase` suitable for
|
|
41
|
+
local development, unit testing, and rapid prototyping without any external
|
|
42
|
+
infrastructure.
|
|
43
|
+
|
|
44
|
+
## Capabilities
|
|
45
|
+
|
|
46
|
+
- Generate symmetric AES-256-GCM keys and several asymmetric algorithms
|
|
47
|
+
(Ed25519, X25519, RSA-OAEP/PSS-SHA256, and ECDSA P-256-SHA256).
|
|
48
|
+
- Import existing key material and rotate to new versions on demand.
|
|
49
|
+
- Retrieve stored keys (optionally including the secret material) and list
|
|
50
|
+
available versions.
|
|
51
|
+
- Export public material as individual JWKs or aggregate JWKS documents.
|
|
52
|
+
- Produce cryptographically secure random bytes or derive material using HKDF.
|
|
53
|
+
- Destroy keys when they are no longer needed to keep local environments tidy.
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
Choose the tool that best matches your workflow:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# pip
|
|
61
|
+
pip install swarmauri_keyprovider_local
|
|
62
|
+
|
|
63
|
+
# Poetry
|
|
64
|
+
poetry add swarmauri_keyprovider_local
|
|
65
|
+
|
|
66
|
+
# uv
|
|
67
|
+
uv add swarmauri_keyprovider_local
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Quickstart
|
|
71
|
+
|
|
72
|
+
The example below mirrors `swarmauri_keyprovider_local.examples.basic_usage`
|
|
73
|
+
and demonstrates how to create, store, and retrieve a symmetric key.
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
import asyncio
|
|
77
|
+
from swarmauri_keyprovider_local import LocalKeyProvider
|
|
78
|
+
from swarmauri_core.key_providers.types import (
|
|
79
|
+
ExportPolicy,
|
|
80
|
+
KeyAlg,
|
|
81
|
+
KeyClass,
|
|
82
|
+
KeySpec,
|
|
83
|
+
)
|
|
84
|
+
from swarmauri_core.crypto.types import KeyUse
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
async def run_example() -> str:
|
|
88
|
+
"""Create and retrieve a symmetric key using LocalKeyProvider."""
|
|
89
|
+
|
|
90
|
+
provider = LocalKeyProvider()
|
|
91
|
+
spec = KeySpec(
|
|
92
|
+
klass=KeyClass.symmetric,
|
|
93
|
+
alg=KeyAlg.AES256_GCM,
|
|
94
|
+
uses=(KeyUse.ENCRYPT,),
|
|
95
|
+
export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
|
|
96
|
+
)
|
|
97
|
+
created = await provider.create_key(spec)
|
|
98
|
+
fetched = await provider.get_key(created.kid, include_secret=True)
|
|
99
|
+
assert fetched.material is not None
|
|
100
|
+
return fetched.kid
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
if __name__ == "__main__":
|
|
104
|
+
print(asyncio.run(run_example()))
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Rotate, export, and derive
|
|
108
|
+
|
|
109
|
+
Once you have a provider instance, additional asynchronous helpers are
|
|
110
|
+
available to manage keys and metadata:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
# Rotate the current key in-place (keeps the same KID with a new version)
|
|
114
|
+
rotated = await provider.rotate_key(created.kid)
|
|
115
|
+
|
|
116
|
+
# List available versions for auditing or debugging
|
|
117
|
+
versions = await provider.list_versions(created.kid)
|
|
118
|
+
|
|
119
|
+
# Export public material
|
|
120
|
+
jwk = await provider.get_public_jwk(created.kid)
|
|
121
|
+
jwks = await provider.jwks()
|
|
122
|
+
|
|
123
|
+
# Destroy keys when finished
|
|
124
|
+
await provider.destroy_key(created.kid)
|
|
125
|
+
|
|
126
|
+
# Generate bytes or derive new material locally
|
|
127
|
+
random_bytes = await provider.random_bytes(32)
|
|
128
|
+
derived = await provider.hkdf(b"ikm", salt=b"salt", info=b"context", length=32)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Want to help?
|
|
132
|
+
|
|
133
|
+
If you want to contribute to swarmauri-sdk, read up on our
|
|
134
|
+
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
135
|
+
that will help you get started.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_local/"><img src="https://img.shields.io/pypi/dm/swarmauri_keyprovider_local" alt="PyPI - Downloads"/></a>
|
|
5
|
+
<a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_keyprovider_local/"><img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/standards/swarmauri_keyprovider_local.svg"/></a>
|
|
6
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_local/"><img src="https://img.shields.io/pypi/pyversions/swarmauri_keyprovider_local" alt="PyPI - Python Version"/></a>
|
|
7
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_local/"><img src="https://img.shields.io/pypi/l/swarmauri_keyprovider_local" alt="PyPI - License"/></a>
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_keyprovider_local/"><img src="https://img.shields.io/pypi/v/swarmauri_keyprovider_local?label=swarmauri_keyprovider_local&color=green" alt="PyPI - swarmauri_keyprovider_local"/></a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
# Swarmauri Local Key Provider
|
|
12
|
+
|
|
13
|
+
Provides a pure in-memory implementation of the `KeyProviderBase` suitable for
|
|
14
|
+
local development, unit testing, and rapid prototyping without any external
|
|
15
|
+
infrastructure.
|
|
16
|
+
|
|
17
|
+
## Capabilities
|
|
18
|
+
|
|
19
|
+
- Generate symmetric AES-256-GCM keys and several asymmetric algorithms
|
|
20
|
+
(Ed25519, X25519, RSA-OAEP/PSS-SHA256, and ECDSA P-256-SHA256).
|
|
21
|
+
- Import existing key material and rotate to new versions on demand.
|
|
22
|
+
- Retrieve stored keys (optionally including the secret material) and list
|
|
23
|
+
available versions.
|
|
24
|
+
- Export public material as individual JWKs or aggregate JWKS documents.
|
|
25
|
+
- Produce cryptographically secure random bytes or derive material using HKDF.
|
|
26
|
+
- Destroy keys when they are no longer needed to keep local environments tidy.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
Choose the tool that best matches your workflow:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# pip
|
|
34
|
+
pip install swarmauri_keyprovider_local
|
|
35
|
+
|
|
36
|
+
# Poetry
|
|
37
|
+
poetry add swarmauri_keyprovider_local
|
|
38
|
+
|
|
39
|
+
# uv
|
|
40
|
+
uv add swarmauri_keyprovider_local
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quickstart
|
|
44
|
+
|
|
45
|
+
The example below mirrors `swarmauri_keyprovider_local.examples.basic_usage`
|
|
46
|
+
and demonstrates how to create, store, and retrieve a symmetric key.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import asyncio
|
|
50
|
+
from swarmauri_keyprovider_local import LocalKeyProvider
|
|
51
|
+
from swarmauri_core.key_providers.types import (
|
|
52
|
+
ExportPolicy,
|
|
53
|
+
KeyAlg,
|
|
54
|
+
KeyClass,
|
|
55
|
+
KeySpec,
|
|
56
|
+
)
|
|
57
|
+
from swarmauri_core.crypto.types import KeyUse
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def run_example() -> str:
|
|
61
|
+
"""Create and retrieve a symmetric key using LocalKeyProvider."""
|
|
62
|
+
|
|
63
|
+
provider = LocalKeyProvider()
|
|
64
|
+
spec = KeySpec(
|
|
65
|
+
klass=KeyClass.symmetric,
|
|
66
|
+
alg=KeyAlg.AES256_GCM,
|
|
67
|
+
uses=(KeyUse.ENCRYPT,),
|
|
68
|
+
export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
|
|
69
|
+
)
|
|
70
|
+
created = await provider.create_key(spec)
|
|
71
|
+
fetched = await provider.get_key(created.kid, include_secret=True)
|
|
72
|
+
assert fetched.material is not None
|
|
73
|
+
return fetched.kid
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if __name__ == "__main__":
|
|
77
|
+
print(asyncio.run(run_example()))
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Rotate, export, and derive
|
|
81
|
+
|
|
82
|
+
Once you have a provider instance, additional asynchronous helpers are
|
|
83
|
+
available to manage keys and metadata:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
# Rotate the current key in-place (keeps the same KID with a new version)
|
|
87
|
+
rotated = await provider.rotate_key(created.kid)
|
|
88
|
+
|
|
89
|
+
# List available versions for auditing or debugging
|
|
90
|
+
versions = await provider.list_versions(created.kid)
|
|
91
|
+
|
|
92
|
+
# Export public material
|
|
93
|
+
jwk = await provider.get_public_jwk(created.kid)
|
|
94
|
+
jwks = await provider.jwks()
|
|
95
|
+
|
|
96
|
+
# Destroy keys when finished
|
|
97
|
+
await provider.destroy_key(created.kid)
|
|
98
|
+
|
|
99
|
+
# Generate bytes or derive new material locally
|
|
100
|
+
random_bytes = await provider.random_bytes(32)
|
|
101
|
+
derived = await provider.hkdf(b"ikm", salt=b"salt", info=b"context", length=32)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Want to help?
|
|
105
|
+
|
|
106
|
+
If you want to contribute to swarmauri-sdk, read up on our
|
|
107
|
+
[guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md)
|
|
108
|
+
that will help you get started.
|
{swarmauri_keyprovider_local-0.2.0.dev4 → swarmauri_keyprovider_local-0.2.1.dev9}/pyproject.toml
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_keyprovider_local"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.1.dev9"
|
|
4
4
|
description = "In-memory key provider for development and testing"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
requires-python = ">=3.10,<3.13"
|
|
8
|
-
authors = [{ name = "
|
|
8
|
+
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
9
9
|
classifiers = [
|
|
10
10
|
"License :: OSI Approved :: Apache Software License",
|
|
11
11
|
"Natural Language :: English",
|
|
@@ -16,12 +16,23 @@ classifiers = [
|
|
|
16
16
|
"Development Status :: 3 - Alpha",
|
|
17
17
|
"Topic :: Security :: Cryptography",
|
|
18
18
|
"Intended Audience :: Developers",
|
|
19
|
+
"Programming Language :: Python",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
19
22
|
]
|
|
20
23
|
dependencies = [
|
|
21
24
|
"swarmauri_core",
|
|
22
25
|
"swarmauri_base",
|
|
23
26
|
"cryptography",
|
|
24
27
|
]
|
|
28
|
+
keywords = [
|
|
29
|
+
'swarmauri',
|
|
30
|
+
'sdk',
|
|
31
|
+
'standards',
|
|
32
|
+
'keyprovider',
|
|
33
|
+
'local',
|
|
34
|
+
'key-management',
|
|
35
|
+
]
|
|
25
36
|
|
|
26
37
|
[tool.uv.sources]
|
|
27
38
|
swarmauri_core = { workspace = true }
|
|
@@ -36,6 +47,7 @@ markers = [
|
|
|
36
47
|
"r8n: Regression tests",
|
|
37
48
|
"acceptance: Acceptance tests",
|
|
38
49
|
"perf: Performance tests",
|
|
50
|
+
"example: Example usage tests",
|
|
39
51
|
]
|
|
40
52
|
timeout = 300
|
|
41
53
|
log_cli = true
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
"""In-memory key provider for symmetric and asymmetric algorithms.
|
|
2
|
+
|
|
3
|
+
This module offers :class:`LocalKeyProvider` for quick development and testing
|
|
4
|
+
without external dependencies.
|
|
5
|
+
"""
|
|
6
|
+
|
|
1
7
|
from __future__ import annotations
|
|
2
8
|
|
|
3
9
|
import base64
|
|
@@ -10,17 +16,28 @@ from cryptography.hazmat.primitives import hashes, serialization
|
|
|
10
16
|
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
|
|
11
17
|
from cryptography.hazmat.primitives.asymmetric import ed25519, rsa, ec, x25519
|
|
12
18
|
|
|
13
|
-
from swarmauri_base.
|
|
14
|
-
from swarmauri_core.
|
|
19
|
+
from swarmauri_base.key_providers.KeyProviderBase import KeyProviderBase
|
|
20
|
+
from swarmauri_core.key_providers.types import KeySpec, KeyAlg, KeyClass, ExportPolicy
|
|
15
21
|
from swarmauri_core.crypto.types import KeyRef
|
|
16
22
|
|
|
17
23
|
|
|
18
24
|
def _b64u(b: bytes) -> str:
|
|
25
|
+
"""URL-safe base64 encoding without padding.
|
|
26
|
+
|
|
27
|
+
b (bytes): Data to encode.
|
|
28
|
+
RETURNS (str): Encoded string.
|
|
29
|
+
"""
|
|
30
|
+
|
|
19
31
|
return base64.urlsafe_b64encode(b).rstrip(b"=").decode("ascii")
|
|
20
32
|
|
|
21
33
|
|
|
22
34
|
def _serialize_keypair(priv, spec: KeySpec) -> tuple[bytes, Optional[bytes]]:
|
|
23
|
-
"""Serialize a private key and its public counterpart
|
|
35
|
+
"""Serialize a private key and its public counterpart.
|
|
36
|
+
|
|
37
|
+
priv: The private key to serialize.
|
|
38
|
+
spec (KeySpec): Options controlling the encoding.
|
|
39
|
+
RETURNS (Tuple[bytes, Optional[bytes]]): Private bytes and public bytes.
|
|
40
|
+
"""
|
|
24
41
|
|
|
25
42
|
encoding = (
|
|
26
43
|
serialization.Encoding[spec.encoding]
|
|
@@ -53,7 +70,17 @@ def _serialize_keypair(priv, spec: KeySpec) -> tuple[bytes, Optional[bytes]]:
|
|
|
53
70
|
|
|
54
71
|
|
|
55
72
|
class LocalKeyProvider(KeyProviderBase):
|
|
56
|
-
"""
|
|
73
|
+
"""Store and manage keys entirely in memory.
|
|
74
|
+
|
|
75
|
+
create_key(spec) -> KeyRef:
|
|
76
|
+
Generate a key according to ``spec`` and store it.
|
|
77
|
+
import_key(spec, material, public=None) -> KeyRef:
|
|
78
|
+
Register an existing key pair or secret.
|
|
79
|
+
rotate_key(kid, spec_overrides=None) -> KeyRef:
|
|
80
|
+
Produce a new version for ``kid``.
|
|
81
|
+
jwks(prefix_kids=None) -> dict:
|
|
82
|
+
Export all public keys as a JWKS document.
|
|
83
|
+
"""
|
|
57
84
|
|
|
58
85
|
type: Literal["LocalKeyProvider"] = "LocalKeyProvider"
|
|
59
86
|
|
|
@@ -5,7 +5,7 @@ This example demonstrates creating and retrieving a symmetric key with `LocalKey
|
|
|
5
5
|
```python
|
|
6
6
|
import asyncio
|
|
7
7
|
from swarmauri_keyprovider_local import LocalKeyProvider
|
|
8
|
-
from swarmauri_core.
|
|
8
|
+
from swarmauri_core.key_providers.types import (
|
|
9
9
|
ExportPolicy,
|
|
10
10
|
KeyAlg,
|
|
11
11
|
KeyClass,
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: swarmauri_keyprovider_local
|
|
3
|
-
Version: 0.2.0.dev4
|
|
4
|
-
Summary: In-memory key provider for development and testing
|
|
5
|
-
License: Apache-2.0
|
|
6
|
-
Author: Swarmauri
|
|
7
|
-
Author-email: opensource@swarmauri.com
|
|
8
|
-
Requires-Python: >=3.10,<3.13
|
|
9
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
-
Classifier: Natural Language :: English
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
-
Classifier: Development Status :: 3 - Alpha
|
|
16
|
-
Classifier: Topic :: Security :: Cryptography
|
|
17
|
-
Classifier: Intended Audience :: Developers
|
|
18
|
-
Requires-Dist: cryptography
|
|
19
|
-
Requires-Dist: swarmauri_base
|
|
20
|
-
Requires-Dist: swarmauri_core
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
|
|
23
|
-

|
|
24
|
-
|
|
25
|
-
# Swarmauri Local Key Provider
|
|
26
|
-
|
|
27
|
-
Provides a simple in-memory key provider for development and testing.
|
|
28
|
-
|
|
29
|
-
## Installation
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
pip install swarmauri_keyprovider_local
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Usage
|
|
36
|
-
|
|
37
|
-
```python
|
|
38
|
-
import asyncio
|
|
39
|
-
from swarmauri_keyprovider_local import LocalKeyProvider
|
|
40
|
-
from swarmauri_core.keys.types import (
|
|
41
|
-
ExportPolicy,
|
|
42
|
-
KeyAlg,
|
|
43
|
-
KeyClass,
|
|
44
|
-
KeySpec,
|
|
45
|
-
)
|
|
46
|
-
from swarmauri_core.crypto.types import KeyUse
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
async def run_example() -> str:
|
|
50
|
-
provider = LocalKeyProvider()
|
|
51
|
-
spec = KeySpec(
|
|
52
|
-
klass=KeyClass.symmetric,
|
|
53
|
-
alg=KeyAlg.AES256_GCM,
|
|
54
|
-
uses=(KeyUse.ENCRYPT,),
|
|
55
|
-
export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
|
|
56
|
-
)
|
|
57
|
-
created = await provider.create_key(spec)
|
|
58
|
-
fetched = await provider.get_key(created.kid, include_secret=True)
|
|
59
|
-
print(f"Retrieved key: {fetched.kid}")
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
asyncio.run(run_example())
|
|
63
|
-
```
|
|
64
|
-
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
# Swarmauri Local Key Provider
|
|
4
|
-
|
|
5
|
-
Provides a simple in-memory key provider for development and testing.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
pip install swarmauri_keyprovider_local
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
```python
|
|
16
|
-
import asyncio
|
|
17
|
-
from swarmauri_keyprovider_local import LocalKeyProvider
|
|
18
|
-
from swarmauri_core.keys.types import (
|
|
19
|
-
ExportPolicy,
|
|
20
|
-
KeyAlg,
|
|
21
|
-
KeyClass,
|
|
22
|
-
KeySpec,
|
|
23
|
-
)
|
|
24
|
-
from swarmauri_core.crypto.types import KeyUse
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
async def run_example() -> str:
|
|
28
|
-
provider = LocalKeyProvider()
|
|
29
|
-
spec = KeySpec(
|
|
30
|
-
klass=KeyClass.symmetric,
|
|
31
|
-
alg=KeyAlg.AES256_GCM,
|
|
32
|
-
uses=(KeyUse.ENCRYPT,),
|
|
33
|
-
export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
|
|
34
|
-
)
|
|
35
|
-
created = await provider.create_key(spec)
|
|
36
|
-
fetched = await provider.get_key(created.kid, include_secret=True)
|
|
37
|
-
print(f"Retrieved key: {fetched.kid}")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
asyncio.run(run_example())
|
|
41
|
-
```
|
|
File without changes
|
|
File without changes
|