| 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
}
|