
/// <reference path="node/node.d.ts" />
/// <reference path="imap/imap.d.ts" />
/// <reference path="node-imap/imap.d.ts" />
/// <reference path="express-serve-static-core/express-serve-static-core.d.ts" />
/// <reference path="express/express.d.ts" />
/// <reference path="mime/mime.d.ts" />
/// <reference path="serve-static/serve-static.d.ts" />
/// <reference path="async/async.d.ts" />
/// <reference path="body-parser/body-parser.d.ts" />
/// <reference path="cookie-parser/cookie-parser.d.ts" />
/// <reference path="socket.io/socket.io.d.ts" />
/// <reference path="compression/compression.d.ts" />
/// <reference path="openpgp/openpgp.d.ts" />




declare module "osenv" {
    export function home():string;
    export function user():string;
    export function prompt():string;
    export function tmpdir():string;
    export function path():string;
    export function editor():string;
    export function shell():string;
}
declare module "openpgp" {
    export = openpgp
}

declare module Pem {
    interface option {
        serviceKey?: any;
        serviceKeyPassword?: string;
        serviceCertificate?: any;
        serial?: number;
        selfSigned?: boolean;
        csr?: any;
        days: number;
        extFile?: any;
        config?: any;
    }
    interface key {
        certificate: string;
        csr: string;
        serviceKey: string;
        clientKey: string;
    }
    export interface Static {
        createCertificate: ( option: option, CallBack: ( err: Error, keys: key ) => void ) => void
    }
}
declare module "pem" {
    var pem: Pem.Static;
    export = pem;
}

declare module "serve-favicon" {
    import express = require('express');

    /**
     * Node.js middleware for serving a favicon.
     */
    function serveFavicon(path: string, options?: {
        /**
        * The cache-control max-age directive in ms, defaulting to 1 day. This can also be a string accepted by the ms module.
        */
        maxAge?: number;
    }): express.RequestHandler;

    export = serveFavicon;
}

declare module "shortid" {
    interface main {
        generate:()=>string;
    }
    let u:main
    export = u
}

declare module "is-online"{
    interface ss {
        (err:string, data:boolean):void;
    }
    function e(tt:ss):boolean;
    export = e;
}
interface IKeyInformation {
    userId: string;
    userName: string;
    email: string;
    privateKeyUTF8: string;
    publicKeyUTF8: string;
    privateKey: any;
    publicKey: any;
    keyPassword: string;
    keyBitLength: number;
    createDate: string;
    keyPasswordOK: boolean;
}
interface IAccountType {
    name: string;
    detail: string;
    price: string;
    active: boolean;
    is_promotions: boolean;
    annual: string;
    monthly_max_transfer: string;
    multi_email: string;
    over_transfer_fee: string;
    day_max_transfer: string;
}
interface stripePayment {
	stripeToken: string;
	stripeTokenType: string;
	stripeEmail: string;
}
interface region {
	
}

interface ISentMessage {
    //		if client's public key is different than regiest will true
    publicKeyChanged: boolean;
    serverError: string;
    //		system message for user
    message: string[];		
    password: string;
    //		active user	
    active: boolean;
    serverMailFolder: string;
    tempText: string;
    toServerPassword: string;
    toServer_command: String;
    account: string;
    publicKeyId: string;
    production: string;
    accountTypeList: IAccountType[];
    accountType: string;
    stripePayment: stripePayment;
    random: string;
    region: region[];
    echo: boolean;
    disconnect: boolean;
    haveDockerPublicKey: boolean;
}
interface IinputData {
    account:string;
    email:string;
    password:string;
    smtpServer:string;
    imapServer:string;
    smtpUserName:string;
    imapUserName:string;
    smtpUserPassword:string;
    imapUserPassword:string;
    smtpPortNumber:string;
    imapPortNumber:string;
    imapSsl:boolean,
    smtpSsl:boolean,
    //  imap 0 == deable, 1 == imap connectReady, 2 == imapConnect between VpnVia.email and client 
    Status:number;
    publicKey:string;
    uuid:string;
    remoteImapConnect?:boolean;
	systemPassword: string;
	publicKey_id: string;
	serverMailBoxName: string;
    imapConnect?:boolean;
    dummyData:string;
    VpnviaEmailCheckOK: boolean;
    power: string;
    machineID: string;
    runningContainerData: string
    smtpTested: boolean
    imapTested: boolean

}
interface ISockSession {
    keyPair: IKeyInformation,
    keyPairPassword: string;
    vpnEmailPublicKey: string;
    imapArray: IinputData,
    vpnServerConnectData: ISentMessage;
    sentEmail: number;
    vpnEmailServerKeepConnected: boolean;
    imapConnected: boolean;
    newKeyPairProcessRunning: boolean;
    dockerPublicKey: string;
    newKeyProcessPid: any
}

interface ICallBack {
    <T> (err?: Error|string, Date?: T) : void;
}


interface IClientEmailCommand {
    command: string;
    data: string;
    account: string;
}
interface INewKeyPair {
    email: string;
    keyLength: string;
    nikeName: string;
    password: string
}