CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-josepy

tessl install tessl/pypi-josepy@2.1.0

JOSE protocol implementation in Python with support for JSON Web Algorithms, Keys, and Signatures

Agent Success

Agent success rate when using this tile

73%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.16x

Baseline

Agent success rate without this tile

63%

task.mdevals/scenario-9/

Audit Trail Serialization

A lightweight audit record model that must support partial and full JSON conversion for nested objects, plus robust string serialization for storage and transport.

Capabilities

Partial serialization preserves objects

  • Serializing an audit record with actor Alice viewing /systems/1 yields a mapping where resource, action, and details are plain types while actor remains a library-aware object instead of a dict; the details map contains {"ip": "127.0.0.1"} @test

Full serialization resolves nested values

  • Full serialization of the same record returns only built-in Python types, expanding the actor into a dict with name, role, claims, and an ISO-8601 issued_at string; details keeps the ip entry @test

Round-trip load from string

  • Loading from the JSON string produced by full serialization reconstructs an equivalent record (same actor fields, action, resource, and details) and rejects malformed JSON input by raising the dependency's deserialization error @test

Pretty dumps formatting

  • Pretty-printing the record produces deterministically indented JSON (2 spaces, sorted keys) that matches a stored fixture string and ends with a newline @test

Implementation

@generates

API

from dataclasses import dataclass, field
from datetime import datetime
from typing import Any, Dict, Union

@dataclass
class ActorProfile:
    name: str
    role: str
    issued_at: datetime
    claims: Dict[str, Any] = field(default_factory=dict)

    def to_partial_json(self) -> Any: ...
    def to_json(self) -> Any: ...
    @classmethod
    def from_json(cls, jobj: Any) -> "ActorProfile": ...

@dataclass
class AuditRecord:
    actor: ActorProfile
    resource: str
    action: str
    details: Dict[str, Any] = field(default_factory=dict)

    def to_partial_json(self) -> Any: ...
    def to_json(self) -> Any: ...
    def dumps(self, pretty: bool = False) -> str: ...
    @classmethod
    def loads(cls, data: Union[str, bytes]) -> "AuditRecord": ...

Dependencies { .dependencies }

josepy { .dependency }

Use the package's JSON serialization helpers to implement partial vs full conversion, safe loading from JSON strings, and pretty output.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/josepy@2.1.x
tile.json