/** * @name premium/activation-manager * @description Session activation manager for x402/pay.sh receipt binding. * * After a buyer creates a session plan (status `pending_payment`) and settles * the x402/pay.sh challenge on the delivery rail, the activation manager * verifies the receipt and transitions the session to `active`. * * Solking disclosure 2026-09-07 (Finding 2): activation previously only * length-checked the receipt string, so any 8-character placeholder activated * a paid premium session. Activation now REQUIRES an injected * {@link ReceiptVerifier} and FAILS CLOSED when none is configured — the only * bypass is the explicit dev escape hatch `SAP_MCP_ALLOW_UNVERIFIED_ACTIVATION=true`, * which must never be set on hosted deployments. * * @flow * 1. Buyer settles x402 challenge → receives `paymentReceipt` (tx signature). * 2. Buyer calls `POST /premium/activate` or MCP tool `sap_premium_activate_session`. * 3. → Receipt format is validated, then the injected `ReceiptVerifier` * checks the settlement on-chain (or against the facilitator). * 4. → On success, `session-manager.activateSession()` transitions to `active`. * 5. → Returns `PremiumActivationResult` with `unitsQuota` and `activatedAt`. * 6. Stream broker / webhook engine check `status=active` before delivering. * * @module premium/activation-manager */ import type { PremiumActivationRequest, PremiumActivationResult } from './types.js'; /** * @name ReceiptVerifier * @description Asynchronous payment-receipt verification contract. * * Implementations check that `receipt` is a real settled payment (on-chain tx * signature lookup against the recorded payTo/price, or a facilitator verify * call). Injected by the HTTP route / MCP tool layer; the premium package * itself stays network-free for testability. */ export interface ReceiptVerifier { verify(receipt: string, expectedAmountUsd?: number): Promise<{ valid: boolean; payer?: string; reason?: string; }>; } /** * @name activatePremiumSession * @description Activate a pending premium session with a verified payment receipt. * * Steps: * 1. Validate the receipt format (non-empty, reasonable length). * 2. Look up the session via `getPremiumSession`. * 3. Check the session is in `pending_payment` status. * 4. Verify the receipt via the injected `ReceiptVerifier` — fail closed * when no verifier is configured unless the dev escape hatch is set. * 5. Call `activateSession` to transition to `active`. * 6. Return `PremiumActivationResult`. * * @param request - Activation request with session id, payment receipt, and * optional receipt verifier. * @returns `PremiumActivationResult` with `status=active` on success, * `status=rejected` when verification fails or is unavailable. * * @usedBy `premium-tools.ts` → MCP tool `sap_premium_activate_session`, * `remote/server.ts` → `POST /premium/activate` */ export declare function activatePremiumSession(request: PremiumActivationRequest): Promise; //# sourceMappingURL=activation-manager.d.ts.map