"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../../Class/Functional");
const _ids_1 = require("../../../../_ids");
class ExportJwtKey extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['key', 'format'],
            o: ['key'],
        }, {
            input: {
                key: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_EXPORT_JWK_KEY);
    }
    async f({ key, format }, done) {
        const { api: { crypto: { exportKey }, }, } = this.__system;
        const key__ = (await key.raw());
        let key_;
        try {
            key_ = (await exportKey(format, key__));
        }
        catch (err) {
            done(undefined, err.message.toLowerCase());
            return;
        }
        done({ key: key_ });
    }
}
exports.default = ExportJwtKey;
//# sourceMappingURL=index.js.map