download_xpi.js 604 B

12345678910111213141516171819202122232425
  1. // `npm install -g jsonwebtoken`
  2. var jwt = require('jsonwebtoken');
  3. var key = 'user:13243312:78';
  4. var secret = process.env.MDN_KEY;
  5. var issuedAt = Math.floor(Date.now() / 1000);
  6. var payload = {
  7. iss: key,
  8. jti: Math.random().toString(),
  9. iat: issuedAt,
  10. exp: issuedAt + 60,
  11. };
  12. var token = jwt.sign(payload, secret, {
  13. algorithm: 'HS256', // HMAC-SHA256 signing algorithm
  14. });
  15. var auth = 'JWT ' + token;
  16. var path = '848208/browsh-0.2.3-an+fx.xpi';
  17. var base = 'https://addons.mozilla.org/api/v3/file/';
  18. var uri = base + path;
  19. process.stdout.write('curl -H "Authorization: ' + auth + '" ' + uri);