import type { DBConnection } from '../connection/db.js'; export interface AuthModes { OAuth1: 'OAUTH1'; OAuth2: 'OAUTH2'; OAuth2CC: 'OAUTH2_CC'; Basic: 'BASIC'; ApiKey: 'API_KEY'; AppStore: 'APP_STORE'; Custom: 'CUSTOM'; App: 'APP'; None: 'NONE'; TBA: 'TBA'; Jwt: 'JWT'; Bill: 'BILL'; TwoStep: 'TWO_STEP'; Signature: 'SIGNATURE'; MCP_OAUTH2: 'MCP_OAUTH2'; MCP_OAUTH2_GENERIC: 'MCP_OAUTH2_GENERIC'; InstallPlugin: 'INSTALL_PLUGIN'; } export type AuthModeType = AuthModes[keyof AuthModes]; export type AuthOperationType = 'creation' | 'override' | 'refresh' | 'unknown'; export interface OAuthAuthorizationMethod { BODY: 'body'; HEADER: 'header'; } export type OAuthAuthorizationMethodType = OAuthAuthorizationMethod[keyof OAuthAuthorizationMethod]; export type OAuthBodyFormatType = OAuthBodyFormat[keyof OAuthBodyFormat]; export interface OAuthBodyFormat { FORM: 'form'; JSON: 'json'; } export interface ConnectionUpsertResponse { connection: DBConnection; operation: AuthOperationType; } export interface OAuth1RequestTokenResult { request_token: string; request_token_secret: string; parsed_query_string: any; } export interface CredentialsCommon> { type: AuthModeType; raw: T; } export interface OAuth1Token { oAuthToken: string; oAuthTokenSecret: string; } export interface BasicApiCredentials { type: AuthModes['Basic']; username: string; password: string; } export interface ApiKeyCredentials { type: AuthModes['ApiKey']; apiKey: string; } export interface AppCredentials { type: AuthModes['App']; access_token: string; expires_at?: Date | undefined; raw: Record; jwtToken?: string; } export interface AppStoreCredentials { type?: AuthModes['AppStore']; access_token: string; expires_at?: Date | undefined; raw: Record; private_key: string; } export interface OAuth2Credentials extends CredentialsCommon { type: AuthModes['OAuth2']; access_token: string; refresh_token?: string | undefined; expires_at?: Date | undefined; config_override?: { client_id?: string | undefined; client_secret?: string | undefined; } | undefined; } export interface CustomCredentials extends CredentialsCommon { type: AuthModes['Custom']; } export interface OAuth2ClientCredentials extends CredentialsCommon { type: AuthModes['OAuth2CC']; token: string; expires_at?: Date | undefined; client_id: string; client_secret: string; client_certificate?: string | undefined; client_private_key?: string | undefined; } export interface OAuth1Credentials extends CredentialsCommon { type: AuthModes['OAuth1']; oauth_token: string; oauth_token_secret: string; } export interface CredentialsRefresh { providerConfigKey: string; connectionId: string; promise: Promise; } export interface TbaCredentials { type: AuthModes['TBA']; token_id: string; token_secret: string; config_override?: { client_id?: string | undefined; client_secret?: string | undefined; } | undefined; } export interface BillCredentials extends CredentialsCommon { type: AuthModes['Bill']; username: string; password: string; organization_id: string; dev_key: string; session_id?: string; user_id?: string; expires_at?: Date | undefined; } export interface JwtCredentials { type: AuthModes['Jwt']; [key: string]: any; token?: string; expires_at?: Date | undefined; } export interface TwoStepCredentials extends CredentialsCommon { type: AuthModes['TwoStep']; [key: string]: any; token?: string; refresh_token?: string; expires_at?: Date | undefined; } export interface SignatureCredentials { type: AuthModes['Signature']; username: string; password: string; token?: string; expires_at?: Date | undefined; } export interface InstallPluginCredentials { type: AuthModes['Basic']; [key: string]: any; } export interface CombinedOauth2AppCredentials extends CredentialsCommon { type: AuthModes['Custom']; app: AppCredentials; user: OAuth2Credentials | null; } export type UnauthCredentials = Record; export type RefreshTokenResponse = AuthorizationTokenResponse; export interface AuthorizationTokenResponse extends Omit { expires_in?: number; } export type TestableCredentials = ApiKeyCredentials | BasicApiCredentials | TbaCredentials | JwtCredentials | SignatureCredentials; export type RefreshableCredentials = OAuth2Credentials | AppCredentials | AppStoreCredentials | OAuth2ClientCredentials | JwtCredentials | TwoStepCredentials | BillCredentials | SignatureCredentials; export type AllAuthCredentials = OAuth1Credentials | OAuth2Credentials | OAuth2ClientCredentials | BasicApiCredentials | ApiKeyCredentials | AppCredentials | AppStoreCredentials | UnauthCredentials | CustomCredentials | TbaCredentials | JwtCredentials | BillCredentials | TwoStepCredentials | CombinedOauth2AppCredentials | SignatureCredentials | InstallPluginCredentials;