UNPKG

admob-ssv

Version:

Tool for validate AdMob rewarded ads signatures SSV

42 lines 1.24 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const node_crypto_1 = require("node:crypto"); const debug_1 = __importDefault(require("debug")); const debug = (0, debug_1.default)('admob-ssv:keydict:MemoryCache'); 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 (0, node_crypto_1.createPublicKey)(key.pem); } async save(key) { debug(`Set key ${key.keyId}`); const now = Date.now(); this.keys.set(key.keyId, { ...key, added: now, }); } } exports.default = MemoryCache; //# sourceMappingURL=memory.js.map