Skip to content

Commit 1952dff

Browse files
committed
fix: update docstring
1 parent b1e3c5c commit 1952dff

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

src/joserfc/_rfc7517/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def check_use(self, use: str) -> None:
216216
requires its presence.
217217
218218
:param use: this key is used for, e.g. "sig", "enc"
219-
:raise: UnsupportedKeyUseError
219+
:raise UnsupportedKeyUseError: if this key is not designed for the given use
220220
"""
221221
designed_use = self.get("use")
222222
if designed_use and designed_use != use:
@@ -226,7 +226,7 @@ def check_alg(self, alg: str) -> None:
226226
"""Check if this key supports the given "alg".
227227
228228
:param alg: the algorithm this key is intended to be used, e.g. "HS256", "ECDH-EC"
229-
:raise: UnsupportedKeyAlgorithmError
229+
:raise UnsupportedKeyAlgorithmError: if this key is not designed for the given algorithm
230230
"""
231231
designed_alg = self.get("alg")
232232
if designed_alg and designed_alg != alg:
@@ -236,7 +236,7 @@ def check_key_op(self, operation: str) -> None:
236236
"""Check if the given key_op is supported by this key.
237237
238238
:param operation: key operation value, such as "sign", "encrypt".
239-
:raise: UnsupportedKeyOperationError
239+
:raise UnsupportedKeyOperationError: if the operation is not supported by this key.
240240
"""
241241
key_ops = self.get("key_ops")
242242
if key_ops is not None and operation not in key_ops:

src/joserfc/_rfc7519/security.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@
2222

2323

2424
def check_sensitive_data(claims: dict[str, Any]) -> None:
25-
"""Check if claims contains sensitive information."""
25+
"""
26+
Checks for sensitive data within a dictionary of claims and raises an
27+
error if any sensitive names or values are detected.
28+
29+
:param claims: JWT claims to check for sensitive data
30+
:raises InsecureClaimError: if any sensitive names or values are detected
31+
"""
2632
for k in claims:
2733
# check claims key name
2834
if k in SENSITIVE_NAMES:

src/joserfc/_rfc7797/compact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def extract_rfc7515_compact(
3636
:param value: JWS in bytes
3737
:param payload: optional payload, required with detached content
3838
:param registry: optional JWSRegistry instance
39-
:raise: DecodeError
39+
:raise DecodeError: when decoding fails
4040
"""
4141
parts = value.split(b".")
4242
if len(parts) != 3:

src/joserfc/jws.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ def deserialize_compact(
178178
:param algorithms: a list of allowed algorithms
179179
:param registry: a JWSRegistry to use
180180
:param payload: optional payload, required with detached content
181-
:return: object of the ``CompactSignature``
181+
:raises BadSignatureError: when signature verification fails
182+
:return: object of the CompactSignature
182183
"""
183184
obj = extract_compact(to_bytes(value), payload, registry)
184185
if not validate_compact(obj, public_key, algorithms, registry):
@@ -286,8 +287,8 @@ def deserialize_json(
286287
:param public_key: a flexible public key to verify the signature
287288
:param algorithms: a list of allowed algorithms
288289
:param registry: a JWSRegistry to use
289-
:return: object of the SignatureData
290-
:raise: ValueError or BadSignatureError
290+
:return: object of GeneralJSONSignature or FlattenedJSONSignature
291+
:raises BadSignatureError: when signature verification fails
291292
"""
292293
if registry is None:
293294
registry = construct_registry(algorithms)

src/joserfc/jwt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ def decode(
9999
:param algorithms: a list of allowed algorithms
100100
:param registry: a ``JWSRegistry`` or ``JWERegistry`` to use
101101
:param decoder_cls: A JSONDecoder subclass to use
102-
:raise: BadSignatureError
102+
:raise BadSignatureError: when signature verification fails
103+
:raise InvalidPayloadError: when payload is not a valid JSON object
103104
"""
104105
_value = to_bytes(value)
105106
header: Header

0 commit comments

Comments
 (0)