/** * @module * AWS Signature Version 4 signing using Web Crypto (HMAC-SHA256). * Works on Node.js, Bun, Deno, and Cloudflare Workers. * No external dependencies. * * @example * ```ts * import { signRequest } from "sently/core/sigv4"; * const signed = await signRequest({ * method: "POST", * url: "https://email.us-east-1.amazonaws.com/v2/email/outbound-emails", * headers: { "content-type": "application/json" }, * body: '{"..."}', * credentials: { accessKeyId, secretAccessKey, region: "us-east-1", service: "ses" }, * }); * ``` */ /** AWS credentials and signing scope for SigV4. */ export interface SigV4Credentials { /** AWS access key ID. */ accessKeyId: string; /** AWS secret access key. */ secretAccessKey: string; /** AWS region (e.g. `us-east-1`). */ region: string; /** AWS service name (e.g. `ses`, `s3`). */ service: string; /** Optional STS session token for temporary credentials. */ sessionToken?: string; } /** HTTP request to sign with AWS Signature Version 4. */ export interface SigV4Request { /** HTTP method (e.g. `POST`). */ method: string; /** Full request URL including path and query. */ url: string; /** Request headers to include in the signature. */ headers: Record; /** Request body as a string (empty for GET). */ body: string; /** AWS credentials and signing scope. */ credentials: SigV4Credentials; /** Override datetime for testing. Full 'YYYYMMDDTHHMMSSZ' when provided. */ _date?: string; } /** Signed request headers including Authorization. */ export interface SigV4Result { /** All headers including Authorization, x-amz-date, and x-amz-security-token */ headers: Record; } /** * Compute SHA-256 hash of a string using Web Crypto. * Returns lowercase hex string. * @internal */ export declare function sha256Hex(data: string): Promise; /** * Compute HMAC-SHA256 using Web Crypto. * @internal */ export declare function hmacSHA256(key: Uint8Array | string, data: string): Promise; /** * Sign an HTTP request with AWS Signature Version 4. * Returns the complete set of headers to include in the request. */ export declare function signRequest(request: SigV4Request): Promise;