UNPKG

n8n-nodes-linkupapi

Version:

n8n node for LINKUP API - Complete LinkedIn automation with 100% API coverage and full documentation

125 lines (124 loc) • 5.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LinkupUtils = void 0; const types_1 = require("./types"); class LinkupUtils { static sanitizeCredentialValue(value) { if (!value || value.includes("__n8n_BLANK_VALUE_")) { return null; } return value; } static async getCredentialsWithFallback(context) { // Always use saved credentials (no more custom credentials) const credentials = await context.getCredentials("linkupApi"); if (!credentials) { throw new Error("Missing API key. Please configure your LINKUP credentials in the node settings."); } const apiKey = LinkupUtils.sanitizeCredentialValue(credentials.apiKey); const email = LinkupUtils.sanitizeCredentialValue(credentials.linkedinEmail); const password = LinkupUtils.sanitizeCredentialValue(credentials.linkedinPassword); const country = LinkupUtils.sanitizeCredentialValue(credentials.country); const loginToken = LinkupUtils.sanitizeCredentialValue(credentials.loginToken); if (!apiKey) { throw new Error("Missing API key. Please configure your LINKUP credentials in the node settings."); } // Debug: log de la longueur de l'API key (sans exposer la valeur) console.log("🔑 LINKUP Debug - API Key length:", apiKey.length, "characters"); // Vérification basique du format de l'API key if (apiKey.length < 10) { throw new Error("API key seems too short. Please verify your LINKUP API key."); } return { apiKey: apiKey, email: email || "", password: password || "", country: country || "FR", loginToken: loginToken || "", }; } static buildRequestOptions(endpoint, method, apiKey, body, timeout) { return { method, url: `${types_1.LINKUP_API_BASE_URL}${endpoint}`, headers: { "x-api-key": apiKey, "Content-Type": "application/json", "User-Agent": "n8n-linkup-node/1.2.0", }, body, timeout, }; } static getEndpointForOperation(operation) { const endpointMap = { // AUTH login: "/auth/login", verifyCode: "/auth/verify", // PROFILE getMyProfile: "/profile/me", extractProfileInfo: "/profile/info", searchProfile: "/profile/search", // COMPANIES searchCompanies: "/companies/search", getCompanyInfo: "/companies/info", // NETWORK sendConnectionRequest: "/network/connect", getConnections: "/network/connections", acceptConnectionInvitation: "/network/accept-invitations", getReceivedInvitations: "/network/invitations", getSentInvitations: "/network/sent-invitations", withdrawInvitation: "/network/withdraw-invitation", getNetworkRecommendations: "/network/recommendations", getInvitationStatus: "/network/invitation-status", // MESSAGES sendMessage: "/messages/send", getMessageInbox: "/messages/inbox", getConversationMessages: "/messages/conversation-messages", // POSTS getPostReactions: "/posts/reactions", reactToPost: "/posts/react", repost: "/posts/repost", repostContent: "/posts/repost", commentPost: "/posts/comment", addCommentToPost: "/posts/comment", extractComments: "/posts/extract-comments", getComments: "/posts/extract-comments", answerComment: "/posts/answer-comment", searchPosts: "/posts/search", createPost: "/posts/create", getFeed: "/posts/feed", getLinkedInFeed: "/posts/feed", timeSpent: "/posts/time-spent", sendPostTimeSpent: "/posts/time-spent", // RECRUITER getCandidates: "/recruiter/candidates", getCandidateCV: "/recruiter/cv", getJobPosts: "/recruiter/job-posts", publishJob: "/recruiter/publish-job", closeJob: "/recruiter/close-job", createJob: "/recruiter/create-job", // SIGNAL API (nouveaux) extractPostReactions: "/data/signals/posts/reactions", extractPostComments: "/data/signals/posts/comments", extractProfileReactions: "/data/signals/profile/reactions", extractProfileComments: "/data/signals/profile/comments", extractProfilePosts: "/data/signals/profile/posts", extractCompanyPosts: "/data/signals/company/posts", // COMPANY API (nouveaux) searchCompaniesApi: "/data/search/companies", getCompanyInfoApi: "/data/company/info", getCompanyInfoByDomain: "/data/company/info-by-domain", // PERSON API (nouveaux) searchProfilesApi: "/data/search/profiles", searchProfiles: "/data/search/profiles", extractProfileInfoApi: "/person/extract-info", profileEnrichment: "/data/profil/enrich", extractCompanyEmployees: "/data/employees/extract", // MULTI-REQUESTS customRequest: "/custom", // Generic endpoint for custom requests }; return endpointMap[operation] || "/unknown"; } } exports.LinkupUtils = LinkupUtils;