/** * Consent HTML Shell Generator * * Generates the minimal HTML shell that Workers serve for consent pages. * The shell loads the bundled consent.js and renders . * * Architecture: * 1. Worker receives consent page request * 2. Worker calls generateConsentShell() with config * 3. Browser loads HTML, fetches consent.js * 4. Lit components render the consent UI * 5. Form submission posts back to Worker * * @module @kya-os/consent/bundle/shell */ import type { ConsentConfig } from "../types/config.types.js"; import type { OAuthIdentity } from "../types/api.types.js"; /** * Options for generating the consent HTML shell */ export interface ConsentShellOptions { /** Consent page configuration (from AgentShield remote config) */ config: ConsentConfig; /** Tool being requested */ tool: string; /** Permission scopes requested */ scopes: string[]; /** Agent's DID */ agentDid: string; /** Session identifier */ sessionId: string; /** Project identifier */ projectId: string; /** Server URL for form submission */ serverUrl: string; /** OAuth identity if already authenticated */ oauthIdentity?: OAuthIdentity; /** * Path to the consent bundle. Defaults to {@link CONSENT_BUNDLE_PATH}, the * content-addressed path the worker serves. Override only when hosting the * bundle yourself — a path that does not match what the server routes will * leave the page unable to load its own component. */ bundlePath?: string; /** Custom page title */ pageTitle?: string; /** CSP nonce for inline scripts/styles */ nonce?: string; /** Authentication mode (consent-only, credentials, oauth, magic-link, otp) */ authMode?: string; /** Human-readable agent name for display */ agentName?: string; /** Provider name for credentials/oauth flows */ provider?: string; /** CSRF token for form security (required for credential auth) */ csrfToken?: string; /** Credential provider type from prior auth step (for 3-screen flow) */ credentialProviderType?: string; /** Credential provider name from prior auth step (for 3-screen flow) */ credentialProvider?: string; /** * User DID from prior auth step * CRITICAL: Bypasses KV eventual consistency issues by passing directly */ userDid?: string; /** * User email from credential provider response * Used for human-readable display in AgentShield dashboard (user_identifier) */ credentialUserEmail?: string; /** * Provider's internal user ID from credential provider response * Used for business reference (e.g., Hardware World customer ID 696395) */ credentialProviderUserId?: string; /** * Pre-built OAuth authorization URL * When provided, the OAuth button will link directly to this URL instead of * constructing a URL like /oauth/:provider which may not exist. * Example: https://github.com/login/oauth/authorize?client_id=...&redirect_uri=... */ oauthUrl?: string; /** * Authorization type from tool protection config * Determines the provider_type sent in credential form submissions * Values: 'password', 'oauth2', 'none', etc. * Default: 'password' for credential flows */ authorizationType?: string; /** * OAuth provider type from prior OAuth auth step (for 3-screen flow) * Set to 'oauth' after OAuth completes to ensure delegation is created * with correct authorization.type instead of 'none'. */ oauthProviderType?: string; /** * OAuth provider name from prior OAuth auth step (e.g., 'custom', 'github') * Used for display and delegation metadata */ oauthProviderName?: string; /** * Operator-authored capability groups. When present, the new humanized * consent layout renders instead of the legacy raw scope list. */ capabilities?: import("../types/capabilities.types.js").CapabilityGroup[]; /** Resolved agent identity tile (logo, vendor, surface, verified). */ agentMetadata?: import("../types/capabilities.types.js").AgentMetadata; /** Theme override (`light` / `dark`). Defaults to `light`. */ consentTheme?: import("../types/capabilities.types.js").ConsentTheme; /** Org name shown in the headline + revocation footer. */ orgName?: string; /** Operator-set headline verb (e.g., 'use', 'shop'). */ headlineVerb?: string; /** Path the user can visit to revoke (footer notice). */ revocationPath?: string; /** Days of inactivity before auto-revocation (footer notice). */ inactivityDays?: number; /** Optional URL backing the "How does this work?" link. */ howItWorksUrl?: string; /** Cedar template context bound at render time for "View policy" disclosures. */ cedarContext?: import("../types/capabilities.types.js").CedarTemplateContext; } /** * Generate the consent page HTML shell * * This produces a minimal HTML document that: * - Loads the bundled consent.js * - Renders the web component * - Includes a loading skeleton for perceived performance * - Has a no-JS fallback form * * @example * ```typescript * const html = generateConsentShell({ * config: remoteConfig, * tool: 'purchase', * scopes: ['billing:read', 'orders:write'], * agentDid: 'did:key:z6Mk...', * sessionId: 'sess_abc123', * projectId: 'proj_xyz', * serverUrl: 'https://api.example.com', * }); * * return new Response(html, { * headers: { 'Content-Type': 'text/html' } * }); * ``` */ export declare function generateConsentShell(options: ConsentShellOptions): string; /** * Generate inline consent component (no external bundle) * * For scenarios where you want to inline everything into a single HTML response. * This is useful for: * - Offline/embedded scenarios * - Single-request consent pages * - Testing/debugging * * Note: This requires the consent bundle to be inlined as a string. * * @param options - Shell options * @param bundleSource - The bundled consent.js source code */ export declare function generateInlineConsentShell(options: Omit, bundleSource: string): string; //# sourceMappingURL=shell.d.ts.map