Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fairmont-helpers

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fairmont-helpers - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

71

lib/hash.js
// Generated by CoffeeScript 1.10.0
(function() {
var Crypto, Method, base64, base64url, isBuffer, isString, md5, ref;
var Base64Words, Crypto, Method, async, base64, base64URL, fromBase64Words, fs, isBuffer, isString, md5, promise, randomBytes, randomKey, randomWords, ref, ref1, toBase64Words;
fs = require("fs");
Crypto = require("crypto");

@@ -11,2 +13,6 @@

Base64Words = require("base64-words");
ref1 = require("./promise"), promise = ref1.promise, async = ref1.async;
md5 = Method.create();

@@ -22,16 +28,69 @@

base64 = function(string) {
return new Buffer(string).toString('base64').replace(/\=+$/, '');
base64 = Method.create();
Method.define(base64, isString, function(string) {
return base64(new Buffer(string));
});
Method.define(base64, isBuffer, function(buffer) {
return buffer.toString('base64');
});
base64URL = function(buffer) {
return base64(buffer).replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, '');
};
base64url = function(string) {
return new Buffer(string).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=+$/, '');
toBase64Words = function(buffer) {
return Base64Words.fromBase64(base64URL(buffer));
};
fromBase64Words = function(string) {
return new Buffer(Base64Words.toBase64(string), 'base64');
};
randomBytes = process.platform !== "win32" ? function(n) {
return promise(function(resolve, reject) {
return fs.open("/dev/urandom", "r", function(error, fd) {
var buffer;
buffer = Buffer.alloc(n);
return fs.read(fd, buffer, 0, n, 0, function(error, m) {
if (n === m) {
return resolve(buffer);
} else {
return reject("Unable to read " + n + " bytes from /dev/urandom");
}
});
});
});
} : function(n) {
return promise(function(resolve, reject) {
return Crypto.randomBytes(n, function(error, buffer) {
if (error == null) {
return resolve(buffer);
} else {
return reject(error);
}
});
});
};
randomKey = async(function*(n) {
return base64URL((yield randomBytes(n)));
});
randomWords = async(function*(n) {
return toBase64Words((yield randomBytes(n)));
});
module.exports = {
md5: md5,
base64: base64,
base64url: base64url
base64URL: base64URL,
toBase64Words: toBase64Words,
fromBase64Words: fromBase64Words,
randomBytes: randomBytes,
randomKey: randomKey,
randomWords: randomWords
};
}).call(this);

3

package.json
{
"name": "fairmont-helpers",
"version": "1.1.2",
"version": "1.2.0",
"description": "Functional and reactive programming for JavaScript.",

@@ -32,2 +32,3 @@ "files": [

"dependencies": {
"base64-words": "^0.1.1",
"fairmont-core": "1.0.x",

@@ -34,0 +35,0 @@ "fairmont-multimethods": "1.0.x"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc