AsyncEncryption
Async counterpart of Encryption. Integrates encryption logic and async
key management via the AsyncEncryptionKeyStorageStrategy interface.
Source code in event_sourcery/_event_store/_async/encryption.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
ashred(subject_id)
async
Deletes the encryption key for the given subject, effectively making all encrypted data for that subject unrecoverable (crypto-shredding).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject_id
|
str
|
The subject identifier whose key should be deleted. |
required |
Source code in event_sourcery/_event_store/_async/encryption.py
decrypt(event_type, raw, stream_id)
async
Decrypts all fields of the event marked as encrypted in the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
type[BaseModel]
|
The event class type. |
required |
raw
|
dict[str, Any]
|
The raw event data with encrypted fields. |
required |
stream_id
|
StreamId
|
The stream identifier used for subject resolution. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: The event data with decrypted fields (or masked if no key). |
Source code in event_sourcery/_event_store/_async/encryption.py
encrypt(event, stream_id)
async
Encrypts all fields of the event marked as encrypted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
BaseModel
|
The event instance to encrypt. |
required |
stream_id
|
StreamId
|
The stream identifier used for subject resolution. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: The event data with encrypted fields. |
Raises:
| Type | Description |
|---|---|
NoSubjectIdFound
|
If the subject id cannot be determined for encryption. |
KeyNotFoundError
|
If the encryption key for a subject is missing. |