/** * Consent API Types * * Canonical type definitions for consent API request/response payloads. * * @module @kya-os/consent/types/api */ import type { AuthMode } from "./modes.types.js"; /** * OAuth Identity * * Represents a user's OAuth provider account information. * Used to link OAuth accounts to persistent User DIDs. */ export interface OAuthIdentity { /** * OAuth provider name (e.g., "google", "github", "microsoft") */ provider: string; /** * OAuth subject identifier (unique user ID from provider) * @example "123456789" (Google), "github-user-id" (GitHub) */ subject: string; /** * User's email address from OAuth provider (optional) */ email?: string; /** * User's display name from OAuth provider (optional) */ name?: string; } /** * Consent Approval Request * * Request payload when user approves consent. * Note: Uses snake_case for API compatibility (agent_did, session_id, project_id) * Note: auth_mode and provider_type are optional with defaults for backwards compatibility. */ export interface ConsentApprovalRequest { /** Tool name */ tool: string; /** Approved scopes */ scopes: string[]; /** Agent DID (snake_case for API compatibility) */ agent_did: string; /** Session ID (snake_case for API compatibility) */ session_id: string; /** Project ID (snake_case for API compatibility) */ project_id: string; /** Authentication mode used (defaults to "consent-only") */ auth_mode?: AuthMode; /** Provider type (defaults to "none") */ provider_type?: string; /** Whether terms were accepted */ termsAccepted: boolean; /** Terms version (if applicable) */ termsVersion?: string; /** Custom field values */ customFields?: Record; /** OAuth provider identity information (optional) */ oauth_identity?: OAuthIdentity | null; /** User DID for persistent identity (optional) */ user_did?: string; /** * Human-readable user identifier from credential authentication (email/username). * Used for display in AgentShield dashboard. * Maps to: user_identifier in delegation request */ credential_user_email?: string; /** * Provider's internal user ID from credential authentication. * This is the provider-specific identifier (e.g., customer ID 696395, UUID). * Maps to: user_id in delegation request */ credential_provider_user_id?: string; } /** * Consent Approval Response * * Response after processing consent approval. */ export interface ConsentApprovalResponse { /** Whether approval was successful */ success: boolean; /** Delegation ID (if successful) */ delegation_id?: string; /** Delegation token (if successful) */ delegation_token?: string; /** Error message (if failed) */ error?: string; /** Error code (if failed) */ error_code?: string; } /** * Consent Config API Response * * Response from the consent config API endpoint. */ export interface ConsentConfigAPIResponse { /** Whether the request was successful */ success: boolean; /** The consent configuration (if successful) */ data?: import("./config.types").ConsentConfigWithMeta; /** Error message (if failed) */ error?: string; } /** * Credential Authentication Request * * Request payload for username/password authentication. */ export interface CredentialAuthRequest { /** Username */ username: string; /** Password */ password: string; /** CSRF token */ csrf_token: string; /** Session ID */ session_id: string; /** Agent DID */ agent_did: string; /** Project ID */ project_id: string; /** Provider identifier */ provider: string; /** Remember me preference */ remember_me?: boolean; } /** * Credential Authentication Response * * Response from credential authentication. */ export interface CredentialAuthResponse { /** Whether authentication was successful */ success: boolean; /** OAuth identity (if authentication successful) */ oauth_identity?: OAuthIdentity; /** Error message (if failed) */ error?: string; /** Error code (if failed) */ error_code?: string; } //# sourceMappingURL=api.types.d.ts.map