plugg 0.0.0__py3-none-any.whl

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.
plugg/__init__.py ADDED
@@ -0,0 +1,21 @@
1
+ from .core import (
2
+ AuthAdapter,
3
+ AuthError,
4
+ AuthErrorCode,
5
+ Principal,
6
+ PrincipalKind,
7
+ canonicalize_principal,
8
+ is_auth_error,
9
+ principal_to_json,
10
+ )
11
+
12
+ __all__ = [
13
+ "AuthAdapter",
14
+ "AuthError",
15
+ "AuthErrorCode",
16
+ "Principal",
17
+ "PrincipalKind",
18
+ "canonicalize_principal",
19
+ "is_auth_error",
20
+ "principal_to_json",
21
+ ]
plugg/core.py ADDED
@@ -0,0 +1,39 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from typing import Any, Literal, Protocol, TypedDict
5
+
6
+ PrincipalKind = Literal["user", "agent", "service"]
7
+ AuthErrorCode = Literal["invalid_credential", "expired_credential", "unavailable"]
8
+
9
+
10
+ class Principal(TypedDict):
11
+ id: str
12
+ kind: str
13
+ claims: dict[str, Any]
14
+
15
+
16
+ class AuthAdapter(Protocol):
17
+ async def resolve(self, credential: str) -> Principal: ...
18
+
19
+
20
+ class AuthError(Exception):
21
+ def __init__(self, code: AuthErrorCode, message: str) -> None:
22
+ super().__init__(message)
23
+ self.code = code
24
+
25
+
26
+ def principal_to_json(principal: Principal) -> Principal:
27
+ return {
28
+ "id": principal["id"],
29
+ "kind": principal["kind"],
30
+ "claims": principal["claims"],
31
+ }
32
+
33
+
34
+ def canonicalize_principal(principal: Principal) -> str:
35
+ return json.dumps(principal_to_json(principal), sort_keys=True, separators=(",", ":"))
36
+
37
+
38
+ def is_auth_error(error: BaseException) -> bool:
39
+ return isinstance(error, AuthError)
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: plugg
3
+ Version: 0.0.0
4
+ Summary: Neutral authentication port for agent-fabric primitives: resolves opaque credentials into fabric principals.
5
+ Project-URL: Homepage, https://github.com/cachetronaut/plugg
6
+ Project-URL: Repository, https://github.com/cachetronaut/plugg
7
+ Project-URL: Issues, https://github.com/cachetronaut/plugg/issues
8
+ License: MIT
9
+ Requires-Python: >=3.11
10
+ Description-Content-Type: text/markdown
11
+
12
+ # plugg
13
+
14
+ Python implementation of Plugg.
15
+
16
+ For product-level context, shared contracts, and cross-language repository information, see the public repository: https://github.com/cachetronaut/plugg.
17
+
18
+ ## Install
19
+
20
+ ```sh
21
+ pip install plugg
22
+ ```
23
+
24
+ ## Import
25
+
26
+ ```python
27
+ import plugg
28
+ ```
29
+
30
+ ## Development
31
+
32
+ Run from `py/`:
33
+
34
+ ```sh
35
+ uv sync --dev
36
+ uv run --with ruff ruff check .
37
+ uv run --with ruff ruff format --check .
38
+ uv run --with ty ty check
39
+ uv run --with pytest --with pytest-asyncio python -m pytest
40
+ ```
41
+
42
+ ## License
43
+
44
+ MIT
@@ -0,0 +1,5 @@
1
+ plugg/__init__.py,sha256=u22H155PvSnc_eOcymGwRaI3U2ko1EVVhoHKbWAvQ7c,363
2
+ plugg/core.py,sha256=CcK33WkzVucyABakccGqaR14umPu1d1ovp5FoMmrT80,995
3
+ plugg-0.0.0.dist-info/METADATA,sha256=746P3-vMgJkdwMOC8OquZY1ACf3aOHHyytkVq3agcY8,945
4
+ plugg-0.0.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
5
+ plugg-0.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any