{"size": 1150, "ext": "js", "max_stars_repo_path": "server/dist/controllers/auth.controller.js", "max_stars_repo_name": "abdeljalil-salhi/fisbok", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/dist/controllers/auth.controller.js", "max_issues_repo_name": "abdeljalil-salhi/fisbok", "max_issues_repo_issues_event_min_datetime": "2022-03-04T19:43:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-04T19:46:21.000Z", "max_forks_repo_path": "server/dist/controllers/auth.controller.js", "max_forks_repo_name": "abdeljalil-salhi/OpenHub", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 39.6551724138, "max_line_length": 152, "alphanum_fraction": 0.6486956522}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.verifyToken = exports.signJwt = void 0;
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
const privateKey = Buffer.from(process.env.PRIVATE_KEY, "base64").toString("ascii");
const signJwt = (user, options) => {
    try {
        const token = jsonwebtoken_1.default.sign({
            id: user._id,
            isAdmin: user.isAdmin,
            isSeller: user.isSeller,
        }, privateKey, Object.assign(Object.assign({}, (options && options)), { algorithm: "RS256" }));
        return token;
    }
    catch (err) {
        return "";
    }
};
exports.signJwt = signJwt;
const verifyToken = (context, token, options) => {
    const results = jsonwebtoken_1.default.verify(token, privateKey, Object.assign(Object.assign({}, (options && options)), { algorithms: ["RS256"] }));
    if (results)
        context.user = results;
};
exports.verifyToken = verifyToken;
//# sourceMappingURL=auth.controller.js.map