mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
refactor: Format all credentials (#3720)
* Apply Prettier to all credentials * Fix quotes for lint * 👕 Remove `quotemark` rule * 👕 Run Prettier to take over quotes * ⬆️ Upgrade `eslint-plugin-n8n-nodes-base` * 📦 Update `package-lock.json` Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -5,7 +5,6 @@ import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
export class CustomerIoApi implements ICredentialType {
|
||||
name = 'customerIoApi';
|
||||
displayName = 'Customer.io API';
|
||||
@@ -53,16 +52,23 @@ export class CustomerIoApi implements ICredentialType {
|
||||
description: 'Required for App API',
|
||||
},
|
||||
];
|
||||
async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
|
||||
async authenticate(
|
||||
credentials: ICredentialDataDecryptedObject,
|
||||
requestOptions: IHttpRequestOptions,
|
||||
): Promise<IHttpRequestOptions> {
|
||||
// @ts-ignore
|
||||
const url = requestOptions.url ? requestOptions.url : requestOptions.uri;
|
||||
if (url.includes('track') || url.includes('api.customer.io')) {
|
||||
const basicAuthKey = Buffer.from(`${credentials.trackingSiteId}:${credentials.trackingApiKey}`).toString('base64');
|
||||
const basicAuthKey = Buffer.from(
|
||||
`${credentials.trackingSiteId}:${credentials.trackingApiKey}`,
|
||||
).toString('base64');
|
||||
// @ts-ignore
|
||||
Object.assign(requestOptions.headers, { 'Authorization': `Basic ${basicAuthKey}` });
|
||||
Object.assign(requestOptions.headers, { Authorization: `Basic ${basicAuthKey}` });
|
||||
} else if (url.includes('beta-api.customer.io')) {
|
||||
// @ts-ignore
|
||||
Object.assign(requestOptions.headers, { 'Authorization': `Bearer ${credentials.appApiKey as string}` });
|
||||
Object.assign(requestOptions.headers, {
|
||||
Authorization: `Bearer ${credentials.appApiKey as string}`,
|
||||
});
|
||||
} else {
|
||||
throw new Error('Unknown way of authenticating');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user