mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08: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:
parent
17b0cd8f76
commit
d3fecb9f6d
|
@ -123,9 +123,6 @@ export class ExportCredentialsCommand extends Command {
|
||||||
|
|
||||||
if (flags.decrypted) {
|
if (flags.decrypted) {
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
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++) {
|
for (let i = 0; i < credentials.length; i++) {
|
||||||
const { name, type, nodesAccess, data } = credentials[i];
|
const { name, type, nodesAccess, data } = credentials[i];
|
||||||
|
|
|
@ -85,9 +85,6 @@ export class ImportCredentialsCommand extends Command {
|
||||||
await UserSettings.prepareUserSettings();
|
await UserSettings.prepareUserSettings();
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
const encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
if (encryptionKey === undefined) {
|
|
||||||
throw new Error('No encryption key found to encrypt the credentials!');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags.separate) {
|
if (flags.separate) {
|
||||||
const files = await glob(
|
const files = await glob(
|
||||||
|
|
|
@ -33,7 +33,6 @@ import {
|
||||||
} from '../src';
|
} from '../src';
|
||||||
|
|
||||||
import { getLogger } from '../src/Logger';
|
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
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
||||||
const open = require('open');
|
const open = require('open');
|
||||||
|
@ -173,9 +172,6 @@ export class Start extends Command {
|
||||||
// If we don't have a JWT secret set, generate
|
// If we don't have a JWT secret set, generate
|
||||||
// one based and save to config.
|
// one based and save to config.
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
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
|
// For a key off every other letter from encryption key
|
||||||
// CAREFUL: do not change this or it breaks all existing tokens.
|
// 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
|
// Wait till the database is ready
|
||||||
await startDbInitPromise;
|
await startDbInitPromise;
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
await UserSettings.getEncryptionKey();
|
||||||
|
|
||||||
if (!encryptionKey) {
|
|
||||||
throw new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load settings from database and set them to config.
|
// Load settings from database and set them to config.
|
||||||
const databaseSettings = await Db.collections.Settings.find({ loadOnStartup: true });
|
const databaseSettings = await Db.collections.Settings.find({ loadOnStartup: true });
|
||||||
|
|
|
@ -1703,13 +1703,11 @@ class App {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
let encryptionKey: string;
|
||||||
if (!encryptionKey) {
|
try {
|
||||||
throw new ResponseHelper.ResponseError(
|
encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
} catch (error) {
|
||||||
undefined,
|
throw new ResponseHelper.ResponseError(error.message, undefined, 500);
|
||||||
500,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mode: WorkflowExecuteMode = 'internal';
|
const mode: WorkflowExecuteMode = 'internal';
|
||||||
|
@ -1842,15 +1840,11 @@ class App {
|
||||||
return ResponseHelper.sendErrorResponse(res, errorResponse);
|
return ResponseHelper.sendErrorResponse(res, errorResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
let encryptionKey: string;
|
||||||
|
try {
|
||||||
if (!encryptionKey) {
|
encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
const errorResponse = new ResponseHelper.ResponseError(
|
} catch (error) {
|
||||||
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
throw new ResponseHelper.ResponseError(error.message, undefined, 500);
|
||||||
undefined,
|
|
||||||
503,
|
|
||||||
);
|
|
||||||
return ResponseHelper.sendErrorResponse(res, errorResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mode: WorkflowExecuteMode = 'internal';
|
const mode: WorkflowExecuteMode = 'internal';
|
||||||
|
@ -1962,13 +1956,11 @@ class App {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
let encryptionKey: string;
|
||||||
if (!encryptionKey) {
|
try {
|
||||||
throw new ResponseHelper.ResponseError(
|
encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
} catch (error) {
|
||||||
undefined,
|
throw new ResponseHelper.ResponseError(error.message, undefined, 500);
|
||||||
500,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mode: WorkflowExecuteMode = 'internal';
|
const mode: WorkflowExecuteMode = 'internal';
|
||||||
|
@ -2103,15 +2095,11 @@ class App {
|
||||||
return ResponseHelper.sendErrorResponse(res, errorResponse);
|
return ResponseHelper.sendErrorResponse(res, errorResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
let encryptionKey: string;
|
||||||
|
try {
|
||||||
if (!encryptionKey) {
|
encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
const errorResponse = new ResponseHelper.ResponseError(
|
} catch (error) {
|
||||||
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
throw new ResponseHelper.ResponseError(error.message, undefined, 500);
|
||||||
undefined,
|
|
||||||
503,
|
|
||||||
);
|
|
||||||
return ResponseHelper.sendErrorResponse(res, errorResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mode: WorkflowExecuteMode = 'internal';
|
const mode: WorkflowExecuteMode = 'internal';
|
||||||
|
|
|
@ -66,6 +66,7 @@ import {
|
||||||
getWorkflowOwner,
|
getWorkflowOwner,
|
||||||
} from './UserManagement/UserManagementHelper';
|
} from './UserManagement/UserManagementHelper';
|
||||||
import { whereClause } from './WorkflowHelpers';
|
import { whereClause } from './WorkflowHelpers';
|
||||||
|
import { RESPONSE_ERROR_MESSAGES } from './constants';
|
||||||
|
|
||||||
const ERROR_TRIGGER_TYPE = config.getEnv('nodes.errorTriggerType');
|
const ERROR_TRIGGER_TYPE = config.getEnv('nodes.errorTriggerType');
|
||||||
|
|
||||||
|
@ -1030,9 +1031,6 @@ export async function getBase(
|
||||||
const webhookTestBaseUrl = urlBaseWebhook + config.getEnv('endpoints.webhookTest');
|
const webhookTestBaseUrl = urlBaseWebhook + config.getEnv('endpoints.webhookTest');
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
const encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
if (encryptionKey === undefined) {
|
|
||||||
throw new Error('No encryption key got found to decrypt the credentials!');
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
credentialsHelper: new CredentialsHelper(encryptionKey),
|
credentialsHelper: new CredentialsHelper(encryptionKey),
|
||||||
|
|
|
@ -115,13 +115,15 @@ credentialsController.post(
|
||||||
ResponseHelper.send(async (req: CredentialRequest.Test): Promise<INodeCredentialTestResult> => {
|
ResponseHelper.send(async (req: CredentialRequest.Test): Promise<INodeCredentialTestResult> => {
|
||||||
const { credentials, nodeToTestWith } = req.body;
|
const { credentials, nodeToTestWith } = req.body;
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
let encryptionKey: string;
|
||||||
|
try {
|
||||||
if (!encryptionKey) {
|
encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
return {
|
} catch (error) {
|
||||||
status: 'Error',
|
throw new ResponseHelper.ResponseError(
|
||||||
message: RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
||||||
};
|
undefined,
|
||||||
|
500,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const helper = new CredentialsHelper(encryptionKey);
|
const helper = new CredentialsHelper(encryptionKey);
|
||||||
|
@ -149,9 +151,10 @@ credentialsController.post(
|
||||||
nodeAccess.date = new Date();
|
nodeAccess.date = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
let encryptionKey: string;
|
||||||
|
try {
|
||||||
if (!encryptionKey) {
|
encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
|
} catch (error) {
|
||||||
throw new ResponseHelper.ResponseError(
|
throw new ResponseHelper.ResponseError(
|
||||||
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -285,9 +288,10 @@ credentialsController.patch(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
let encryptionKey: string;
|
||||||
|
try {
|
||||||
if (!encryptionKey) {
|
encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
|
} catch (error) {
|
||||||
throw new ResponseHelper.ResponseError(
|
throw new ResponseHelper.ResponseError(
|
||||||
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -393,9 +397,10 @@ credentialsController.get(
|
||||||
|
|
||||||
const { data, id, ...rest } = credential;
|
const { data, id, ...rest } = credential;
|
||||||
|
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
let encryptionKey: string;
|
||||||
|
try {
|
||||||
if (!encryptionKey) {
|
encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
|
} catch (error) {
|
||||||
throw new ResponseHelper.ResponseError(
|
throw new ResponseHelper.ResponseError(
|
||||||
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY,
|
||||||
undefined,
|
undefined,
|
||||||
|
|
|
@ -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 */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
|
import { RESPONSE_ERROR_MESSAGES as CORE_RESPONSE_ERROR_MESSAGES } from 'n8n-core';
|
||||||
|
|
||||||
export const RESPONSE_ERROR_MESSAGES = {
|
export const RESPONSE_ERROR_MESSAGES = {
|
||||||
NO_CREDENTIAL: 'Credential not found',
|
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';
|
export const AUTH_COOKIE_NAME = 'n8n-auth';
|
||||||
|
|
|
@ -7,6 +7,7 @@ import type { CredentialPayload, SaveCredentialFunction } from './shared/types';
|
||||||
import type { Role } from '../../src/databases/entities/Role';
|
import type { Role } from '../../src/databases/entities/Role';
|
||||||
import type { User } from '../../src/databases/entities/User';
|
import type { User } from '../../src/databases/entities/User';
|
||||||
import * as testDb from './shared/testDb';
|
import * as testDb from './shared/testDb';
|
||||||
|
import { RESPONSE_ERROR_MESSAGES } from '../../src/constants';
|
||||||
import { CredentialsEntity } from '../../src/databases/entities/CredentialsEntity';
|
import { CredentialsEntity } from '../../src/databases/entities/CredentialsEntity';
|
||||||
|
|
||||||
jest.mock('../../src/telemetry');
|
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 () => {
|
test('POST /credentials should fail with missing encryption key', async () => {
|
||||||
const mock = jest.spyOn(UserSettings, 'getEncryptionKey');
|
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 ownerShell = await testDb.createUserShell(globalOwnerRole);
|
||||||
const authOwnerAgent = utils.createAgent(app, { auth: true, user: ownerShell });
|
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 () => {
|
test('PATCH /credentials/:id should fail with missing encryption key', async () => {
|
||||||
const mock = jest.spyOn(UserSettings, 'getEncryptionKey');
|
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 ownerShell = await testDb.createUserShell(globalOwnerRole);
|
||||||
const authOwnerAgent = utils.createAgent(app, { auth: true, user: ownerShell });
|
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 savedCredential = await saveCredential(credentialPayload(), { user: ownerShell });
|
||||||
|
|
||||||
const mock = jest.spyOn(UserSettings, 'getEncryptionKey');
|
const mock = jest.spyOn(UserSettings, 'getEncryptionKey');
|
||||||
mock.mockResolvedValue(undefined);
|
mock.mockRejectedValue(new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY));
|
||||||
|
|
||||||
|
|
||||||
const response = await authOwnerAgent
|
const response = await authOwnerAgent
|
||||||
.get(`/credentials/${savedCredential.id}`)
|
.get(`/credentials/${savedCredential.id}`)
|
||||||
|
|
|
@ -392,10 +392,6 @@ export const getMySqlOptions = ({ name }: { name: string }): ConnectionOptions =
|
||||||
async function encryptCredentialData(credential: CredentialsEntity) {
|
async function encryptCredentialData(credential: CredentialsEntity) {
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
const encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
|
|
||||||
if (!encryptionKey) {
|
|
||||||
throw new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
const coreCredential = new Credentials(
|
const coreCredential = new Credentials(
|
||||||
{ id: null, name: credential.name },
|
{ id: null, name: credential.name },
|
||||||
credential.type,
|
credential.type,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
export const BINARY_ENCODING = 'base64';
|
export const BINARY_ENCODING = 'base64';
|
||||||
export const CUSTOM_EXTENSION_ENV = 'N8N_CUSTOM_EXTENSIONS';
|
export const CUSTOM_EXTENSION_ENV = 'N8N_CUSTOM_EXTENSIONS';
|
||||||
export const ENCRYPTION_KEY_ENV_OVERWRITE = 'N8N_ENCRYPTION_KEY';
|
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 PLACEHOLDER_EMPTY_WORKFLOW_ID = '__EMPTY__';
|
||||||
export const TUNNEL_SUBDOMAIN_ENV = 'N8N_TUNNEL_SUBDOMAIN';
|
export const TUNNEL_SUBDOMAIN_ENV = 'N8N_TUNNEL_SUBDOMAIN';
|
||||||
export const WAIT_TIME_UNLIMITED = '3000-01-01T00:00:00.000Z';
|
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',
|
||||||
|
};
|
||||||
|
|
|
@ -874,13 +874,7 @@ export async function requestOAuth2(
|
||||||
oAuth2Options?: IOAuth2Options,
|
oAuth2Options?: IOAuth2Options,
|
||||||
isN8nRequest = false,
|
isN8nRequest = false,
|
||||||
) {
|
) {
|
||||||
const credentials = (await this.getCredentials(
|
const credentials = await this.getCredentials(credentialsType);
|
||||||
credentialsType,
|
|
||||||
)) as ICredentialDataDecryptedObject;
|
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new Error('No credentials were returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (credentials.oauthTokenData === undefined) {
|
if (credentials.oauthTokenData === undefined) {
|
||||||
throw new Error('OAuth credentials not connected!');
|
throw new Error('OAuth credentials not connected!');
|
||||||
|
@ -997,9 +991,7 @@ export async function requestOAuth1(
|
||||||
| IHttpRequestOptions,
|
| IHttpRequestOptions,
|
||||||
isN8nRequest = false,
|
isN8nRequest = false,
|
||||||
) {
|
) {
|
||||||
const credentials = (await this.getCredentials(
|
const credentials = await this.getCredentials(credentialsType);
|
||||||
credentialsType,
|
|
||||||
)) as ICredentialDataDecryptedObject;
|
|
||||||
|
|
||||||
if (credentials === undefined) {
|
if (credentials === undefined) {
|
||||||
throw new Error('No credentials were returned!');
|
throw new Error('No credentials were returned!');
|
||||||
|
@ -1269,7 +1261,7 @@ export async function getCredentials(
|
||||||
runIndex?: number,
|
runIndex?: number,
|
||||||
connectionInputData?: INodeExecutionData[],
|
connectionInputData?: INodeExecutionData[],
|
||||||
itemIndex?: number,
|
itemIndex?: number,
|
||||||
): Promise<ICredentialDataDecryptedObject | undefined> {
|
): Promise<ICredentialDataDecryptedObject> {
|
||||||
// Get the NodeType as it has the information if the credentials are required
|
// Get the NodeType as it has the information if the credentials are required
|
||||||
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
const nodeType = workflow.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
||||||
if (nodeType === undefined) {
|
if (nodeType === undefined) {
|
||||||
|
@ -1309,8 +1301,8 @@ export async function getCredentials(
|
||||||
node.parameters,
|
node.parameters,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
// Credentials should not be displayed so return undefined even if they would be defined
|
// Credentials should not be displayed even if they would be defined
|
||||||
return undefined;
|
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}"!`);
|
throw new NodeOperationError(node, `Node does not have any credentials set for "${type}"!`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Credentials are not required so resolve with undefined
|
// Credentials are not required
|
||||||
return undefined;
|
throw new NodeOperationError(node, 'Node does not require credentials');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullAccess && (!node.credentials || !node.credentials[type])) {
|
if (fullAccess && (!node.credentials || !node.credentials[type])) {
|
||||||
// Make sure that fullAccess nodes still behave like before that if they
|
// Make sure that fullAccess nodes still behave like before that if they
|
||||||
// request access to credentials that are currently not set it returns undefined
|
// 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;
|
let expressionResolveValues: ICredentialsExpressionResolveValues | undefined;
|
||||||
|
@ -1605,7 +1597,7 @@ export function getExecutePollFunctions(
|
||||||
__emit: (data: INodeExecutionData[][]): void => {
|
__emit: (data: INodeExecutionData[][]): void => {
|
||||||
throw new Error('Overwrite NodeExecuteFunctions.getExecutePullFunctions.__emit function!');
|
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);
|
return getCredentials(workflow, node, type, additionalData, mode);
|
||||||
},
|
},
|
||||||
getMode: (): WorkflowExecuteMode => {
|
getMode: (): WorkflowExecuteMode => {
|
||||||
|
@ -1759,7 +1751,7 @@ export function getExecuteTriggerFunctions(
|
||||||
emitError: (error: Error): void => {
|
emitError: (error: Error): void => {
|
||||||
throw new Error('Overwrite NodeExecuteFunctions.getExecuteTriggerFunctions.emit function!');
|
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);
|
return getCredentials(workflow, node, type, additionalData, mode);
|
||||||
},
|
},
|
||||||
getNode: () => {
|
getNode: () => {
|
||||||
|
@ -1949,7 +1941,7 @@ export function getExecuteFunctions(
|
||||||
async getCredentials(
|
async getCredentials(
|
||||||
type: string,
|
type: string,
|
||||||
itemIndex?: number,
|
itemIndex?: number,
|
||||||
): Promise<ICredentialDataDecryptedObject | undefined> {
|
): Promise<ICredentialDataDecryptedObject> {
|
||||||
return getCredentials(
|
return getCredentials(
|
||||||
workflow,
|
workflow,
|
||||||
node,
|
node,
|
||||||
|
@ -2193,7 +2185,7 @@ export function getExecuteSingleFunctions(
|
||||||
getContext(type: string): IContextObject {
|
getContext(type: string): IContextObject {
|
||||||
return NodeHelpers.getContext(runExecutionData, type, node);
|
return NodeHelpers.getContext(runExecutionData, type, node);
|
||||||
},
|
},
|
||||||
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
|
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject> {
|
||||||
return getCredentials(
|
return getCredentials(
|
||||||
workflow,
|
workflow,
|
||||||
node,
|
node,
|
||||||
|
@ -2389,7 +2381,7 @@ export function getLoadOptionsFunctions(
|
||||||
): ILoadOptionsFunctions {
|
): ILoadOptionsFunctions {
|
||||||
return ((workflow: Workflow, node: INode, path: string) => {
|
return ((workflow: Workflow, node: INode, path: string) => {
|
||||||
const that = {
|
const that = {
|
||||||
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
|
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject> {
|
||||||
return getCredentials(workflow, node, type, additionalData, 'internal');
|
return getCredentials(workflow, node, type, additionalData, 'internal');
|
||||||
},
|
},
|
||||||
getCurrentNodeParameter: (
|
getCurrentNodeParameter: (
|
||||||
|
@ -2533,7 +2525,7 @@ export function getExecuteHookFunctions(
|
||||||
): IHookFunctions {
|
): IHookFunctions {
|
||||||
return ((workflow: Workflow, node: INode) => {
|
return ((workflow: Workflow, node: INode) => {
|
||||||
const that = {
|
const that = {
|
||||||
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
|
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject> {
|
||||||
return getCredentials(workflow, node, type, additionalData, mode);
|
return getCredentials(workflow, node, type, additionalData, mode);
|
||||||
},
|
},
|
||||||
getMode: (): WorkflowExecuteMode => {
|
getMode: (): WorkflowExecuteMode => {
|
||||||
|
@ -2692,7 +2684,7 @@ export function getExecuteWebhookFunctions(
|
||||||
}
|
}
|
||||||
return additionalData.httpRequest.body;
|
return additionalData.httpRequest.body;
|
||||||
},
|
},
|
||||||
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
|
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject> {
|
||||||
return getCredentials(workflow, node, type, additionalData, mode);
|
return getCredentials(workflow, node, type, additionalData, mode);
|
||||||
},
|
},
|
||||||
getHeaderData(): object {
|
getHeaderData(): object {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
ENCRYPTION_KEY_ENV_OVERWRITE,
|
ENCRYPTION_KEY_ENV_OVERWRITE,
|
||||||
EXTENSIONS_SUBDIRECTORY,
|
EXTENSIONS_SUBDIRECTORY,
|
||||||
IUserSettings,
|
IUserSettings,
|
||||||
|
RESPONSE_ERROR_MESSAGES,
|
||||||
USER_FOLDER_ENV_OVERWRITE,
|
USER_FOLDER_ENV_OVERWRITE,
|
||||||
USER_SETTINGS_FILE_NAME,
|
USER_SETTINGS_FILE_NAME,
|
||||||
USER_SETTINGS_SUBFOLDER,
|
USER_SETTINGS_SUBFOLDER,
|
||||||
|
@ -73,19 +74,15 @@ export async function prepareUserSettings(): Promise<IUserSettings> {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export async function getEncryptionKey(): Promise<string | undefined> {
|
export async function getEncryptionKey(): Promise<string> {
|
||||||
if (process.env[ENCRYPTION_KEY_ENV_OVERWRITE] !== undefined) {
|
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();
|
const userSettings = await getUserSettings();
|
||||||
|
|
||||||
if (userSettings === undefined) {
|
if (userSettings === undefined || userSettings.encryptionKey === undefined) {
|
||||||
return undefined;
|
throw new Error(RESPONSE_ERROR_MESSAGES.NO_ENCRYPTION_KEY);
|
||||||
}
|
|
||||||
|
|
||||||
if (userSettings.encryptionKey === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return userSettings.encryptionKey;
|
return userSettings.encryptionKey;
|
||||||
|
|
|
@ -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
|
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');
|
const credentials = await this.getCredentials('activeCampaignApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query === undefined) {
|
if (query === undefined) {
|
||||||
query = {};
|
query = {};
|
||||||
|
|
|
@ -26,9 +26,6 @@ export async function acuitySchedulingApiRequest(this: IHookFunctions | IExecute
|
||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'apiKey') {
|
if (authenticationMethod === 'apiKey') {
|
||||||
const credentials = await this.getCredentials('acuitySchedulingApi');
|
const credentials = await this.getCredentials('acuitySchedulingApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
options.auth = {
|
options.auth = {
|
||||||
user: credentials.userId as string,
|
user: credentials.userId as string,
|
||||||
|
|
|
@ -20,10 +20,6 @@ export async function affinityApiRequest(this: IExecuteFunctions | IWebhookFunct
|
||||||
|
|
||||||
const credentials = await this.getCredentials('affinityApi');
|
const credentials = await this.getCredentials('affinityApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const apiKey = `:${credentials.apiKey}`;
|
const apiKey = `:${credentials.apiKey}`;
|
||||||
|
|
||||||
const endpoint = 'https://api.affinity.co';
|
const endpoint = 'https://api.affinity.co';
|
||||||
|
|
|
@ -31,11 +31,11 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
username: credentials!.email as string,
|
username: credentials.email as string,
|
||||||
password: credentials!.apiKey as string,
|
password: credentials.apiKey as string,
|
||||||
},
|
},
|
||||||
qs: query,
|
qs: query,
|
||||||
uri: uri || `https://${credentials!.subdomain}.agilecrm.com/dev/${endpoint}`,
|
uri: uri || `https://${credentials.subdomain}.agilecrm.com/dev/${endpoint}`,
|
||||||
json: true,
|
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
|
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 credentials = await this.getCredentials('agileCrmApi');
|
||||||
const baseUri = `https://${credentials!.subdomain}.agilecrm.com/dev/`;
|
const baseUri = `https://${credentials.subdomain}.agilecrm.com/dev/`;
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -91,8 +91,8 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu
|
||||||
},
|
},
|
||||||
body: { id: body.id },
|
body: { id: body.id },
|
||||||
auth: {
|
auth: {
|
||||||
username: credentials!.email as string,
|
username: credentials.email as string,
|
||||||
password: credentials!.apiKey as string,
|
password: credentials.apiKey as string,
|
||||||
},
|
},
|
||||||
uri: uri || baseUri,
|
uri: uri || baseUri,
|
||||||
json: true,
|
json: true,
|
||||||
|
|
|
@ -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
|
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');
|
const credentials = await this.getCredentials('airtableApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
query = query || {};
|
query = query || {};
|
||||||
|
|
||||||
// For some reason for some endpoints the bearer auth does not work
|
// For some reason for some endpoints the bearer auth does not work
|
||||||
|
|
|
@ -98,9 +98,6 @@ export class Amqp implements INodeType {
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
try {
|
try {
|
||||||
const credentials = await this.getCredentials('amqp');
|
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 sink = this.getNodeParameter('sink', 0, '') as string;
|
||||||
const applicationProperties = this.getNodeParameter('headerParametersJson', 0, {}) as string | object;
|
const applicationProperties = this.getNodeParameter('headerParametersJson', 0, {}) as string | object;
|
||||||
|
|
|
@ -132,9 +132,6 @@ export class AmqpTrigger implements INodeType {
|
||||||
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
|
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
|
||||||
|
|
||||||
const credentials = await this.getCredentials('amqp');
|
const credentials = await this.getCredentials('amqp');
|
||||||
if (!credentials) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'Credentials are mandatory!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const sink = this.getNodeParameter('sink', '') as string;
|
const sink = this.getNodeParameter('sink', '') as string;
|
||||||
const clientname = this.getNodeParameter('clientname', '') as string;
|
const clientname = this.getNodeParameter('clientname', '') as string;
|
||||||
|
|
|
@ -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
|
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');
|
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
|
// Concatenate path and instantiate URL object so it parses correctly query strings
|
||||||
const endpoint = new URL(getEndpointForService(service, credentials) + path);
|
const endpoint = new URL(getEndpointForService(service, credentials) + path);
|
||||||
|
|
|
@ -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
|
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');
|
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
|
// Concatenate path and instantiate URL object so it parses correctly query strings
|
||||||
const endpoint = new URL(getEndpointForService(service, credentials) + path);
|
const endpoint = new URL(getEndpointForService(service, credentials) + path);
|
||||||
|
|
|
@ -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
|
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');
|
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
|
// Concatenate path and instantiate URL object so it parses correctly query strings
|
||||||
const endpoint = new URL(getEndpointForService(service, credentials) + path);
|
const endpoint = new URL(getEndpointForService(service, credentials) + path);
|
||||||
|
|
|
@ -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
|
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');
|
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);
|
const endpoint = new URL(((credentials.rekognitionEndpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ export class AwsS3 implements INodeType {
|
||||||
if (additionalFields.grantWriteAcp) {
|
if (additionalFields.grantWriteAcp) {
|
||||||
headers['x-amz-grant-write-acp'] = '';
|
headers['x-amz-grant-write-acp'] = '';
|
||||||
}
|
}
|
||||||
let region = credentials!.region as string;
|
let region = credentials.region as string;
|
||||||
|
|
||||||
if (additionalFields.region) {
|
if (additionalFields.region) {
|
||||||
region = additionalFields.region as string;
|
region = additionalFields.region as string;
|
||||||
|
|
|
@ -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
|
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');
|
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);
|
const endpoint = new URL(((credentials.s3Endpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);
|
||||||
|
|
||||||
|
|
|
@ -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
|
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');
|
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);
|
const endpoint = new URL(((credentials.sesEndpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);
|
||||||
|
|
||||||
|
|
|
@ -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
|
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');
|
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
|
// Concatenate path and instantiate URL object so it parses correctly query strings
|
||||||
const endpoint = new URL(getEndpointForService(service, credentials) + path);
|
const endpoint = new URL(getEndpointForService(service, credentials) + path);
|
||||||
|
|
|
@ -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
|
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');
|
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
|
// Concatenate path and instantiate URL object so it parses correctly query strings
|
||||||
const endpoint = new URL(getEndpointForService(service, credentials) + path);
|
const endpoint = new URL(getEndpointForService(service, credentials) + path);
|
||||||
|
|
|
@ -27,10 +27,6 @@ export async function apiRequest(
|
||||||
) {
|
) {
|
||||||
const credentials = await this.getCredentials('bambooHrApi');
|
const credentials = await this.getCredentials('bambooHrApi');
|
||||||
|
|
||||||
if (!credentials) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
//set-up credentials
|
//set-up credentials
|
||||||
const apiKey = credentials.apiKey;
|
const apiKey = credentials.apiKey;
|
||||||
const subdomain = credentials.subdomain;
|
const subdomain = credentials.subdomain;
|
||||||
|
|
|
@ -23,10 +23,6 @@ export async function bannerbearApiRequest(this: IExecuteFunctions | IWebhookFun
|
||||||
|
|
||||||
const credentials = await this.getCredentials('bannerbearApi');
|
const credentials = await this.getCredentials('bannerbearApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
|
|
|
@ -32,10 +32,6 @@ export async function baserowApiRequest(
|
||||||
) {
|
) {
|
||||||
const credentials = await this.getCredentials('baserowApi') as BaserowCredentials;
|
const credentials = await this.getCredentials('baserowApi') as BaserowCredentials;
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `JWT ${jwtToken}`,
|
Authorization: `JWT ${jwtToken}`,
|
||||||
|
|
|
@ -18,10 +18,6 @@ import {
|
||||||
export async function createDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
|
export async function createDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
|
||||||
const credentials = await this.getCredentials('beeminderApi');
|
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`;
|
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`;
|
||||||
|
|
||||||
return await beeminderApiRequest.call(this, 'POST', endpoint, data);
|
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) {
|
export async function getAllDatapoints(this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
|
||||||
const credentials = await this.getCredentials('beeminderApi');
|
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`;
|
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`;
|
||||||
|
|
||||||
if (data.count !== undefined) {
|
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) {
|
export async function updateDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
|
||||||
const credentials = await this.getCredentials('beeminderApi');
|
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`;
|
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`;
|
||||||
|
|
||||||
return await beeminderApiRequest.call(this, 'PUT', endpoint, data);
|
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) {
|
export async function deleteDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
|
||||||
const credentials = await this.getCredentials('beeminderApi');
|
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`;
|
const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`;
|
||||||
|
|
||||||
return await beeminderApiRequest.call(this, 'DELETE', endpoint);
|
return await beeminderApiRequest.call(this, 'DELETE', endpoint);
|
||||||
|
|
|
@ -307,10 +307,6 @@ export class Beeminder implements INodeType {
|
||||||
|
|
||||||
const credentials = await this.getCredentials('beeminderApi');
|
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 endpoint = `/users/${credentials.user}/goals.json`;
|
||||||
|
|
||||||
const returnData: INodePropertyOptions[] = [];
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
|
|
@ -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
|
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');
|
const credentials = await this.getCredentials('bitbucketApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
method,
|
method,
|
||||||
auth: {
|
auth: {
|
||||||
|
|
|
@ -31,9 +31,6 @@ export async function bitlyApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||||
try{
|
try{
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
const credentials = await this.getCredentials('bitlyApi');
|
const credentials = await this.getCredentials('bitlyApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
options.headers = { Authorization: `Bearer ${credentials.accessToken}`};
|
options.headers = { Authorization: `Bearer ${credentials.accessToken}`};
|
||||||
|
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
|
|
|
@ -61,7 +61,7 @@ export async function getAccessToken(
|
||||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||||
): Promise<any> { // tslint:disable-line:no-any
|
): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
const credentials = await this.getCredentials('bitwardenApi') as IDataObject;
|
const credentials = await this.getCredentials('bitwardenApi');
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -116,7 +116,7 @@ export async function handleGetAll(
|
||||||
* Return the access token URL based on the user's environment.
|
* Return the access token URL based on the user's environment.
|
||||||
*/
|
*/
|
||||||
async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
|
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'
|
return environment === 'cloudHosted'
|
||||||
? 'https://identity.bitwarden.com/connect/token'
|
? '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.
|
* Return the base API URL based on the user's environment.
|
||||||
*/
|
*/
|
||||||
async function getBaseUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
|
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'
|
return environment === 'cloudHosted'
|
||||||
? 'https://api.bitwarden.com'
|
? 'https://api.bitwarden.com'
|
||||||
|
|
|
@ -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
|
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 {
|
try {
|
||||||
const credentials = await this.getCredentials('brandfetchApi');
|
const credentials = await this.getCredentials('brandfetchApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'x-api-key': credentials.apiKey,
|
'x-api-key': credentials.apiKey,
|
||||||
|
|
|
@ -17,10 +17,6 @@ export async function calendlyApiRequest(this: IExecuteFunctions | IWebhookFunct
|
||||||
|
|
||||||
const credentials = await this.getCredentials('calendlyApi');
|
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';
|
const endpoint = 'https://calendly.com/api/v1';
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
|
|
|
@ -489,10 +489,6 @@ export class Chargebee implements INodeType {
|
||||||
|
|
||||||
const credentials = await this.getCredentials('chargebeeApi');
|
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`;
|
const baseUrl = `https://${credentials.accountName}.chargebee.com/api/v2`;
|
||||||
|
|
||||||
// For Post
|
// For Post
|
||||||
|
|
|
@ -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
|
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');
|
const credentials = await this.getCredentials('circleCiApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'Circle-Token': credentials.apiKey,
|
'Circle-Token': credentials.apiKey,
|
||||||
|
|
|
@ -601,9 +601,6 @@ export class CiscoWebexTrigger implements INodeType {
|
||||||
const resource = this.getNodeParameter('resource') as string;
|
const resource = this.getNodeParameter('resource') as string;
|
||||||
const filters = this.getNodeParameter('filters', {}) as IDataObject;
|
const filters = this.getNodeParameter('filters', {}) as IDataObject;
|
||||||
const credentials = await this.getCredentials('ciscoWebexOAuth2Api');
|
const credentials = await this.getCredentials('ciscoWebexOAuth2Api');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'Credentials could not be obtained');
|
|
||||||
}
|
|
||||||
const secret = getAutomaticSecret(credentials);
|
const secret = getAutomaticSecret(credentials);
|
||||||
const filter = [];
|
const filter = [];
|
||||||
for (const key of Object.keys(filters)) {
|
for (const key of Object.keys(filters)) {
|
||||||
|
|
|
@ -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
|
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');
|
const credentials = await this.getCredentials('clearbitApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: { Authorization: `Bearer ${credentials.apiKey}` },
|
headers: { Authorization: `Bearer ${credentials.apiKey}` },
|
||||||
method,
|
method,
|
||||||
|
|
|
@ -36,7 +36,7 @@ export async function clickupApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||||
|
|
||||||
const credentials = await this.getCredentials('clickUpApi');
|
const credentials = await this.getCredentials('clickUpApi');
|
||||||
|
|
||||||
options.headers!['Authorization'] = credentials?.accessToken;
|
options.headers!['Authorization'] = credentials.accessToken;
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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
|
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');
|
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 BASE_URL = 'https://api.clockify.me/api/v1';
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
|
|
|
@ -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
|
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');
|
const credentials = await this.getCredentials('cockpitApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials available.');
|
|
||||||
}
|
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
|
|
|
@ -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
|
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');
|
const credentials = await this.getCredentials('codaApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: { 'Authorization': `Bearer ${credentials.accessToken}`},
|
headers: { 'Authorization': `Bearer ${credentials.accessToken}`},
|
||||||
|
|
|
@ -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
|
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');
|
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 source = this.getNodeParameter('source', 0) as string;
|
||||||
const isPreview = source === 'previewApi';
|
const isPreview = source === 'previewApi';
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,6 @@ export async function convertKitApiRequest(this: IExecuteFunctions | IExecuteSin
|
||||||
|
|
||||||
const credentials = await this.getCredentials('convertKitApi');
|
const credentials = await this.getCredentials('convertKitApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
|
@ -134,7 +134,7 @@ export class CopperTrigger implements INodeType {
|
||||||
|
|
||||||
const credentials = await this.getCredentials('copperApi');
|
const credentials = await this.getCredentials('copperApi');
|
||||||
body.secret = {
|
body.secret = {
|
||||||
secret: getAutomaticSecret(credentials!),
|
secret: getAutomaticSecret(credentials),
|
||||||
};
|
};
|
||||||
|
|
||||||
const { id } = await copperApiRequest.call(this, 'POST', endpoint, body);
|
const { id } = await copperApiRequest.call(this, 'POST', endpoint, body);
|
||||||
|
@ -160,7 +160,7 @@ export class CopperTrigger implements INodeType {
|
||||||
const req = this.getRequestObject();
|
const req = this.getRequestObject();
|
||||||
|
|
||||||
// Check if the supplied secret matches. If not ignore request.
|
// Check if the supplied secret matches. If not ignore request.
|
||||||
if (req.body.secret !== getAutomaticSecret(credentials!)) {
|
if (req.body.secret !== getAutomaticSecret(credentials)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,6 @@ export async function cortexApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||||
|
|
||||||
const credentials = await this.getCredentials('cortexApi');
|
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}` });
|
const headerWithAuthentication = Object.assign({}, { Authorization: ` Bearer ${credentials.cortexApiKey}` });
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
|
|
|
@ -253,10 +253,6 @@ export class CrateDb implements INodeType {
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const credentials = await this.getCredentials('crateDb');
|
const credentials = await this.getCredentials('crateDb');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const pgp = pgPromise();
|
const pgp = pgPromise();
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
|
|
|
@ -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
|
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');
|
const credentials = await this.getCredentials('customerIoApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
query = query || {};
|
query = query || {};
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
|
|
|
@ -27,10 +27,6 @@ export async function deepLApiRequest(
|
||||||
|
|
||||||
const credentials = await this.getCredentials('deepLApi');
|
const credentials = await this.getCredentials('deepLApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -53,10 +49,6 @@ export async function deepLApiRequest(
|
||||||
|
|
||||||
const credentials = await this.getCredentials('deepLApi');
|
const credentials = await this.getCredentials('deepLApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
options.qs.auth_key = credentials.apiKey;
|
options.qs.auth_key = credentials.apiKey;
|
||||||
|
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
|
|
|
@ -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
|
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 {
|
try {
|
||||||
const credentials = await this.getCredentials('demioApi');
|
const credentials = await this.getCredentials('demioApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'Api-Key': credentials.apiKey,
|
'Api-Key': credentials.apiKey,
|
||||||
|
|
|
@ -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
|
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 = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -18,9 +18,6 @@ export async function disqusApiRequest(
|
||||||
|
|
||||||
const credentials = await this.getCredentials('disqusApi') as IDataObject;
|
const credentials = await this.getCredentials('disqusApi') as IDataObject;
|
||||||
qs.api_key = credentials.accessToken;
|
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
|
// Convert to query string into a format the API can read
|
||||||
const queryStringElements: string[] = [];
|
const queryStringElements: string[] = [];
|
||||||
|
|
|
@ -37,10 +37,6 @@ export async function driftApiRequest(this: IExecuteFunctions | IWebhookFunction
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
const credentials = await this.getCredentials('driftApi');
|
const credentials = await this.getCredentials('driftApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
|
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
|
||||||
|
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
|
|
|
@ -27,10 +27,6 @@ export async function erpNextApiRequest(
|
||||||
const credentials = await this.getCredentials('erpNextApi') as ERPNextApiCredentials;
|
const credentials = await this.getCredentials('erpNextApi') as ERPNextApiCredentials;
|
||||||
const baseUrl = getBaseUrl(credentials);
|
const baseUrl = getBaseUrl(credentials);
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
|
|
|
@ -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
|
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 = {
|
const options: OptionsWithUrl = {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -179,10 +179,6 @@ export class EmailReadImap implements INodeType {
|
||||||
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
|
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
|
||||||
const credentials = await this.getCredentials('imap');
|
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 mailbox = this.getNodeParameter('mailbox') as string;
|
||||||
const postProcessAction = this.getNodeParameter('postProcessAction') as string;
|
const postProcessAction = this.getNodeParameter('postProcessAction') as string;
|
||||||
const options = this.getNodeParameter('options', {}) as IDataObject;
|
const options = this.getNodeParameter('options', {}) as IDataObject;
|
||||||
|
|
|
@ -146,10 +146,6 @@ export class EmailSend implements INodeType {
|
||||||
|
|
||||||
const credentials = await this.getCredentials('smtp');
|
const credentials = await this.getCredentials('smtp');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const connectionOptions: SMTPTransport.Options = {
|
const connectionOptions: SMTPTransport.Options = {
|
||||||
host: credentials.host as string,
|
host: credentials.host as string,
|
||||||
port: credentials.port as number,
|
port: credentials.port as number,
|
||||||
|
|
|
@ -33,9 +33,6 @@ export async function eventbriteApiRequest(this: IHookFunctions | IExecuteFuncti
|
||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'privateKey') {
|
if (authenticationMethod === 'privateKey') {
|
||||||
const credentials = await this.getCredentials('eventbriteApi');
|
const credentials = await this.getCredentials('eventbriteApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
options.headers!['Authorization'] = `Bearer ${credentials.apiKey}`;
|
options.headers!['Authorization'] = `Bearer ${credentials.apiKey}`;
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
|
|
|
@ -247,7 +247,7 @@ export class FacebookTrigger implements INodeType {
|
||||||
const res = this.getResponseObject();
|
const res = this.getResponseObject();
|
||||||
const req = this.getRequestObject();
|
const req = this.getRequestObject();
|
||||||
const headerData = this.getHeaderData() as IDataObject;
|
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)
|
// Check if we're getting facebook's challenge request (https://developers.facebook.com/docs/graph-api/webhooks/getting-started)
|
||||||
if (this.getWebhookName() === 'setup') {
|
if (this.getWebhookName() === 'setup') {
|
||||||
if (query['hub.challenge']) {
|
if (query['hub.challenge']) {
|
||||||
|
|
|
@ -23,9 +23,9 @@ export async function facebookApiRequest(this: IHookFunctions | IExecuteFunction
|
||||||
let credentials;
|
let credentials;
|
||||||
|
|
||||||
if (this.getNode().name.includes('Trigger')) {
|
if (this.getNode().name.includes('Trigger')) {
|
||||||
credentials = await this.getCredentials('facebookGraphAppApi') as IDataObject;
|
credentials = await this.getCredentials('facebookGraphAppApi');
|
||||||
} else {
|
} else {
|
||||||
credentials = await this.getCredentials('facebookGraphApi') as IDataObject;
|
credentials = await this.getCredentials('facebookGraphApi');
|
||||||
}
|
}
|
||||||
|
|
||||||
qs.access_token = credentials!.accessToken;
|
qs.access_token = credentials!.accessToken;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {
|
||||||
} from 'n8n-workflow';
|
} 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
|
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 = {
|
let options: OptionsWithUri = {
|
||||||
headers: { 'X-FIGMA-TOKEN': credentials.accessToken },
|
headers: { 'X-FIGMA-TOKEN': credentials.accessToken },
|
||||||
|
|
|
@ -774,10 +774,6 @@ export class FileMaker implements INodeType {
|
||||||
|
|
||||||
const credentials = await this.getCredentials('fileMaker');
|
const credentials = await this.getCredentials('fileMaker');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
let token;
|
let token;
|
||||||
try {
|
try {
|
||||||
token = await getToken.call(this);
|
token = await getToken.call(this);
|
||||||
|
|
|
@ -41,9 +41,6 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu
|
||||||
const token = await getToken.call(this);
|
const token = await getToken.call(this);
|
||||||
const credentials = await this.getCredentials('fileMaker');
|
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 host = credentials.host as string;
|
||||||
const db = credentials.db 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 credentials = await this.getCredentials('fileMaker');
|
||||||
const layout = this.getCurrentNodeParameter('layout') as string;
|
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 host = credentials.host as string;
|
||||||
const db = credentials.db 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 credentials = await this.getCredentials('fileMaker');
|
||||||
const layout = this.getCurrentNodeParameter('layout') as string;
|
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 host = credentials.host as string;
|
||||||
const db = credentials.db 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 token = await getToken.call(this);
|
||||||
const credentials = await this.getCredentials('fileMaker');
|
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 host = credentials.host as string;
|
||||||
const db = credentials.db 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
|
export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<any> { // tslint:disable-line:no-any
|
||||||
const credentials = await this.getCredentials('fileMaker');
|
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 host = credentials.host as string;
|
||||||
const db = credentials.db 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
|
export async function logout(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions, token: string): Promise<any> { // tslint:disable-line:no-any
|
||||||
const credentials = await this.getCredentials('fileMaker');
|
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 host = credentials.host as string;
|
||||||
const db = credentials.db as string;
|
const db = credentials.db as string;
|
||||||
|
|
|
@ -64,10 +64,6 @@ export class Flow implements INodeType {
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
const credentials = await this.getCredentials('flowApi');
|
const credentials = await this.getCredentials('flowApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const items = this.getInputData();
|
const items = this.getInputData();
|
||||||
const returnData: IDataObject[] = [];
|
const returnData: IDataObject[] = [];
|
||||||
const length = items.length as unknown as number;
|
const length = items.length as unknown as number;
|
||||||
|
|
|
@ -110,10 +110,6 @@ export class FlowTrigger implements INodeType {
|
||||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||||
const credentials = await this.getCredentials('flowApi');
|
const credentials = await this.getCredentials('flowApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
let webhooks;
|
let webhooks;
|
||||||
const qs: IDataObject = {};
|
const qs: IDataObject = {};
|
||||||
const webhookData = this.getWorkflowStaticData('node');
|
const webhookData = this.getWorkflowStaticData('node');
|
||||||
|
@ -144,10 +140,6 @@ export class FlowTrigger implements INodeType {
|
||||||
async create(this: IHookFunctions): Promise<boolean> {
|
async create(this: IHookFunctions): Promise<boolean> {
|
||||||
const credentials = await this.getCredentials('flowApi');
|
const credentials = await this.getCredentials('flowApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
let resourceIds, body, responseData;
|
let resourceIds, body, responseData;
|
||||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||||
const webhookData = this.getWorkflowStaticData('node');
|
const webhookData = this.getWorkflowStaticData('node');
|
||||||
|
@ -188,10 +180,6 @@ export class FlowTrigger implements INodeType {
|
||||||
async delete(this: IHookFunctions): Promise<boolean> {
|
async delete(this: IHookFunctions): Promise<boolean> {
|
||||||
const credentials = await this.getCredentials('flowApi');
|
const credentials = await this.getCredentials('flowApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const qs: IDataObject = {};
|
const qs: IDataObject = {};
|
||||||
const webhookData = this.getWorkflowStaticData('node');
|
const webhookData = this.getWorkflowStaticData('node');
|
||||||
qs.organization_id = credentials.organizationId as number;
|
qs.organization_id = credentials.organizationId as number;
|
||||||
|
|
|
@ -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
|
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');
|
const credentials = await this.getCredentials('flowApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: { 'Authorization': `Bearer ${credentials.accessToken}`},
|
headers: { 'Authorization': `Bearer ${credentials.accessToken}`},
|
||||||
|
|
|
@ -78,10 +78,6 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
const credentials = await this.getCredentials('formstackApi') as IDataObject;
|
const credentials = await this.getCredentials('formstackApi') as IDataObject;
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new Error('No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
|
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,10 +16,6 @@ export async function freshdeskApiRequest(this: IExecuteFunctions | ILoadOptions
|
||||||
|
|
||||||
const credentials = await this.getCredentials('freshdeskApi');
|
const credentials = await this.getCredentials('freshdeskApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const apiKey = `${credentials.apiKey}:X`;
|
const apiKey = `${credentials.apiKey}:X`;
|
||||||
|
|
||||||
const endpoint = 'freshdesk.com/api/v2';
|
const endpoint = 'freshdesk.com/api/v2';
|
||||||
|
|
|
@ -403,10 +403,6 @@ export class Ftp implements INodeType {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'Failed to get credentials!');
|
|
||||||
}
|
|
||||||
|
|
||||||
let ftp: ftpClient;
|
let ftp: ftpClient;
|
||||||
let sftp: sftpClient;
|
let sftp: sftpClient;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ export async function getresponseApiRequest(this: IWebhookFunctions | IHookFunct
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authentication === 'apiKey') {
|
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}`;
|
options!.headers!['X-Auth-Token'] = `api-key ${credentials.apiKey}`;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
return await this.helpers.request.call(this, options);
|
return await this.helpers.request.call(this, options);
|
||||||
|
|
|
@ -26,11 +26,11 @@ export async function ghostApiRequest(this: IHookFunctions | IExecuteFunctions |
|
||||||
if (source === 'contentApi') {
|
if (source === 'contentApi') {
|
||||||
//https://ghost.org/faq/api-versioning/
|
//https://ghost.org/faq/api-versioning/
|
||||||
version = 'v3';
|
version = 'v3';
|
||||||
credentials = await this.getCredentials('ghostContentApi') as IDataObject;
|
credentials = await this.getCredentials('ghostContentApi');
|
||||||
query.key = credentials.apiKey as string;
|
query.key = credentials.apiKey as string;
|
||||||
} else {
|
} else {
|
||||||
version = 'v2';
|
version = 'v2';
|
||||||
credentials = await this.getCredentials('ghostAdminApi') as IDataObject;
|
credentials = await this.getCredentials('ghostAdminApi');
|
||||||
// Create the token (including decoding secret)
|
// Create the token (including decoding secret)
|
||||||
const [id, secret] = (credentials.apiKey as string).split(':');
|
const [id, secret] = (credentials.apiKey as string).split(':');
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ export class Git implements INodeType {
|
||||||
const authentication = this.getNodeParameter('authentication', 0) as string;
|
const authentication = this.getNodeParameter('authentication', 0) as string;
|
||||||
|
|
||||||
if (authentication === 'gitPassword') {
|
if (authentication === 'gitPassword') {
|
||||||
const gitCredentials = await this.getCredentials('gitPassword') as IDataObject;
|
const gitCredentials = await this.getCredentials('gitPassword');
|
||||||
|
|
||||||
const url = new URL(repositoryPath);
|
const url = new URL(repositoryPath);
|
||||||
url.username = gitCredentials.username as string;
|
url.username = gitCredentials.username as string;
|
||||||
|
|
|
@ -40,9 +40,6 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions,
|
||||||
|
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
const credentials = await this.getCredentials('githubApi');
|
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';
|
const baseUrl = credentials!.server || 'https://api.github.com';
|
||||||
options.uri = `${baseUrl}${endpoint}`;
|
options.uri = `${baseUrl}${endpoint}`;
|
||||||
|
@ -52,7 +49,7 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions,
|
||||||
} else {
|
} else {
|
||||||
const credentials = await this.getCredentials('githubOAuth2Api');
|
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}`;
|
options.uri = `${baseUrl}${endpoint}`;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
return await this.helpers.requestOAuth2.call(this, 'githubOAuth2Api', options);
|
return await this.helpers.requestOAuth2.call(this, 'githubOAuth2Api', options);
|
||||||
|
|
|
@ -40,9 +40,6 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
|
||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
const credentials = await this.getCredentials('gitlabApi');
|
const credentials = await this.getCredentials('gitlabApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
options.headers!['Private-Token'] = `${credentials.accessToken}`;
|
options.headers!['Private-Token'] = `${credentials.accessToken}`;
|
||||||
|
|
||||||
|
@ -51,9 +48,6 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
|
||||||
return await this.helpers.request(options);
|
return await this.helpers.request(options);
|
||||||
} else {
|
} else {
|
||||||
const credentials = await this.getCredentials('gitlabOAuth2Api');
|
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}`;
|
options.uri = `${(credentials.server as string).replace(/\/$/, '')}/api/v4${endpoint}`;
|
||||||
|
|
||||||
|
|
|
@ -1101,16 +1101,8 @@ export class Gitlab implements INodeType {
|
||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
credentials = await this.getCredentials('gitlabApi');
|
credentials = await this.getCredentials('gitlabApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
credentials = await this.getCredentials('gitlabOAuth2Api');
|
credentials = await this.getCredentials('gitlabOAuth2Api');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (this.continueOnFail()) {
|
if (this.continueOnFail()) {
|
||||||
|
|
|
@ -49,10 +49,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
||||||
privateKey: string;
|
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);
|
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
|
||||||
|
|
||||||
options.headers!.Authorization = `Bearer ${access_token}`;
|
options.headers!.Authorization = `Bearer ${access_token}`;
|
||||||
|
|
|
@ -57,10 +57,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
||||||
} else{
|
} else{
|
||||||
const credentials = await this.getCredentials('googleApi');
|
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);
|
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
|
||||||
options.headers!.Authorization = `Bearer ${access_token}`;
|
options.headers!.Authorization = `Bearer ${access_token}`;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
|
|
|
@ -53,10 +53,6 @@ export async function googleApiRequest(
|
||||||
if (authenticationMethod === 'serviceAccount') {
|
if (authenticationMethod === 'serviceAccount') {
|
||||||
const credentials = await this.getCredentials('googleApi');
|
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);
|
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
|
||||||
|
|
||||||
options.headers!.Authorization = `Bearer ${access_token}`;
|
options.headers!.Authorization = `Bearer ${access_token}`;
|
||||||
|
|
|
@ -50,10 +50,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
||||||
if (authenticationMethod === 'serviceAccount') {
|
if (authenticationMethod === 'serviceAccount') {
|
||||||
const credentials = await this.getCredentials('googleApi');
|
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);
|
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
|
||||||
|
|
||||||
options.headers!.Authorization = `Bearer ${access_token}`;
|
options.headers!.Authorization = `Bearer ${access_token}`;
|
||||||
|
|
|
@ -65,10 +65,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
||||||
if (authenticationMethod === 'serviceAccount') {
|
if (authenticationMethod === 'serviceAccount') {
|
||||||
const credentials = await this.getCredentials('googleApi');
|
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);
|
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
|
||||||
|
|
||||||
options.headers!.Authorization = `Bearer ${access_token}`;
|
options.headers!.Authorization = `Bearer ${access_token}`;
|
||||||
|
|
|
@ -47,10 +47,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
||||||
if (authenticationMethod === 'serviceAccount') {
|
if (authenticationMethod === 'serviceAccount') {
|
||||||
const credentials = await this.getCredentials('googleApi');
|
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);
|
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
|
||||||
|
|
||||||
options.headers!.Authorization = `Bearer ${access_token}`;
|
options.headers!.Authorization = `Bearer ${access_token}`;
|
||||||
|
|
|
@ -56,10 +56,6 @@ export async function googleApiRequest(
|
||||||
if (authenticationMethod === 'serviceAccount') {
|
if (authenticationMethod === 'serviceAccount') {
|
||||||
const credentials = await this.getCredentials('googleApi');
|
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);
|
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
|
||||||
options.headers.Authorization = `Bearer ${access_token}`;
|
options.headers.Authorization = `Bearer ${access_token}`;
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
|
|
|
@ -46,10 +46,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
||||||
if (authenticationMethod === 'serviceAccount') {
|
if (authenticationMethod === 'serviceAccount') {
|
||||||
const credentials = await this.getCredentials('googleApi');
|
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);
|
const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials);
|
||||||
|
|
||||||
options.headers!.Authorization = `Bearer ${access_token}`;
|
options.headers!.Authorization = `Bearer ${access_token}`;
|
||||||
|
|
|
@ -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
|
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 = {
|
const options: OptionsWithUri = {
|
||||||
method,
|
method,
|
||||||
|
|
|
@ -305,12 +305,44 @@ export class GraphQL implements INodeType {
|
||||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
|
|
||||||
const items = this.getInputData();
|
const items = this.getInputData();
|
||||||
const httpBasicAuth = await this.getCredentials('httpBasicAuth');
|
let httpBasicAuth;
|
||||||
const httpDigestAuth = await this.getCredentials('httpDigestAuth');
|
let httpDigestAuth;
|
||||||
const httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
|
let httpHeaderAuth;
|
||||||
const httpQueryAuth = await this.getCredentials('httpQueryAuth');
|
let httpQueryAuth;
|
||||||
const oAuth1Api = await this.getCredentials('oAuth1Api');
|
let oAuth1Api;
|
||||||
const oAuth2Api = await this.getCredentials('oAuth2Api');
|
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;
|
let requestOptions: OptionsWithUri & RequestPromiseOptions;
|
||||||
|
|
||||||
|
|
|
@ -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
|
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');
|
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);
|
body = Object.assign({ access_token: credentials.accessToken }, body);
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
|
|
|
@ -28,7 +28,7 @@ interface IHaloPSATokens {
|
||||||
export async function getAccessTokens(
|
export async function getAccessTokens(
|
||||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||||
): Promise<IHaloPSATokens> {
|
): Promise<IHaloPSATokens> {
|
||||||
const credentials = (await this.getCredentials('haloPSAApi')) as IDataObject;
|
const credentials = await this.getCredentials('haloPSAApi');
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -67,7 +67,7 @@ export async function haloPSAApiRequest(
|
||||||
qs: IDataObject = {},
|
qs: IDataObject = {},
|
||||||
option: IDataObject = {},
|
option: IDataObject = {},
|
||||||
): Promise<any> { // tslint:disable-line:no-any
|
): Promise<any> { // tslint:disable-line:no-any
|
||||||
const resourceApiUrl = ((await this.getCredentials('haloPSAApi')) as IDataObject)
|
const resourceApiUrl = (await this.getCredentials('haloPSAApi'))
|
||||||
.resourceApiUrl as string;
|
.resourceApiUrl as string;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -35,11 +35,7 @@ export async function harvestApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (authenticationMethod === 'accessToken') {
|
if (authenticationMethod === 'accessToken') {
|
||||||
const credentials = await this.getCredentials('harvestApi') as IDataObject;
|
const credentials = await this.getCredentials('harvestApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
options.headers['Authorization'] = `Bearer ${credentials.accessToken}`;
|
options.headers['Authorization'] = `Bearer ${credentials.accessToken}`;
|
||||||
|
|
|
@ -17,10 +17,6 @@ import {
|
||||||
export async function homeAssistantApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}) {
|
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');
|
const credentials = await this.getCredentials('homeAssistantApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${credentials.accessToken}`,
|
Authorization: `Bearer ${credentials.accessToken}`,
|
||||||
|
|
|
@ -658,12 +658,43 @@ export class HttpRequest implements INodeType {
|
||||||
const parametersAreJson = this.getNodeParameter('jsonParameters', 0) as boolean;
|
const parametersAreJson = this.getNodeParameter('jsonParameters', 0) as boolean;
|
||||||
const responseFormat = this.getNodeParameter('responseFormat', 0) as string;
|
const responseFormat = this.getNodeParameter('responseFormat', 0) as string;
|
||||||
|
|
||||||
const httpBasicAuth = await this.getCredentials('httpBasicAuth');
|
let httpBasicAuth;
|
||||||
const httpDigestAuth = await this.getCredentials('httpDigestAuth');
|
let httpDigestAuth;
|
||||||
const httpHeaderAuth = await this.getCredentials('httpHeaderAuth');
|
let httpHeaderAuth;
|
||||||
const httpQueryAuth = await this.getCredentials('httpQueryAuth');
|
let httpQueryAuth;
|
||||||
const oAuth1Api = await this.getCredentials('oAuth1Api');
|
let oAuth1Api;
|
||||||
const oAuth2Api = await this.getCredentials('oAuth2Api');
|
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 requestOptions: OptionsWithUri;
|
||||||
let setUiParameter: IDataObject;
|
let setUiParameter: IDataObject;
|
||||||
|
|
|
@ -41,18 +41,18 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions
|
||||||
if (authenticationMethod === 'apiKey') {
|
if (authenticationMethod === 'apiKey') {
|
||||||
const credentials = await this.getCredentials('hubspotApi');
|
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);
|
return await this.helpers.request!(options);
|
||||||
} else if (authenticationMethod === 'appToken') {
|
} else if (authenticationMethod === 'appToken') {
|
||||||
const credentials = await this.getCredentials('hubspotAppToken');
|
const credentials = await this.getCredentials('hubspotAppToken');
|
||||||
|
|
||||||
options.headers!['Authorization'] = `Bearer ${credentials!.appToken}`;
|
options.headers!['Authorization'] = `Bearer ${credentials.appToken}`;
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.request!(options);
|
||||||
} else if (authenticationMethod === 'developerApi') {
|
} else if (authenticationMethod === 'developerApi') {
|
||||||
if (endpoint.includes('webhooks')) {
|
if (endpoint.includes('webhooks')) {
|
||||||
|
|
||||||
const credentials = await this.getCredentials('hubspotDeveloperApi');
|
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);
|
return await this.helpers.request!(options);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -282,7 +282,7 @@ export class HubspotTrigger implements INodeType {
|
||||||
// Check all the webhooks which exist already if it is identical to the
|
// Check all the webhooks which exist already if it is identical to the
|
||||||
// one that is supposed to get created.
|
// one that is supposed to get created.
|
||||||
const currentWebhookUrl = this.getNodeWebhookUrl('default') as string;
|
const currentWebhookUrl = this.getNodeWebhookUrl('default') as string;
|
||||||
const { appId } = await this.getCredentials('hubspotDeveloperApi') as IDataObject;
|
const { appId } = await this.getCredentials('hubspotDeveloperApi');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { targetUrl } = await hubspotApiRequest.call(this, 'GET', `/webhooks/v3/${appId}/settings`, {});
|
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> {
|
async create(this: IHookFunctions): Promise<boolean> {
|
||||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
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 events = (this.getNodeParameter('eventsUi') as IDataObject || {}).eventValues as IDataObject[] || [];
|
||||||
const additionalFields = this.getNodeParameter('additionalFields') as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields') as IDataObject;
|
||||||
let endpoint = `/webhooks/v3/${appId}/settings`;
|
let endpoint = `/webhooks/v3/${appId}/settings`;
|
||||||
|
@ -341,7 +341,7 @@ export class HubspotTrigger implements INodeType {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
async delete(this: IHookFunctions): Promise<boolean> {
|
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`, {});
|
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> {
|
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||||
|
|
||||||
const credentials = await this.getCredentials('hubspotDeveloperApi') as IDataObject;
|
const credentials = await this.getCredentials('hubspotDeveloperApi');
|
||||||
|
|
||||||
if (credentials === undefined) {
|
if (credentials === undefined) {
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials found!');
|
throw new NodeOperationError(this.getNode(), 'No credentials found!');
|
||||||
|
|
|
@ -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
|
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 {
|
try {
|
||||||
const credentials = await this.getCredentials('humanticAiApi');
|
const credentials = await this.getCredentials('humanticAiApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
|
@ -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
|
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');
|
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);
|
qs = Object.assign({ api_key: credentials.apiKey }, qs);
|
||||||
let options: OptionsWithUri = {
|
let options: OptionsWithUri = {
|
||||||
method,
|
method,
|
||||||
|
|
|
@ -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
|
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');
|
const credentials = await this.getCredentials('intercomApi');
|
||||||
if (credentials === undefined) {
|
|
||||||
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
||||||
}
|
|
||||||
|
|
||||||
const headerWithAuthentication = Object.assign({},
|
const headerWithAuthentication = Object.assign({},
|
||||||
{ Authorization: `Bearer ${credentials.apiKey}`, Accept: 'application/json' });
|
{ Authorization: `Bearer ${credentials.apiKey}`, Accept: 'application/json' });
|
||||||
|
|
|
@ -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
|
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');
|
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 baseUrl = credentials!.url || 'https://app.invoiceninja.com';
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue