Skip to content

Commit 5c61b9b

Browse files
committed
Fix: black in aleph_vm_authentification.py
fix: isort issue Fix: mypy issue Fix: black Fix: isort
1 parent 328e087 commit 5c61b9b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/aleph/sdk/client/vmclient.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ async def _generate_header(
9898
signed_operation = self.sign_payload(payload, self.ephemeral_key)
9999

100100
if not self.pubkey_signature_header:
101-
self.pubkey_signature_header = await self.generate_pubkey_signature_header()
101+
self.pubkey_signature_header = (
102+
await self._generate_pubkey_signature_header()
103+
)
102104

103105
headers = {
104106
"X-SignedPubKey": self.pubkey_signature_header,

tests/unit/aleph_vm_authentication.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import logging
66
from collections.abc import Awaitable, Coroutine
7-
from typing import Any, Callable, Literal, Union
7+
from typing import Any, Callable, Dict, Literal, Union
88

99
import cryptography.exceptions
1010
import pydantic
@@ -15,11 +15,11 @@
1515
from jwcrypto.jwa import JWA
1616
from pydantic import BaseModel, ValidationError, root_validator, validator
1717

18-
1918
logger = logging.getLogger(__name__)
2019

2120
DOMAIN_NAME = "localhost"
2221

22+
2323
def is_token_still_valid(datestr: str):
2424
"""
2525
Checks if a token has expired based on its expiry timestamp
@@ -42,7 +42,7 @@ def verify_wallet_signature(signature, message, address):
4242
class SignedPubKeyPayload(BaseModel):
4343
"""This payload is signed by the wallet of the user to authorize an ephemeral key to act on his behalf."""
4444

45-
pubkey: dict[str, Any]
45+
pubkey: Dict[str, Any]
4646
# {'pubkey': {'alg': 'ES256', 'crv': 'P-256', 'ext': True, 'key_ops': ['verify'], 'kty': 'EC',
4747
# 'x': '4blJBYpltvQLFgRvLE-2H7dsMr5O0ImHkgOnjUbG2AU', 'y': '5VHnq_hUSogZBbVgsXMs0CjrVfMy4Pa3Uv2BEBqfrN4'}
4848
# alg: Literal["ECDSA"]
@@ -63,15 +63,15 @@ class SignedPubKeyHeader(BaseModel):
6363
@validator("signature")
6464
def signature_must_be_hex(cls, v: bytes) -> bytes:
6565
"""Convert the signature from hexadecimal to bytes"""
66-
return bytes.fromhex(v.removeprefix(b"0x").decode())
66+
return bytes.fromhex(v.decode())
6767

6868
@validator("payload")
6969
def payload_must_be_hex(cls, v: bytes) -> bytes:
7070
"""Convert the payload from hexadecimal to bytes"""
7171
return bytes.fromhex(v.decode())
7272

7373
@root_validator(pre=False, skip_on_failure=True)
74-
def check_expiry(cls, values) -> dict[str, bytes]:
74+
def check_expiry(cls, values) -> Dict[str, bytes]:
7575
"""Check that the token has not expired"""
7676
payload: bytes = values["payload"]
7777
content = SignedPubKeyPayload.parse_raw(payload)
@@ -81,7 +81,7 @@ def check_expiry(cls, values) -> dict[str, bytes]:
8181
return values
8282

8383
@root_validator(pre=False, skip_on_failure=True)
84-
def check_signature(cls, values) -> dict[str, bytes]:
84+
def check_signature(cls, values) -> Dict[str, bytes]:
8585
"""Check that the signature is valid"""
8686
signature: bytes = values["signature"]
8787
payload: bytes = values["payload"]

0 commit comments

Comments
 (0)