+9
-65
@@ -1,74 +0,18 @@ | ||
| #! /usr/bin/env node | ||
| 'use strict'; | ||
| /* | ||
| * TRAWLER-STD (entry point). | ||
| * MD5-BASE64 | ||
| */ | ||
| const packageJSON = require('./package.json'); | ||
| const appPackageJSON = require('./modules/appPackageJSON'); | ||
| const extender = require('object-extender'); | ||
| const TrawlerStd = require('./TrawlerStd'); | ||
| const crypto = require('crypto'); | ||
| // Prepare Trawler. | ||
| const boat = new TrawlerStd({ | ||
| app: { | ||
| name: appPackageJSON.name, | ||
| version: appPackageJSON.version, | ||
| mainFile: appPackageJSON.main, | ||
| env: process.env.NODE_ENV, | ||
| }, | ||
| trawler: extender.copy(appPackageJSON.trawler) || {}, // Break the reference with the app's packageJSON object. | ||
| cliArgs: process.argv.slice(2), | ||
| }); | ||
| module.exports = function (input) { | ||
| function processExitOnException (code) { | ||
| boat.log.debug('Goodbye.'); | ||
| process.exit(code || 1); | ||
| } | ||
| // Create the algorithm. | ||
| const algo = crypto.createHash('md5'); | ||
| // Ensure we throw exceptions that occur within Trawler rather than swallowing them. | ||
| // We bind this method to 'boat' (the Trawler instance) below. | ||
| function handleUncaughtException (unhandledErr) { | ||
| // Create the base64 encoded hash. | ||
| algo.update(input); | ||
| return algo.digest('base64'); | ||
| // Output the unhandled error and add a timer to force quit the app if we get stuck in an error loop. | ||
| boat.log.error(unhandledErr.stack); | ||
| setTimeout(processExitOnException.bind(null, 1), 3000); // Prevent error loops. | ||
| // Log the Trawler crash. | ||
| boat.outputLog('trawler', { | ||
| message: `Trawler (v${packageJSON.version}) itself has crashed!`, | ||
| trawlerLogType: 'error', | ||
| }, () => { // Ignore any error here. | ||
| // Attempt to notify our services. | ||
| boat.sendNotifications({ | ||
| notificationType: 'trawler-crash', | ||
| trawlerErr: unhandledErr, | ||
| }, () => { // Ignore any error here. | ||
| // Crash Trawler with the unhandled error. | ||
| setTimeout(processExitOnException.bind(null, 1), 1000); // Slight delay to allow streams to flush. | ||
| }); | ||
| }); | ||
| } | ||
| process.on('uncaughtException', handleUncaughtException); | ||
| // Initialise Trawler instance. | ||
| boat.init((err) => { | ||
| if (err) { throw err; } | ||
| // Ensure we tidy up the child app when Trawler quits. | ||
| process.on('SIGINT', () => { | ||
| console.log(''); // Line break after the ^C in the console. | ||
| process.exit(0); // When ctrl-c is pressed. | ||
| }); | ||
| process.on('exit', () => { | ||
| boat.killApp(); | ||
| }); | ||
| }); | ||
| }; |
+2
-4
@@ -10,3 +10,3 @@ { | ||
| "name": "md5-base64", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "description": "Quickly create MD5 hashes encoded as base64 strings.", | ||
@@ -37,5 +37,3 @@ "keywords": [ | ||
| }, | ||
| "dependencies": { | ||
| }, | ||
| "dependencies": {}, | ||
| "license": "MIT", | ||
@@ -42,0 +40,0 @@ "engines": { |
+15
-1
@@ -1,2 +0,16 @@ | ||
| # md5-base64 | ||
| # MD5 Base64 | ||
| Quickly create MD5 hashes encoded as base64 strings. | ||
| ## Install | ||
| ``` | ||
| npm install --save md5-base64 | ||
| ``` | ||
| ## Usage | ||
| ```javascript | ||
| const md5Base64 = require('md5-base64'); | ||
| const hash = md5Base64('my-plain-text-string'); | ||
| ``` |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
17
466.67%0
-100%1540
-52.07%17
-73.02%