import { Extension, SDKBase } from '@magic-sdk/provider';
import { JsonRpcRequestPayload } from '@magic-sdk/types';
import { ClientConfig } from './types/client-config';
export declare const MAGIC_WIDGET_PROVIDER = "magic-widget";
export type OAuthProvider = 'google' | 'facebook' | 'apple' | 'github' | 'bitbucket' | 'gitlab' | 'linkedin' | 'twitter' | 'discord' | 'twitch' | 'microsoft';
export interface OpenIDConnectUserInfo {
    name?: string;
    familyName?: string;
    givenName?: string;
    middleName?: string;
    nickname?: string;
    preferredUsername?: string;
    profile?: string;
    picture?: string;
    website?: string;
    email?: string;
    emailVerified?: boolean;
    gender?: string;
    birthdate?: string;
    zoneinfo?: string;
    locale?: string;
    phoneNumber?: string;
    phoneNumberVerified?: boolean;
    sub?: string;
    sources?: Record<string, unknown>;
    [key: string]: unknown;
}
export interface MagicUserMetadata {
    issuer: string | null;
    publicAddress: string | null;
    email: string | null;
    phoneNumber?: string | null;
    isMfaEnabled?: boolean;
    recoveryFactors?: Array<{
        type: string;
        value: string;
    }>;
}
export interface OAuthRedirectResult {
    oauth: {
        provider: OAuthProvider;
        scope: string[];
        userHandle: string;
        userInfo: OpenIDConnectUserInfo;
    };
    magic: {
        idToken: string;
        userMetadata: MagicUserMetadata;
    };
}
export interface OAuthRedirectError {
    provider: OAuthProvider;
    error: string;
    error_description?: string;
    error_uri?: string;
}
export interface SiweGenerateNonceParams {
    address?: string;
}
export interface SiweGenerateMessageParams {
    address: string;
    chainId?: number;
    statement?: string;
}
export interface SiweLoginParams {
    message: string;
    signature: string;
}
/**
 * Get the initialized MagicWidgetExtension instance.
 * Used internally by React components to access SIWE methods.
 * @throws Error if extension hasn't been initialized yet
 */
export declare function getExtensionInstance(): MagicWidgetExtension;
export declare class MagicWidgetExtension extends Extension.Internal<'magicWidget'> {
    name: "magicWidget";
    config: {};
    private clientConfig;
    private configPromise;
    private eventsListenerAdded;
    private reconnectPromise;
    constructor();
    /**
     * Called by Magic SDK when the extension is initialized.
     * We override to store a reference for internal React component access.
     */
    init(sdk: SDKBase): void;
    private restoreWalletConnection;
    /**
     * Set up the connected state after successful SIWE login.
     * This enables RPC request routing through the 3rd party wallet.
     */
    setConnectedState(address: string, chainId?: number): void;
    /**
     * Clear the connected state (called on logout/disconnect).
     */
    clearConnectedState(): void;
    /**
     * Get the current wallet provider from wagmi.
     * Returns null if not connected.
     */
    getWalletProvider(): Promise<any | null>;
    /**
     * Execute an RPC request through the connected 3rd party wallet.
     * This is called by ThirdPartyWalletsModule for magic-widget provider.
     */
    walletRequest<T = unknown>(payload: Partial<JsonRpcRequestPayload>): Promise<T>;
    /**
     * Set up event listeners for account and chain changes.
     */
    private setupEip1193EventListeners;
    /**
     * Handle wallet disconnect - clear SDK state AND invalidate Magic iframe session.
     * Called when user disconnects wallet via wallet extension UI.
     */
    private handleWalletDisconnect;
    private dispatchWalletUpdate;
    /**
     * Generate a nonce for SIWE message construction.
     * This calls the Magic backend to get a unique nonce.
     */
    generateNonce(params?: SiweGenerateNonceParams): Promise<string>;
    /**
     * Generate a complete SIWE message.
     * Fetches a nonce from the backend and constructs the message client-side.
     */
    generateMessage(params: SiweGenerateMessageParams): Promise<string>;
    /**
     * Login with SIWE message and signature.
     * Sends the signed message to Magic backend for verification and returns a DID token.
     */
    login(params: SiweLoginParams): Promise<string>;
    /**
     * Login with OAuth popup.
     * Opens a popup for the specified OAuth provider and returns the result.
     */
    loginWithPopup(provider: OAuthProvider): Promise<OAuthRedirectResult>;
    /**
     * Fetch client configuration via RPC (proxied through embedded-wallet iframe).
     * This avoids CORS issues by having the iframe make the request.
     */
    fetchConfig(): Promise<ClientConfig>;
    /**
     * Get the cached client configuration (synchronous).
     * Returns null if config hasn't been fetched yet.
     */
    getConfig(): ClientConfig | null;
    /**
     * Login with Email OTP
     */
    loginWithEmailOTP(email: string): import("@magic-sdk/provider").PromiEvent<string | null, {
        "email-otp-sent": () => void;
        "login-throttled": () => void;
        "invalid-email-otp": () => void;
        "invalid-mfa-otp": () => void;
        "expired-email-otp": () => void;
        "mfa-sent-handle": () => void;
        "recovery-code-sent-handle": () => void;
        "invalid-recovery-code": () => void;
        "recovery-code-success": () => void;
        "max-attempts-reached": () => void;
        "Auth/id-token-created": (idToken: string) => void;
        "Wallet/wallet-info-fetched": () => void;
        "verify-email-otp": (otp: string) => void;
        "verify-mfa-code": (mfa: string) => void;
        "lost-device": () => void;
        "verify-recovery-code": (recoveryCode: string) => void;
        cancel: () => void;
    } & {
        "device-needs-approval": () => void;
        "device-verification-email-sent": () => void;
        "device-verification-link-expired": () => void;
        "device-approved": () => void;
        "device-retry": () => void;
    } & {
        done: (result: string | null) => void;
        error: (reason: any) => void;
        settled: () => void;
        "closed-by-user": () => void;
    }>;
}
