import { OTP } from '@alessiofrittoli/crypto-otp';
import { Algo } from '@alessiofrittoli/crypto-algorithm/types';

type ResourceId = string | number;
interface CredentialInit {
    /**
     * The Credential ID.
     *
     */
    id?: ResourceId;
    /**
     * The Credential unique ID.
     *
     */
    credentialId?: string;
    /**
     * The Credential creation Date.
     *
     */
    createdAt?: string | number | Date;
    /**
     * The Credential last use Date.
     *
     */
    lastUse?: string | number | Date;
    /**
     * The Credential Display name.
     *
     */
    title?: string;
    /**
     * The User ID who owns this Credential.
     *
     */
    user: ResourceId;
    /**
     * The User device user-agent string at the moment of the Credential was created.
     *
     */
    userAgent?: string;
    /**
     * The Credential counter.
     *
     * @default 0
     */
    counter?: number;
    /**
     * The public/secret key.
     *
     */
    key?: string;
    /**
     * The public/secret key encoding.
     *
     */
    encoding?: BufferEncoding | 'base32';
    /**
     * The Credential Authenticator attachment.
     *
     * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/PublicKeyCredential/authenticatorAttachment)
     */
    authenticatorAttachment?: AuthenticatorAttachment;
}
declare abstract class Credential implements CredentialInit {
    id: ResourceId;
    credentialId: string;
    createdAt: Date | undefined;
    lastUse: Date | undefined;
    title: string | undefined;
    user: ResourceId;
    userAgent: string | undefined;
    key: string | undefined;
    encoding: BufferEncoding | "base32" | undefined;
    counter: number;
    authenticatorAttachment: AuthenticatorAttachment | undefined;
    constructor(init: CredentialInit);
}

/**
 * Defines the One-Time-Password transport.
 *
 * | Constant | Description |
 * |----------|-------------|
 * | `Sms`    | The OTP get delivered through sms notifications. |
 * | `Mail`   | The OTP get delivered through email notifications. |
 * | `Usb`    | The OTP token is generated by a USB Security Key. |
 * | `App`    | The OTP token is generated by an Authenticator App. |
 */
declare enum OtpTransport {
    Sms = "sms",
    Mail = "mail",
    Usb = "usb",
    App = "app"
}
interface OtpCredentialInit extends Omit<CredentialInit, 'authenticatorAttachment' | 'encoding'>, Pick<OTP.GenericOptions, 'digits'>, Pick<OTP.AuthURLOptions, 'label' | 'issuer'> {
    /**
     * Defines the One-Time-Password transport.
     *
     * @default [OtpTransport.Mail]
     */
    transports?: OtpTransport[];
    /**
     * The secret key encoding.
     *
     * @default Otp.Encoding
     */
    encoding?: OTP.Encoding;
    /**
     * The secret key hash algorithm.
     *
     */
    hash?: Algo.Hash;
}
declare abstract class OtpCredential extends Credential implements OtpCredentialInit {
    transports: OtpTransport[];
    encoding: OTP.Encoding;
    hash: Algo.Hash;
    digits: OTP.Digits;
    label: string;
    issuer: string | undefined;
    secrets: OTP.Secrets;
    authenticatorAttachment: AuthenticatorAttachment;
    constructor(init: OtpCredentialInit);
    /**
     * Check if the current `OtpCredential.transports` includes the given `transport`.
     *
     * @param transport The `OtpTransport` to check.
     * @returns `true` if the `OtpCredential.transports` includes the given `transport`, `false` otherwise.
     */
    hasTransport(transport: OtpTransport): boolean;
    /**
     * Get the Secret key configuration used in OTP generation.
     *
     * @returns The Secret key configuration used in OTP generation.
     */
    protected getSecret(): OTP.Secret;
    /**
     * Retrieve the Secret Key in different encodings.
     *
     * @returns	An object with Secret Key in different encodings, indexed by encoding name.
     */
    getSecrets(): OTP.Secrets;
}

export { Credential, type CredentialInit, OtpCredential, type OtpCredentialInit, OtpTransport, type ResourceId };
