Skip to content

Commit

Permalink
Merge pull request #32 from Indicio-tech/chore/quick-updates
Browse files Browse the repository at this point in the history
chore: update dependencies, dependabot config
  • Loading branch information
mepeltier authored Apr 23, 2024
2 parents f8ecfd6 + 5986c5f commit 00bfded
Show file tree
Hide file tree
Showing 13 changed files with 322 additions and 363 deletions.
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# For details on how this file works refer to:
# - https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
# Maintain dependencies for GitHub Actions
# - Check for updates once a week
# - Group all updates into a single PR
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
all-actions:
patterns: ["*"]

# Maintain pip dependencies
- package-ecosystem: pip
directory: /
schedule:
interval: daily
7 changes: 6 additions & 1 deletion .github/workflows/code-quality-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/[email protected]
- uses: chartboost/ruff-action@v1
with:
version: "0.4.1"
args: 'format --check'
- uses: chartboost/ruff-action@v1
with:
version: "0.4.1"
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ repos:
stages: [commit-msg]
args: ["--config", ".commitlint.config.js"]
additional_dependencies: ['@commitlint/config-conventional']
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
stages: [commit]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.284
rev: v0.4.1
hooks:
- id: ruff
stages: [commit]
args: ["--fix", "--exit-non-zero-on-fix"]
- id: ruff-format
stages: [commit]
1 change: 1 addition & 0 deletions didcomm_messaging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""DIDComm Messaging."""

from dataclasses import dataclass
import json
from typing import Generic, Optional, List
Expand Down
13 changes: 4 additions & 9 deletions didcomm_messaging/crypto/backend/askar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Askar backend for DIDComm Messaging."""

from collections import OrderedDict
import hashlib
import json
Expand Down Expand Up @@ -133,9 +134,7 @@ def kid(self) -> str:
class AskarCryptoService(CryptoService[AskarKey, AskarSecretKey]):
"""CryptoService backend implemented using Askar."""

async def ecdh_es_encrypt(
self, to_keys: Sequence[AskarKey], message: bytes
) -> bytes:
async def ecdh_es_encrypt(self, to_keys: Sequence[AskarKey], message: bytes) -> bytes:
"""Encode a message into DIDComm v2 anonymous encryption."""
builder = JweBuilder(with_flatten_recipients=False)

Expand Down Expand Up @@ -225,9 +224,7 @@ async def ecdh_es_decrypt(
"A256CBC-HS512",
"XC20P",
):
raise CryptoServiceError(
f"Unsupported ECDH-ES content encryption: {enc_alg}"
)
raise CryptoServiceError(f"Unsupported ECDH-ES content encryption: {enc_alg}")

epk_header = recip.header.get("epk")
if not epk_header:
Expand All @@ -239,9 +236,7 @@ async def ecdh_es_decrypt(
raise CryptoServiceError("Error loading ephemeral key")

try:
cek = ecdh.EcdhEs(
alg_id, None, wrapper.apv_bytes
).receiver_unwrap_key( # type: ignore
cek = ecdh.EcdhEs(alg_id, None, wrapper.apv_bytes).receiver_unwrap_key( # type: ignore
wrap_alg,
enc_alg,
epk,
Expand Down
1 change: 0 additions & 1 deletion didcomm_messaging/crypto/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""CryptoService and SecretsManager interfaces for DIDComm Messaging."""


from abc import ABC, abstractmethod
from typing import Generic, Mapping, Optional, Sequence, TypeVar, Union

Expand Down
4 changes: 1 addition & 3 deletions didcomm_messaging/crypto/jwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,7 @@ def _deserialize(cls, parsed: Mapping[str, Any]) -> "JweEnvelope": # noqa: C901
try:
protected: dict = json.loads(from_b64url(protected_b64))
except json.JSONDecodeError:
raise ValueError(
"Invalid JWE: invalid JSON for protected headers"
) from None
raise ValueError("Invalid JWE: invalid JSON for protected headers") from None
unprotected = parsed.get("unprotected") or {}
if protected.keys() & unprotected.keys():
raise ValueError("Invalid JWE: duplicate header")
Expand Down
5 changes: 1 addition & 4 deletions didcomm_messaging/packaging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""PackagingService interface."""


from dataclasses import dataclass
import hashlib
from typing import Generic, Literal, Optional, Sequence, Tuple, Union
Expand Down Expand Up @@ -179,9 +178,7 @@ async def pack(
await self.recip_for_kid_or_default_for_did(crypto, resolver, kid)
for kid in to
]
sender_kid = (
await self.default_sender_kid_for_did(resolver, frm) if frm else None
)
sender_kid = await self.default_sender_kid_for_did(resolver, frm) if frm else None
sender_key = await secrets.get_secret_by_kid(sender_kid) if sender_kid else None
if frm and not sender_key:
raise PackagingServiceError("No sender key found")
Expand Down
1 change: 1 addition & 0 deletions didcomm_messaging/quickstart.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Quickstart helpers for beginner users of DIDComm."""

from typing import (
Optional,
Dict,
Expand Down
Loading

0 comments on commit 00bfded

Please sign in to comment.