(needsSubtle: boolean)
| 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. |
| 171 | const 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 | |
| 184 | const layerSignature = Signature.layerWebCrypto.pipe(Layer.provide(SecureRandom.layerWebCrypto)) |
| 185 |
no test coverage detected