/**
 * Parses a JWT token and extracts orgId, orgName, userId, and userEmail if present.
 * @param jwt - The JWT token string.
 * @returns An object containing the extracted fields.
 */
export function parseJwt(jwt) {
    const result = {};
    if (!jwt) {
        return result;
    }
    try {
        const parts = jwt.split(".");
        if (parts.length === 3 && parts[1]) {
            const payload = JSON.parse(Buffer.from(parts[1], "base64").toString());
            if (payload.org_id)
                result.orgId = payload.org_id;
            if (payload.org_name)
                result.orgName = payload.org_name;
            if (payload.user_id)
                result.userId = payload.user_id;
            if (payload.user_email)
                result.userEmail = payload.user_email;
        }
    }
    catch {
        // Silently handle JWT parsing errors
    }
    return result;
}
//# sourceMappingURL=parse-jwt.js.map