Comparing version 3.0.5 to 3.0.6
@@ -0,1 +1,6 @@ | ||
3.0.6 / 2017-03-14 | ||
================== | ||
* Remove `base64-url` dependency | ||
3.0.5 / 2017-03-07 | ||
@@ -2,0 +7,0 @@ ================== |
32
index.js
@@ -19,5 +19,13 @@ /*! | ||
var crypto = require('crypto') | ||
var escape = require('base64-url').escape | ||
/** | ||
* Module variables. | ||
* @private | ||
*/ | ||
var EQUAL_GLOBAL_REGEXP = /=/g | ||
var PLUS_GLOBAL_REGEXP = /\+/g | ||
var SLASH_GLOBAL_REGEXP = /\//g | ||
/** | ||
* Module exports. | ||
@@ -106,7 +114,3 @@ * @public | ||
Tokens.prototype._tokenize = function tokenize (secret, salt) { | ||
var hash = crypto | ||
.createHash('sha1') | ||
.update(salt + '-' + secret, 'ascii') | ||
.digest('base64') | ||
return escape(salt + '-' + hash) | ||
return salt + '-' + hash(salt + '-' + secret) | ||
} | ||
@@ -142,1 +146,17 @@ | ||
} | ||
/** | ||
* Hash a string with SHA1, returning url-safe base64 | ||
* @param {string} str | ||
* @private | ||
*/ | ||
function hash (str) { | ||
return crypto | ||
.createHash('sha1') | ||
.update(str, 'ascii') | ||
.digest('base64') | ||
.replace(PLUS_GLOBAL_REGEXP, '-') | ||
.replace(SLASH_GLOBAL_REGEXP, '_') | ||
.replace(EQUAL_GLOBAL_REGEXP, '') | ||
} |
{ | ||
"name": "csrf", | ||
"description": "primary logic behind csrf tokens", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)", | ||
@@ -12,3 +12,2 @@ "contributors": [ | ||
"dependencies": { | ||
"base64-url": "1.3.3", | ||
"rndm": "1.2.0", | ||
@@ -15,0 +14,0 @@ "tsscmp": "1.0.5", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11399
3
126
- Removedbase64-url@1.3.3
- Removedbase64-url@1.3.3(transitive)