1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-09-20 01:19:07 +03:00

🎨 Centralize error throwing for encryption keys and credentials (#3105)

* Centralized error throwing for encryption key

* Unifying the error message used by cli and core packages

* Improvements to error messages to make it more DRY

* Removed unnecessary throw

* Throwing error when credential does not exist to simplify node behavior (#3112)

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
Omar Ajoue 2022-04-15 08:00:47 +02:00 committed by GitHub
parent 17b0cd8f76
commit d3fecb9f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
227 changed files with 348 additions and 848 deletions

View File

@ -123,9 +123,6 @@ export class ExportCredentialsCommand extends Command {
if (flags.decrypted) {
const encryptionKey = await UserSettings.getEncryptionKey();
if (encryptionKey === undefined) {
throw new Error('No encryption key got found to decrypt the credentials!');
}
for (let i = 0; i < credentials.length; i++) {
const { name, type, nodesAccess, data } = credentials[i];

View File

@ -85,9 +85,6 @@ export class ImportCredentialsCommand extends Command {
await UserSettings.prepareUserSettings();
const encryptionKey = await UserSettings.getEncryptionKey();
if (encryptionKey === undefined) {
throw new Error('No encryption key found to encrypt the credentials!');
}
if (flags.separate) {
const files = await glob(

View File

@ -33,7 +33,6 @@ import {
} from '../src';
import { getLogger } from '../src/Logger';
import { RESPONSE_ERROR_MESSAGES } from '../src/constants';
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
const open = require('open');
@ -173,9 +172,6 @@ export class Start extends Command {
// If we don't have a JWT secret set, generate
// one based and save to config.
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
throw new Error('Fatal error setting up user management: no encryption key set.');
}
// For a key off every other letter from encryption key
// CAREFUL: do not change this or it breaks all existing tokens.
@ -210,11 +206,7 @@ export class Start extends Command {
// Wait till the database is ready
await startDbInitPromise;
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
throw new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY);
}
await UserSettings.getEncryptionKey();
// Load settings from database and set them to config.
const databaseSettings = await Db.collections.Settings.find({ loadOnStartup: true });

View File

@ -1703,13 +1703,11 @@ class App {
);
}
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
throw new ResponseHelper.ResponseError(
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
undefined,
500,
);
let encryptionKey: string;
try {
encryptionKey = await UserSettings.getEncryptionKey();
} catch (error) {
throw new ResponseHelper.ResponseError(error.message, undefined, 500);
}
const mode: WorkflowExecuteMode = 'internal';
@ -1842,15 +1840,11 @@ class App {
return ResponseHelper.sendErrorResponse(res, errorResponse);
}
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
const errorResponse = new ResponseHelper.ResponseError(
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
undefined,
503,
);
return ResponseHelper.sendErrorResponse(res, errorResponse);
let encryptionKey: string;
try {
encryptionKey = await UserSettings.getEncryptionKey();
} catch (error) {
throw new ResponseHelper.ResponseError(error.message, undefined, 500);
}
const mode: WorkflowExecuteMode = 'internal';
@ -1962,13 +1956,11 @@ class App {
);
}
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
throw new ResponseHelper.ResponseError(
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
undefined,
500,
);
let encryptionKey: string;
try {
encryptionKey = await UserSettings.getEncryptionKey();
} catch (error) {
throw new ResponseHelper.ResponseError(error.message, undefined, 500);
}
const mode: WorkflowExecuteMode = 'internal';
@ -2103,15 +2095,11 @@ class App {
return ResponseHelper.sendErrorResponse(res, errorResponse);
}
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
const errorResponse = new ResponseHelper.ResponseError(
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
undefined,
503,
);
return ResponseHelper.sendErrorResponse(res, errorResponse);
let encryptionKey: string;
try {
encryptionKey = await UserSettings.getEncryptionKey();
} catch (error) {
throw new ResponseHelper.ResponseError(error.message, undefined, 500);
}
const mode: WorkflowExecuteMode = 'internal';

View File

@ -66,6 +66,7 @@ import {
getWorkflowOwner,
} from './UserManagement/UserManagementHelper';
import { whereClause } from './WorkflowHelpers';
import { RESPONSE_ERROR_MESSAGES } from './constants';
const ERROR_TRIGGER_TYPE = config.getEnv('nodes.errorTriggerType');
@ -1030,9 +1031,6 @@ export async function getBase(
const webhookTestBaseUrl = urlBaseWebhook + config.getEnv('endpoints.webhookTest');
const encryptionKey = await UserSettings.getEncryptionKey();
if (encryptionKey === undefined) {
throw new Error('No encryption key got found to decrypt the credentials!');
}
return {
credentialsHelper: new CredentialsHelper(encryptionKey),

View File

@ -115,13 +115,15 @@ credentialsController.post(
ResponseHelper.send(async (req: CredentialRequest.Test): Promise<INodeCredentialTestResult> => {
const { credentials, nodeToTestWith } = req.body;
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
return {
status: 'Error',
message: RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
};
let encryptionKey: string;
try {
encryptionKey = await UserSettings.getEncryptionKey();
} catch (error) {
throw new ResponseHelper.ResponseError(
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
undefined,
500,
);
}
const helper = new CredentialsHelper(encryptionKey);
@ -149,9 +151,10 @@ credentialsController.post(
nodeAccess.date = new Date();
}
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
let encryptionKey: string;
try {
encryptionKey = await UserSettings.getEncryptionKey();
} catch (error) {
throw new ResponseHelper.ResponseError(
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
undefined,
@ -285,9 +288,10 @@ credentialsController.patch(
}
}
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
let encryptionKey: string;
try {
encryptionKey = await UserSettings.getEncryptionKey();
} catch (error) {
throw new ResponseHelper.ResponseError(
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
undefined,
@ -393,9 +397,10 @@ credentialsController.get(
const { data, id, ...rest } = credential;
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
let encryptionKey: string;
try {
encryptionKey = await UserSettings.getEncryptionKey();
} catch (error) {
throw new ResponseHelper.ResponseError(
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
undefined,

View File

@ -1,8 +1,12 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/naming-convention */
import { RESPONSE_ERROR_MESSAGES as CORE_RESPONSE_ERROR_MESSAGES } from 'n8n-core';
export const RESPONSE_ERROR_MESSAGES = {
NO_CREDENTIAL: 'Credential not found',
NO_ENCRYPTION_KEY: 'Encryption key missing to decrypt credentials',
NO_ENCRYPTION_KEY: CORE_RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
};
export const AUTH_COOKIE_NAME = 'n8n-auth';

View File

@ -7,6 +7,7 @@ import type { CredentialPayload, SaveCredentialFunction } from './shared/types';
import type { Role } from '../../src/databases/entities/Role';
import type { User } from '../../src/databases/entities/User';
import * as testDb from './shared/testDb';
import { RESPONSE_ERROR_MESSAGES } from '../../src/constants';
import { CredentialsEntity } from '../../src/databases/entities/CredentialsEntity';
jest.mock('../../src/telemetry');
@ -91,7 +92,7 @@ test('POST /credentials should fail with invalid inputs', async () => {
test('POST /credentials should fail with missing encryption key', async () => {
const mock = jest.spyOn(UserSettings, 'getEncryptionKey');
mock.mockResolvedValue(undefined);
mock.mockRejectedValue(new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY));
const ownerShell = await testDb.createUserShell(globalOwnerRole);
const authOwnerAgent = utils.createAgent(app, { auth: true, user: ownerShell });
@ -354,7 +355,8 @@ test('PATCH /credentials/:id should fail if cred not found', async () => {
test('PATCH /credentials/:id should fail with missing encryption key', async () => {
const mock = jest.spyOn(UserSettings, 'getEncryptionKey');
mock.mockResolvedValue(undefined);
mock.mockRejectedValue(new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY));
const ownerShell = await testDb.createUserShell(globalOwnerRole);
const authOwnerAgent = utils.createAgent(app, { auth: true, user: ownerShell });
@ -504,7 +506,8 @@ test('GET /credentials/:id should fail with missing encryption key', async () =>
const savedCredential = await saveCredential(credentialPayload(), { user: ownerShell });
const mock = jest.spyOn(UserSettings, 'getEncryptionKey');
mock.mockResolvedValue(undefined);
mock.mockRejectedValue(new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY));
const response = await authOwnerAgent
.get(`/credentials/${savedCredential.id}`)

View File

@ -392,10 +392,6 @@ export const getMySqlOptions = ({ name }: { name: string }): ConnectionOptions =
async function encryptCredentialData(credential: CredentialsEntity) {
const encryptionKey = await UserSettings.getEncryptionKey();
if (!encryptionKey) {
throw new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY);
}
const coreCredential = new Credentials(
{ id: null, name: credential.name },
credential.type,

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention */
export const BINARY_ENCODING = 'base64';
export const CUSTOM_EXTENSION_ENV = 'N8N_CUSTOM_EXTENSIONS';
export const ENCRYPTION_KEY_ENV_OVERWRITE = 'N8N_ENCRYPTION_KEY';
@ -9,3 +10,7 @@ export const PLACEHOLDER_EMPTY_EXECUTION_ID = '__UNKOWN__';
export const PLACEHOLDER_EMPTY_WORKFLOW_ID = '__EMPTY__';
export const TUNNEL_SUBDOMAIN_ENV = 'N8N_TUNNEL_SUBDOMAIN';
export const WAIT_TIME_UNLIMITED = '3000-01-01T00:00:00.000Z';
export const RESPONSE_ERROR_MESSAGES = {
NO_ENCRYPTION_KEY: 'Encryption key is missing or was not set',
};

View File

@ -874,13 +874,7 @@ export async function requestOAuth2(
oAuth2Options?: IOAuth2Options,
isN8nRequest = false,
) {
const credentials = (await this.getCredentials(
credentialsType,
)) as ICredentialDataDecryptedObject;
if (credentials === undefined) {
throw new Error('No credentials were returned!');
}
const credentials = await this.getCredentials(credentialsType);
if (credentials.oauthTokenData === undefined) {
throw new Error('OAuth credentials not connected!');
@ -997,9 +991,7 @@ export async function requestOAuth1(
| IHttpRequestOptions,
isN8nRequest = false,
) {
const credentials = (await this.getCredentials(
credentialsType,
)) as ICredentialDataDecryptedObject;
const credentials = await this.getCredentials(credentialsType);
if (credentials === undefined) {
throw new Error('No credentials were returned!');
@ -1269,7 +1261,7 @@ export async function getCredentials(
runIndex?: number,
connectionInputData?: INodeExecutionData[],
itemIndex?: number,
): Promise<ICredentialDataDecryptedObject | undefined> {
): Promise<ICredentialDataDecryptedObject> {
// Get the NodeType as it has the information if the credentials are required
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
if (nodeType === undefined) {
@ -1309,8 +1301,8 @@ export async function getCredentials(
node.parameters,
)
) {
// Credentials should not be displayed so return undefined even if they would be defined
return undefined;
// Credentials should not be displayed even if they would be defined
throw new NodeOperationError(node, 'Credentials not found');
}
}
@ -1327,15 +1319,15 @@ export async function getCredentials(
throw new NodeOperationError(node, `Node does not have any credentials set for "${type}"!`);
}
} else {
// Credentials are not required so resolve with undefined
return undefined;
// Credentials are not required
throw new NodeOperationError(node, 'Node does not require credentials');
}
}
if (fullAccess && (!node.credentials || !node.credentials[type])) {
// Make sure that fullAccess nodes still behave like before that if they
// request access to credentials that are currently not set it returns undefined
return undefined;
throw new NodeOperationError(node, 'Credentials not found');
}
let expressionResolveValues: ICredentialsExpressionResolveValues | undefined;
@ -1605,7 +1597,7 @@ export function getExecutePollFunctions(
__emit: (data: INodeExecutionData[][]): void => {
throw new Error('Overwrite NodeExecuteFunctions.getExecutePullFunctions.__emit function!');
},
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject> {
return getCredentials(workflow, node, type, additionalData, mode);
},
getMode: (): WorkflowExecuteMode => {
@ -1759,7 +1751,7 @@ export function getExecuteTriggerFunctions(
emitError: (error: Error): void => {
throw new Error('Overwrite NodeExecuteFunctions.getExecuteTriggerFunctions.emit function!');
},
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject> {
return getCredentials(workflow, node, type, additionalData, mode);
},
getNode: () => {
@ -1949,7 +1941,7 @@ export function getExecuteFunctions(
async getCredentials(
type: string,
itemIndex?: number,
): Promise<ICredentialDataDecryptedObject | undefined> {
): Promise<ICredentialDataDecryptedObject> {
return getCredentials(
workflow,
node,
@ -2193,7 +2185,7 @@ export function getExecuteSingleFunctions(
getContext(type: string): IContextObject {
return NodeHelpers.getContext(runExecutionData, type, node);
},
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject> {
return getCredentials(
workflow,
node,
@ -2389,7 +2381,7 @@ export function getLoadOptionsFunctions(
): ILoadOptionsFunctions {
return ((workflow: Workflow, node: INode, path: string) => {
const that = {
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject> {
return getCredentials(workflow, node, type, additionalData, 'internal');
},
getCurrentNodeParameter: (
@ -2533,7 +2525,7 @@ export function getExecuteHookFunctions(
): IHookFunctions {
return ((workflow: Workflow, node: INode) => {
const that = {
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject> {
return getCredentials(workflow, node, type, additionalData, mode);
},
getMode: (): WorkflowExecuteMode => {
@ -2692,7 +2684,7 @@ export function getExecuteWebhookFunctions(
}
return additionalData.httpRequest.body;
},
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject> {
return getCredentials(workflow, node, type, additionalData, mode);
},
getHeaderData(): object {

View File

@ -10,6 +10,7 @@ import {
ENCRYPTION_KEY_ENV_OVERWRITE,
EXTENSIONS_SUBDIRECTORY,
IUserSettings,
RESPONSE_ERROR_MESSAGES,
USER_FOLDER_ENV_OVERWRITE,
USER_SETTINGS_FILE_NAME,
USER_SETTINGS_SUBFOLDER,
@ -73,19 +74,15 @@ export async function prepareUserSettings(): Promise<IUserSettings> {
* @returns
*/
export async function getEncryptionKey(): Promise<string | undefined> {
export async function getEncryptionKey(): Promise<string> {
if (process.env[ENCRYPTION_KEY_ENV_OVERWRITE] !== undefined) {
return process.env[ENCRYPTION_KEY_ENV_OVERWRITE];
return process.env[ENCRYPTION_KEY_ENV_OVERWRITE] as string;
}
const userSettings = await getUserSettings();
if (userSettings === undefined) {
return undefined;
}
if (userSettings.encryptionKey === undefined) {
return undefined;
if (userSettings === undefined || userSettings.encryptionKey === undefined) {
throw new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY);
}
return userSettings.encryptionKey;

View File

@ -27,9 +27,6 @@ export interface IProduct {
*/
export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, dataKey?: string): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('activeCampaignApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
if (query === undefined) {
query = {};

View File

@ -26,9 +26,6 @@ export async function acuitySchedulingApiRequest(this: IHookFunctions | IExecute
try {
if (authenticationMethod === 'apiKey') {
const credentials = await this.getCredentials('acuitySchedulingApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
options.auth = {
user: credentials.userId as string,

View File

@ -20,10 +20,6 @@ export async function affinityApiRequest(this: IExecuteFunctions | IWebhookFunct
const credentials = await this.getCredentials('affinityApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const apiKey = `:${credentials.apiKey}`;
const endpoint = 'https://api.affinity.co';

View File

@ -12,7 +12,7 @@ import {
NodeApiError,
} from 'n8n-workflow';
import {
import {
IContactUpdate,
} from './ContactInterface';
@ -31,11 +31,11 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction
'Accept': 'application/json',
},
auth: {
username: credentials!.email as string,
password: credentials!.apiKey as string,
username: credentials.email as string,
password: credentials.apiKey as string,
},
qs: query,
uri: uri || `https://${credentials!.subdomain}.agilecrm.com/dev/${endpoint}`,
uri: uri || `https://${credentials.subdomain}.agilecrm.com/dev/${endpoint}`,
json: true,
};
@ -83,7 +83,7 @@ export async function agileCrmApiRequestAllItems(this: IHookFunctions | ILoadOpt
export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method = 'PUT', endpoint?: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('agileCrmApi');
const baseUri = `https://${credentials!.subdomain}.agilecrm.com/dev/`;
const baseUri = `https://${credentials.subdomain}.agilecrm.com/dev/`;
const options: OptionsWithUri = {
method,
headers: {
@ -91,8 +91,8 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu
},
body: { id: body.id },
auth: {
username: credentials!.email as string,
password: credentials!.apiKey as string,
username: credentials.email as string,
password: credentials.apiKey as string,
},
uri: uri || baseUri,
json: true,

View File

@ -42,10 +42,6 @@ export interface IRecord {
export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, endpoint: string, body: object, query?: IDataObject, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('airtableApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
query = query || {};
// For some reason for some endpoints the bearer auth does not work

View File

@ -98,9 +98,6 @@ export class Amqp implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
try {
const credentials = await this.getCredentials('amqp');
if (!credentials) {
throw new NodeOperationError(this.getNode(), 'Credentials are mandatory!');
}
const sink = this.getNodeParameter('sink', 0, '') as string;
const applicationProperties = this.getNodeParameter('headerParametersJson', 0, {}) as string | object;

View File

@ -132,9 +132,6 @@ export class AmqpTrigger implements INodeType {
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
const credentials = await this.getCredentials('amqp');
if (!credentials) {
throw new NodeOperationError(this.getNode(), 'Credentials are mandatory!');
}
const sink = this.getNodeParameter('sink', '') as string;
const clientname = this.getNodeParameter('clientname', '') as string;

View File

@ -40,9 +40,6 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
// Concatenate path and instantiate URL object so it parses correctly query strings
const endpoint = new URL(getEndpointForService(service, credentials) + path);

View File

@ -37,9 +37,6 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: object | IRequestBody, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new Error('No credentials got returned!');
}
// Concatenate path and instantiate URL object so it parses correctly query strings
const endpoint = new URL(getEndpointForService(service, credentials) + path);

View File

@ -30,9 +30,6 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
// Concatenate path and instantiate URL object so it parses correctly query strings
const endpoint = new URL(getEndpointForService(service, credentials) + path);

View File

@ -38,9 +38,6 @@ import {
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer | IDataObject, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const endpoint = new URL(((credentials.rekognitionEndpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);

View File

@ -137,7 +137,7 @@ export class AwsS3 implements INodeType {
if (additionalFields.grantWriteAcp) {
headers['x-amz-grant-write-acp'] = '';
}
let region = credentials!.region as string;
let region = credentials.region as string;
if (additionalFields.region) {
region = additionalFields.region as string;

View File

@ -32,9 +32,6 @@ import {
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const endpoint = new URL(((credentials.s3Endpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);

View File

@ -32,9 +32,6 @@ import {
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const endpoint = new URL(((credentials.sesEndpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);

View File

@ -43,9 +43,6 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
// Concatenate path and instantiate URL object so it parses correctly query strings
const endpoint = new URL(getEndpointForService(service, credentials) + path);
@ -69,7 +66,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
const errorMessage = error?.response?.data || error?.response?.body;
if (errorMessage.includes('AccessDeniedException')) {
const user = JSON.parse(errorMessage).Message.split(' ')[1];
throw new NodeApiError(this.getNode(), error, {
throw new NodeApiError(this.getNode(), error, {
message: 'Unauthorized — please check your AWS policy configuration',
description: `Make sure an identity-based policy allows user ${user} to perform textract:AnalyzeExpense` });
}

View File

@ -43,9 +43,6 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
// Concatenate path and instantiate URL object so it parses correctly query strings
const endpoint = new URL(getEndpointForService(service, credentials) + path);

View File

@ -27,10 +27,6 @@ export async function apiRequest(
) {
const credentials = await this.getCredentials('bambooHrApi');
if (!credentials) {
throw new NodeOperationError(this.getNode(), 'No credentials returned!');
}
//set-up credentials
const apiKey = credentials.apiKey;
const subdomain = credentials.subdomain;

View File

@ -23,10 +23,6 @@ export async function bannerbearApiRequest(this: IExecuteFunctions | IWebhookFun
const credentials = await this.getCredentials('bannerbearApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const options: OptionsWithUri = {
headers: {
Accept: 'application/json',

View File

@ -32,10 +32,6 @@ export async function baserowApiRequest(
) {
const credentials = await this.getCredentials('baserowApi') as BaserowCredentials;
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const options: OptionsWithUri = {
headers: {
Authorization: `JWT ${jwtToken}`,

View File

@ -18,10 +18,6 @@ import {
export async function createDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
const credentials = await this.getCredentials('beeminderApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`;
return await beeminderApiRequest.call(this, 'POST', endpoint, data);
@ -30,10 +26,6 @@ export async function createDatapoint(this: IExecuteFunctions | IWebhookFunction
export async function getAllDatapoints(this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
const credentials = await this.getCredentials('beeminderApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`;
if (data.count !== undefined) {
@ -46,10 +38,6 @@ export async function getAllDatapoints(this: IExecuteFunctions | IHookFunctions
export async function updateDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
const credentials = await this.getCredentials('beeminderApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`;
return await beeminderApiRequest.call(this, 'PUT', endpoint, data);
@ -58,10 +46,6 @@ export async function updateDatapoint(this: IExecuteFunctions | IWebhookFunction
export async function deleteDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
const credentials = await this.getCredentials('beeminderApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`;
return await beeminderApiRequest.call(this, 'DELETE', endpoint);

View File

@ -307,10 +307,6 @@ export class Beeminder implements INodeType {
const credentials = await this.getCredentials('beeminderApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const endpoint = `/users/${credentials.user}/goals.json`;
const returnData: INodePropertyOptions[] = [];

View File

@ -9,9 +9,6 @@ import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
export async function bitbucketApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('bitbucketApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
method,
auth: {

View File

@ -31,9 +31,6 @@ export async function bitlyApiRequest(this: IHookFunctions | IExecuteFunctions |
try{
if (authenticationMethod === 'accessToken') {
const credentials = await this.getCredentials('bitlyApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
options.headers = { Authorization: `Bearer ${credentials.accessToken}`};
return await this.helpers.request!(options);

View File

@ -61,7 +61,7 @@ export async function getAccessToken(
this: IExecuteFunctions | ILoadOptionsFunctions,
): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('bitwardenApi') as IDataObject;
const credentials = await this.getCredentials('bitwardenApi');
const options: OptionsWithUri = {
headers: {
@ -116,7 +116,7 @@ export async function handleGetAll(
* Return the access token URL based on the user's environment.
*/
async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
const { environment, domain } = await this.getCredentials('bitwardenApi') as IDataObject;
const { environment, domain } = await this.getCredentials('bitwardenApi');
return environment === 'cloudHosted'
? 'https://identity.bitwarden.com/connect/token'
@ -128,7 +128,7 @@ export async function handleGetAll(
* Return the base API URL based on the user's environment.
*/
async function getBaseUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
const { environment, domain } = await this.getCredentials('bitwardenApi') as IDataObject;
const { environment, domain } = await this.getCredentials('bitwardenApi');
return environment === 'cloudHosted'
? 'https://api.bitwarden.com'

View File

@ -16,9 +16,6 @@ import {
export async function brandfetchApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
try {
const credentials = await this.getCredentials('brandfetchApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
headers: {
'x-api-key': credentials.apiKey,

View File

@ -17,10 +17,6 @@ export async function calendlyApiRequest(this: IExecuteFunctions | IWebhookFunct
const credentials = await this.getCredentials('calendlyApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const endpoint = 'https://calendly.com/api/v1';
let options: OptionsWithUri = {

View File

@ -489,10 +489,6 @@ export class Chargebee implements INodeType {
const credentials = await this.getCredentials('chargebeeApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const baseUrl = `https://${credentials.accountName}.chargebee.com/api/v2`;
// For Post

View File

@ -15,9 +15,6 @@ import {
export async function circleciApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('circleCiApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
headers: {
'Circle-Token': credentials.apiKey,

View File

@ -601,9 +601,6 @@ export class CiscoWebexTrigger implements INodeType {
const resource = this.getNodeParameter('resource') as string;
const filters = this.getNodeParameter('filters', {}) as IDataObject;
const credentials = await this.getCredentials('ciscoWebexOAuth2Api');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'Credentials could not be obtained');
}
const secret = getAutomaticSecret(credentials);
const filter = [];
for (const key of Object.keys(filters)) {

View File

@ -13,9 +13,6 @@ import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, api: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('clearbitApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
headers: { Authorization: `Bearer ${credentials.apiKey}` },
method,

View File

@ -36,7 +36,7 @@ export async function clickupApiRequest(this: IHookFunctions | IExecuteFunctions
const credentials = await this.getCredentials('clickUpApi');
options.headers!['Authorization'] = credentials?.accessToken;
options.headers!['Authorization'] = credentials.accessToken;
return await this.helpers.request!(options);
} else {

View File

@ -15,11 +15,6 @@ import {
export async function clockifyApiRequest(this: ILoadOptionsFunctions | IPollFunctions | IExecuteFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('clockifyApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const BASE_URL = 'https://api.clockify.me/api/v1';
const options: OptionsWithUri = {

View File

@ -8,11 +8,6 @@ import { OptionsWithUri } from 'request';
export async function cockpitApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('cockpitApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials available.');
}
let options: OptionsWithUri = {
headers: {
Accept: 'application/json',

View File

@ -8,9 +8,6 @@ import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
export async function codaApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('codaApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
headers: { 'Authorization': `Bearer ${credentials.accessToken}`},

View File

@ -15,10 +15,6 @@ import {
export async function contentfulApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('contentfulApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const source = this.getNodeParameter('source', 0) as string;
const isPreview = source === 'previewApi';

View File

@ -20,10 +20,6 @@ export async function convertKitApiRequest(this: IExecuteFunctions | IExecuteSin
const credentials = await this.getCredentials('convertKitApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
headers: {
'Content-Type': 'application/json',

View File

@ -134,7 +134,7 @@ export class CopperTrigger implements INodeType {
const credentials = await this.getCredentials('copperApi');
body.secret = {
secret: getAutomaticSecret(credentials!),
secret: getAutomaticSecret(credentials),
};
const { id } = await copperApiRequest.call(this, 'POST', endpoint, body);
@ -160,7 +160,7 @@ export class CopperTrigger implements INodeType {
const req = this.getRequestObject();
// Check if the supplied secret matches. If not ignore request.
if (req.body.secret !== getAutomaticSecret(credentials!)) {
if (req.body.secret !== getAutomaticSecret(credentials)) {
return {};
}

View File

@ -25,10 +25,6 @@ export async function cortexApiRequest(this: IHookFunctions | IExecuteFunctions
const credentials = await this.getCredentials('cortexApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const headerWithAuthentication = Object.assign({}, { Authorization: ` Bearer ${credentials.cortexApiKey}` });
let options: OptionsWithUri = {

View File

@ -253,10 +253,6 @@ export class CrateDb implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const credentials = await this.getCredentials('crateDb');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const pgp = pgPromise();
const config = {

View File

@ -19,10 +19,6 @@ import {
export async function customerIoApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, baseApi?: string, query?: IDataObject): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('customerIoApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
query = query || {};
const options: OptionsWithUri = {

View File

@ -27,10 +27,6 @@ export async function deepLApiRequest(
const credentials = await this.getCredentials('deepLApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const options: OptionsWithUri = {
headers: {
'Content-Type': 'application/json',
@ -53,10 +49,6 @@ export async function deepLApiRequest(
const credentials = await this.getCredentials('deepLApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
options.qs.auth_key = credentials.apiKey;
return await this.helpers.request!(options);

View File

@ -16,9 +16,6 @@ import {
export async function demioApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
try {
const credentials = await this.getCredentials('demioApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
headers: {
'Api-Key': credentials.apiKey,

View File

@ -14,7 +14,7 @@ import {
export async function discourseApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('discourseApi') as IDataObject;
const credentials = await this.getCredentials('discourseApi');
const options: OptionsWithUri = {
headers: {

View File

@ -18,9 +18,6 @@ export async function disqusApiRequest(
const credentials = await this.getCredentials('disqusApi') as IDataObject;
qs.api_key = credentials.accessToken;
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
// Convert to query string into a format the API can read
const queryStringElements: string[] = [];

View File

@ -37,10 +37,6 @@ export async function driftApiRequest(this: IExecuteFunctions | IWebhookFunction
if (authenticationMethod === 'accessToken') {
const credentials = await this.getCredentials('driftApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
return await this.helpers.request!(options);

View File

@ -27,10 +27,6 @@ export async function erpNextApiRequest(
const credentials = await this.getCredentials('erpNextApi') as ERPNextApiCredentials;
const baseUrl = getBaseUrl(credentials);
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
headers: {
'Accept': 'application/json',

View File

@ -35,7 +35,7 @@ export async function getFields(this: IExecuteFunctions, listId: string) {
export async function egoiApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('egoiApi') as IDataObject;
const credentials = await this.getCredentials('egoiApi');
const options: OptionsWithUrl = {
headers: {

View File

@ -179,10 +179,6 @@ export class EmailReadImap implements INodeType {
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
const credentials = await this.getCredentials('imap');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const mailbox = this.getNodeParameter('mailbox') as string;
const postProcessAction = this.getNodeParameter('postProcessAction') as string;
const options = this.getNodeParameter('options', {}) as IDataObject;

View File

@ -146,10 +146,6 @@ export class EmailSend implements INodeType {
const credentials = await this.getCredentials('smtp');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const connectionOptions: SMTPTransport.Options = {
host: credentials.host as string,
port: credentials.port as number,

View File

@ -33,9 +33,6 @@ export async function eventbriteApiRequest(this: IHookFunctions | IExecuteFuncti
try {
if (authenticationMethod === 'privateKey') {
const credentials = await this.getCredentials('eventbriteApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
options.headers!['Authorization'] = `Bearer ${credentials.apiKey}`;
return await this.helpers.request!(options);

View File

@ -247,7 +247,7 @@ export class FacebookTrigger implements INodeType {
const res = this.getResponseObject();
const req = this.getRequestObject();
const headerData = this.getHeaderData() as IDataObject;
const credentials = await this.getCredentials('facebookGraphAppApi') as IDataObject;
const credentials = await this.getCredentials('facebookGraphAppApi');
// Check if we're getting facebook's challenge request (https://developers.facebook.com/docs/graph-api/webhooks/getting-started)
if (this.getWebhookName() === 'setup') {
if (query['hub.challenge']) {

View File

@ -23,9 +23,9 @@ export async function facebookApiRequest(this: IHookFunctions | IExecuteFunction
let credentials;
if (this.getNode().name.includes('Trigger')) {
credentials = await this.getCredentials('facebookGraphAppApi') as IDataObject;
credentials = await this.getCredentials('facebookGraphAppApi');
} else {
credentials = await this.getCredentials('facebookGraphApi') as IDataObject;
credentials = await this.getCredentials('facebookGraphApi');
}
qs.access_token = credentials!.accessToken;
@ -550,4 +550,4 @@ export function getFields(object: string) {
export function getAllFields(object: string) {
return getFields(object).filter((field: IDataObject) => field.value !== '*').map((field: IDataObject) => field.value);
}
}

View File

@ -15,7 +15,7 @@ import {
} from 'n8n-workflow';
export async function figmaApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('figmaApi') as { accessToken: string };
const credentials = await this.getCredentials('figmaApi');
let options: OptionsWithUri = {
headers: { 'X-FIGMA-TOKEN': credentials.accessToken },

View File

@ -774,10 +774,6 @@ export class FileMaker implements INodeType {
const credentials = await this.getCredentials('fileMaker');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let token;
try {
token = await getToken.call(this);

View File

@ -41,9 +41,6 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu
const token = await getToken.call(this);
const credentials = await this.getCredentials('fileMaker');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const host = credentials.host as string;
const db = credentials.db as string;
@ -92,9 +89,6 @@ export async function getFields(this: ILoadOptionsFunctions): Promise<any> { //
const credentials = await this.getCredentials('fileMaker');
const layout = this.getCurrentNodeParameter('layout') as string;
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const host = credentials.host as string;
const db = credentials.db as string;
@ -128,9 +122,6 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise<any> { //
const credentials = await this.getCredentials('fileMaker');
const layout = this.getCurrentNodeParameter('layout') as string;
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const host = credentials.host as string;
const db = credentials.db as string;
@ -163,9 +154,6 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { //
const token = await getToken.call(this);
const credentials = await this.getCredentials('fileMaker');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const host = credentials.host as string;
const db = credentials.db as string;
@ -208,9 +196,6 @@ function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] {
export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('fileMaker');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const host = credentials.host as string;
const db = credentials.db as string;
@ -257,9 +242,6 @@ export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions |
export async function logout(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions, token: string): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('fileMaker');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const host = credentials.host as string;
const db = credentials.db as string;

View File

@ -64,10 +64,6 @@ export class Flow implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const credentials = await this.getCredentials('flowApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const items = this.getInputData();
const returnData: IDataObject[] = [];
const length = items.length as unknown as number;

View File

@ -110,10 +110,6 @@ export class FlowTrigger implements INodeType {
async checkExists(this: IHookFunctions): Promise<boolean> {
const credentials = await this.getCredentials('flowApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let webhooks;
const qs: IDataObject = {};
const webhookData = this.getWorkflowStaticData('node');
@ -144,10 +140,6 @@ export class FlowTrigger implements INodeType {
async create(this: IHookFunctions): Promise<boolean> {
const credentials = await this.getCredentials('flowApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let resourceIds, body, responseData;
const webhookUrl = this.getNodeWebhookUrl('default');
const webhookData = this.getWorkflowStaticData('node');
@ -188,10 +180,6 @@ export class FlowTrigger implements INodeType {
async delete(this: IHookFunctions): Promise<boolean> {
const credentials = await this.getCredentials('flowApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const qs: IDataObject = {};
const webhookData = this.getWorkflowStaticData('node');
qs.organization_id = credentials.organizationId as number;

View File

@ -9,9 +9,6 @@ import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
export async function flowApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('flowApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
headers: { 'Authorization': `Bearer ${credentials.accessToken}`},

View File

@ -78,10 +78,6 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
if (authenticationMethod === 'accessToken') {
const credentials = await this.getCredentials('formstackApi') as IDataObject;
if (credentials === undefined) {
throw new Error('No credentials got returned!');
}
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
return await this.helpers.request!(options);
} else {

View File

@ -16,10 +16,6 @@ export async function freshdeskApiRequest(this: IExecuteFunctions | ILoadOptions
const credentials = await this.getCredentials('freshdeskApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const apiKey = `${credentials.apiKey}:X`;
const endpoint = 'freshdesk.com/api/v2';

View File

@ -403,10 +403,6 @@ export class Ftp implements INodeType {
}
try {
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'Failed to get credentials!');
}
let ftp: ftpClient;
let sftp: sftpClient;

View File

@ -34,7 +34,7 @@ export async function getresponseApiRequest(this: IWebhookFunctions | IHookFunct
}
if (authentication === 'apiKey') {
const credentials = await this.getCredentials('getResponseApi') as IDataObject;
const credentials = await this.getCredentials('getResponseApi');
options!.headers!['X-Auth-Token'] = `api-key ${credentials.apiKey}`;
//@ts-ignore
return await this.helpers.request.call(this, options);

View File

@ -26,11 +26,11 @@ export async function ghostApiRequest(this: IHookFunctions | IExecuteFunctions |
if (source === 'contentApi') {
//https://ghost.org/faq/api-versioning/
version = 'v3';
credentials = await this.getCredentials('ghostContentApi') as IDataObject;
credentials = await this.getCredentials('ghostContentApi');
query.key = credentials.apiKey as string;
} else {
version = 'v2';
credentials = await this.getCredentials('ghostAdminApi') as IDataObject;
credentials = await this.getCredentials('ghostAdminApi');
// Create the token (including decoding secret)
const [id, secret] = (credentials.apiKey as string).split(':');

View File

@ -209,7 +209,7 @@ export class Git implements INodeType {
const authentication = this.getNodeParameter('authentication', 0) as string;
if (authentication === 'gitPassword') {
const gitCredentials = await this.getCredentials('gitPassword') as IDataObject;
const gitCredentials = await this.getCredentials('gitPassword');
const url = new URL(repositoryPath);
url.username = gitCredentials.username as string;

View File

@ -40,9 +40,6 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions,
if (authenticationMethod === 'accessToken') {
const credentials = await this.getCredentials('githubApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const baseUrl = credentials!.server || 'https://api.github.com';
options.uri = `${baseUrl}${endpoint}`;
@ -52,7 +49,7 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions,
} else {
const credentials = await this.getCredentials('githubOAuth2Api');
const baseUrl = credentials!.server || 'https://api.github.com';
const baseUrl = credentials.server || 'https://api.github.com';
options.uri = `${baseUrl}${endpoint}`;
//@ts-ignore
return await this.helpers.requestOAuth2.call(this, 'githubOAuth2Api', options);

View File

@ -40,9 +40,6 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
try {
if (authenticationMethod === 'accessToken') {
const credentials = await this.getCredentials('gitlabApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
options.headers!['Private-Token'] = `${credentials.accessToken}`;
@ -51,9 +48,6 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
return await this.helpers.request(options);
} else {
const credentials = await this.getCredentials('gitlabOAuth2Api');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
options.uri = `${(credentials.server as string).replace(/\/$/, '')}/api/v4${endpoint}`;

View File

@ -1101,16 +1101,8 @@ export class Gitlab implements INodeType {
try {
if (authenticationMethod === 'accessToken') {
credentials = await this.getCredentials('gitlabApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
} else {
credentials = await this.getCredentials('gitlabOAuth2Api');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
}
} catch (error) {
if (this.continueOnFail()) {

View File

@ -49,10 +49,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
privateKey: string;
};
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
options.headers!.Authorization = `Bearer ${access_token}`;

View File

@ -57,10 +57,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
} else{
const credentials = await this.getCredentials('googleApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
options.headers!.Authorization = `Bearer ${access_token}`;
//@ts-ignore

View File

@ -53,10 +53,6 @@ export async function googleApiRequest(
if (authenticationMethod === 'serviceAccount') {
const credentials = await this.getCredentials('googleApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
options.headers!.Authorization = `Bearer ${access_token}`;

View File

@ -50,10 +50,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
if (authenticationMethod === 'serviceAccount') {
const credentials = await this.getCredentials('googleApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
options.headers!.Authorization = `Bearer ${access_token}`;

View File

@ -65,10 +65,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
if (authenticationMethod === 'serviceAccount') {
const credentials = await this.getCredentials('googleApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
options.headers!.Authorization = `Bearer ${access_token}`;

View File

@ -47,10 +47,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
if (authenticationMethod === 'serviceAccount') {
const credentials = await this.getCredentials('googleApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
options.headers!.Authorization = `Bearer ${access_token}`;

View File

@ -56,10 +56,6 @@ export async function googleApiRequest(
if (authenticationMethod === 'serviceAccount') {
const credentials = await this.getCredentials('googleApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
options.headers.Authorization = `Bearer ${access_token}`;
return await this.helpers.request!(options);

View File

@ -46,10 +46,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
if (authenticationMethod === 'serviceAccount') {
const credentials = await this.getCredentials('googleApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
options.headers!.Authorization = `Bearer ${access_token}`;

View File

@ -14,7 +14,7 @@ import {
export async function gotifyApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, uri?: string | undefined, option = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('gotifyApi') as IDataObject;
const credentials = await this.getCredentials('gotifyApi');
const options: OptionsWithUri = {
method,

View File

@ -305,12 +305,44 @@ export class GraphQL implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const httpBasicAuth = await this.getCredentials('httpBasicAuth');
const httpDigestAuth = await this.getCredentials('httpDigestAuth');
const httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
const httpQueryAuth = await this.getCredentials('httpQueryAuth');
const oAuth1Api = await this.getCredentials('oAuth1Api');
const oAuth2Api = await this.getCredentials('oAuth2Api');
let httpBasicAuth;
let httpDigestAuth;
let httpHeaderAuth;
let httpQueryAuth;
let oAuth1Api;
let oAuth2Api;
try {
httpBasicAuth = await this.getCredentials('httpBasicAuth');
} catch(error) {
// Do nothing
}
try {
httpDigestAuth = await this.getCredentials('httpDigestAuth');
} catch(error) {
// Do nothing
}
try {
httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
} catch(error) {
// Do nothing
}
try {
httpQueryAuth = await this.getCredentials('httpQueryAuth');
} catch(error) {
// Do nothing
}
try {
oAuth1Api = await this.getCredentials('oAuth1Api');
} catch(error) {
// Do nothing
}
try {
oAuth2Api = await this.getCredentials('oAuth2Api');
} catch(error) {
// Do nothing
}
let requestOptions: OptionsWithUri & RequestPromiseOptions;

View File

@ -10,9 +10,6 @@ import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
export async function gumroadApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('gumroadApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
body = Object.assign({ access_token: credentials.accessToken }, body);
let options: OptionsWithUri = {

View File

@ -28,7 +28,7 @@ interface IHaloPSATokens {
export async function getAccessTokens(
this: IExecuteFunctions | ILoadOptionsFunctions,
): Promise<IHaloPSATokens> {
const credentials = (await this.getCredentials('haloPSAApi')) as IDataObject;
const credentials = await this.getCredentials('haloPSAApi');
const options: OptionsWithUri = {
headers: {
@ -67,7 +67,7 @@ export async function haloPSAApiRequest(
qs: IDataObject = {},
option: IDataObject = {},
): Promise<any> { // tslint:disable-line:no-any
const resourceApiUrl = ((await this.getCredentials('haloPSAApi')) as IDataObject)
const resourceApiUrl = (await this.getCredentials('haloPSAApi'))
.resourceApiUrl as string;
try {

View File

@ -35,11 +35,7 @@ export async function harvestApiRequest(this: IHookFunctions | IExecuteFunctions
try {
if (authenticationMethod === 'accessToken') {
const credentials = await this.getCredentials('harvestApi') as IDataObject;
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const credentials = await this.getCredentials('harvestApi');
//@ts-ignore
options.headers['Authorization'] = `Bearer ${credentials.accessToken}`;

View File

@ -17,10 +17,6 @@ import {
export async function homeAssistantApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}) {
const credentials = await this.getCredentials('homeAssistantApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
headers: {
Authorization: `Bearer ${credentials.accessToken}`,

View File

@ -658,12 +658,43 @@ export class HttpRequest implements INodeType {
const parametersAreJson = this.getNodeParameter('jsonParameters', 0) as boolean;
const responseFormat = this.getNodeParameter('responseFormat', 0) as string;
const httpBasicAuth = await this.getCredentials('httpBasicAuth');
const httpDigestAuth = await this.getCredentials('httpDigestAuth');
const httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
const httpQueryAuth = await this.getCredentials('httpQueryAuth');
const oAuth1Api = await this.getCredentials('oAuth1Api');
const oAuth2Api = await this.getCredentials('oAuth2Api');
let httpBasicAuth;
let httpDigestAuth;
let httpHeaderAuth;
let httpQueryAuth;
let oAuth1Api;
let oAuth2Api;
try {
httpBasicAuth = await this.getCredentials('httpBasicAuth');
} catch (error) {
// Do nothing
}
try {
httpDigestAuth = await this.getCredentials('httpDigestAuth');
} catch (error) {
// Do nothing
}
try {
httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
} catch (error) {
// Do nothing
}
try {
httpQueryAuth = await this.getCredentials('httpQueryAuth');
} catch (error) {
// Do nothing
}
try {
oAuth1Api = await this.getCredentials('oAuth1Api');
} catch (error) {
// Do nothing
}
try {
oAuth2Api = await this.getCredentials('oAuth2Api');
} catch (error) {
// Do nothing
}
let requestOptions: OptionsWithUri;
let setUiParameter: IDataObject;

View File

@ -41,18 +41,18 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions
if (authenticationMethod === 'apiKey') {
const credentials = await this.getCredentials('hubspotApi');
options.qs.hapikey = credentials!.apiKey as string;
options.qs.hapikey = credentials.apiKey as string;
return await this.helpers.request!(options);
} else if (authenticationMethod === 'appToken') {
const credentials = await this.getCredentials('hubspotAppToken');
options.headers!['Authorization'] = `Bearer ${credentials!.appToken}`;
options.headers!['Authorization'] = `Bearer ${credentials.appToken}`;
return await this.helpers.request!(options);
} else if (authenticationMethod === 'developerApi') {
if (endpoint.includes('webhooks')) {
const credentials = await this.getCredentials('hubspotDeveloperApi');
options.qs.hapikey = credentials!.apiKey as string;
options.qs.hapikey = credentials.apiKey as string;
return await this.helpers.request!(options);
} else {

View File

@ -282,7 +282,7 @@ export class HubspotTrigger implements INodeType {
// Check all the webhooks which exist already if it is identical to the
// one that is supposed to get created.
const currentWebhookUrl = this.getNodeWebhookUrl('default') as string;
const { appId } = await this.getCredentials('hubspotDeveloperApi') as IDataObject;
const { appId } = await this.getCredentials('hubspotDeveloperApi');
try {
const { targetUrl } = await hubspotApiRequest.call(this, 'GET', `/webhooks/v3/${appId}/settings`, {});
@ -309,7 +309,7 @@ export class HubspotTrigger implements INodeType {
},
async create(this: IHookFunctions): Promise<boolean> {
const webhookUrl = this.getNodeWebhookUrl('default');
const { appId } = await this.getCredentials('hubspotDeveloperApi') as IDataObject;
const { appId } = await this.getCredentials('hubspotDeveloperApi');
const events = (this.getNodeParameter('eventsUi') as IDataObject || {}).eventValues as IDataObject[] || [];
const additionalFields = this.getNodeParameter('additionalFields') as IDataObject;
let endpoint = `/webhooks/v3/${appId}/settings`;
@ -341,7 +341,7 @@ export class HubspotTrigger implements INodeType {
return true;
},
async delete(this: IHookFunctions): Promise<boolean> {
const { appId } = await this.getCredentials('hubspotDeveloperApi') as IDataObject;
const { appId } = await this.getCredentials('hubspotDeveloperApi');
const { results: subscriptions } = await hubspotApiRequest.call(this, 'GET', `/webhooks/v3/${appId}/subscriptions`, {});
@ -361,7 +361,7 @@ export class HubspotTrigger implements INodeType {
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const credentials = await this.getCredentials('hubspotDeveloperApi') as IDataObject;
const credentials = await this.getCredentials('hubspotDeveloperApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials found!');

View File

@ -16,9 +16,6 @@ import {
export async function humanticAiApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
try {
const credentials = await this.getCredentials('humanticAiApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
let options: OptionsWithUri = {
headers: {
'Content-Type': 'application/json',

View File

@ -9,9 +9,6 @@ import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow';
export async function hunterApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('hunterApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
qs = Object.assign({ api_key: credentials.apiKey }, qs);
let options: OptionsWithUri = {
method,

View File

@ -13,9 +13,6 @@ import {
export async function intercomApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('intercomApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const headerWithAuthentication = Object.assign({},
{ Authorization: `Bearer ${credentials.apiKey}`, Accept: 'application/json' });

View File

@ -19,9 +19,6 @@ import {
export async function invoiceNinjaApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query?: IDataObject, uri?: string): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('invoiceNinjaApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
const baseUrl = credentials!.url || 'https://app.invoiceninja.com';
const options: OptionsWithUri = {

Some files were not shown because too many files have changed in this diff Show More