diff --git a/src/api/Launchpad.js b/src/api/Launchpad.js index 07c7d30..fc88764 100644 --- a/src/api/Launchpad.js +++ b/src/api/Launchpad.js @@ -1,7 +1,8 @@ 'use strict'; import core from 'bower:metal/src/core'; -import Auth from '../api/Auth'; +import Auth from './Auth'; +import Btoa from '../btoa/Btoa'; import Embodied from '../api-query/Embodied'; import Filter from '../api-query/Filter'; import Query from '../api-query/Query'; @@ -403,7 +404,7 @@ class Launchpad { clientRequest.header('Authorization', 'Bearer ' + this.auth_.token()); } else { var credentials = this.auth_.username() + ':' + this.auth_.password(); - clientRequest.header('Authorization', 'Basic ' + btoa(credentials)); + clientRequest.header('Authorization', 'Basic ' + Btoa.btoa(credentials)); } } diff --git a/src/btoa/Btoa.js b/src/btoa/Btoa.js new file mode 100644 index 0000000..8d4266d --- /dev/null +++ b/src/btoa/Btoa.js @@ -0,0 +1,13 @@ +'use strict'; + +class Btoa { + static btoa(stringToEncode) { + if (typeof btoa === 'function') { + return btoa(stringToEncode); + } + + return new Buffer(stringToEncode.toString(), 'binary'); + } +} + +export default Btoa;