The Web Crypto API the layer_web_crypto layers run on (Effect's
effect/crypto/WebCrypto).
WebCrypto is a reference holding a Crypto: get_random_values
and a subtle (SubtleCrypto), as JavaScript's globalThis.crypto.
Its default, host, is pyfect's own: os.urandom, hashlib and,
for keys, the cryptography package (the crypto extra), with Web
Crypto's key formats, usages and errors. layer(crypto) swaps it, for
a hardware-backed implementation or a test double.
A SubtleCrypto method fails by raising DOMException with Web
Crypto's name ("DataError", "InvalidAccessError",
"NotSupportedError", "OperationError"); anything else it raises
is a defect.
Types#
| Type | Definition | Description |
|---|---|---|
KeyType | type KeyType = Literal['private', 'public', 'secret'] | |
KeyUsage | type KeyUsage = Literal['encrypt', 'decrypt', 'sign', 'verify', 'deriveKey', 'deriveBits', 'wrapKey', 'unwrapKey'] | |
BinaryFormat | type BinaryFormat = Literal['raw', 'spki', 'pkcs8'] | |
KeyFormat | type KeyFormat = Literal['raw', 'spki', 'pkcs8', 'jwk'] | |
AlgorithmIdentifier | type AlgorithmIdentifier = str | Params |
Classes#
Functions#
layer#
layer(crypto) -> Layer[Never]Run the layer_web_crypto layers built under it on crypto.
| Parameter | Type | Description |
|---|---|---|
crypto | Crypto |
Returns Layer[Never]
def layer(crypto: Crypto) -> Layer[Never]:
"""Run the ``layer_web_crypto`` layers built under it on ``crypto``."""
return layer_succeed(WebCrypto, crypto)