'use strict' ; import { Catch } from './catch.js' ; import { Key } from '../core/crypto/key.js' ; let KEY_CACHE = { } ; let KEY_CACHE_WIPE_TIMEOUT ; export class KeyCache { public static setDecrypted = ( k ) => { } ; public static getDecrypted = ( longid ) : Key | undefined => { KeyCache . extendExpiry ( ) ; return KEY_CACHE [ longid ] ; } ; public static setArmored = ( armored , k ) => { } ; public static getArmored = ( armored ) : Key | undefined => { KeyCache . extendExpiry ( ) ; return KEY_CACHE [ armored ] ; } ; public static wipe = ( ) => { KEY_CACHE = { } ; } ; private static extendExpiry = ( ) => { if ( KEY_CACHE_WIPE_TIMEOUT ) { clearTimeout ( KEY_CACHE_WIPE_TIMEOUT ) ; } KEY_CACHE_WIPE_TIMEOUT = Catch . setHandledTimeout ( KeyCache . wipe , 2 * 60 * 1000 ) ; } ; }