"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Auth_1 = require("../../modules/Auth");
const login_1 = require("./login");
function default_1() {
    const auth = new Auth_1.default();
    return auth.checkAuth()
        .catch(handleError);
}
exports.default = default_1;
function handleError(err) {
    const errorCodes = ['UNAUTHORIZED', 'NOT_LOGGED_IN', 'NO_EWIZARD_INSTANCE'];
    const code = err.code.toString();
    if (errorCodes.includes(code)) {
        return (0, login_1.doLogin)();
    }
    throw err;
}
//# sourceMappingURL=ensureAuth.js.map