-
Notifications
You must be signed in to change notification settings - Fork 15
/
types.py
115 lines (93 loc) · 2.81 KB
/
types.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from __future__ import annotations
from dataclasses import dataclass
from enum import Enum
from typing import Dict, Any, Union, List
JSON_OBJ = Dict[str, Any]
JSON_VALUE = Union[type(None), str, int, bool, float, Dict, List]
JSON = str
JWK = JSON
JWT = JSON
JWS = JSON
DID = str
DID_URL = str
DID_OR_DID_URL = Union[DID, DID_URL]
class VerificationMethodType(Enum):
JSON_WEB_KEY_2020 = 1
X25519_KEY_AGREEMENT_KEY_2019 = 2
ED25519_VERIFICATION_KEY_2018 = 3
X25519_KEY_AGREEMENT_KEY_2020 = 4
ED25519_VERIFICATION_KEY_2020 = 5
# ECDSA_SECP_256K1_VERIFICATION_KEY_2019 = 6 - not supported now
OTHER = 1000
class VerificationMaterialFormat(Enum):
JWK = 1
BASE58 = 2
MULTIBASE = 3
OTHER = 1000
@dataclass
class VerificationMaterial:
format: VerificationMaterialFormat
value: str
class DIDDocServiceTypes(Enum):
DID_COMM_MESSAGING = "DIDCommMessaging"
class DIDCommMessageTypes(Enum):
ENCRYPTED = "application/didcomm-encrypted+json"
ENCRYPTED_SHORT = "didcomm-encrypted+json"
SIGNED = "application/didcomm-signed+json"
SIGNED_SHORT = "didcomm-signed+json"
PLAINTEXT = "application/didcomm-plain+json"
PLAINTEXT_SHORT = "didcomm-plain+json"
DIDCommMessageMediaTypes = DIDCommMessageTypes
# TODO
# - replace DIDCommMessageTypes with DIDCommMessageMediaTypes
# - rename DIDCommMessageProtocolTypes to DIDCommMessageTypes
JWT_TYPE = "JWT"
class DIDCommMessageProtocolTypes(Enum):
FORWARD = "https://didcomm.org/routing/2.0/forward"
class JOSEFields:
# JOSE Header fields as defined in JWS and JWE specs
# (RFCs 7515, 7516, 7518, 7519, 7797, 8225, 8555)
# https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-header-parameters
JOSE_ALG = "alg"
JOSE_JKU = "jku"
JOSE_JWK = "jwk"
JOSE_KID = "kid"
JOSE_X5U = "x5u"
JOSE_X5C = "x5c"
JOSE_X5T = "x5t"
JOSE_X5T_S256 = "x5t#S256"
JOSE_TYP = "typ"
JOSE_CTY = "cty"
JOSE_CRIT = "crit"
JOSE_ENC = "enc"
JOSE_ZIP = "zip"
JOSE_EPK = "epk"
JOSE_APU = "apu"
JOSE_APV = "apv"
JOSE_IV = "iv"
JOSE_TAG = "tag"
JOSE_P2S = "p2s"
JOSE_P2C = "p2c"
JOSE_ISS = "iss"
JOSE_SUB = "sub"
JOSE_AUD = "aud"
JOSE_B64 = "b64"
JOSE_PPT = "ppt"
JOSE_URL = "url"
JOSE_NONCE = "nonce"
# JWS (non-header) fields
# https://datatracker.ietf.org/doc/html/rfc7515#section-3.2
JWS_PROTECTED = "protected"
JWS_HEADER = "header"
JWS_PAYLOAD = "payload"
JWS_SIGNATURE = "signature"
# JWE (non-heder) fields
# https://datatracker.ietf.org/doc/html/rfc7516#section-3.2
JWE_PROTECTED = JWS_PROTECTED
JWE_UNPROTECTED = "unprotected"
JWE_HEADER = JWS_HEADER
JWE_ENCRYPTED_KEY = "encrypted_key"
JWE_IV = JOSE_IV
JWE_CIPHERTEXT = "ciphertext"
JWE_TAG = JOSE_TAG
JWE_AAD = "aad"