v1.1.9: bugfix Node.js `atob` invocation

Browsers have a global `atob` function, but Node.js does not.
This is very important for allowing `PEM.parseBlock` to work
out of the box, as it calls `Enc.base64ToBuf` directly.
This commit is contained in:
Valters Jansons 2020-02-14 02:12:29 +02:00
parent 9511f1e130
commit 36e450659d
No known key found for this signature in database
GPG Key ID: 4F021EB3A83CE748
2 changed files with 2 additions and 2 deletions

View File

@ -129,7 +129,7 @@ PEM.parseBlock = PEM.parseBlock || function (str) {
};
Enc.base64ToBuf = function (b64) {
return Enc.binToBuf(atob(b64));
return Enc.binToBuf('function' === typeof atob ? atob(b64) : Buffer.from(b64, 'base64').toString('binary'));
};
Enc.binToBuf = function (bin) {
var arr = bin.split('').map(function (ch) {

View File

@ -1,6 +1,6 @@
{
"name": "asn1-parser",
"version": "1.1.8",
"version": "1.1.9",
"description": "An ASN.1 parser in less than 100 lines of Vanilla JavaScript, part of the Bluecrypt suite.",
"homepage": "https://git.coolaj86.com/coolaj86/asn1-parser.js",
"main": "asn1-parser.js",