jam.paseto.v4¶
v4
¶
Classes:
| Name | Description |
|---|---|
PASETOv4 |
PASETO v4 factory. |
PASETOv4
¶
PASETOv4()
Bases: BasePASETO
PASETO v4 factory.
Methods:
| Name | Description |
|---|---|
decode |
Decode PASETO. |
encode |
Encode PASETO. |
key |
Create PASETO Factory. |
decode
¶
decode(
token: str,
serializer: type[BaseEncoder]
| BaseEncoder = JsonEncoder,
) -> tuple[
dict[str, Any], dict[str, Any] | str | bytes | None
]
Decode PASETO.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
PASETO |
required |
serializer
|
type[BaseEncoder] | BaseEncoder]
|
JSON Serializer |
JsonEncoder
|
Raises:
| Type | Description |
|---|---|
JamPASETOInvalidTokenFormat
|
If the token format is invalid. |
JamPASETOInvalidED25519Key
|
If the key is not a valid ED25519 key. |
JamPASETOKeyVerificationError
|
If the token signature is invalid. |
JamPASETOInvalidPurpose
|
If the purpose is not "local" or "public". |
encode
¶
encode(
payload: dict[str, Any],
footer: dict[str, Any] | str | bytes | None = None,
serializer: type[BaseEncoder]
| BaseEncoder = JsonEncoder,
) -> str
Encode PASETO.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
PASETO Payload |
required |
footer
|
dict[str, Any] | str | None
|
Footer if needed |
None
|
serializer
|
type[BaseEncoder] | BaseEncoder
|
JSON Serializer |
JsonEncoder
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
PASETO |
Raises:
| Type | Description |
|---|---|
JamPASETOInvalidED25519Key
|
If the key is not a valid ED25519 key. |
JamPASETOInvalidPurpose
|
If the purpose is not "local" or "public". |
key
classmethod
¶
key(
purpose: Literal["local", "public"],
secret_key: str | bytes | Ed25519PrivateKey,
) -> PASETO
Create PASETO Factory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
purpose
|
Literal['local', 'public']
|
PASETO type |
required |
secret_key
|
str | bytes | Ed25519PrivateKey
|
Secret or ED Private key |
required |
Raises:
| Type | Description |
|---|---|
JamPASETOInvalidED25519Key
|
If the key is not a valid ED25519 key. |
JamPASETOInvalidPurpose
|
If the purpose is not "local" or "public". |