Skip to content

Commit 31cc58b

Browse files
committed
Fixing BasicAuth due to missing btoa().
nodejs/node#3462
1 parent 0c3bc0d commit 31cc58b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/api/Launchpad.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22

33
import core from 'bower:metal/src/core';
4-
import Auth from '../api/Auth';
4+
import Auth from './Auth';
5+
import Btoa from '../btoa/Btoa';
56
import Embodied from '../api-query/Embodied';
67
import Filter from '../api-query/Filter';
78
import Query from '../api-query/Query';
@@ -403,7 +404,7 @@ class Launchpad {
403404
clientRequest.header('Authorization', 'Bearer ' + this.auth_.token());
404405
} else {
405406
var credentials = this.auth_.username() + ':' + this.auth_.password();
406-
clientRequest.header('Authorization', 'Basic ' + btoa(credentials));
407+
clientRequest.header('Authorization', 'Basic ' + Btoa.btoa(credentials));
407408
}
408409
}
409410

src/btoa/Btoa.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
class Btoa {
4+
static btoa(stringToEncode) {
5+
if (typeof btoa === 'function') {
6+
return btoa(stringToEncode);
7+
}
8+
9+
return new Buffer(stringToEncode.toString(), 'binary');
10+
}
11+
}
12+
13+
export default Btoa;

0 commit comments

Comments
 (0)