UNPKG

admob-ssv

Version:

Tool for validate AdMob rewarded ads signatures SSV

36 lines 959 B
import { createPublicKey } from 'node:crypto'; import debugLib from 'debug'; const debug = debugLib('admob-ssv:keydict:MemoryCache'); export default class MemoryCache { constructor(keys) { this.keys = new Map(); if (keys) { const now = Date.now(); for (const key of keys) { this.keys.set(key.keyId, { ...key, added: now, }); } } } async has(id) { return this.keys.has(id); } async get(id) { debug(`Get key ${id}`); const key = this.keys.get(id); if (!key) throw new Error('Key not found'); return createPublicKey(key.pem); } async save(key) { debug(`Set key ${key.keyId}`); const now = Date.now(); this.keys.set(key.keyId, { ...key, added: now, }); } } //# sourceMappingURL=memory.js.map