/** * push/encryption.ts * * Browser-push payload encryption, implemented with Node's built-in crypto * (node:crypto), no third-party web-push dependency. This is the daemon-side * (Node/Bun) delivery path only; nothing here is imported by the runtime-neutral * or browser bundles (see scripts/browser-compat-check.ts). * * Two standards are combined here, exactly as a browser Push service expects: * * - RFC 8291 (Message Encryption for Web Push): derive a shared secret from an * ephemeral P-256 keypair and the subscription's public key + auth secret. * - RFC 8188 (aes128gcm content encoding): expand that secret into a * content-encryption key + nonce and encrypt one record, then frame it with * the salt / record-size / sender-public-key header the receiver reads back. * * The output Buffer is the raw request body sent to the subscription endpoint * with `Content-Encoding: aes128gcm`. */ /** The subscription's own key material, base64url-encoded (browser PushSubscription shape). */ export interface SubscriptionKeyMaterial { /** The receiver's public key, 65-byte uncompressed P-256 point, base64url. */ readonly p256dh: string; /** The receiver's 16-byte authentication secret, base64url. */ readonly auth: string; } export interface EncryptedPushPayload { /** The aes128gcm request body: header || ciphertext || GCM tag. */ readonly body: Buffer; /** Always `aes128gcm`, the value for the Content-Encoding request header. */ readonly contentEncoding: 'aes128gcm'; } /** * Encrypt `plaintext` for a subscription's key material. * * A fresh ephemeral sender keypair and salt are generated per call (RFC 8291 * requires this, the same salt/key pair must never encrypt two messages), so * the result is non-deterministic by design. */ export declare function encryptPushPayload(keys: SubscriptionKeyMaterial, plaintext: Buffer): EncryptedPushPayload; //# sourceMappingURL=encryption.d.ts.map