"use strict";
/*
v2 API endpoint for managing your v1 API key.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const get_account_1 = __importDefault(require("lib/account/get-account"));
const manage_1 = __importDefault(require("@cocalc/server/api/manage"));
const get_params_1 = __importDefault(require("lib/api/get-params"));
async function handle(req, res) {
    try {
        const account_id = await (0, get_account_1.default)(req);
        if (!account_id) {
            throw Error("must be signed in");
        }
        const { action, password } = (0, get_params_1.default)(req);
        const api_key = await (0, manage_1.default)({ account_id, password, action });
        res.json({ api_key });
    }
    catch (err) {
        res.json({ error: err.message });
    }
}
exports.default = handle;
//# sourceMappingURL=api-key.js.map