MCPcopy Create free account
hub / github.com/Effect-TS/effect / requireWebCrypto

Function requireWebCrypto

packages/effect/src/eventlog/EventLogSessionAuth.ts:171–182  ·  view source on GitHub ↗
(needsSubtle: boolean)

Source from the content-addressed store, hash-verified

169// The Web Crypto layers read the `WebCrypto` reference, so a runtime without
170// Web Crypto fails here rather than with a defect inside the layer.
171const requireWebCrypto = (needsSubtle: boolean): Effect.Effect<void, EventLogSessionAuthError> =>
172 WebCrypto.use((crypto) => {
173 if (crypto === undefined || (needsSubtle && crypto.subtle === undefined)) {
174 return Effect.fail(
175 new EventLogSessionAuthError({
176 reason: "CryptoUnavailable",
177 message: needsSubtle ? "crypto.subtle is not available" : "crypto is not available"
178 })
179 )
180 }
181 return Effect.void
182 })
183
184const layerSignature = Signature.layerWebCrypto.pipe(Layer.provide(SecureRandom.layerWebCrypto))
185

Callers 1

Calls 2

useMethod · 0.65
failMethod · 0.65

Tested by

no test coverage detected