workaround for #9, try {} catch () {} on Buffer.from
This commit is contained in:
parent
2c6db04ab6
commit
c728f25bc8
|
@ -7,7 +7,13 @@ function _bigIntToBase64Url(fbin) {
|
||||||
// Invalid hex string
|
// Invalid hex string
|
||||||
hex = '0' + hex;
|
hex = '0' + hex;
|
||||||
}
|
}
|
||||||
var buf = Buffer.from(hex, 'hex');
|
var buf;
|
||||||
|
// See https://github.com/Daplie/rsa-compat.js/issues/9
|
||||||
|
try {
|
||||||
|
buf = Buffer.from(hex, 'hex');
|
||||||
|
} catch(e) {
|
||||||
|
buf = new Buffer(hex, 'hex');
|
||||||
|
}
|
||||||
var b64 = buf.toString('base64');
|
var b64 = buf.toString('base64');
|
||||||
var b64Url = b64.replace(/[+]/g, "-").replace(/\//g, "_").replace(/=/g,"");
|
var b64Url = b64.replace(/[+]/g, "-").replace(/\//g, "_").replace(/=/g,"");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue