UNPKG

n8n-nodes-kaduu

Version:
88 lines 3.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.KaduuApi = void 0; class KaduuApi { constructor() { this.name = 'kaduuApi'; this.displayName = 'Kaduu API'; this.documentationUrl = 'https://app.leak.center/docs'; this.properties = [ { displayName: 'Username', name: 'username', type: 'string', default: '', required: true, description: 'Your Kaduu username', }, { displayName: 'Password', name: 'password', type: 'string', typeOptions: { password: true, }, default: '', required: true, description: 'Your Kaduu password', }, ]; this.authenticate = { type: 'generic', properties: { headers: { 'Authorization': '=Bearer {{$credentials.oauthTokenData.access_token}}', 'Content-Type': 'application/json', 'Accept': 'application/json', }, }, }; this.test = { request: { baseURL: 'https://app.leak.center/svc-saas', url: '/stats', method: 'GET', timeout: 10000, }, }; } async preAuthentication(credentials) { var _a, _b; const username = (_a = credentials.username) === null || _a === void 0 ? void 0 : _a.toString(); const password = (_b = credentials.password) === null || _b === void 0 ? void 0 : _b.toString(); if (!username || !password) { throw new Error('Username and password are required for authentication'); } const formData = new URLSearchParams(); formData.append('client_id', 'client-api'); formData.append('client_secret', 'comfy-litigate-embargo-forelimb'); formData.append('grant_type', 'password'); formData.append('username', username); formData.append('password', password); const options = { headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json', }, method: 'POST', body: formData.toString(), url: 'https://app.leak.center/uaa/oauth/token', json: true, timeout: 10000, }; try { const response = await this.helpers.httpRequest(options); if (!response.access_token) { throw new Error('Failed to obtain access token'); } return { oauthTokenData: response, }; } catch (error) { throw new Error(`Authentication failed: ${error.message}`); } } } exports.KaduuApi = KaduuApi; //# sourceMappingURL=KaduuApi.credentials.js.map