/* tslint:disable */
/* eslint-disable */

/**
 * Age proof credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * // Verify user is at least 21
 * const policy = new AgeProofPolicy()
 *     .atLeast(21)
 *     .withCallback("https://yourapp.com/callback");
 *
 * // Verify user is between 18 and 65
 * const policy2 = new AgeProofPolicy()
 *     .between(18, 65)
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
export class AgeProofPolicy {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Require user to be at least the specified age (>=).
     */
    atLeast(age: number): AgeProofPolicy;
    /**
     * Require user to be at most the specified age (<=).
     */
    atMost(age: number): AgeProofPolicy;
    /**
     * Require user to be within the specified age range (inclusive).
     */
    between(min_age: number, max_age: number): AgeProofPolicy;
    /**
     * Require user to be exactly the specified age.
     */
    exactly(age: number): AgeProofPolicy;
    constructor();
    /**
     * Require user to be over the specified age (>).
     */
    over(age: number): AgeProofPolicy;
    /**
     * Require user to be under the specified age (<).
     */
    under(age: number): AgeProofPolicy;
    withCallback(url: string): AgeProofPolicy;
    readonly credentialType: string;
    readonly isComplete: boolean;
}

/**
 * Base credential policy builder for WASM.
 *
 * Creates a policy for requesting the basic user DID credential.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new BaseCredentialPolicy()
 *     .withState("csrf-token")
 *     .withNonce("binding-nonce")
 *     .withCallback("https://yourapp.com/callback");
 *
 * const response = await client.requestCredential(policy);
 * ```
 */
export class BaseCredentialPolicy {
    free(): void;
    [Symbol.dispose](): void;
    constructor();
    withCallback(url: string): BaseCredentialPolicy;
    withNonce(nonce: string): BaseCredentialPolicy;
    withState(state: string): BaseCredentialPolicy;
    readonly credentialType: string;
    readonly isComplete: boolean;
}

/**
 * Employment credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new EmploymentPolicy()
 *     .withEmployerDomain("acme.com")
 *     .withStatus("Current")
 *     .withFields(["company", "title"])
 *     .withOptionalFields(["department", "start_date"])
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
export class EmploymentPolicy {
    free(): void;
    [Symbol.dispose](): void;
    constructor();
    withCallback(url: string): EmploymentPolicy;
    /**
     * Constrain to a specific employer domain (e.g., "example.com").
     */
    withEmployerDomain(domain: string): EmploymentPolicy;
    withField(field: string): EmploymentPolicy;
    /**
     * Add required fields that must be disclosed.
     * Valid fields: company, title, department, start_date, end_date,
     * is_current, responsibilities
     */
    withFields(fields: string[]): EmploymentPolicy;
    withOptionalField(field: string): EmploymentPolicy;
    /**
     * Add optional fields that the user can choose to disclose.
     * Valid fields: company, title, department, start_date, end_date,
     * is_current, responsibilities
     */
    withOptionalFields(fields: string[]): EmploymentPolicy;
    /**
     * Set the required employment status: Current, Former, or Any.
     */
    withStatus(status: string): EmploymentPolicy;
    readonly credentialType: string;
    readonly isComplete: boolean;
}

/**
 * Error codes for programmatic error handling in JavaScript.
 *
 * These codes allow TypeScript developers to handle errors programmatically
 * without parsing error message strings.
 */
export enum ErrorCode {
    /**
     * Configuration error (invalid endpoint, missing client_id, etc.)
     */
    ConfigError = 1,
    /**
     * Network error (connection failed, timeout, DNS resolution)
     */
    NetworkError = 2,
    /**
     * Authentication error (invalid credentials, token expired)
     */
    AuthError = 3,
    /**
     * Policy validation error (missing required fields, invalid constraints)
     */
    PolicyError = 4,
    /**
     * Credential verification error (signature invalid, expired, revoked)
     */
    VerificationError = 5,
    /**
     * Trust registry error (issuer not found, suspended, unauthorized)
     */
    TrustError = 6,
    /**
     * Request not found (404 from IDP)
     */
    NotFoundError = 7,
    /**
     * Request expired (credential request timed out)
     */
    ExpiredError = 8,
    /**
     * Request denied by user
     */
    DeniedError = 9,
    /**
     * Rate limited by IDP
     */
    RateLimitError = 10,
    /**
     * Internal SDK error (unexpected state)
     */
    InternalError = 99,
}

/**
 * Structured error for JavaScript with code, message, and optional details.
 *
 * This provides a better developer experience than plain string errors,
 * allowing programmatic error handling in TypeScript.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * try {
 *     const response = await client.requestCredential(policy);
 * } catch (error) {
 *     if (error.code === 'NETWORK_ERROR') {
 *         // Retry with backoff
 *     } else if (error.code === 'POLICY_ERROR') {
 *         // Show validation errors to user
 *         console.error(error.details);
 *     }
 * }
 * ```
 */
export class LastIDError {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Create a new error.
     */
    constructor(code: ErrorCode, message: string);
    /**
     * Create an error with additional details.
     */
    static with_details(code: ErrorCode, message: string, details: string): LastIDError;
    /**
     * Get the error code string (e.g., "NETWORK_ERROR").
     */
    readonly code: string;
    /**
     * Get additional error details (if available).
     */
    readonly details: string | undefined;
    /**
     * Check if this error is retryable.
     */
    readonly isRetryable: boolean;
    /**
     * Get the human-readable error message.
     */
    readonly message: string;
    /**
     * Get the numeric error code for switch statements.
     */
    readonly numericCode: number;
    /**
     * Get a suggested retry delay in milliseconds (if retryable).
     */
    readonly suggestedRetryMs: number | undefined;
}

/**
 * Persona credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new PersonaPolicy()
 *     .withFields(["display_name", "email"])
 *     .withOptionalFields(["phone", "company"])
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
export class PersonaPolicy {
    free(): void;
    [Symbol.dispose](): void;
    constructor();
    withCallback(url: string): PersonaPolicy;
    withField(field: string): PersonaPolicy;
    /**
     * Add required fields that must be disclosed.
     * Valid fields: display_name, email, phone, company, job_title,
     * avatar_url, website, location, visibility
     */
    withFields(fields: string[]): PersonaPolicy;
    withOptionalField(field: string): PersonaPolicy;
    /**
     * Add optional fields that the user can choose to disclose.
     * Valid fields: display_name, email, phone, company, job_title,
     * avatar_url, website, location, visibility
     */
    withOptionalFields(fields: string[]): PersonaPolicy;
    readonly credentialType: string;
    readonly isComplete: boolean;
}

/**
 * Trust credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new TrustPolicy()
 *     .withMinimumLevel("Verified")
 *     .withTrustedIssuer("did:lastid:trusted-org")
 *     .requireMutualTrust()
 *     .withMaxAgeDays(30)
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
export class TrustPolicy {
    free(): void;
    [Symbol.dispose](): void;
    constructor();
    /**
     * Require mutual trust (both parties have established trust).
     */
    requireMutualTrust(): TrustPolicy;
    withCallback(url: string): TrustPolicy;
    /**
     * Set maximum age of the trust credential in days.
     */
    withMaxAgeDays(days: number): TrustPolicy;
    /**
     * Set the minimum required trust level: None, Basic, Verified, High, or
     * Ultimate.
     */
    withMinimumLevel(level: string): TrustPolicy;
    /**
     * Add a trusted issuer DID that must have established trust.
     */
    withTrustedIssuer(issuer_did: string): TrustPolicy;
    readonly credentialType: string;
    readonly isComplete: boolean;
}

/**
 * Verified email credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new VerifiedEmailPolicy()
 *     .withDomainConstraint("company.com")
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
export class VerifiedEmailPolicy {
    free(): void;
    [Symbol.dispose](): void;
    constructor();
    withCallback(url: string): VerifiedEmailPolicy;
    /**
     * Add a domain constraint (e.g., "example.com" requires @example.com
     * emails).
     */
    withDomainConstraint(domain: string): VerifiedEmailPolicy;
    readonly credentialType: string;
    readonly isComplete: boolean;
}

/**
 * Verified persona (KYC) credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new VerifiedPersonaPolicy()
 *     .withVerificationLevel("Enhanced")
 *     .withFields(["legal_name", "date_of_birth"])
 *     .withOptionalFields(["nationality", "residential_address"])
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
export class VerifiedPersonaPolicy {
    free(): void;
    [Symbol.dispose](): void;
    constructor();
    withCallback(url: string): VerifiedPersonaPolicy;
    withField(field: string): VerifiedPersonaPolicy;
    /**
     * Add required fields that must be disclosed.
     * Valid fields: legal_name, first_name, last_name, date_of_birth, age,
     * nationality, residential_address, structured_address, government_id_type,
     * document_number, liveness_score, face_match_score
     */
    withFields(fields: string[]): VerifiedPersonaPolicy;
    withOptionalField(field: string): VerifiedPersonaPolicy;
    /**
     * Add optional fields that the user can choose to disclose.
     * Valid fields: legal_name, first_name, last_name, date_of_birth, age,
     * nationality, residential_address, structured_address, government_id_type,
     * document_number, liveness_score, face_match_score
     */
    withOptionalFields(fields: string[]): VerifiedPersonaPolicy;
    /**
     * Set the required verification level: Basic, Standard, or Enhanced.
     */
    withVerificationLevel(level: string): VerifiedPersonaPolicy;
    readonly credentialType: string;
    readonly isComplete: boolean;
}

/**
 * Verified phone credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new VerifiedPhonePolicy()
 *     .withCountryCode("+1")
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
export class VerifiedPhonePolicy {
    free(): void;
    [Symbol.dispose](): void;
    constructor();
    withCallback(url: string): VerifiedPhonePolicy;
    /**
     * Add a country code constraint (e.g., "+1" for US numbers).
     */
    withCountryCode(code: string): VerifiedPhonePolicy;
    readonly credentialType: string;
    readonly isComplete: boolean;
}

/**
 * JavaScript-friendly `LastID` client.
 *
 * Provides methods to request credentials, poll for status, and verify
 * presentations.
 */
export class WasmClient {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Create a new client with the given configuration.
     *
     * The client will automatically manage OAuth token acquisition and
     * refresh.
     *
     * @param config - The SDK configuration
     * @throws Error if the configuration is invalid
     */
    constructor(config: WasmConfig);
    /**
     * Poll for request status.
     *
     * Returns the status as a JSON object.
     */
    pollStatus(request_id: string): Promise<any>;
    /**
     * Request an age proof credential.
     */
    requestAgeProofCredential(policy: AgeProofPolicy): Promise<any>;
    /**
     * Request a credential using a policy builder.
     *
     * Use the fluent API policy builders (e.g., `BaseCredentialPolicy`) to
     * create a policy, then pass it to this method.
     *
     * @param policy - A policy builder (e.g., BaseCredentialPolicy)
     * @returns Response with requestId, requestUri (for QR code), expiresIn,
     * and nonce @throws Error if the policy is invalid or the request
     * fails
     *
     * @example
     * ```javascript
     * const policy = new BaseCredentialPolicy()
     *     .withState(crypto.randomUUID())
     *     .withNonce(crypto.randomUUID())
     *     .withCallback("https://myapp.com/callback");
     *
     * const response = await client.requestCredential(policy);
     * console.log(response.requestUri); // Use for QR code
     * ```
     */
    requestCredential(policy: BaseCredentialPolicy): Promise<any>;
    /**
     * Request an employment credential.
     */
    requestEmploymentCredential(policy: EmploymentPolicy): Promise<any>;
    /**
     * Request a persona credential with optional field selection.
     */
    requestPersonaCredential(policy: PersonaPolicy): Promise<any>;
    /**
     * Request a trust credential.
     */
    requestTrustCredential(policy: TrustPolicy): Promise<any>;
    /**
     * Request a verified email credential with optional domain constraint.
     */
    requestVerifiedEmailCredential(policy: VerifiedEmailPolicy): Promise<any>;
    /**
     * Request a verified persona (KYC) credential.
     */
    requestVerifiedPersonaCredential(policy: VerifiedPersonaPolicy): Promise<any>;
    /**
     * Request a verified phone credential with optional country code
     * constraint.
     */
    requestVerifiedPhoneCredential(policy: VerifiedPhonePolicy): Promise<any>;
    /**
     * Validate an issuer DID against the trust registry.
     */
    validateIssuer(issuer_did: string): Promise<any>;
    /**
     * Verify a presentation string.
     *
     * Returns the verified credential as a JSON object.
     */
    verifyPresentation(presentation: string): Promise<any>;
}

/**
 * JavaScript-friendly SDK configuration.
 */
export class WasmConfig {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Create a new configuration with the IDP endpoint and client ID.
     *
     * # Arguments
     *
     * * `idp_endpoint` - The IDP endpoint URL (e.g., `https://human.lastid.co`)
     * * `client_id` - OAuth client ID for authentication
     */
    constructor(idp_endpoint: string, client_id: string);
    /**
     * Create configuration with custom settings.
     *
     * # Arguments
     *
     * * `idp_endpoint` - The IDP endpoint URL
     * * `client_id` - OAuth client ID for authentication
     * * `trust_registry_endpoint` - Optional custom trust registry endpoint
     * * `timeout_seconds` - Optional HTTP timeout in seconds
     */
    static withOptions(idp_endpoint: string, client_id: string, trust_registry_endpoint?: string | null, timeout_seconds?: bigint | null): WasmConfig;
}

/**
 * Generate a unique nonce for replay protection.
 */
export function generateNonce(): string;

/**
 * Generate a unique state parameter for CSRF protection.
 */
export function generateState(): string;

/**
 * Get all supported credential types.
 */
export function getSupportedCredentialTypes(): any;

/**
 * Get the SDK version.
 */
export function getVersion(): string;

/**
 * Initialize panic hook for better error messages in browser console.
 */
export function init(): void;
