export interface OAuthToken extends Record<string, unknown> {
  provider: string // OAuth provider ID (notion, google-sheets)
  accessToken: string
  refreshToken: string
  expiresAt: string // ISO 8601 timestamp
  tokenType: 'Bearer'
  scope?: string
}

export interface OAuthProviderConfig {
  id: string
  name: string
  authUrl: string
  tokenUrl: string
  scopes?: string[]
  authParams?: Record<string, string> // Provider-specific auth params
  tokenExchange: 'basic-auth' | 'form-encoded' | 'json-body'
  usePKCE?: boolean

  // Custom override hooks for edge cases (95% won't need these)
  customAuthFlow?: (config: OAuthProviderConfig, state: OAuthState) => URL
  customTokenExchange?: (
    code: string,
    config: OAuthProviderConfig
  ) => Promise<OAuthToken>
}

export interface OAuthState {
  organizationId: string
  nonce: string
  timestamp: number
  credentialName: string
  provider: string // Which provider this flow is for
}
