liveperson-functions-cli
Version:
LivePerson Functions CLI
32 lines • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SwiftAuth = void 0;
const httpClient_1 = require("../http-client/httpClient");
/**
* Implementation of the swift auth strategy. Uses username and password.
*/
class SwiftAuth {
constructor(username, password) {
this.username = username;
this.password = password;
}
async getAuthHeaders(host) {
try {
const { headers: { 'x-auth-token': token }, } = await (0, httpClient_1.httpClient)(`https://${host}/auth/v1.0`, {
method: 'GET',
simple: true,
resolveWithFullResponse: true,
headers: {
'X-Auth-User': this.username,
'X-Auth-Key': this.password,
},
});
return { 'x-auth-token': token };
}
catch (error) {
throw new Error(`Unable to authorize at Swift: ${error.message}`);
}
}
}
exports.SwiftAuth = SwiftAuth;
//# sourceMappingURL=SwiftAuth.js.map