| 1 | /** |
| 2 | * The `BunCrypto` module provides Bun's `Crypto` service layer for Effect |
| 3 | * programs. Provide {@link layer} at the edge of a Bun app, CLI, script, or |
| 4 | * test to satisfy `effect/Crypto` with cryptographically secure random bytes, |
| 5 | * UUID generation, random values, and SHA digest operations. |
| 6 | * |
| 7 | * This adapter reuses the shared Node-compatible implementation, so randomness |
| 8 | * and digest behavior follow Bun's `node:crypto` compatibility layer. SHA-1 is |
| 9 | * present for interoperability with existing protocols, not for new |
| 10 | * security-sensitive designs. |
| 11 | * |
| 12 | * @since 1.0.0 |
| 13 | */ |
| 14 | import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto" |
| 15 | import type * as Crypto from "effect/Crypto" |
| 16 | import type * as Layer from "effect/Layer" |
| 17 | |
| 18 | /** |
| 19 | * Layer that provides the Bun Crypto service implementation. |
| 20 | * |
| 21 | * @category layers |
| 22 | * @since 1.0.0 |
| 23 | */ |
| 24 | export const layer: Layer.Layer<Crypto.Crypto> = NodeCrypto.layer |