Skip to content

Commit 49b5b04

Browse files
committed
Fixing BasicAuth due to missing btoa().
nodejs/node#3462
1 parent 728e4a2 commit 49b5b04

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/api/Launchpad.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
import Auth from '../api/Auth';
3+
import Auth from './Auth';
44
import Embodied from '../api-query/Embodied';
55
import Filter from '../api-query/Filter';
66
import Query from '../api-query/Query';
@@ -415,7 +415,15 @@ class Launchpad {
415415
clientRequest.header('Authorization', 'Bearer ' + this.auth_.token());
416416
} else {
417417
var credentials = this.auth_.username() + ':' + this.auth_.password();
418-
clientRequest.header('Authorization', 'Basic ' + btoa(credentials));
418+
var basic;
419+
420+
if (typeof btoa === 'function') {
421+
basic = btoa(credentials);
422+
} else {
423+
basic = new Buffer(credentials.toString(), 'binary');
424+
}
425+
426+
clientRequest.header('Authorization', 'Basic ' + basic);
419427
}
420428
}
421429

0 commit comments

Comments
 (0)