swarmauri_keyprovider_gcpkms 0.9.0.dev4__tar.gz → 0.9.2.dev6__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.
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_keyprovider_gcpkms
3
+ Version: 0.9.2.dev6
4
+ Summary: Google Cloud KMS Key Provider for Swarmauri
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: swarmauri,keyprovider,gcpkms,google,cloud,kms,key,provider
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: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Natural Language :: English
16
+ Classifier: Development Status :: 3 - Alpha
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
19
+ Provides-Extra: cbor
20
+ Requires-Dist: cbor2 ; extra == "cbor"
21
+ Requires-Dist: cryptography
22
+ Requires-Dist: google-auth
23
+ Requires-Dist: requests
24
+ Requires-Dist: swarmauri_base
25
+ Requires-Dist: swarmauri_core
26
+ Requires-Dist: swarmauri_standard
27
+ Description-Content-Type: text/markdown
28
+
29
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
30
+
31
+ <p align="center">
32
+ <a href="https://pypi.org/project/swarmauri_keyprovider_gcpkms/">
33
+ <img src="https://img.shields.io/pypi/dm/swarmauri_keyprovider_gcpkms" alt="PyPI - Downloads"/></a>
34
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_keyprovider_gcpkms/">
35
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_keyprovider_gcpkms.svg"/></a>
36
+ <a href="https://pypi.org/project/swarmauri_keyprovider_gcpkms/">
37
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_keyprovider_gcpkms" alt="PyPI - Python Version"/></a>
38
+ <a href="https://pypi.org/project/swarmauri_keyprovider_gcpkms/">
39
+ <img src="https://img.shields.io/pypi/l/swarmauri_keyprovider_gcpkms" alt="PyPI - License"/></a>
40
+ <a href="https://pypi.org/project/swarmauri_keyprovider_gcpkms/">
41
+ <img src="https://img.shields.io/pypi/v/swarmauri_keyprovider_gcpkms?label=swarmauri_keyprovider_gcpkms&color=green" alt="PyPI - swarmauri_keyprovider_gcpkms"/></a>
42
+
43
+ </p>
44
+
45
+ ---
46
+
47
+ # Swarmauri GCP KMS Key Provider
48
+
49
+ Google Cloud KMS-backed key provider for the Swarmauri framework. It exposes Cloud KMS asymmetric and symmetric keys through the common `IKeyProvider` interface so agents can sign, verify, encrypt, decrypt, wrap, and unwrap data without leaving Swarmauri.
50
+
51
+ ## Optional Canonicalization Extras
52
+
53
+ - `cbor` – installs `cbor2` to enable canonical CBOR utilities where workflows require deterministic binary encoding.
54
+
55
+ ## Features
56
+
57
+ - Use Cloud KMS asymmetric keys for RSA/EC signing and verification while receiving RFC 7517 JWKS payloads for downstream services.
58
+ - Perform RSA-OAEP wrapping/unwrapping of data encryption keys and AES-256 encryption/decryption with hardware-backed material.
59
+ - Publish JWKS documents from Cloud KMS public keys, including caching and TTL-based refresh to minimize API calls.
60
+ - Generate random bytes and derive key material via HKDF with SHA-256 for envelope encryption scenarios.
61
+ - Destroy individual key versions via the Cloud KMS REST API when performing decommissioning workflows.
62
+
63
+ ## Prerequisites
64
+
65
+ - Python 3.10 or newer.
66
+ - `google-auth` and `requests` (installed automatically) plus network access to Google Cloud KMS endpoints.
67
+ - A Google Cloud project with the KMS API enabled, along with a key ring (`key_ring_id`) in your chosen location (`location_id`).
68
+ - Service account or workload identity with permissions such as `cloudkms.cryptoKeys.get`, `cloudkms.cryptoKeyVersions.useToSign`, `cloudkms.cryptoKeyVersions.useToDecrypt`, `cloudkms.cryptoKeys.list`, and `cloudkms.keyRings.get`.
69
+ - Application Default Credentials available to the runtime (e.g., `GOOGLE_APPLICATION_CREDENTIALS`, workload identity, or Cloud Run default service account).
70
+
71
+ ## Installation
72
+
73
+ ```bash
74
+ # pip
75
+ pip install swarmauri_keyprovider_gcpkms
76
+
77
+ # poetry
78
+ poetry add swarmauri_keyprovider_gcpkms
79
+
80
+ # uv (pyproject-based projects)
81
+ uv add swarmauri_keyprovider_gcpkms
82
+
83
+ # Extras for CBOR canonicalization
84
+ pip install "swarmauri_keyprovider_gcpkms[cbor]"
85
+ ```
86
+
87
+ ## Quickstart: Sign and Verify with Cloud KMS
88
+
89
+ ```python
90
+ import asyncio
91
+ from swarmauri_keyprovider_gcpkms import GcpKmsKeyProvider
92
+ from swarmauri_core.key_providers.types import KeySpec, KeyUse
93
+
94
+
95
+ async def main() -> None:
96
+ provider = GcpKmsKeyProvider(
97
+ project_id="my-project",
98
+ location_id="us-central1",
99
+ key_ring_id="swarmauri",
100
+ )
101
+
102
+ key_ref = await provider.get_key(
103
+ kid="projects/my-project/locations/us-central1/keyRings/swarmauri/cryptoKeys/jwt-key",
104
+ version=None,
105
+ )
106
+
107
+ message = b"payload to sign"
108
+ signature = await provider.sign(key_ref.kid, message, alg=JWAAlg.RS256)
109
+ await provider.verify(key_ref.kid, message, signature, alg=JWAAlg.RS256)
110
+
111
+ jwk = await provider.get_public_jwk(key_ref.kid, key_ref.version)
112
+ print("Public JWK", jwk)
113
+
114
+
115
+ if __name__ == "__main__":
116
+ asyncio.run(main())
117
+ ```
118
+
119
+ ## Encrypt and Wrap Data Keys
120
+
121
+ ```python
122
+ import asyncio
123
+ from swarmauri_keyprovider_gcpkms import GcpKmsKeyProvider
124
+
125
+
126
+ async def encrypt_documents() -> None:
127
+ provider = GcpKmsKeyProvider(
128
+ project_id="my-project",
129
+ location_id="us-east1",
130
+ key_ring_id="data-protection",
131
+ )
132
+
133
+ dek = await provider.random_bytes(32)
134
+ aad = b"swarmauri::tenant-a"
135
+
136
+ ciphertext = await provider.encrypt(
137
+ kid="projects/my-project/locations/us-east1/keyRings/data-protection/cryptoKeys/primary",
138
+ plaintext=b"secret payload",
139
+ associated_data=aad,
140
+ )
141
+
142
+ wrapped = await provider.wrap(
143
+ kid="projects/my-project/locations/us-east1/keyRings/data-protection/cryptoKeys/wrapping",
144
+ plaintext=dek,
145
+ )
146
+
147
+ unwrapped = await provider.unwrap(
148
+ kid="projects/my-project/locations/us-east1/keyRings/data-protection/cryptoKeys/wrapping",
149
+ ciphertext=wrapped,
150
+ )
151
+ assert unwrapped == dek
152
+
153
+
154
+ # asyncio.run(encrypt_documents())
155
+ ```
156
+
157
+ ## Operational Tips
158
+
159
+ - The provider caches public keys (`_pub_cache`) for 5 minutes; call `get_public_jwk(..., force=True)` if you rotate Cloud KMS key versions and need instant propagation.
160
+ - Use explicit key version names when destroying or disabling keys: `projects/.../cryptoKeys/<name>/cryptoKeyVersions/<n>`.
161
+ - Cloud KMS rotation is controlled outside the provider (per key configuration). Combine the provider with IAM rotation settings to enforce regular key versioning.
162
+ - For auditability, inspect the `tags` field on returned `KeyRef` objects—they include algorithm purpose and key type hints derived from Cloud KMS metadata.
163
+
@@ -0,0 +1,134 @@
1
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/swarmauri_keyprovider_gcpkms/">
5
+ <img src="https://img.shields.io/pypi/dm/swarmauri_keyprovider_gcpkms" alt="PyPI - Downloads"/></a>
6
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_keyprovider_gcpkms/">
7
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_keyprovider_gcpkms.svg"/></a>
8
+ <a href="https://pypi.org/project/swarmauri_keyprovider_gcpkms/">
9
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_keyprovider_gcpkms" alt="PyPI - Python Version"/></a>
10
+ <a href="https://pypi.org/project/swarmauri_keyprovider_gcpkms/">
11
+ <img src="https://img.shields.io/pypi/l/swarmauri_keyprovider_gcpkms" alt="PyPI - License"/></a>
12
+ <a href="https://pypi.org/project/swarmauri_keyprovider_gcpkms/">
13
+ <img src="https://img.shields.io/pypi/v/swarmauri_keyprovider_gcpkms?label=swarmauri_keyprovider_gcpkms&color=green" alt="PyPI - swarmauri_keyprovider_gcpkms"/></a>
14
+
15
+ </p>
16
+
17
+ ---
18
+
19
+ # Swarmauri GCP KMS Key Provider
20
+
21
+ Google Cloud KMS-backed key provider for the Swarmauri framework. It exposes Cloud KMS asymmetric and symmetric keys through the common `IKeyProvider` interface so agents can sign, verify, encrypt, decrypt, wrap, and unwrap data without leaving Swarmauri.
22
+
23
+ ## Optional Canonicalization Extras
24
+
25
+ - `cbor` – installs `cbor2` to enable canonical CBOR utilities where workflows require deterministic binary encoding.
26
+
27
+ ## Features
28
+
29
+ - Use Cloud KMS asymmetric keys for RSA/EC signing and verification while receiving RFC 7517 JWKS payloads for downstream services.
30
+ - Perform RSA-OAEP wrapping/unwrapping of data encryption keys and AES-256 encryption/decryption with hardware-backed material.
31
+ - Publish JWKS documents from Cloud KMS public keys, including caching and TTL-based refresh to minimize API calls.
32
+ - Generate random bytes and derive key material via HKDF with SHA-256 for envelope encryption scenarios.
33
+ - Destroy individual key versions via the Cloud KMS REST API when performing decommissioning workflows.
34
+
35
+ ## Prerequisites
36
+
37
+ - Python 3.10 or newer.
38
+ - `google-auth` and `requests` (installed automatically) plus network access to Google Cloud KMS endpoints.
39
+ - A Google Cloud project with the KMS API enabled, along with a key ring (`key_ring_id`) in your chosen location (`location_id`).
40
+ - Service account or workload identity with permissions such as `cloudkms.cryptoKeys.get`, `cloudkms.cryptoKeyVersions.useToSign`, `cloudkms.cryptoKeyVersions.useToDecrypt`, `cloudkms.cryptoKeys.list`, and `cloudkms.keyRings.get`.
41
+ - Application Default Credentials available to the runtime (e.g., `GOOGLE_APPLICATION_CREDENTIALS`, workload identity, or Cloud Run default service account).
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ # pip
47
+ pip install swarmauri_keyprovider_gcpkms
48
+
49
+ # poetry
50
+ poetry add swarmauri_keyprovider_gcpkms
51
+
52
+ # uv (pyproject-based projects)
53
+ uv add swarmauri_keyprovider_gcpkms
54
+
55
+ # Extras for CBOR canonicalization
56
+ pip install "swarmauri_keyprovider_gcpkms[cbor]"
57
+ ```
58
+
59
+ ## Quickstart: Sign and Verify with Cloud KMS
60
+
61
+ ```python
62
+ import asyncio
63
+ from swarmauri_keyprovider_gcpkms import GcpKmsKeyProvider
64
+ from swarmauri_core.key_providers.types import KeySpec, KeyUse
65
+
66
+
67
+ async def main() -> None:
68
+ provider = GcpKmsKeyProvider(
69
+ project_id="my-project",
70
+ location_id="us-central1",
71
+ key_ring_id="swarmauri",
72
+ )
73
+
74
+ key_ref = await provider.get_key(
75
+ kid="projects/my-project/locations/us-central1/keyRings/swarmauri/cryptoKeys/jwt-key",
76
+ version=None,
77
+ )
78
+
79
+ message = b"payload to sign"
80
+ signature = await provider.sign(key_ref.kid, message, alg=JWAAlg.RS256)
81
+ await provider.verify(key_ref.kid, message, signature, alg=JWAAlg.RS256)
82
+
83
+ jwk = await provider.get_public_jwk(key_ref.kid, key_ref.version)
84
+ print("Public JWK", jwk)
85
+
86
+
87
+ if __name__ == "__main__":
88
+ asyncio.run(main())
89
+ ```
90
+
91
+ ## Encrypt and Wrap Data Keys
92
+
93
+ ```python
94
+ import asyncio
95
+ from swarmauri_keyprovider_gcpkms import GcpKmsKeyProvider
96
+
97
+
98
+ async def encrypt_documents() -> None:
99
+ provider = GcpKmsKeyProvider(
100
+ project_id="my-project",
101
+ location_id="us-east1",
102
+ key_ring_id="data-protection",
103
+ )
104
+
105
+ dek = await provider.random_bytes(32)
106
+ aad = b"swarmauri::tenant-a"
107
+
108
+ ciphertext = await provider.encrypt(
109
+ kid="projects/my-project/locations/us-east1/keyRings/data-protection/cryptoKeys/primary",
110
+ plaintext=b"secret payload",
111
+ associated_data=aad,
112
+ )
113
+
114
+ wrapped = await provider.wrap(
115
+ kid="projects/my-project/locations/us-east1/keyRings/data-protection/cryptoKeys/wrapping",
116
+ plaintext=dek,
117
+ )
118
+
119
+ unwrapped = await provider.unwrap(
120
+ kid="projects/my-project/locations/us-east1/keyRings/data-protection/cryptoKeys/wrapping",
121
+ ciphertext=wrapped,
122
+ )
123
+ assert unwrapped == dek
124
+
125
+
126
+ # asyncio.run(encrypt_documents())
127
+ ```
128
+
129
+ ## Operational Tips
130
+
131
+ - The provider caches public keys (`_pub_cache`) for 5 minutes; call `get_public_jwk(..., force=True)` if you rotate Cloud KMS key versions and need instant propagation.
132
+ - Use explicit key version names when destroying or disabling keys: `projects/.../cryptoKeys/<name>/cryptoKeyVersions/<n>`.
133
+ - Cloud KMS rotation is controlled outside the provider (per key configuration). Combine the provider with IAM rotation settings to enforce regular key versioning.
134
+ - For auditability, inspect the `tags` field on returned `KeyRef` objects—they include algorithm purpose and key type hints derived from Cloud KMS metadata.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_keyprovider_gcpkms"
3
- version = "0.9.0.dev4"
3
+ version = "0.9.2.dev6"
4
4
  description = "Google Cloud KMS Key Provider for Swarmauri"
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
@@ -11,8 +11,12 @@ classifiers = [
11
11
  "Programming Language :: Python :: 3.10",
12
12
  "Programming Language :: Python :: 3.11",
13
13
  "Programming Language :: Python :: 3.12",
14
+ "Natural Language :: English",
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
14
18
  ]
15
- authors = [{ name = "Swarmauri", email = "opensource@swarmauri.com" }]
19
+ authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
16
20
  dependencies = [
17
21
  "google-auth",
18
22
  "requests",
@@ -21,6 +25,16 @@ dependencies = [
21
25
  "swarmauri_base",
22
26
  "swarmauri_standard",
23
27
  ]
28
+ keywords = [
29
+ "swarmauri",
30
+ "keyprovider",
31
+ "gcpkms",
32
+ "google",
33
+ "cloud",
34
+ "kms",
35
+ "key",
36
+ "provider",
37
+ ]
24
38
 
25
39
  [project.optional-dependencies]
26
40
  cbor = ["cbor2"]
@@ -20,8 +20,8 @@ import secrets
20
20
 
21
21
  from pydantic import PrivateAttr
22
22
 
23
- from swarmauri_base.keys.KeyProviderBase import KeyProviderBase
24
- from swarmauri_core.keys.types import ExportPolicy, KeySpec, KeyUse
23
+ from swarmauri_base.key_providers.KeyProviderBase import KeyProviderBase
24
+ from swarmauri_core.key_providers.types import ExportPolicy, KeySpec, KeyUse
25
25
  from swarmauri_core.crypto.types import JWAAlg, KeyRef
26
26
 
27
27
 
@@ -1,63 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: swarmauri_keyprovider_gcpkms
3
- Version: 0.9.0.dev4
4
- Summary: Google Cloud KMS Key Provider for Swarmauri
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: Programming Language :: Python :: 3.10
11
- Classifier: Programming Language :: Python :: 3.11
12
- Classifier: Programming Language :: Python :: 3.12
13
- Provides-Extra: cbor
14
- Requires-Dist: cbor2 ; extra == "cbor"
15
- Requires-Dist: cryptography
16
- Requires-Dist: google-auth
17
- Requires-Dist: requests
18
- Requires-Dist: swarmauri_base
19
- Requires-Dist: swarmauri_core
20
- Requires-Dist: swarmauri_standard
21
- Description-Content-Type: text/markdown
22
-
23
- # Swarmauri GCP KMS Key Provider
24
-
25
- GCP KMS-backed key provider for the Swarmauri framework. This plugin exposes
26
- Google Cloud KMS keys through the common `IKeyProvider` interface, enabling
27
- signing, verification, encryption and random byte generation.
28
-
29
- ## Optional Canonicalization Extras
30
-
31
- - `cbor` – enables CBOR canonicalization utilities via `cbor2`.
32
-
33
- ## Features
34
-
35
- - AES encryption and decryption using KMS-managed symmetric keys.
36
- - RSA and EC signing backed by Cloud KMS.
37
- - RSA wrapping and unwrapping of data encryption keys.
38
- - JWKS export for asymmetric public keys.
39
-
40
- ## Installation
41
-
42
- ```bash
43
- uv add swarmauri_keyprovider_gcpkms
44
- ```
45
-
46
- Enable CBOR canonicalization support:
47
-
48
- ```bash
49
- uv add swarmauri_keyprovider_gcpkms[cbor]
50
- ```
51
-
52
- ## Usage
53
-
54
- ```python
55
- from swarmauri_keyprovider_gcpkms import GcpKmsKeyProvider
56
-
57
- kp = GcpKmsKeyProvider(
58
- project_id="my-project",
59
- location_id="us-east1",
60
- key_ring_id="my-ring",
61
- )
62
- ```
63
-
@@ -1,40 +0,0 @@
1
- # Swarmauri GCP KMS Key Provider
2
-
3
- GCP KMS-backed key provider for the Swarmauri framework. This plugin exposes
4
- Google Cloud KMS keys through the common `IKeyProvider` interface, enabling
5
- signing, verification, encryption and random byte generation.
6
-
7
- ## Optional Canonicalization Extras
8
-
9
- - `cbor` – enables CBOR canonicalization utilities via `cbor2`.
10
-
11
- ## Features
12
-
13
- - AES encryption and decryption using KMS-managed symmetric keys.
14
- - RSA and EC signing backed by Cloud KMS.
15
- - RSA wrapping and unwrapping of data encryption keys.
16
- - JWKS export for asymmetric public keys.
17
-
18
- ## Installation
19
-
20
- ```bash
21
- uv add swarmauri_keyprovider_gcpkms
22
- ```
23
-
24
- Enable CBOR canonicalization support:
25
-
26
- ```bash
27
- uv add swarmauri_keyprovider_gcpkms[cbor]
28
- ```
29
-
30
- ## Usage
31
-
32
- ```python
33
- from swarmauri_keyprovider_gcpkms import GcpKmsKeyProvider
34
-
35
- kp = GcpKmsKeyProvider(
36
- project_id="my-project",
37
- location_id="us-east1",
38
- key_ring_id="my-ring",
39
- )
40
- ```