import { KeetaNet } from '../../client/index.js';
import * as CurrencyInfo from '@keetanetwork/currency-info';
import type * as KeetaAnchorHTTPServer from '../../lib/http-server/index.js';
import type { KeetaAnchorMetadataServerConfig } from '../../lib/anchor-metadata-server.js';
import type { KeetaKYCAnchorCreateVerificationRequest, KeetaKYCAnchorCreateVerificationResponse, KeetaKYCAnchorGetCertificateResponse } from './common.ts';
import type * as Signing from '../../lib/utils/signing.js';
import type { ServiceMetadata } from '../../lib/resolver.ts';
import { KeetaAnchorMetadataServer } from '../../lib/anchor-metadata-server.js';
/**
 * The Base certificate type, from the KeetaNet Client
 *
 * The KYC Certificate type is a subclass of this, so it will also work
 */
type BaseCertificate = InstanceType<typeof KeetaNet.lib.Utils.Certificate.Certificate>;
export interface KeetaAnchorKYCServerConfig extends KeetaAnchorMetadataServerConfig {
    /**
     * The data to use for the index page (optional)
     */
    homepage?: string | (() => Promise<string> | string);
    /**
     * The network client to use for submitting blocks
     */
    client: {
        client: KeetaNet.Client;
        network: bigint;
        networkAlias: typeof KeetaNet.Client.Config.networksArray[number];
    } | KeetaNet.UserClient;
    /**
     * Configuration for the KYC Anchor
     *
     * The flow for a KYC Anchor is as follows:
     *      1. Client requests a new verification with a country code and
     *           account from the KYC Anchor Server
     *      2. KYC Anchor Server responds with a verification ID and a URL
     *           to the KYC provider's web URL, including the verification ID
     *      3. Client visits the KYC provider's web URL to complete the
     *           verification
     *      4. KYC provider notifies the Anchor server that the
     *           verification is complete
     *      5. Client requests the certificate for the verification ID
     *           (polling) from the KYC Anchor Server
     *      6. KYC Anchor Server responds with the certificate(s) for the
     *           verification ID (if complete, pending if still in progress,
     *           an error if failed)
     *      7. Client installs the certificate(s) in their wallet using
     *           the KeetaNet Client library
     *
     *
     *   +-------------------+            +---------------------+             +------------------+
     *   |       Client      |            |   KYC Anchor Server |             |   KYC Provider   |
     *   +-------------------+            +---------------------+             +------------------+
     *         |                                   |                                  |
     * (1) Create Verification                     |                                  |
     * countryCode, account ---------------------->|                                  |
     *         |                                   |                                  |
     *         |                           (2) Create verification                    |
     *         |----------------------------------- verificationID, providerURL       |
     *         |                                   |                                  |
     * (3) Open providerURL (with verificationID)------------------------------------>|
     *         |                                   |                                  |
     *         |                                   |                           (4)  Notify
     *         |                                   |<-------- verificationID, verificationStatus, certificates?
     *         |                                   |
     * (5) Poll certificate for verificationID --->|
     *         |                                   |
     *         |<-------------------------- (6) Pending / Certificate(s) / Error
     *         |                    (repeat #5 until complete)
     *         |
     * (7) Install certificate(s) in wallet using KeetaNet Client library
     */
    kyc: {
        /**
         * Notification that a verification has been started (optional)
         *
         * This method can be used to notify the KYC provider that
         * a verification has been started.  It can return additional
         * information about the verification, such as the web URL
         * where the user can complete the verification.
         *
         * If this method is not provided, the server will generate
         * a random verification ID and use the `kycProviderURL` from
         * the server configuration, replacing `{id}` with the
         * verification ID.
         */
        verificationStarted?: (request: KeetaKYCAnchorCreateVerificationRequest) => Promise<Partial<KeetaKYCAnchorCreateVerificationResponse> | undefined>;
        /**
         * Retrieve the certificate for a verification
         *
         * This should return the certificate(s) for the
         * verification ID.  If the verification is still
         * in progress, it should throw an `CertificateNotFound`
         * error.
         * If the verification has failed permanently, it should
         * throw a `KeetaAnchorUserError` with an appropriate
         * error message or `VerificationNotFound` if the
         * verification ID is not found.
         */
        getCertificates: (verificationID: string) => Promise<Extract<KeetaKYCAnchorGetCertificateResponse, {
            ok: true;
        }>['results']>;
        /**
         * Country codes that this KYC provider can service (default is all country codes)
         */
        countryCodes?: (CurrencyInfo.Country | CurrencyInfo.ISOCountryCode)[];
    };
    /**
     * The certificate to use for signing certificates
     */
    ca: BaseCertificate;
    /**
     * The account to use for signing certificates
     */
    signer: Signing.SignableAccount;
    /**
     * URL for the KYC Provider (optional)
     *
     * This is the URL that clients will be directed to in order to
     * complete the KYC verification process.  It is optional because
     * the `kyc.verificationStarted` method can also return a `webURL`.
     * If both are provided, the URL from `kyc.verificationStarted` takes
     * precedence.
     */
    kycProviderURL?: string | ((verificationID: string) => string);
    /**
     * Additional routes to add to the server (optional)
     */
    routes?: KeetaAnchorHTTPServer.Routes;
}
export declare class KeetaNetKYCAnchorHTTPServer extends KeetaAnchorMetadataServer<NonNullable<ServiceMetadata['services']['kyc']>[string], KeetaAnchorKYCServerConfig> implements Required<KeetaAnchorKYCServerConfig> {
    #private;
    readonly homepage: NonNullable<KeetaAnchorKYCServerConfig['homepage']>;
    readonly client: KeetaAnchorKYCServerConfig['client'];
    readonly signer: NonNullable<KeetaAnchorKYCServerConfig['signer']>;
    readonly ca: KeetaAnchorKYCServerConfig['ca'];
    readonly kyc: KeetaAnchorKYCServerConfig['kyc'];
    readonly kycProviderURL: NonNullable<KeetaAnchorKYCServerConfig['kycProviderURL']>;
    readonly routes: NonNullable<KeetaAnchorKYCServerConfig['routes']>;
    constructor(config: KeetaAnchorKYCServerConfig);
    protected initRoutes(config: KeetaAnchorKYCServerConfig): Promise<KeetaAnchorHTTPServer.Routes>;
    protected buildServiceMetadata(): Promise<NonNullable<ServiceMetadata['services']['kyc']>[string]>;
}
export {};
//# sourceMappingURL=server.d.ts.map