v1.2.2: remove telemetry and stray logs, lint some
This commit is contained in:
parent
6ae7076185
commit
b7508bba6c
|
@ -20,7 +20,7 @@ if (!infile) {
|
|||
}
|
||||
|
||||
if (-1 !== [ 'jwk', 'pem', 'json', 'der', 'pkcs1', 'pkcs8', 'spki' ].indexOf(infile)) {
|
||||
console.log("Generating new key...");
|
||||
console.info("Generating new key...");
|
||||
Rasha.generate({
|
||||
format: infile
|
||||
, modulusLength: parseInt(format, 10) || 2048
|
||||
|
@ -30,8 +30,8 @@ if (-1 !== [ 'jwk', 'pem', 'json', 'der', 'pkcs1', 'pkcs8', 'spki' ].indexOf(inf
|
|||
key.private = key.private.toString('binary');
|
||||
key.public = key.public.toString('binary');
|
||||
}
|
||||
console.log(key.private);
|
||||
console.log(key.public);
|
||||
console.info(key.private);
|
||||
console.info(key.public);
|
||||
}).catch(function (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
|
@ -98,7 +98,7 @@ function signMessage(pem, name) {
|
|||
sign.write(msg)
|
||||
sign.end()
|
||||
var buf = sign.sign(pem);
|
||||
console.log(buf.toString('base64'));
|
||||
console.info(buf.toString('base64'));
|
||||
/*
|
||||
Rasha.sign({ pem: pem, message: msg, alg: 'SHA256' }).then(function (sig) {
|
||||
}).catch(function () {
|
||||
|
|
23
lib/asn1.js
23
lib/asn1.js
|
@ -129,9 +129,7 @@ ASN1.parse = function parseAsn1(buf, depth, ws) {
|
|||
index += (2 + child.lengthSize + child.length);
|
||||
//console.warn('2 len:', (2 + asn1.lengthSize + asn1.length), 'idx:', index, 'clen:', (2 + child.lengthSize + child.length));
|
||||
if (index > (2 + asn1.lengthSize + asn1.length)) {
|
||||
console.error(JSON.stringify(asn1, function (k, v) {
|
||||
if ('value' === k) { return '0x' + Enc.bufToHex(v.data); } return v;
|
||||
}, 2));
|
||||
console.error(JSON.stringify(asn1, toPrettyHex, 2));
|
||||
throw new Error("Parse error: child value length (" + child.length
|
||||
+ ") is greater than remaining parent length (" + (asn1.length - index)
|
||||
+ " = " + asn1.length + " - " + index + ")");
|
||||
|
@ -140,13 +138,14 @@ ASN1.parse = function parseAsn1(buf, depth, ws) {
|
|||
//console.warn(ws + '0x' + Enc.numToHex(asn1.type), index, 'len:', asn1.length, asn1);
|
||||
}
|
||||
if (index !== (2 + asn1.lengthSize + asn1.length)) {
|
||||
console.warn('index:', index, 'length:', (2 + asn1.lengthSize + asn1.length))
|
||||
console.warn('index:', index, 'length:', (2 + asn1.lengthSize + asn1.length));
|
||||
throw new Error("premature end-of-file");
|
||||
}
|
||||
if (iters >= 15) { throw new Error(ASN1.ELOOP); }
|
||||
|
||||
return asn1;
|
||||
};
|
||||
function toPrettyHex(k, v) { if ('value' === k) { return '0x' + Enc.bufToHex(v.data); } return v; }
|
||||
|
||||
/*
|
||||
ASN1._stringify = function(asn1) {
|
||||
|
@ -222,14 +221,14 @@ ASN1.tpl = function (asn1) {
|
|||
}
|
||||
|
||||
write(asn1);
|
||||
console.log('var opts = {};');
|
||||
console.log(vars.join('\n') + '\n');
|
||||
console.log();
|
||||
console.log('function buildSchema(opts) {');
|
||||
console.log(sp + 'return Enc.hexToBuf(' + str.slice(3) + ');');
|
||||
console.log('}');
|
||||
console.log();
|
||||
console.log('buildSchema(opts);');
|
||||
console.info('var opts = {};');
|
||||
console.info(vars.join('\n') + '\n');
|
||||
console.info();
|
||||
console.info('function buildSchema(opts) {');
|
||||
console.info(sp + 'return Enc.hexToBuf(' + str.slice(3) + ');');
|
||||
console.info('}');
|
||||
console.info();
|
||||
console.info('buildSchema(opts);');
|
||||
};
|
||||
|
||||
module.exports = ASN1;
|
||||
|
|
111
lib/telemetry.js
111
lib/telemetry.js
|
@ -1,111 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
// We believe in a proactive approach to sustainable open source.
|
||||
// As part of that we make it easy for you to opt-in to following our progress
|
||||
// and we also stay up-to-date on telemetry such as operating system and node
|
||||
// version so that we can focus our efforts where they'll have the greatest impact.
|
||||
//
|
||||
// Want to learn more about our Terms, Privacy Policy, and Mission?
|
||||
// Check out https://therootcompany.com/legal/
|
||||
|
||||
var os = require('os');
|
||||
var crypto = require('crypto');
|
||||
var https = require('https');
|
||||
var pkg = require('../package.json');
|
||||
|
||||
// to help focus our efforts in the right places
|
||||
var data = {
|
||||
package: pkg.name
|
||||
, version: pkg.version
|
||||
, node: process.version
|
||||
, arch: process.arch || os.arch()
|
||||
, platform: process.platform || os.platform()
|
||||
, release: os.release()
|
||||
};
|
||||
|
||||
function addCommunityMember(opts) {
|
||||
setTimeout(function () {
|
||||
var req = https.request({
|
||||
hostname: 'api.therootcompany.com'
|
||||
, port: 443
|
||||
, path: '/api/therootcompany.com/public/community'
|
||||
, method: 'POST'
|
||||
, headers: { 'Content-Type': 'application/json' }
|
||||
}, function (resp) {
|
||||
// let the data flow, so we can ignore it
|
||||
resp.on('data', function () {});
|
||||
//resp.on('data', function (chunk) { console.log(chunk.toString()); });
|
||||
resp.on('error', function () { /*ignore*/ });
|
||||
//resp.on('error', function (err) { console.error(err); });
|
||||
});
|
||||
var obj = JSON.parse(JSON.stringify(data));
|
||||
obj.action = 'updates';
|
||||
try {
|
||||
obj.ppid = ppid(obj.action);
|
||||
} catch(e) {
|
||||
// ignore
|
||||
//console.error(e);
|
||||
}
|
||||
obj.name = opts.name || undefined;
|
||||
obj.address = opts.email;
|
||||
obj.community = 'node.js@therootcompany.com';
|
||||
|
||||
req.write(JSON.stringify(obj, 2, null));
|
||||
req.end();
|
||||
req.on('error', function () { /*ignore*/ });
|
||||
//req.on('error', function (err) { console.error(err); });
|
||||
}, 50);
|
||||
}
|
||||
|
||||
function ping(action) {
|
||||
setTimeout(function () {
|
||||
var req = https.request({
|
||||
hostname: 'api.therootcompany.com'
|
||||
, port: 443
|
||||
, path: '/api/therootcompany.com/public/ping'
|
||||
, method: 'POST'
|
||||
, headers: { 'Content-Type': 'application/json' }
|
||||
}, function (resp) {
|
||||
// let the data flow, so we can ignore it
|
||||
resp.on('data', function () { });
|
||||
//resp.on('data', function (chunk) { console.log(chunk.toString()); });
|
||||
resp.on('error', function () { /*ignore*/ });
|
||||
//resp.on('error', function (err) { console.error(err); });
|
||||
});
|
||||
var obj = JSON.parse(JSON.stringify(data));
|
||||
obj.action = action;
|
||||
try {
|
||||
obj.ppid = ppid(obj.action);
|
||||
} catch(e) {
|
||||
// ignore
|
||||
//console.error(e);
|
||||
}
|
||||
|
||||
req.write(JSON.stringify(obj, 2, null));
|
||||
req.end();
|
||||
req.on('error', function (/*e*/) { /*console.error('req.error', e);*/ });
|
||||
}, 50);
|
||||
}
|
||||
|
||||
// to help identify unique installs without getting
|
||||
// the personally identifiable info that we don't want
|
||||
function ppid(action) {
|
||||
var parts = [ action, data.package, data.version, data.node, data.arch, data.platform, data.release ];
|
||||
var ifaces = os.networkInterfaces();
|
||||
Object.keys(ifaces).forEach(function (ifname) {
|
||||
if (/^en/.test(ifname) || /^eth/.test(ifname) || /^wl/.test(ifname)) {
|
||||
if (ifaces[ifname] && ifaces[ifname].length) {
|
||||
parts.push(ifaces[ifname][0].mac);
|
||||
}
|
||||
}
|
||||
});
|
||||
return crypto.createHash('sha1').update(parts.join(',')).digest('base64');
|
||||
}
|
||||
|
||||
module.exports.ping = ping;
|
||||
module.exports.joinCommunity = addCommunityMember;
|
||||
|
||||
if (require.main === module) {
|
||||
ping('install');
|
||||
//addCommunityMember({ name: "AJ ONeal", email: 'coolaj86@gmail.com' });
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "rasha",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"description": "💯 PEM-to-JWK and JWK-to-PEM for RSA keys in a lightweight, zero-dependency library focused on perfect universal compatibility.",
|
||||
"homepage": "https://git.coolaj86.com/coolaj86/rasha.js",
|
||||
"main": "index.js",
|
||||
|
@ -16,7 +16,6 @@
|
|||
"lib": "lib"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "node lib/telemetry.js event:install",
|
||||
"test": "bash test.sh"
|
||||
},
|
||||
"repository": {
|
||||
|
|
Loading…
Reference in New Issue