import { AbstractSelfAccountKeyring } from "./account_base";
import { PeerAccountKeyring } from "./account_peer";
import { RoomKeyring } from "./room";

/**
 * All keyring that are not the private or self should be created and used from this cache object. Utilizing this
    will make sure that derived-key caches operate correctly.

    The used keys in an account-keyring are designed for slow-upgrade or change. New key(s) will be introduced and
    only after an extensive time will they be used. This allows the clients to lazily update account keyrings and
    cache them for a relatively long time.

    Event of a new member-key being available shall be used to refresh the room keyring that is related.

    The self-keyring of an account is special, it is always available even it is considered "expired", which means
    it should be updated.

    NOTE: This is made to be primarily useful for Nano and not the clients.
 */
export class KeyringCache{

    private self_kr;
    private _self_ttl;
    private _peer_krs;
    private _anon_krs;
    private _own_room_krs;

    public static CACHE_TTL = 60 * 60 * 24 * 7;

    constructor(self_kr: AbstractSelfAccountKeyring){
        // TODOIMP
    }

    public is_self_kr_expired(): boolean{
        // TODOIMP
        return null;
    }

    public get_peer_kr(account_id: number): PeerAccountKeyring{
        return this._peer_krs.get(account_id);
    }

    public load_peer_kr(
        account_id: number,
        curve25519_public: Uint8Array,
        curve25519_public_sig: Uint8Array,
        ed25519_public: Uint8Array,
        trust_fingerprint?: Uint8Array,
    ): PeerAccountKeyring{
        // TODOIMP
        return null;
    }

    public get_anon_kr(ephemeral_curve25519_pk: Uint8Array): PeerAccountKeyring{
        // TODOIMP
        return null;
    }

    public get_own_room_kr(resource_id: number): RoomKeyring{
        return this._own_room_krs.get(resource_id);
    }

    public load_own_room_kr(resource_id: number, pinned_key: Uint8Array){
        // TODOIMP
        return null;
    }


}