All files / lib/auth basic.js

14.29% Statements 1/7
0% Branches 0/1
0% Functions 0/2
14.29% Lines 1/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                            3x      
class BasicAuthentication {
  constructor (options = {}) {
    const username = options.username
    const password = options.password
    const hash = window.btoa(username + ':' + password)
    this.auth = 'Basic ' + hash
  }
 
  authenticate (options) {
    options.headers['Authorization'] = this.auth
    return options
  }
}
 
module.exports = {
  BasicAuthentication: BasicAuthentication
}