61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
const jwt = require('jsonwebtoken');
|
|
const https = require('https');
|
|
const http = require('http');
|
|
const fs = require('fs');
|
|
|
|
const KEY = 'user:1022172:47';
|
|
const SECRET = 'da4e4367277668aa6e048b0a04d1a417ba8bad630f4ac37ccdcea064a9de151e';
|
|
const PROXY = 'http://localhost:12334';
|
|
|
|
const payload = {
|
|
iss: KEY,
|
|
jti: Math.random().toString(36).slice(2),
|
|
iat: Math.floor(Date.now() / 1000),
|
|
exp: Math.floor(Date.now() / 1000) + 300
|
|
};
|
|
const token = jwt.sign(payload, SECRET);
|
|
|
|
// First, get version info to find download URL
|
|
const apiUrl = 'https://addons.mozilla.org/api/v5/addons/verstak-bridge@verstak.app/versions/6297193/';
|
|
const url = new URL(apiUrl);
|
|
|
|
const proxyHost = PROXY.replace('http://', '').split(':');
|
|
const proxyHostname = proxyHost[0];
|
|
const proxyPort = parseInt(proxyHost[1] || '8080');
|
|
|
|
const options = {
|
|
hostname: proxyHostname,
|
|
port: proxyPort,
|
|
path: apiUrl,
|
|
method: 'GET',
|
|
headers: {
|
|
'Host': url.hostname,
|
|
'Authorization': 'JWT ' + token,
|
|
'User-Agent': 'web-ext/7.0.0'
|
|
}
|
|
};
|
|
|
|
const req = http.request(options, (res) => {
|
|
let data = '';
|
|
res.on('data', chunk => data += chunk);
|
|
res.on('end', () => {
|
|
try {
|
|
const json = JSON.parse(data);
|
|
console.log('Status:', res.statusCode);
|
|
console.log('Version data:', JSON.stringify(json, null, 2).substring(0, 2000));
|
|
|
|
// Look for download URL
|
|
if (json.files && json.files.length > 0) {
|
|
const fileUrl = json.files[0].download_url;
|
|
if (fileUrl) {
|
|
console.log('Download URL:', fileUrl);
|
|
}
|
|
}
|
|
} catch(e) {
|
|
console.log('Raw response:', data.substring(0, 500));
|
|
}
|
|
});
|
|
});
|
|
req.on('error', (e) => console.error('Error:', e.message));
|
|
req.end();
|