fix browsers
This commit is contained in:
parent
0378bf8617
commit
bf8b4e940c
|
@ -51,7 +51,7 @@ module.exports = function(grunt) {
|
||||||
standalone: 'openpgp'
|
standalone: 'openpgp'
|
||||||
},
|
},
|
||||||
// Don't bundle these packages with openpgp.js
|
// Don't bundle these packages with openpgp.js
|
||||||
external: ['crypto', 'buffer', 'node-localstorage', 'node-fetch', 'asn1.js', 'jwk-to-pem'],
|
external: ['crypto', 'node-localstorage', 'node-fetch', 'asn1.js', 'jwk-to-pem'],
|
||||||
transform: [
|
transform: [
|
||||||
["babelify", {
|
["babelify", {
|
||||||
plugins: ["transform-async-to-generator",
|
plugins: ["transform-async-to-generator",
|
||||||
|
@ -74,7 +74,7 @@ module.exports = function(grunt) {
|
||||||
debug: true,
|
debug: true,
|
||||||
standalone: 'openpgp'
|
standalone: 'openpgp'
|
||||||
},
|
},
|
||||||
external: ['crypto', 'buffer', 'node-localstorage', 'node-fetch', 'asn1.js', 'jwk-to-pem'],
|
external: ['crypto', 'node-localstorage', 'node-fetch', 'asn1.js', 'jwk-to-pem'],
|
||||||
transform: [
|
transform: [
|
||||||
["babelify", {
|
["babelify", {
|
||||||
plugins: ["transform-async-to-generator",
|
plugins: ["transform-async-to-generator",
|
||||||
|
|
|
@ -59,7 +59,9 @@ if(nodeCrypto) { // Use Node native crypto for all hash functions
|
||||||
sha512: sha.sha512,
|
sha512: sha.sha512,
|
||||||
/** @see module:ripemd160 */
|
/** @see module:ripemd160 */
|
||||||
ripemd: function(data) {
|
ripemd: function(data) {
|
||||||
return util.str2Uint8Array(util.hex2bin(new RIPEMD160.update(data).digest('hex')));
|
// Convert Uint8Array to buffer
|
||||||
|
data = require('buffer').Buffer.from(data.buffer);
|
||||||
|
return util.str2Uint8Array(util.hex2bin(new RIPEMD160().update(data).digest('hex')));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -585,7 +585,10 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return require('buffer').Buffer;
|
// This "hack" allows us to access the native node buffer module.
|
||||||
|
// otherwise, it gets replaced with the browserified version
|
||||||
|
// eslint-disable-next-line no-useless-concat, import/no-dynamic-require
|
||||||
|
return require('buf'+'fer').Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user