n8n-nodes-kaduu
Version:
n8n Kaduu API Nodes
88 lines • 3.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Kaduu = void 0;
class Kaduu {
constructor() {
this.name = 'kaduu';
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.Kaduu = Kaduu;
//# sourceMappingURL=KaduuOAuth2Api.credentials.js.map