11from __future__ import annotations
22from typing import overload , Any
3+ from collections .abc import Collection
34from ._rfc7515 .model import (
45 JWSAlgModel ,
56 HeaderMember ,
@@ -75,7 +76,7 @@ def serialize_compact(
7576 protected : Header ,
7677 payload : bytes | str ,
7778 private_key : KeyFlexible | None ,
78- algorithms : list [str ] | None = None ,
79+ algorithms : Collection [str ] | None = None ,
7980 registry : JWSRegistry | None = None ,
8081) -> str :
8182 """Generate a JWS Compact Serialization. The JWS Compact Serialization
@@ -91,7 +92,7 @@ def serialize_compact(
9192 :param protected: protected header part of the JWS, in dict
9293 :param payload: payload data of the JWS, in bytes
9394 :param private_key: a flexible private key to sign the signature
94- :param algorithms: a list of allowed algorithms
95+ :param algorithms: a collection ( list, tuple, or set) of allowed algorithms
9596 :param registry: a JWSRegistry to use
9697 :return: JWS in str
9798 """
@@ -123,15 +124,15 @@ def serialize_compact(
123124def validate_compact (
124125 obj : CompactSignature ,
125126 public_key : KeyFlexible | None ,
126- algorithms : list [str ] | None = None ,
127+ algorithms : Collection [str ] | None = None ,
127128 registry : JWSRegistry | None = None ,
128129) -> bool :
129130 """Validate the JWS Compact Serialization with the given key.
130131 This method is usually used together with ``extract_compact``.
131132
132133 :param obj: object of the JWS Compact Serialization
133134 :param public_key: a flexible public key to verify the signature
134- :param algorithms: a list of allowed algorithms
135+ :param algorithms: a collection ( list, tuple, or set) of allowed algorithms
135136 :param registry: a JWSRegistry to use
136137 """
137138 if registry is None :
@@ -156,7 +157,7 @@ def validate_compact(
156157def deserialize_compact (
157158 value : bytes | str ,
158159 public_key : KeyFlexible | None ,
159- algorithms : list [str ] | None = None ,
160+ algorithms : Collection [str ] | None = None ,
160161 registry : JWSRegistry | None = None ,
161162 payload : bytes | str | None = None ,
162163) -> CompactSignature :
@@ -175,7 +176,7 @@ def deserialize_compact(
175176
176177 :param value: a string (or bytes) of the JWS Compact Serialization
177178 :param public_key: a flexible public key to verify the signature
178- :param algorithms: a list of allowed algorithms
179+ :param algorithms: a collection ( list, tuple, or set) of allowed algorithms
179180 :param registry: a JWSRegistry to use
180181 :param payload: optional payload, required with detached content
181182 :raises BadSignatureError: when signature verification fails
@@ -192,7 +193,7 @@ def serialize_json(
192193 members : list [HeaderDict ],
193194 payload : bytes | str ,
194195 private_key : KeyFlexible ,
195- algorithms : list [str ] | None = None ,
196+ algorithms : Collection [str ] | None = None ,
196197 registry : JWSRegistry | None = None ,
197198) -> GeneralJSONSerialization : ...
198199
@@ -202,7 +203,7 @@ def serialize_json(
202203 members : HeaderDict ,
203204 payload : bytes | str ,
204205 private_key : KeyFlexible ,
205- algorithms : list [str ] | None = None ,
206+ algorithms : Collection [str ] | None = None ,
206207 registry : JWSRegistry | None = None ,
207208) -> FlattenedJSONSerialization : ...
208209
@@ -211,7 +212,7 @@ def serialize_json(
211212 members : HeaderDict | list [HeaderDict ],
212213 payload : bytes | str ,
213214 private_key : KeyFlexible ,
214- algorithms : list [str ] | None = None ,
215+ algorithms : Collection [str ] | None = None ,
215216 registry : JWSRegistry | None = None ,
216217) -> GeneralJSONSerialization | FlattenedJSONSerialization :
217218 """Generate a JWS JSON Serialization (in dict). The JWS JSON Serialization
@@ -261,7 +262,7 @@ def find_key(obj: HeaderMember) -> Key:
261262def deserialize_json (
262263 value : GeneralJSONSerialization ,
263264 public_key : KeyFlexible ,
264- algorithms : list [str ] | None = None ,
265+ algorithms : Collection [str ] | None = None ,
265266 registry : JWSRegistry | None = None ,
266267) -> GeneralJSONSignature : ...
267268
@@ -270,22 +271,22 @@ def deserialize_json(
270271def deserialize_json (
271272 value : FlattenedJSONSerialization ,
272273 public_key : KeyFlexible ,
273- algorithms : list [str ] | None = None ,
274+ algorithms : Collection [str ] | None = None ,
274275 registry : JWSRegistry | None = None ,
275276) -> FlattenedJSONSignature : ...
276277
277278
278279def deserialize_json (
279280 value : GeneralJSONSerialization | FlattenedJSONSerialization ,
280281 public_key : KeyFlexible ,
281- algorithms : list [str ] | None = None ,
282+ algorithms : Collection [str ] | None = None ,
282283 registry : JWSRegistry | None = None ,
283284) -> GeneralJSONSignature | FlattenedJSONSignature :
284285 """Extract and validate the JWS (in string) with the given key.
285286
286287 :param value: a dict of the JSON signature
287288 :param public_key: a flexible public key to verify the signature
288- :param algorithms: a list of allowed algorithms
289+ :param algorithms: a collection ( list, tuple, or set) of allowed algorithms
289290 :param registry: a JWSRegistry to use
290291 :return: object of GeneralJSONSignature or FlattenedJSONSignature
291292 :raises BadSignatureError: when signature verification fails
0 commit comments