admob-ssv
Version:
Tool for validate AdMob rewarded ads signatures SSV
39 lines • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RetryFetcher = exports.KEY_URL = void 0;
exports.KEY_URL = 'https://www.gstatic.com/admob/reward/verifier-keys.json';
class SimpleFetcher {
constructor(options = {}) {
this.options = options;
}
async fetch() {
const res = await fetch(this.options.url || exports.KEY_URL);
if (!res.ok) {
throw new Error(`Failed to fetch keys: ${res.statusText}`);
}
const data = await res.json();
return data.keys;
}
}
exports.default = SimpleFetcher;
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`);
}
}
exports.RetryFetcher = RetryFetcher;
//# sourceMappingURL=index.js.map