/** * Strict TypeScript types for webhook payloads * Generated from EVENT_DATA_REQUIREMENTS to provide type safety for webhook data */ export interface BaseWebhookPayload { id: string; event: string; data: Record; created_at: string; } export interface UserEventData { object: 'user'; id: string; email: string; first_name: string | null; last_name: string | null; email_verified: boolean; profile_picture_url: string | null; created_at: string; updated_at: string; } export interface OrganizationEventData { object: 'organization'; id: string; name: string; domains: Array<{ object: string; id: string; domain: string; state: string; }>; metadata: Record; external_id: string | null; created_at: string; updated_at: string; } export interface OrganizationMembershipEventData { object: 'organization_membership'; id: string; user_id: string; organization_id: string; role: { slug: string; }; roles: Array<{ slug: string; }>; status: 'active' | 'inactive' | 'pending'; external_id: string | null; metadata: Record; created_at: string; updated_at: string; } export interface SessionEventData { object: 'session'; id: string; user_id: string; organization_id: string | null; auth_method: 'oauth' | 'password' | 'magic_auth' | 'email_verification' | 'mfa' | 'sso'; status: 'active' | 'revoked'; created_at: string; updated_at: string; ended_at: string | null; } export interface AuthenticationEventData { type: 'oauth' | 'password' | 'magic_auth' | 'email_verification' | 'mfa' | 'sso'; status: 'succeeded' | 'failed'; user_id: string | null; email: string | null; ip_address: string | null; user_agent: string | null; error?: { code: string; message: string; }; sso?: { organization_id: string | null; connection_id: string | null; session_id: string | null; }; } export interface ConnectionEventData { object: 'connection'; id: string; organization_id: string; connection_type: string; name: string; state: 'active' | 'inactive' | 'validating'; domains: Array<{ object: string; id: string; domain: string; }>; created_at: string; updated_at: string; } export interface MagicAuthEventData { object: 'magic_auth'; id: string; user_id: string | null; email: string; code: string; expires_at: string; created_at: string; } export interface PasswordResetEventData { object: 'password_reset'; id: string; user_id: string; email: string; password_reset_token: string; password_reset_url: string; expires_at: string; created_at: string; } export interface EmailVerificationEventData { object: 'email_verification'; id: string; user_id: string; email: string; code: string; expires_at: string; created_at: string; } export declare function isUserEventData(data: unknown): data is UserEventData; export declare function isOrganizationEventData(data: unknown): data is OrganizationEventData; export declare function isAuthenticationEventData(data: unknown): data is AuthenticationEventData; export declare function isSessionEventData(data: unknown): data is SessionEventData; export type UserCreatedWebhook = BaseWebhookPayload & { data: UserEventData; }; export type UserUpdatedWebhook = BaseWebhookPayload & { data: UserEventData; }; export type UserDeletedWebhook = BaseWebhookPayload & { data: UserEventData; }; export type OrganizationCreatedWebhook = BaseWebhookPayload & { data: OrganizationEventData; }; export type OrganizationUpdatedWebhook = BaseWebhookPayload & { data: OrganizationEventData; }; export type OrganizationDeletedWebhook = BaseWebhookPayload & { data: OrganizationEventData; }; export type AuthenticationSucceededWebhook = BaseWebhookPayload & { data: AuthenticationEventData; }; export type AuthenticationFailedWebhook = BaseWebhookPayload & { data: AuthenticationEventData; }; export type SessionCreatedWebhook = BaseWebhookPayload & { data: SessionEventData; }; export type SessionRevokedWebhook = BaseWebhookPayload & { data: SessionEventData; }; export type MagicAuthCreatedWebhook = BaseWebhookPayload & { data: MagicAuthEventData; }; export type PasswordResetCreatedWebhook = BaseWebhookPayload & { data: PasswordResetEventData; }; export type EmailVerificationCreatedWebhook = BaseWebhookPayload & { data: EmailVerificationEventData; }; export declare function validateWebhookPayload(event: string, data: Record): { valid: boolean; missingFields: string[]; }; export declare function createWebhookPayload>(event: string, data: T): BaseWebhookPayload & { data: T; };