Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: pdm-project/setup-pdm@v4
uses: astral-sh/setup-uv@v4
with:
python-version: 3.9
python-version: "3.11"
cache: true
- name: Install dependencies
run: pdm install
run: uv sync --all-extras
- name: Run pytest
run: pdm run pytest
run: uv run pytest
- name: Build
run: uv build
- name: Publish
run: pdm publish
run: uv publish
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: pdm-project/setup-pdm@v4
- uses: astral-sh/setup-uv@v4
with:
python-version: ${{ matrix.python-version }}
cache: true
- name: Install dependencies
run: pdm install -G :all
run: uv sync --all-extras
- name: Run pytest
run: pdm run pytest
run: uv run pytest
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
rev: v0.4.5
hooks:
- id: ruff
stages: [commit]
stages: [pre-commit]
args: ["--fix", "--exit-non-zero-on-fix"]
- id: ruff-format
stages: [commit]
stages: [pre-commit]
10 changes: 6 additions & 4 deletions didcomm_messaging/packaging.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""PackagingService interface."""

from dataclasses import dataclass
import hashlib
from dataclasses import dataclass
from typing import Generic, Literal, Optional, Sequence, Tuple, Union

from pydid import DIDUrl, VerificationMethod
from didcomm_messaging.crypto import P, S, CryptoService, SecretsManager

from didcomm_messaging.crypto import CryptoService, P, S, SecretsManager
from didcomm_messaging.crypto.jwe import JweEnvelope, b64url, from_b64url
from didcomm_messaging.resolver import DIDResolver

Expand Down Expand Up @@ -40,7 +41,9 @@ async def extract_packed_message_metadata( # noqa: C901
if not alg:
raise PackagingServiceError("Missing alg header")

method = next((m for m in ("ECDH-1PU", "ECDH-ES") if m in alg), None)
method: Literal["ECDH-1PU", "ECDH-ES"] | None = next(
(m for m in ("ECDH-1PU", "ECDH-ES") if m in alg), None
)
if not method:
raise PackagingServiceError(
f"Unsupported DIDComm encryption algorithm: {alg}"
Expand Down Expand Up @@ -171,7 +174,6 @@ async def pack(
message: bytes,
to: Sequence[str],
frm: Optional[str] = None,
**options,
):
"""Pack a DIDComm message."""
recip_keys = [
Expand Down
9 changes: 4 additions & 5 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ async def main():
"""An example of using DIDComm Messaging."""
secrets = InMemorySecretsManager()
crypto = AskarCryptoService()
packer = PackagingService(
PrefixResolver({"did:peer:2": Peer2(), "did:peer:4": Peer4()}), crypto, secrets
)
resolver = PrefixResolver({"did:peer:2": Peer2(), "did:peer:4": Peer4()})
packer = PackagingService()
verkey = Key.generate(KeyAlg.ED25519)
xkey = Key.generate(KeyAlg.X25519)
did = generate(
Expand All @@ -39,9 +38,9 @@ async def main():
await secrets.add_secret(AskarSecretKey(verkey, f"{did}#key-1"))
await secrets.add_secret(AskarSecretKey(xkey, f"{did}#key-2"))
print(did)
packed = await packer.pack(b"hello world", [did], did)
packed = await packer.pack(crypto, resolver, secrets, b"hello world", [did], did)
print(json.dumps(json.loads(packed), indent=2))
unpacked = await packer.unpack(packed)
unpacked = await packer.unpack(crypto, resolver, secrets, packed)
print(unpacked)


Expand Down
902 changes: 0 additions & 902 deletions pdm.lock

This file was deleted.

28 changes: 13 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ dependencies = [
"base58>=2.1.1",
"pydid>=0.5.1",
]
requires-python = ">=3.9"
requires-python = ">=3.11"
readme = "README.md"
license = {text = "Apache-2.0"}

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project.optional-dependencies]
dev = [
"pytest>=7.4.3",
"pytest-ruff>=0.1.1",
"pre-commit>=3.5.0",
"ruff>=0.4.1",
"pytest-asyncio>=0.23.7",
"pytest-cov>=4.1.0",
]
askar = [
"aries-askar>=0.2.9",
]
Expand All @@ -36,20 +48,6 @@ nacl = [
"PyNaCl>=1.5.0",
]

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.pdm.dev-dependencies]
dev = [
"pytest>=7.4.3",
"pytest-ruff>=0.1.1",
"pre-commit>=3.5.0",
"ruff>=0.4.1",
"pytest-asyncio>=0.23.7",
"pytest-cov>=4.1.0",
]

[tool.pytest.ini_options]
addopts = "--doctest-glob README.md --ruff --cov didcomm_messaging"

Expand Down
Loading
Loading