interface UnqVerifyConfig {
    publicKey: string;
    ageToVerify: number;
    redirectUri: string;
    onVerified: (payload: Record<string, unknown>) => void;
    /** Called for all failure outcomes. Legacy — still always invoked; prefer granular callbacks below. */
    onFailure?: (error?: unknown) => void;
    /** Called when the user does not meet the age requirement (UNDER_AGE). */
    onDenied?: (outcome: VerificationOutcome) => void;
    /** Called when the user cancelled or the popup was closed/timed out before completing. */
    onCancelled?: (outcome: VerificationOutcome) => void;
    /** Called on technical or system errors (network failure, invalid token, popup blocked, etc.). */
    onError?: (outcome: VerificationOutcome) => void;
    /** Enable verbose debug logging. Default: false. */
    debug?: boolean;
}
/** Stable machine-readable codes for all non-success verification outcomes. */
type VerificationErrorCode = "UNDER_AGE" | "POPUP_CLOSED" | "USER_CANCELLED" | "POPUP_BLOCKED" | "POPUP_TIMEOUT" | "UNTRUSTED_ORIGIN" | "NETWORK_ERROR" | "TOKEN_INVALID" | "UNKNOWN_ERROR";
/** Structured outcome for all non-success verification paths. */
interface VerificationOutcome {
    /** Machine-readable stable code — use this for conditional UI logic. */
    code: VerificationErrorCode;
    /** Human-readable description. */
    message: string;
    /** Optional raw detail for debugging — do not rely on its shape for logic. */
    raw?: unknown;
}
type DecodedToken = {
    exp: number;
    aldersverificeringdk_verification_result: boolean;
    aldersverificeringdk_verification_age: number;
};

declare function startVerificationWithRedirect(): Promise<void>;
declare function startVerificationWithPopup(providedPopup?: Window): Promise<void>;

type DecodedPayload = DecodedToken & {
    iss?: string;
    iat?: number;
    [key: string]: unknown;
};
declare function handleRedirectResult({ onVerified, onFailure, onDenied, onError, targetOrigin, }: {
    onVerified: (payload: DecodedPayload) => void;
    onFailure?: (error?: unknown) => void;
    /** Called when the user does not meet the age requirement (UNDER_AGE). */
    onDenied?: (outcome: VerificationOutcome) => void;
    /** Called on technical errors (TOKEN_INVALID, UNKNOWN_ERROR). Optional; use alongside `onFailure`. */
    onError?: (outcome: VerificationOutcome) => void;
    /** Explicit postMessage target origin for the opener window (recommended).
     *  Defaults to the opener's origin if same-origin; skips postMessage otherwise. */
    targetOrigin?: string;
}): Promise<void>;

declare function isVerified(): boolean;

declare function getVerifiedAge(): number | null;

declare function resetVerification(): void;

/**
 * Initialize the UNQVerify SDK with your configuration.
 * Must be called before using any other SDK methods.
 *
 * @param config - Configuration object containing publicKey, ageToVerify, redirectUri, and callbacks
 * @throws {Error} If required configuration fields are missing or invalid
 *
 * @example
 * ```typescript
 * import { init } from 'unqverify-sdk';
 *
 * init({
 *   publicKey: 'pk_test_your_key',
 *   ageToVerify: 18,
 *   redirectUri: 'https://yoursite.com/verify',
 *   onVerified: (payload) => console.log('Verified!', payload),
 *   onFailure: (error) => console.error('Failed:', error)
 * });
 * ```
 */
declare function init(config: UnqVerifyConfig): void;

export { type UnqVerifyConfig, type VerificationErrorCode, type VerificationOutcome, getVerifiedAge, handleRedirectResult, init, isVerified, resetVerification, startVerificationWithPopup, startVerificationWithRedirect };
