Browse Source

v1.2.2: remove telemetry and stray logs, lint some

tags/v1.2.2
AJ ONeal 9 months ago
parent
commit
b7508bba6c
4 changed files with 16 additions and 129 deletions
  1. 4
    4
      bin/rasha.js
  2. 11
    12
      lib/asn1.js
  3. 0
    111
      lib/telemetry.js
  4. 1
    2
      package.json

+ 4
- 4
bin/rasha.js View File

@@ -20,7 +20,7 @@ if (!infile) {
20 20
 }
21 21
 
22 22
 if (-1 !== [ 'jwk', 'pem', 'json', 'der', 'pkcs1', 'pkcs8', 'spki' ].indexOf(infile)) {
23
-  console.log("Generating new key...");
23
+  console.info("Generating new key...");
24 24
   Rasha.generate({
25 25
     format: infile
26 26
   , modulusLength: parseInt(format, 10) || 2048
@@ -30,8 +30,8 @@ if (-1 !== [ 'jwk', 'pem', 'json', 'der', 'pkcs1', 'pkcs8', 'spki' ].indexOf(inf
30 30
       key.private = key.private.toString('binary');
31 31
       key.public = key.public.toString('binary');
32 32
     }
33
-    console.log(key.private);
34
-    console.log(key.public);
33
+    console.info(key.private);
34
+    console.info(key.public);
35 35
   }).catch(function (err) {
36 36
     console.error(err);
37 37
     process.exit(1);
@@ -98,7 +98,7 @@ function signMessage(pem, name) {
98 98
   sign.write(msg)
99 99
   sign.end()
100 100
   var buf = sign.sign(pem);
101
-  console.log(buf.toString('base64'));
101
+  console.info(buf.toString('base64'));
102 102
   /*
103 103
   Rasha.sign({ pem: pem, message: msg, alg: 'SHA256' }).then(function (sig) {
104 104
   }).catch(function () {

+ 11
- 12
lib/asn1.js View File

@@ -129,9 +129,7 @@ ASN1.parse = function parseAsn1(buf, depth, ws) {
129 129
     index += (2 + child.lengthSize + child.length);
130 130
     //console.warn('2 len:', (2 + asn1.lengthSize + asn1.length), 'idx:', index, 'clen:', (2 + child.lengthSize + child.length));
131 131
     if (index > (2 + asn1.lengthSize + asn1.length)) {
132
-      console.error(JSON.stringify(asn1, function (k, v) {
133
-        if ('value' === k) { return '0x' + Enc.bufToHex(v.data); } return v;
134
-      }, 2));
132
+      console.error(JSON.stringify(asn1, toPrettyHex, 2));
135 133
       throw new Error("Parse error: child value length (" + child.length
136 134
         + ") is greater than remaining parent length (" + (asn1.length - index)
137 135
         + " = " + asn1.length + " - " + index + ")");
@@ -140,13 +138,14 @@ ASN1.parse = function parseAsn1(buf, depth, ws) {
140 138
     //console.warn(ws + '0x' + Enc.numToHex(asn1.type), index, 'len:', asn1.length, asn1);
141 139
   }
142 140
   if (index !== (2 + asn1.lengthSize + asn1.length)) {
143
-    console.warn('index:', index, 'length:', (2 + asn1.lengthSize + asn1.length))
141
+    console.warn('index:', index, 'length:', (2 + asn1.lengthSize + asn1.length));
144 142
     throw new Error("premature end-of-file");
145 143
   }
146 144
   if (iters >= 15) { throw new Error(ASN1.ELOOP); }
147 145
 
148 146
   return asn1;
149 147
 };
148
+function toPrettyHex(k, v) { if ('value' === k) { return '0x' + Enc.bufToHex(v.data); } return v; }
150 149
 
151 150
 /*
152 151
 ASN1._stringify = function(asn1) {
@@ -222,14 +221,14 @@ ASN1.tpl = function (asn1) {
222 221
   }
223 222
 
224 223
   write(asn1);
225
-  console.log('var opts = {};');
226
-  console.log(vars.join('\n') + '\n');
227
-  console.log();
228
-  console.log('function buildSchema(opts) {');
229
-  console.log(sp + 'return Enc.hexToBuf(' + str.slice(3) + ');');
230
-  console.log('}');
231
-  console.log();
232
-  console.log('buildSchema(opts);');
224
+  console.info('var opts = {};');
225
+  console.info(vars.join('\n') + '\n');
226
+  console.info();
227
+  console.info('function buildSchema(opts) {');
228
+  console.info(sp + 'return Enc.hexToBuf(' + str.slice(3) + ');');
229
+  console.info('}');
230
+  console.info();
231
+  console.info('buildSchema(opts);');
233 232
 };
234 233
 
235 234
 module.exports = ASN1;

+ 0
- 111
lib/telemetry.js View File

@@ -1,111 +0,0 @@
1
-'use strict';
2
-
3
-// We believe in a proactive approach to sustainable open source.
4
-// As part of that we make it easy for you to opt-in to following our progress
5
-// and we also stay up-to-date on telemetry such as operating system and node
6
-// version so that we can focus our efforts where they'll have the greatest impact.
7
-//
8
-// Want to learn more about our Terms, Privacy Policy, and Mission?
9
-// Check out https://therootcompany.com/legal/
10
-
11
-var os = require('os');
12
-var crypto = require('crypto');
13
-var https = require('https');
14
-var pkg = require('../package.json');
15
-
16
-// to help focus our efforts in the right places
17
-var data = {
18
-  package: pkg.name
19
-, version: pkg.version
20
-, node: process.version
21
-, arch: process.arch || os.arch()
22
-, platform: process.platform || os.platform()
23
-, release: os.release()
24
-};
25
-
26
-function addCommunityMember(opts) {
27
-  setTimeout(function () {
28
-    var req = https.request({
29
-      hostname: 'api.therootcompany.com'
30
-    , port: 443
31
-    , path: '/api/therootcompany.com/public/community'
32
-    , method: 'POST'
33
-    , headers: { 'Content-Type': 'application/json' }
34
-    }, function (resp) {
35
-      // let the data flow, so we can ignore it
36
-      resp.on('data', function () {});
37
-      //resp.on('data', function (chunk) { console.log(chunk.toString()); });
38
-      resp.on('error', function () { /*ignore*/ });
39
-      //resp.on('error', function (err) { console.error(err); });
40
-    });
41
-    var obj = JSON.parse(JSON.stringify(data));
42
-    obj.action = 'updates';
43
-    try {
44
-      obj.ppid = ppid(obj.action);
45
-    } catch(e) {
46
-      // ignore
47
-      //console.error(e);
48
-    }
49
-    obj.name = opts.name || undefined;
50
-    obj.address = opts.email;
51
-    obj.community = 'node.js@therootcompany.com';
52
-
53
-    req.write(JSON.stringify(obj, 2, null));
54
-    req.end();
55
-    req.on('error', function () { /*ignore*/ });
56
-    //req.on('error', function (err) { console.error(err); });
57
-  }, 50);
58
-}
59
-
60
-function ping(action) {
61
-  setTimeout(function () {
62
-    var req = https.request({
63
-      hostname: 'api.therootcompany.com'
64
-    , port: 443
65
-    , path: '/api/therootcompany.com/public/ping'
66
-    , method: 'POST'
67
-    , headers: { 'Content-Type': 'application/json' }
68
-    }, function (resp) {
69
-      // let the data flow, so we can ignore it
70
-      resp.on('data', function () { });
71
-      //resp.on('data', function (chunk) { console.log(chunk.toString()); });
72
-      resp.on('error', function () { /*ignore*/ });
73
-      //resp.on('error', function (err) { console.error(err); });
74
-    });
75
-    var obj = JSON.parse(JSON.stringify(data));
76
-    obj.action = action;
77
-    try {
78
-      obj.ppid = ppid(obj.action);
79
-    } catch(e) {
80
-      // ignore
81
-      //console.error(e);
82
-    }
83
-
84
-    req.write(JSON.stringify(obj, 2, null));
85
-    req.end();
86
-    req.on('error', function (/*e*/) { /*console.error('req.error', e);*/ });
87
-  }, 50);
88
-}
89
-
90
-// to help identify unique installs without getting
91
-// the personally identifiable info that we don't want
92
-function ppid(action) {
93
-  var parts = [ action, data.package, data.version, data.node, data.arch, data.platform, data.release ];
94
-  var ifaces = os.networkInterfaces();
95
-  Object.keys(ifaces).forEach(function (ifname) {
96
-    if (/^en/.test(ifname) || /^eth/.test(ifname) || /^wl/.test(ifname)) {
97
-      if  (ifaces[ifname] && ifaces[ifname].length) {
98
-        parts.push(ifaces[ifname][0].mac);
99
-      }
100
-    }
101
-  });
102
-  return crypto.createHash('sha1').update(parts.join(',')).digest('base64');
103
-}
104
-
105
-module.exports.ping = ping;
106
-module.exports.joinCommunity = addCommunityMember;
107
-
108
-if (require.main === module) {
109
-  ping('install');
110
-  //addCommunityMember({ name: "AJ ONeal", email: 'coolaj86@gmail.com' });
111
-}

+ 1
- 2
package.json View File

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "rasha",
3
-  "version": "1.2.1",
3
+  "version": "1.2.2",
4 4
   "description": "💯 PEM-to-JWK and JWK-to-PEM for RSA keys in a lightweight, zero-dependency library focused on perfect universal compatibility.",
5 5
   "homepage": "https://git.coolaj86.com/coolaj86/rasha.js",
6 6
   "main": "index.js",
@@ -16,7 +16,6 @@
16 16
     "lib": "lib"
17 17
   },
18 18
   "scripts": {
19
-    "postinstall": "node lib/telemetry.js event:install",
20 19
     "test": "bash test.sh"
21 20
   },
22 21
   "repository": {

Loading…
Cancel
Save