From 36e450659de97037049704101112dfddbb2fda3f Mon Sep 17 00:00:00 2001 From: Valters Jansons Date: Fri, 14 Feb 2020 02:12:29 +0200 Subject: [PATCH] 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. --- asn1-parser.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/asn1-parser.js b/asn1-parser.js index 82f7cd0..ef1ac6f 100644 --- a/asn1-parser.js +++ b/asn1-parser.js @@ -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) { diff --git a/package.json b/package.json index c1feaf0..0bcc06f 100644 --- a/package.json +++ b/package.json @@ -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", -- 2.38.5