BrowserCrypto.ts
BrowserCrypto.ts overview
Section titled “BrowserCrypto.ts overview”Browser-backed implementation of Effect’s Crypto service.
This module provides a Crypto.Crypto layer backed by the Web Crypto API.
The WebCrypto context reference defaults to globalThis.crypto, so
browser programs can use the standard implementation while tests or embedded
runtimes can provide their own Crypto object.
Since v1.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”layers
Section titled “layers”Layer that directly interfaces with the Web Crypto API.
When to use
Use to provide cryptographic randomness, UUID generation, and digest
operations in browser runtimes backed by globalThis.crypto.
Details
Random bytes are produced with crypto.getRandomValues. Digests are computed
with crypto.subtle.digest and returned as Uint8Array values.
Gotchas
The layer dies if the Web Crypto object is unavailable. Digest operations
fail with PlatformError when crypto.subtle.digest is unavailable or the
browser rejects the digest request.
Signature
declare const layer: Layer.Layer<EffectCrypto.Crypto, never, never>Since v1.0.0
references
Section titled “references”WebCrypto
Section titled “WebCrypto”Provides Browser Web Crypto APIs used by the Crypto service implementation.
When to use
Use to override the browser Crypto object used by the platform crypto
layer.
Signature
declare const WebCrypto: Context.Reference<Crypto>Since v1.0.0