Skip to content

Commit

Permalink
fix building es5 library
Browse files Browse the repository at this point in the history
  • Loading branch information
nf404 committed Nov 30, 2017
1 parent 0bd4401 commit d8d62de
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
28 changes: 7 additions & 21 deletions src/crypto-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,11 @@ class CryptoApi {
* @ignore
*/
constructor() {
/** @type {Hasher[]} */
this.hasher = {
'Has160': Has160,
'Md2': Md2,
'Md4': Md4,
'Md5': Md5,
'Ripemd': Ripemd,
'Sha0': Sha0,
'Sha1': Sha1,
'Sha256': Sha256,
'Sha512': Sha512,
'Snefru': Snefru,
'Whirlpool': Whirlpool
};
/** @type {{}} */
this.encoder = {};
/** @type {function} */
/** @type {fromUtf} */
this.encoder.fromUtf = fromUtf;
/** @type {function} */
/** @type {toHex} */
this.encoder.toHex = toHex;
}

Expand All @@ -53,7 +39,7 @@ class CryptoApi {
* @param {Object} options
* @returns {Hasher}
*/
static getHasher(name, options) {
getHasher(name, options) {
options = options || {};
switch (name) {
case 'has160':
Expand Down Expand Up @@ -133,9 +119,9 @@ class CryptoApi {
* @param {Object} options
* @returns {string}
*/
static hash(name, message, options) {
hash(name, message, options) {
options = options || {};
let hasher = CryptoApi.getHasher(name, options);
let hasher = this.getHasher(name, options);
hasher.update(fromUtf(message));
return toHex(hasher.finalize());
}
Expand All @@ -147,7 +133,7 @@ class CryptoApi {
* @param {Hasher} hasher
* @returns {Hmac}
*/
static getHmac(key, hasher) {
getHmac(key, hasher) {
return new Hmac(key, hasher);
}

Expand All @@ -159,7 +145,7 @@ class CryptoApi {
* @param {Hasher} hasher
* @returns {string}
*/
static hmac(key, message, hasher) {
hmac(key, message, hasher) {
let mac = this.getHmac(fromUtf(key), hasher);
mac.update(fromUtf(message));
return toHex(mac.finalize());
Expand Down
1 change: 1 addition & 0 deletions src/hasher/whirlpool.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ let RCT = new Array(22);
* Calculates SBOX from eBOX & rBOX
*
* @private
* @returns {void}
*/
function calculateSBOX() {
for (let i = 0; i < 16; i++) {
Expand Down
4 changes: 3 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ module.exports = {
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].min.js'
filename: '[name].min.js',
library: 'CryptoApi',
libraryExport: "default"
},
module: {
rules: [
Expand Down

0 comments on commit d8d62de

Please sign in to comment.