Skip to content

Commit

Permalink
Update: use npm-published base64url implementation (#104)
Browse files Browse the repository at this point in the history
remove urlsafe enc/dec tar dependency
  • Loading branch information
panva authored and linuxwolf committed Apr 12, 2017
1 parent 0d1a8cd commit c6b30c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions lib/util/base64url.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
"use strict";

var impl = require("urlsafe-base64");
var impl = require("base64url");

/**
* @namespace base64url
Expand All @@ -25,15 +25,25 @@ var base64url = {
* @param {String} [encoding = binary] The input encoding format.
* @returns {String} the base64url encoding of {input}.
*/
encode: impl.encode,
encode: function encode(buffer, encoding) {
if (buffer instanceof ArrayBuffer) {
buffer = new Uint8Array(buffer);
}

if (!Buffer.isBuffer(buffer)) {
buffer = new Buffer(buffer, encoding);
}

return impl.encode(buffer);
},
/**
* @function
* Decodes the input from base64url.
*
* @param {String} input The data to decode.
* @returns {Buffer|String} the base64url decoding of {input}.
*/
decode: impl.decode
decode: impl.toBuffer
};

module.exports = base64url;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
],
"license": "Apache-2.0",
"dependencies": {
"base64url": "^2.0.0",
"es6-promise": "^4.0.5",
"jsbn": "^1.1.0",
"lodash.assign": "^4.0.8",
Expand All @@ -40,7 +41,6 @@
"lodash.uniq": "^4.2.1",
"long": "^3.1.0",
"node-forge": "https://github.com/linuxwolf/forge/archive/browserify.tar.gz",
"urlsafe-base64": "https://github.com/linuxwolf/urlsafe-base64/archive/encoding.tar.gz",
"uuid": "^3.0.1"
},
"devDependencies": {
Expand Down

0 comments on commit c6b30c9

Please sign in to comment.