Skip to content

Domain.SecretReceiptKey reference

Source: packages/domain/src/ReceiptKey.ts Kind: Layer · Provides: Domain.ReceiptKey

Sign receipts with HMAC-SHA256 under a secret: 32 random bytes as text, not a password. Pass a name, and Alchemy.Random makes the secret on the first deploy and keeps it in the Stack’s state, so the state store is as sensitive as the secret. Or pass a secret you keep yourself. Every process that serves the Api needs the same secret, or a receipt one signs is unsigned to another.

SecretReceiptKey: Signing receipts with a secret

Section titled “SecretReceiptKey: Signing receipts with a secret”

A secret from the environment

import * as Domain from "@alchemy.run/domain";
import * as Config from "effect/Config";
export const Receipts = Domain.SecretReceiptKey(Config.Redacted("RECEIPT_KEY"));

A secret made at deploy

import * as Domain from "@alchemy.run/domain";
// An `Alchemy.Random` named "ReceiptKey": made on the first deploy and kept in the Stack's state.
export const Receipts = Domain.SecretReceiptKey("ReceiptKey");