"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BasicAuthService = void 0;
const XHR_1 = require("../../icc-api/api/XHR");
var Header = XHR_1.XHR.Header;
const utils_1 = require("../utils");
class BasicAuthService {
    constructor(username, password) {
        this.username = username;
        this.password = password;
        this.error = null;
    }
    getAuthHeaders() {
        if (!!this.error) {
            throw this.error;
        }
        return Promise.resolve([new Header('Authorization', `Basic ${this._base64Encode(`${this.username}:${this.password}`)}`)]);
    }
    _base64Encode(decodedString) {
        return (0, utils_1.b2a)(decodedString);
    }
    invalidateHeader(error) {
        this.error = error;
    }
}
exports.BasicAuthService = BasicAuthService;
//# sourceMappingURL=BasicAuthService.js.map