UNPKG

admob-ssv

Version:

Tool for validate AdMob rewarded ads signatures SSV

34 lines 1.09 kB
export const KEY_URL = 'https://www.gstatic.com/admob/reward/verifier-keys.json'; export default class SimpleFetcher { constructor(options = {}) { this.options = options; } async fetch() { const res = await fetch(this.options.url || KEY_URL); if (!res.ok) { throw new Error(`Failed to fetch keys: ${res.statusText}`); } const data = await res.json(); return data.keys; } } export class RetryFetcher extends SimpleFetcher { constructor(options = {}) { super(options); this.options = options; } async fetch() { const maxRetries = this.options.maxRetries || 3; const delay = this.options.delay || 1000; for (let i = maxRetries || 3; i > 0; i -= 1) { try { return await super.fetch(); } catch (err) { await new Promise(resolve => setTimeout(resolve, delay)); } } throw new Error(`Failed to fetch keys after ${maxRetries} retries`); } } //# sourceMappingURL=index.js.map