Skip to content

Commit

Permalink
Fixing BasicAuth due to missing btoa().
Browse files Browse the repository at this point in the history
  • Loading branch information
henvic committed Dec 1, 2015
1 parent 4826552 commit c9c6563
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/api/Launchpad.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict';

import Auth from '../api/Auth';
import Auth from './Auth';
import Embodied from '../api-query/Embodied';
import Filter from '../api-query/Filter';
import Query from '../api-query/Query';
import TransportFactory from './TransportFactory';
import ClientRequest from './ClientRequest';
import Util from './Util';
import MultiMap from './MultiMap';
import Btoa from '../btoa/Btoa';

var io;

Expand Down Expand Up @@ -402,7 +403,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));
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/btoa/Btoa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

class Btoa {
btoa(stringToEncode) {
if (typeof btoa === 'function') {
return btoa(stringToEncode);
}

return new Buffer(stringToEncode.toString(), 'binary');
}
}

export default Btoa;

0 comments on commit c9c6563

Please sign in to comment.