-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: smaller bundle size using crypto-lite in browser
- Loading branch information
1 parent
0f6d483
commit 7d4cfff
Showing
5 changed files
with
16 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function (key, message) { | ||
return new Buffer(require('crypto-lite').crypto.hmac('sha1', key, message), 'hex'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function (key, message) { | ||
return require('crypto').createHmac('sha1', key).update(message).digest() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
module.exports = calculateSessionId | ||
|
||
var crypto = require('crypto') | ||
|
||
var base64url = require('base64url') | ||
var createHmac = require('./hmac') | ||
var validate = require('aproba') | ||
|
||
function calculateSessionId (username, usersalt, serversecret, timestamp) { | ||
validate('SSSN', arguments) | ||
|
||
var timestamp16 = timestamp.toString(16).toUpperCase() | ||
var sessionData = username + ':' + timestamp16 | ||
var hmac = crypto.createHmac('sha1', serversecret + usersalt).update(sessionData) | ||
var hmac = createHmac(serversecret + usersalt, sessionData) | ||
|
||
return base64url(Buffer.concat([ | ||
new Buffer(sessionData + ':'), | ||
hmac.digest() | ||
hmac | ||
])) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters