Socket
Socket
Sign inDemoInstall

hoek

Package Overview
Dependencies
Maintainers
3
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hoek - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

14

lib/index.js

@@ -486,5 +486,6 @@ // Load modules

exports.base64urlEncode = function (value) {
exports.base64urlEncode = function (value, encoding) {
return (new Buffer(value, 'binary')).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
var buf = (value instanceof Buffer ? value : new Buffer(value, encoding || 'binary'));
return buf.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
};

@@ -495,6 +496,6 @@

exports.base64urlDecode = function (encoded) {
exports.base64urlDecode = function (value, encoding) {
if (encoded &&
!encoded.match(/^[\w\-]*$/)) {
if (value &&
!value.match(/^[\w\-]*$/)) {

@@ -505,3 +506,4 @@ return new Error('Invalid character');

try {
return (new Buffer(encoded.replace(/-/g, '+').replace(/:/g, '/'), 'base64')).toString('binary');
var buf = new Buffer(value.replace(/-/g, '+').replace(/:/g, '/'), 'base64');
return (encoding === 'buffer' ? buf : buf.toString(encoding || 'binary'));
}

@@ -508,0 +510,0 @@ catch (err) {

{
"name": "hoek",
"description": "General purpose node utilities",
"version": "1.0.3",
"version": "1.1.0",
"repository": "git://github.com/spumko/hoek",

@@ -16,3 +16,3 @@ "main": "index",

"devDependencies": {
"lab": "0.2.x"
"lab": "1.x.x"
},

@@ -19,0 +19,0 @@ "scripts": {

@@ -948,2 +948,8 @@ // Load modules

});
it('encodes a buffer', function (done) {
expect(Hoek.base64urlEncode(new Buffer(str, 'binary'))).to.equal(base64str);
done();
});
});

@@ -959,2 +965,10 @@

it('should un-base64 URL-safe a string and return a buffer', function (done) {
var buf = Hoek.base64urlDecode(base64str, 'buffer');
expect(buf instanceof Buffer).to.equal(true);
expect(buf.toString('binary')).to.equal(str);
done();
});
it('should return error on undefined input', function (done) {

@@ -961,0 +975,0 @@

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