/** * Consent Configuration Types * * Canonical type definitions for consent configuration. * * @module @kya-os/consent/types/config */ import type { ConsentBranding, ResolvedConsentBranding } from "./branding.types.js"; import type { ConsentUI, ConsentTerms, ConsentSuccess, ResolvedConsentCopy } from "./copy.types.js"; import type { AgentMetadata, CapabilityGroup, ConsentTheme } from "./capabilities.types.js"; export type { ConsentBranding, ResolvedConsentBranding } from "./branding.types.js"; export type { ConsentUI, ConsentTerms, ConsentSuccess, ResolvedConsentCopy } from "./copy.types.js"; import type { CredentialsConfig, OAuthConfig, MagicLinkConfig, OTPConfig, QRCodeConfig, PasskeyConfig, IDVConfig, AuthMode } from "./modes.types.js"; /** * Consent Custom Field Option * * Option for select/dropdown custom fields. */ export interface ConsentCustomFieldOption { /** Option value */ value: string; /** Display label */ label: string; } /** * Consent Custom Field * * Additional fields to collect during consent (e.g., email, preferences). */ export interface ConsentCustomField { /** Field name (used as form field name, must be valid identifier) */ name: string; /** Display label for the field */ label: string; /** Field type */ type: "text" | "textarea" | "checkbox" | "select" | "email"; /** Whether field is required */ required: boolean; /** Placeholder text */ placeholder?: string; /** Options for select fields */ options?: ConsentCustomFieldOption[]; /** Validation pattern (regex) */ pattern?: string; } /** * Consent Configuration Metadata * * Metadata for tracking config versions and cache invalidation. */ export interface ConsentMetadata { /** Config version number (incremented on each update) */ version?: number; /** Last update timestamp (ISO string) */ updatedAt?: string; /** Cache version string for invalidation */ cacheVersion?: string; } /** * Consent Configuration * * Complete consent configuration fetched from AgentShield or defaults. * This is the canonical type used for remote config storage and API responses. */ export interface ConsentConfig { /** Branding configuration */ branding?: ConsentBranding; /** UI/copy configuration */ ui?: ConsentUI; /** Terms configuration */ terms?: ConsentTerms; /** Success screen configuration */ success?: ConsentSuccess; /** Custom fields configuration */ customFields?: ConsentCustomField[]; /** Credentials mode configuration */ credentials?: CredentialsConfig; /** OAuth mode configuration */ oauth?: OAuthConfig; /** Magic link mode configuration */ magicLink?: MagicLinkConfig; /** OTP mode configuration */ otp?: OTPConfig; /** QR code mode configuration */ qrCode?: QRCodeConfig; /** Passkey mode configuration */ passkey?: PasskeyConfig; /** IDV mode configuration */ idv?: IDVConfig; /** Delegation expiration in days */ expirationDays?: number; /** * Operator-authored capability groups. When present and non-empty, the new * humanized consent layout (`` + ``) * is rendered instead of the legacy raw scope list. */ capabilities?: CapabilityGroup[]; /** * Resolved agent identity tile for the consent header. Optional; when * absent, the consent screen falls back to the company name from branding. */ agentMetadata?: AgentMetadata; /** * Theme override for the consent + (future) gateway screens. * Defaults to `light` when capability metadata is present. */ theme?: ConsentTheme; /** * Verb used in the consent headline (e.g. "use", "shop", "manage"). * Substituted into `{Agent} would like to {verb} at {Org} for you.`. */ headlineVerb?: string; /** * Path the user can visit to revoke or manage permissions, surfaced in the * footer notice ("You can change or revoke any of these permissions * anytime under {revocationPath} at {Org}"). */ revocationPath?: string; /** * Number of days of inactivity after which delegations are automatically * revoked. Surfaced in the footer notice. Defaults to 90. */ inactivityDays?: number; /** Configuration metadata */ metadata?: ConsentMetadata; } /** * Consent Configuration with Metadata * * Extended type including all fields that may come from the remote API. * This is the full type used when fetching config from AgentShield. */ export interface ConsentConfigWithMeta extends ConsentConfig { /** Configuration metadata (always present in API responses) */ metadata?: ConsentMetadata; } /** * Resolved UI Configuration * * Fully resolved UI settings with all defaults applied. */ export interface ResolvedUI { /** Page title */ title: string; /** Description text */ description: string; /** Expiration text prefix */ expirationText: string; /** Cancel button text */ cancelButtonText: string; /** Submit button text */ submitButtonText: string; /** Permissions header text */ permissionsHeader: string; /** Whether to auto-close window */ autoClose: boolean; /** Whether popup mode is enabled */ popupEnabled: boolean; /** Theme preference */ theme: "light" | "dark" | "auto"; } /** * Resolved Terms Configuration * * Fully resolved terms settings with all defaults applied. */ export interface ResolvedTerms { /** Terms text */ text: string; /** Terms URL (optional) */ url?: string; /** Terms version (optional) */ version?: string; /** Whether terms are required */ required: boolean; } /** * Resolved Success Configuration * * Fully resolved success page settings with all defaults applied. */ export interface ResolvedSuccess { /** Success page title */ title: string; /** Success page description */ description: string; /** Whether to show credential */ showCredential: boolean; /** Redirect URL (optional) */ redirectUrl?: string; /** Redirect delay in seconds (optional) */ redirectDelay?: number; /** Continue button text */ continueButtonText: string; } /** * Resolved Consent Configuration * * Fully resolved configuration ready for rendering. * All required fields are populated, no undefined values. */ export interface ResolvedConsentConfig { /** Resolved copy/text content */ copy: ResolvedConsentCopy; /** Resolved branding */ branding: ResolvedConsentBranding; /** Resolved UI settings */ ui: ResolvedUI; /** Resolved terms settings */ terms: ResolvedTerms; /** Resolved success settings */ success: ResolvedSuccess; /** Custom fields (passed through unchanged) */ customFields: ConsentCustomField[]; /** Delegation expiration in days (always has a value) */ expirationDays: number; /** Effective auth mode */ authMode: AuthMode; /** Credentials config (passthrough) */ credentials?: CredentialsConfig; /** OAuth config (passthrough) */ oauth?: OAuthConfig; /** Magic link config (passthrough) */ magicLink?: MagicLinkConfig; /** OTP config (passthrough) */ otp?: OTPConfig; /** QR code config (passthrough) */ qrCode?: QRCodeConfig; /** Passkey config (passthrough) */ passkey?: PasskeyConfig; /** IDV config (passthrough) */ idv?: IDVConfig; } //# sourceMappingURL=config.types.d.ts.map