"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OtherLoginConfigurator = void 0;
const tslib_1 = require("tslib");
const inversify_1 = require("inversify");
const codiac_common_1 = require("@codiac.io/codiac-common");
const codiac_ops_common_1 = require("@codiac.io/codiac-ops-common");
const contracts_1 = require("../../apis/codiac-api/contracts");
let OtherLoginConfigurator = class OtherLoginConfigurator {
    constructor(codiacUser, logger) {
        this.codiacUser = codiacUser;
        this.logger = logger;
    }
    get cloudProvider() {
        return contracts_1.CloudProviderEnum.other;
    }
    /* ***********************************************************************************
     *    ___        _   _
     *   / _ \      | | | |
     *  / /_\ \_   _| |_| |__
     *  |  _  | | | | __| '_ \
     *  | | | | |_| | |_| | | |
     *  \_| |_/\__,_|\__|_| |_|
     *
     * ***********************************************************************************/
    /**
     * No cloud-provider login is required for self-managed clusters.
     * Connection credentials are registered separately via `cod cluster credentials-set`.
     *
     * This stub is intentionally structured as a full ILoginConfigurator implementation
     * so that per-cluster credential management can be added here when the need arises.
     */
    promptToLogin(options) {
        var _a, _b;
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            this.logger.debug(`No CSP login required for ${this.cloudProvider}.`);
            const cspUser = {
                provider: this.cloudProvider,
                subscriptionId: (_a = options === null || options === void 0 ? void 0 : options.providerSubscriptionId) !== null && _a !== void 0 ? _a : '',
                tenantCode: this.codiacUser.tenantCode,
                username: (_b = options === null || options === void 0 ? void 0 : options.providedUserName) !== null && _b !== void 0 ? _b : this.codiacUser.username,
                created: new Date(),
            };
            return [true, cspUser, undefined];
        });
    }
    promptToLogout(_account) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            return [true, this.codiacUser.username];
        });
    }
    assembleLoginRequest(user, secret, subscriptionId, _proprietaryInput) {
        return {
            providerCode: this.cloudProvider,
            providerSubscription: subscriptionId,
            username: user,
            secret: secret,
        };
    }
};
OtherLoginConfigurator = tslib_1.__decorate([
    (0, inversify_1.injectable)(),
    tslib_1.__param(0, (0, inversify_1.inject)(codiac_ops_common_1.UserNameTenantCode)),
    tslib_1.__param(1, (0, inversify_1.inject)(codiac_common_1.INTERFACES.IBetterLogger)),
    tslib_1.__metadata("design:paramtypes", [codiac_ops_common_1.UserNameTenantCode, Object])
], OtherLoginConfigurator);
exports.OtherLoginConfigurator = OtherLoginConfigurator;
//# sourceMappingURL=other-login-configurator.js.map