Skip to main content

Client library for the Wallet Attached Storage specification

Project description

Wallet Attached Storage Client

Python client library for the Wallet Attached Storage specification.

Installation

pip install wallet-attached-storage-client

Usage

import json
from wallet_attached_storage_client import Ed25519Signer, StorageClient

# Generate a new Ed25519 key pair (or pass your own Ed25519PrivateKey)
signer = Ed25519Signer()
print(f"Signer DID: {signer.id}")  # did:key:z6Mk...

with StorageClient("https://your-was-server.example") as client:

    # 1. Create a space (auto-generates a urn:uuid)
    space = client.space(signer=signer)
    print(f"Space: {space.id}")
    print(f"Path:  {space.path}")

    # 2. Write a resource into the space
    resource = space.resource("/hello.txt")
    put_resp = resource.put(b"Hello from Python!", "text/plain")
    print(f"PUT  {resource.path} -> {put_resp.status}")  # 204

    # 3. Read it back
    get_resp = resource.get()
    print(f"GET  {resource.path} -> {get_resp.status}")  # 200
    print(f"Body: {get_resp.text()}")                     # Hello from Python!

    # 4. Overwrite with JSON
    doc = json.dumps({"greeting": "hi", "from": "python"}).encode()
    resource.put(doc, "application/json")
    print(f"JSON: {resource.get().json()}")

    # 5. Delete the resource
    del_resp = resource.delete()
    print(f"DEL  {resource.path} -> {del_resp.status}")  # 204

    # 6. Confirm it's gone
    gone_resp = resource.get()
    print(f"GET  {resource.path} -> {gone_resp.status}")  # 404

Custom Signers

Ed25519Signer is built in, but any object that satisfies the Signer protocol works — you are not locked into a specific cryptography library:

class MySigner:
    @property
    def id(self) -> str:
        """Return a DID key identifier, e.g. did:key:z6Mkh..."""
        ...

    def sign(self, data: bytes) -> bytes:
        """Sign raw bytes and return the raw signature bytes."""
        ...

API

  • StorageClient(base_url) — entry point; creates Space handles
  • Space — represents a WAS space (get(), put(), delete(), resource())
  • Resource — represents a resource within a space (get(), put(), post(), delete())
  • StorageResponse — wraps HTTP responses (status, ok, headers, content(), json(), text())

Scripts

uv run safety scan
uv run ruff check
uv run flake8 src tests
uv run bandit -r src
uv run bandit -r tests -s B101
uv run -m pytest -vv --cov=src --cov-report=term --cov-report=xml
uv version --bump patch
git add . && git commit -m "Bump patch version" && git tag -sm "New feature" $version
rm -rf dist && uv build
uv publish -t $(keyring get https://upload.pypi.org/legacy/ __token__)

References

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

wallet_attached_storage_client-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wallet_attached_storage_client-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file wallet_attached_storage_client-0.1.0.tar.gz.

File metadata

File hashes

Hashes for wallet_attached_storage_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 76b46c140ae2dc17f6fe3b0134d7aad23d5481eeace3cd8e7e5947274495b6d0
MD5 9558abeff37c9a9303a49ff4ac07e6f7
BLAKE2b-256 85ebf1be9a5396ff82991e4f0a4fe2a45554507de8eb3de5485f44b8f6301132

See more details on using hashes here.

File details

Details for the file wallet_attached_storage_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wallet_attached_storage_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ed4636e099776efed7f43a7839310753de09b8543a0751490ac3fa2738998df
MD5 c6d5afdd666818f721694a70cd018b41
BLAKE2b-256 f83d8674cf0ae8d16000ca21858a9d9924fa26d07978d2beba1e0f0fa2e263ae

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