Skip to content

Commit 5566e4d

Browse files
authored
Merge branch 'main' into feature/symkey_init
2 parents a72c2b4 + 8aba046 commit 5566e4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+87
-125
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- "3.11"
2828
- "3.12"
2929
- "3.13"
30+
- "3.14"
3031
steps:
3132
- uses: actions/checkout@v4
3233
- name: Set up Python ${{ matrix.python-version }}

.pre-commit-config.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: check-merge-conflict
66
- id: debug-statements
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- id: check-yaml
10+
- id: check-toml
1011
- id: check-json
12+
- id: check-ast
1113
- repo: https://github.com/astral-sh/ruff-pre-commit
12-
rev: v0.9.9
14+
rev: v0.15.5
1315
hooks:
14-
- id: ruff
16+
- id: ruff-check
1517
- id: ruff-format

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All contributions to the Python JwtConnect packages are welcome!
44

55
Note that as this library is planned to be used in high-profile production code,
66
we insist on a very high standards for the code and design, but don't feel shy:
7-
discuss your plans over
7+
discuss your plans over
88
[GitHub Issues](https://github.com/openid/JWTConnect-Python-OidcMsg/issues) and the
99
[mailing list](http://lists.openid.net/mailman/listinfo/openid-specs-ab), and
1010
send in those pull requests!
@@ -42,14 +42,14 @@ requests).
4242
Before you work on a big new feature, get in touch to make sure that your work
4343
is inline with the direction of the project and get input on your architecture.
4444
You can file an [Issue](https://github.com/openid/JWTConnect-Python-OidcMsg/issues)
45-
discussing your proposal, or email the
46-
[list](http://lists.openid.net/mailman/listinfo/openid-specs-ab).
45+
discussing your proposal, or email the
46+
[list](http://lists.openid.net/mailman/listinfo/openid-specs-ab).
4747

4848
## Coding Standards
4949

5050
The JWTCOnnect-Python-OidcMsg library follows the
51-
[PEP8](https://www.python.org/dev/peps/pep-0008/)
52-
coding style for Python implementations. Please review your own code
51+
[PEP8](https://www.python.org/dev/peps/pep-0008/)
52+
coding style for Python implementations. Please review your own code
5353
for adherence to the standard.
5454

5555
## Pull Request Reviews

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ help:
1717
# Catch-all target: route all unknown targets to Sphinx using the new
1818
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1919
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ dev = [
4343
"sphinx>=3.5.2",
4444
"sphinx-autobuild>=2021.3.14",
4545
"coverage>=7",
46-
"ruff>=0.9.9",
46+
"ruff>=0.14.4",
4747
"pytest-ruff>=0.3.2"
4848
]
4949

src/cryptojwt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""JSON Web Token"""
22

33
import logging
4-
from importlib.metadata import version, PackageNotFoundError
4+
from importlib.metadata import PackageNotFoundError, version
55

66
from cryptojwt.jwe.jwe import JWE
77
from cryptojwt.jwk import JWK

src/cryptojwt/jwe/fernet.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import base64
22
import os
3-
from typing import Optional, Union
43

54
from cryptography.fernet import Fernet
65
from cryptography.hazmat.primitives import hashes
@@ -15,12 +14,12 @@
1514
class FernetEncrypter(Encrypter):
1615
def __init__(
1716
self,
18-
password: Optional[str] = None,
19-
salt: Optional[bytes] = "",
20-
key: Optional[bytes] = None,
21-
hash_alg: Optional[str] = "SHA256",
22-
digest_size: Optional[int] = 0,
23-
iterations: Optional[int] = DEFAULT_ITERATIONS,
17+
password: str | None = None,
18+
salt: bytes | None = "",
19+
key: bytes | None = None,
20+
hash_alg: str | None = "SHA256",
21+
digest_size: int | None = 0,
22+
iterations: int | None = DEFAULT_ITERATIONS,
2423
):
2524
Encrypter.__init__(self)
2625

@@ -45,14 +44,14 @@ def __init__(
4544

4645
self.core = Fernet(self.key)
4746

48-
def encrypt(self, msg: Union[str, bytes], **kwargs) -> bytes:
47+
def encrypt(self, msg: str | bytes, **kwargs) -> bytes:
4948
text = as_bytes(msg)
5049
# Padding to block size of AES
5150
if len(text) % 16:
5251
text += b" " * (16 - len(text) % 16)
5352
return self.core.encrypt(as_bytes(text))
5453

55-
def decrypt(self, msg: Union[str, bytes], **kwargs) -> bytes:
54+
def decrypt(self, msg: str | bytes, **kwargs) -> bytes:
5655
dec_text = self.core.decrypt(as_bytes(msg))
5756
dec_text = dec_text.rstrip(b" ")
5857
return dec_text

src/cryptojwt/jwk/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import hashlib
33
import json
44
import ssl
5-
from typing import List
65

76
from ..exception import UnsupportedAlgorithm
87
from ..utils import as_bytes, as_unicode, b64e, base64url_to_long
@@ -21,7 +20,7 @@ class JWK:
2120
"""
2221

2322
members = ["kty", "alg", "use", "kid", "x5c", "x5t", "x5u", "key_ops"]
24-
longs: List[str] = []
23+
longs: list[str] = []
2524
public_members = ["kty", "alg", "use", "kid", "x5c", "x5t", "x5u", "key_ops"]
2625
required = ["kty"]
2726

@@ -130,7 +129,7 @@ def __init__(
130129
self.kid = as_unicode(kid)
131130

132131
if key_ops:
133-
self.key_ops: List[str] = []
132+
self.key_ops: list[str] = []
134133
for ops in key_ops:
135134
if isinstance(ops, str):
136135
self.key_ops.append(ops)

src/cryptojwt/jwk/ec.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
# This is used to translate between the curve representation in
1515
# Cryptography and the one used by NIST (and in RFC 7518)
1616
NIST2SEC = {
17-
"B-571": ec.SECT571R1,
18-
"K-571": ec.SECT571K1,
19-
"K-409": ec.SECT409K1,
20-
"K-283": ec.SECT283K1,
21-
"K-233": ec.SECT233K1,
22-
"K-163": ec.SECT163K1,
2317
"P-521": ec.SECP521R1,
2418
"P-384": ec.SECP384R1,
2519
"P-256": ec.SECP256R1,

src/cryptojwt/jwk/okp.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Union
2-
31
from cryptography.hazmat.primitives import serialization
42
from cryptography.hazmat.primitives.asymmetric import ed448, ed25519, x448, x25519
53

@@ -14,18 +12,16 @@
1412
import_public_key_from_pem_file,
1513
)
1614

17-
OKPPublicKey = Union[
18-
ed25519.Ed25519PublicKey,
19-
ed448.Ed448PublicKey,
20-
x25519.X25519PublicKey,
21-
x448.X448PublicKey,
22-
]
23-
OKPPrivateKey = Union[
24-
ed25519.Ed25519PrivateKey,
25-
ed448.Ed448PrivateKey,
26-
x25519.X25519PrivateKey,
27-
x448.X448PrivateKey,
28-
]
15+
OKPPublicKey = (
16+
ed25519.Ed25519PublicKey | ed448.Ed448PublicKey | x25519.X25519PublicKey | x448.X448PublicKey
17+
)
18+
19+
OKPPrivateKey = (
20+
ed25519.Ed25519PrivateKey
21+
| ed448.Ed448PrivateKey
22+
| x25519.X25519PrivateKey
23+
| x448.X448PrivateKey
24+
)
2925

3026
OKP_CRV2PUBLIC = {
3127
"Ed25519": ed25519.Ed25519PublicKey,

0 commit comments

Comments
 (0)