const jwt = require('jsonwebtoken'); const http = require('http'); const KEY = 'user:1022172:47'; const SECRET = 'da4e4367277668aa6e048b0a04d1a417ba8bad630f4ac37ccdcea064a9de151e'; function makeJWT() { return jwt.sign({ iss: KEY, jti: Math.random().toString(36).slice(2), iat: Math.floor(Date.now()/1000), exp: Math.floor(Date.now()/1000) + 300 }, SECRET); } function proxyRequest(method, url, headers) { return new Promise((resolve, reject) => { const u = new URL(url); const req = http.request({ hostname: 'localhost', port: 12334, path: url, method: method, headers: Object.assign({ 'Host': u.hostname }, headers) }, res => { let d = ''; res.on('data', c => d += c); res.on('end', () => resolve({ status: res.statusCode, body: d })); }); req.on('error', reject); req.end(); }); } async function main() { const token = makeJWT(); const auth = 'JWT ' + token; // Search for the addon console.log('==> Searching for addon...'); // Try different possible IDs const ids = [ 'verstak-bridge@verstak.app', 'verstak-bridge@mirv.top', 'verstak@mirv.top', 'verstak-bridge', ]; for (const id of ids) { const res = await proxyRequest('GET', `https://addons.mozilla.org/api/v5/addons/${id}/`, { 'Authorization': auth }); if (res.status === 200) { const data = JSON.parse(res.body); console.log(` FOUND: ${id}`); console.log(` Name: ${data.name}`); console.log(` Status: ${data.status}`); } else { console.log(` ${id}: ${res.status}`); } } // Also try listing user's addons console.log('\n==> Listing user addons...'); const listRes = await proxyRequest('GET', `https://addons.mozilla.org/api/v5/addons/?author=user:1022172:47`, { 'Authorization': auth }); console.log(` Status: ${listRes.status}`); if (listRes.status === 200) { const data = JSON.parse(listRes.body); if (data.results) { data.results.forEach(a => console.log(` - ${a.id} (${a.name})`)); } } else { console.log(listRes.body.substring(0, 200)); } } main().catch(e => console.error(e.message));