File tree 2 files changed +26
-2
lines changed
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
import core from 'bower:metal/src/core' ;
4
- import Auth from '../api/Auth' ;
4
+ import Auth from './Auth' ;
5
+ import Base64 from '../crypt/Base64' ;
5
6
import Embodied from '../api-query/Embodied' ;
6
7
import Filter from '../api-query/Filter' ;
7
8
import Query from '../api-query/Query' ;
@@ -403,7 +404,7 @@ class Launchpad {
403
404
clientRequest . header ( 'Authorization' , 'Bearer ' + this . auth_ . token ( ) ) ;
404
405
} else {
405
406
var credentials = this . auth_ . username ( ) + ':' + this . auth_ . password ( ) ;
406
- clientRequest . header ( 'Authorization' , 'Basic ' + btoa ( credentials ) ) ;
407
+ clientRequest . header ( 'Authorization' , 'Basic ' + Base64 . encodeString ( credentials ) ) ;
407
408
}
408
409
}
409
410
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ /**
4
+ * Abstraction layer for string to base64 conversion
5
+ * reference: https://github.com/nodejs/node/issues/3462
6
+ */
7
+ class Base64 {
8
+ /**
9
+ * Creates a base-64 encoded ASCII string from a "string" of binary data.
10
+ * @param {string } string to be encoded.
11
+ * @return {string }
12
+ * @static
13
+ */
14
+ static encodeString ( string ) {
15
+ if ( typeof btoa === 'function' ) {
16
+ return btoa ( string ) ;
17
+ }
18
+
19
+ return new Buffer ( string . toString ( ) , 'binary' ) ;
20
+ }
21
+ }
22
+
23
+ export default Base64 ;
You can’t perform that action at this time.
0 commit comments