Load credentials from the database (#1741)

* Changes to types so that credentials can be always loaded from DB

This first commit changes all return types from the execute functions
and calls to get credentials to be async so we can use await.

This is a first step as previously credentials were loaded in memory and
always available. We will now be loading them from the DB which requires
turning the whole call chain async.

* Fix updated files

* Removed unnecessary credential loading to improve performance

* Fix typo

*  Fix issue

* Updated new nodes to load credentials async

*  Remove not needed comment

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Omar Ajoue 2021-08-20 18:57:30 +02:00 committed by GitHub
parent 178235e148
commit 7ce7285f7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
242 changed files with 450 additions and 481 deletions

View file

@ -155,10 +155,7 @@ export class Execute extends Command {
}
try {
const credentials = await WorkflowCredentials(workflowData!.nodes);
const runData: IWorkflowExecutionDataProcess = {
credentials,
executionMode: 'cli',
startNodes: [startNode.name],
workflowData: workflowData!,

View file

@ -635,10 +635,8 @@ export class ExecuteBatch extends Command {
try {
const credentials = await WorkflowCredentials(workflowData!.nodes);
const runData: IWorkflowExecutionDataProcess = {
credentials,
executionMode: 'cli',
startNodes: [startNode!.name],
workflowData: workflowData!,

View file

@ -148,9 +148,7 @@ export class Worker extends Command {
const workflow = new Workflow({ id: currentExecutionDb.workflowData.id as string, name: currentExecutionDb.workflowData.name, nodes: currentExecutionDb.workflowData!.nodes, connections: currentExecutionDb.workflowData!.connections, active: currentExecutionDb.workflowData!.active, nodeTypes, staticData, settings: currentExecutionDb.workflowData!.settings });
const credentials = await WorkflowCredentials(currentExecutionDb.workflowData.nodes);
const additionalData = await WorkflowExecuteAdditionalData.getBase(credentials, undefined, executionTimeoutTimestamp);
const additionalData = await WorkflowExecuteAdditionalData.getBase(undefined, executionTimeoutTimestamp);
additionalData.hooks = WorkflowExecuteAdditionalData.getWorkflowHooksWorkerExecuter(currentExecutionDb.mode, job.data.executionId, currentExecutionDb.workflowData, { retryOf: currentExecutionDb.retryOf as string });
let workflowExecute: WorkflowExecute;

View file

@ -192,9 +192,7 @@ export class ActiveWorkflowRunner {
const nodeTypes = NodeTypes();
const workflow = new Workflow({ id: webhook.workflowId.toString(), name: workflowData.name, nodes: workflowData.nodes, connections: workflowData.connections, active: workflowData.active, nodeTypes, staticData: workflowData.staticData, settings: workflowData.settings });
const credentials = await WorkflowCredentials([workflow.getNode(webhook.node as string) as INode]);
const additionalData = await WorkflowExecuteAdditionalData.getBase(credentials);
const additionalData = await WorkflowExecuteAdditionalData.getBase();
const webhookData = NodeHelpers.getNodeWebhooks(workflow, workflow.getNode(webhook.node as string) as INode, additionalData).filter((webhook) => {
return (webhook.httpMethod === httpMethod && webhook.path === path);
@ -368,8 +366,7 @@ export class ActiveWorkflowRunner {
const mode = 'internal';
const credentials = await WorkflowCredentials(workflowData.nodes);
const additionalData = await WorkflowExecuteAdditionalData.getBase(credentials);
const additionalData = await WorkflowExecuteAdditionalData.getBase();
const webhooks = WebhookHelpers.getWorkflowWebhooks(workflow, additionalData);
@ -421,7 +418,6 @@ export class ActiveWorkflowRunner {
// Start the workflow
const runData: IWorkflowExecutionDataProcess = {
credentials: additionalData.credentials,
executionMode: mode,
executionData,
workflowData,
@ -508,8 +504,7 @@ export class ActiveWorkflowRunner {
}
const mode = 'trigger';
const credentials = await WorkflowCredentials(workflowData.nodes);
const additionalData = await WorkflowExecuteAdditionalData.getBase(credentials);
const additionalData = await WorkflowExecuteAdditionalData.getBase();
const getTriggerFunctions = this.getExecuteTriggerFunctions(workflowData, additionalData, mode, activation);
const getPollFunctions = this.getExecutePollFunctions(workflowData, additionalData, mode, activation);

View file

@ -48,16 +48,21 @@ export class CredentialsHelper extends ICredentialsHelper {
* @returns {Credentials}
* @memberof CredentialsHelper
*/
getCredentials(name: string, type: string): Credentials {
if (!this.workflowCredentials[type]) {
async getCredentials(name: string, type: string): Promise<Credentials> {
const credentialsDb = await Db.collections.Credentials?.find({type});
if (credentialsDb === undefined || credentialsDb.length === 0) {
throw new Error(`No credentials of type "${type}" exist.`);
}
if (!this.workflowCredentials[type][name]) {
const credential = credentialsDb.find(credential => credential.name === name);
if (credential === undefined) {
throw new Error(`No credentials with name "${name}" exist for type "${type}".`);
}
const credentialData = this.workflowCredentials[type][name];
return new Credentials(credentialData.name, credentialData.type, credentialData.nodesAccess, credentialData.data);
return new Credentials(credential.name, credential.type, credential.nodesAccess, credential.data);
}
@ -102,8 +107,8 @@ export class CredentialsHelper extends ICredentialsHelper {
* @returns {ICredentialDataDecryptedObject}
* @memberof CredentialsHelper
*/
getDecrypted(name: string, type: string, mode: WorkflowExecuteMode, raw?: boolean, expressionResolveValues?: ICredentialsExpressionResolveValues): ICredentialDataDecryptedObject {
const credentials = this.getCredentials(name, type);
async getDecrypted(name: string, type: string, mode: WorkflowExecuteMode, raw?: boolean, expressionResolveValues?: ICredentialsExpressionResolveValues): Promise<ICredentialDataDecryptedObject> {
const credentials = await this.getCredentials(name, type);
const decryptedDataOriginal = credentials.getData(this.encryptionKey);

View file

@ -457,7 +457,6 @@ export interface IProcessMessageDataHook {
}
export interface IWorkflowExecutionDataProcess {
credentials: IWorkflowCredentials;
destinationNode?: string;
executionMode: WorkflowExecuteMode;
executionData?: IRunExecutionData;

View file

@ -66,7 +66,6 @@ import {
TestWebhooks,
WebhookHelpers,
WebhookServer,
WorkflowCredentials,
WorkflowExecuteAdditionalData,
WorkflowHelpers,
WorkflowRunner,
@ -764,8 +763,7 @@ class App {
// If webhooks nodes exist and are active we have to wait for till we receive a call
if (runData === undefined || startNodes === undefined || startNodes.length === 0 || destinationNode === undefined) {
const credentials = await WorkflowCredentials(workflowData.nodes);
const additionalData = await WorkflowExecuteAdditionalData.getBase(credentials);
const additionalData = await WorkflowExecuteAdditionalData.getBase();
const nodeTypes = NodeTypes();
const workflowInstance = new Workflow({ id: workflowData.id, name: workflowData.name, nodes: workflowData.nodes, connections: workflowData.connections, active: false, nodeTypes, staticData: undefined, settings: workflowData.settings });
const needsWebhook = await this.testWebhooks.needsWebhookData(workflowData, workflowInstance, additionalData, executionMode, activationMode, sessionId, destinationNode);
@ -779,11 +777,8 @@ class App {
// For manual testing always set to not active
workflowData.active = false;
const credentials = await WorkflowCredentials(workflowData.nodes);
// Start the workflow
const data: IWorkflowExecutionDataProcess = {
credentials,
destinationNode,
executionMode,
runData,
@ -880,9 +875,7 @@ class App {
// @ts-ignore
const loadDataInstance = new LoadNodeParameterOptions(nodeType, nodeTypes, path, JSON.parse('' + req.query.currentNodeParameters), credentials!);
const workflowData = loadDataInstance.getWorkflowData() as IWorkflowBase;
const workflowCredentials = await WorkflowCredentials(workflowData.nodes);
const additionalData = await WorkflowExecuteAdditionalData.getBase(workflowCredentials, currentNodeParameters);
const additionalData = await WorkflowExecuteAdditionalData.getBase(currentNodeParameters);
return loadDataInstance.getOptions(methodName, additionalData);
}));
@ -1259,15 +1252,9 @@ class App {
return '';
}
// Decrypt the currently saved credentials
const workflowCredentials: IWorkflowCredentials = {
[result.type as string]: {
[result.name as string]: result as ICredentialsEncrypted,
},
};
const mode: WorkflowExecuteMode = 'internal';
const credentialsHelper = new CredentialsHelper(workflowCredentials, encryptionKey);
const decryptedDataOriginal = credentialsHelper.getDecrypted(result.name, result.type, mode, true);
const credentialsHelper = new CredentialsHelper(encryptionKey);
const decryptedDataOriginal = await credentialsHelper.getDecrypted(result.name, result.type, mode, true);
const oauthCredentials = credentialsHelper.applyDefaultsAndOverwrites(decryptedDataOriginal, result.type, mode);
const signatureMethod = _.get(oauthCredentials, 'signatureMethod') as string;
@ -1351,6 +1338,7 @@ class App {
return ResponseHelper.sendErrorResponse(res, errorResponse);
}
// Decrypt the currently saved credentials
const workflowCredentials: IWorkflowCredentials = {
[result.type as string]: {
@ -1358,10 +1346,10 @@ class App {
},
};
const mode: WorkflowExecuteMode = 'internal';
const credentialsHelper = new CredentialsHelper(workflowCredentials, encryptionKey);
const decryptedDataOriginal = credentialsHelper.getDecrypted(result.name, result.type, mode, true);
const credentialsHelper = new CredentialsHelper(encryptionKey);
const decryptedDataOriginal = await credentialsHelper.getDecrypted(result.name, result.type, mode, true);
const oauthCredentials = credentialsHelper.applyDefaultsAndOverwrites(decryptedDataOriginal, result.type, mode);
const options: OptionsWithUrl = {
method: 'POST',
url: _.get(oauthCredentials, 'accessTokenUrl') as string,
@ -1427,15 +1415,9 @@ class App {
return '';
}
// Decrypt the currently saved credentials
const workflowCredentials: IWorkflowCredentials = {
[result.type as string]: {
[result.name as string]: result as ICredentialsEncrypted,
},
};
const mode: WorkflowExecuteMode = 'internal';
const credentialsHelper = new CredentialsHelper(workflowCredentials, encryptionKey);
const decryptedDataOriginal = credentialsHelper.getDecrypted(result.name, result.type, mode, true);
const credentialsHelper = new CredentialsHelper(encryptionKey);
const decryptedDataOriginal = await credentialsHelper.getDecrypted(result.name, result.type, mode, true);
const oauthCredentials = credentialsHelper.applyDefaultsAndOverwrites(decryptedDataOriginal, result.type, mode);
const token = new csrf();
@ -1534,11 +1516,12 @@ class App {
[result.name as string]: result as ICredentialsEncrypted,
},
};
const mode: WorkflowExecuteMode = 'internal';
const credentialsHelper = new CredentialsHelper(workflowCredentials, encryptionKey);
const decryptedDataOriginal = credentialsHelper.getDecrypted(result.name, result.type, mode, true);
const credentialsHelper = new CredentialsHelper(encryptionKey);
const decryptedDataOriginal = await credentialsHelper.getDecrypted(result.name, result.type, mode, true);
const oauthCredentials = credentialsHelper.applyDefaultsAndOverwrites(decryptedDataOriginal, result.type, mode);
const token = new csrf();
if (decryptedDataOriginal.csrfSecret === undefined || !token.verify(decryptedDataOriginal.csrfSecret as string, state.token)) {
const errorResponse = new ResponseHelper.ResponseError('The OAuth2 callback state is invalid!', undefined, 404);
@ -1735,13 +1718,10 @@ class App {
const executionMode = 'retry';
const credentials = await WorkflowCredentials(fullExecutionData.workflowData.nodes);
fullExecutionData.workflowData.active = false;
// Start the workflow
const data: IWorkflowExecutionDataProcess = {
credentials,
executionMode,
executionData: fullExecutionData.data,
retryOf: req.params.id,

View file

@ -129,8 +129,7 @@ export function getWorkflowWebhooksBasic(workflow: Workflow): IWebhookData[] {
}
// Prepare everything that is needed to run the workflow
const credentials = await WorkflowCredentials(workflowData.nodes);
const additionalData = await WorkflowExecuteAdditionalData.getBase(credentials);
const additionalData = await WorkflowExecuteAdditionalData.getBase();
// Add the Response and Request so that this data can be accessed in the node
additionalData.httpRequest = req;
@ -276,7 +275,6 @@ export function getWorkflowWebhooksBasic(workflow: Workflow): IWebhookData[] {
}
const runData: IWorkflowExecutionDataProcess = {
credentials,
executionMode,
executionData: runExecutionData,
sessionId,

View file

@ -545,12 +545,7 @@ export async function getRunData(workflowData: IWorkflowBase, inputData?: INodeE
},
};
// Get the needed credentials for the current workflow as they will differ to the ones of the
// calling workflow.
const credentials = await WorkflowCredentials(workflowData!.nodes);
const runData: IWorkflowExecutionDataProcess = {
credentials,
executionMode: mode,
executionData: runExecutionData,
// @ts-ignore
@ -618,13 +613,9 @@ export async function executeWorkflow(workflowInfo: IExecuteWorkflowInfo, additi
let data;
try {
// Get the needed credentials for the current workflow as they will differ to the ones of the
// calling workflow.
const credentials = await WorkflowCredentials(workflowData!.nodes);
// Create new additionalData to have different workflow loaded and to call
// different webooks
const additionalDataIntegrated = await getBase(credentials);
const additionalDataIntegrated = await getBase();
additionalDataIntegrated.hooks = getWorkflowHooksIntegrated(runData.executionMode, executionId, workflowData!, { parentProcessMode: additionalData.hooks!.mode });
// Make sure we pass on the original executeWorkflow function we received
// This one already contains changes to talk to parent process
@ -735,7 +726,7 @@ export function sendMessageToUI(source: string, message: any) { // tslint:disabl
* @param {INodeParameters} currentNodeParameters
* @returns {Promise<IWorkflowExecuteAdditionalData>}
*/
export async function getBase(credentials: IWorkflowCredentials, currentNodeParameters?: INodeParameters, executionTimeoutTimestamp?: number): Promise<IWorkflowExecuteAdditionalData> {
export async function getBase(currentNodeParameters?: INodeParameters, executionTimeoutTimestamp?: number): Promise<IWorkflowExecuteAdditionalData> {
const urlBaseWebhook = WebhookHelpers.getWebhookBaseUrl();
const timezone = config.get('generic.timezone') as string;
@ -748,8 +739,7 @@ export async function getBase(credentials: IWorkflowCredentials, currentNodePara
}
return {
credentials,
credentialsHelper: new CredentialsHelper(credentials, encryptionKey),
credentialsHelper: new CredentialsHelper(encryptionKey),
encryptionKey,
executeWorkflow,
restApiUrl: urlBaseWebhook + config.get('endpoints.rest') as string,

View file

@ -144,10 +144,7 @@ export async function executeErrorWorkflow(workflowId: string, workflowErrorData
},
};
const credentials = await WorkflowCredentials(workflowData.nodes);
const runData: IWorkflowExecutionDataProcess = {
credentials,
executionMode,
executionData: runExecutionData,
workflowData,

View file

@ -183,7 +183,7 @@ export class WorkflowRunner {
}
const workflow = new Workflow({ id: data.workflowData.id as string | undefined, name: data.workflowData.name, nodes: data.workflowData!.nodes, connections: data.workflowData!.connections, active: data.workflowData!.active, nodeTypes, staticData: data.workflowData!.staticData });
const additionalData = await WorkflowExecuteAdditionalData.getBase(data.credentials, undefined, workflowTimeout <= 0 ? undefined : Date.now() + workflowTimeout * 1000);
const additionalData = await WorkflowExecuteAdditionalData.getBase(undefined, workflowTimeout <= 0 ? undefined : Date.now() + workflowTimeout * 1000);
// Register the active execution
const executionId = await this.activeExecutions.add(data, undefined);
@ -423,43 +423,14 @@ export class WorkflowRunner {
// Register the active execution
const executionId = await this.activeExecutions.add(data, subprocess);
// Check if workflow contains a "executeWorkflow" Node as in this
// case we can not know which nodeTypes and credentialTypes will
// be needed and so have to load all of them in the workflowRunnerProcess
let loadAllNodeTypes = false;
for (const node of data.workflowData.nodes) {
if (node.type === 'n8n-nodes-base.executeWorkflow') {
loadAllNodeTypes = true;
break;
}
}
let nodeTypeData: ITransferNodeTypes;
let credentialTypeData: ICredentialsTypeData;
let credentialsOverwrites = this.credentialsOverwrites;
if (loadAllNodeTypes === true) {
// Supply all nodeTypes and credentialTypes
nodeTypeData = WorkflowHelpers.getAllNodeTypeData();
const credentialTypes = CredentialTypes();
credentialTypeData = credentialTypes.credentialTypes;
} else {
// Supply only nodeTypes, credentialTypes and overwrites that the workflow needs
nodeTypeData = WorkflowHelpers.getNodeTypeData(data.workflowData.nodes);
credentialTypeData = WorkflowHelpers.getCredentialsData(data.credentials);
credentialsOverwrites = {};
for (const credentialName of Object.keys(credentialTypeData)) {
if (this.credentialsOverwrites[credentialName] !== undefined) {
credentialsOverwrites[credentialName] = this.credentialsOverwrites[credentialName];
}
}
}
// Supply all nodeTypes and credentialTypes
const nodeTypeData = WorkflowHelpers.getAllNodeTypeData() as ITransferNodeTypes;
const credentialTypes = CredentialTypes();
(data as unknown as IWorkflowExecutionDataProcessWithExecution).executionId = executionId;
(data as unknown as IWorkflowExecutionDataProcessWithExecution).nodeTypeData = nodeTypeData;
(data as unknown as IWorkflowExecutionDataProcessWithExecution).credentialsOverwrite = credentialsOverwrites;
(data as unknown as IWorkflowExecutionDataProcessWithExecution).credentialsTypeData = credentialTypeData; // TODO: Still needs correct value
(data as unknown as IWorkflowExecutionDataProcessWithExecution).credentialsOverwrite = this.credentialsOverwrites;
(data as unknown as IWorkflowExecutionDataProcessWithExecution).credentialsTypeData = credentialTypes.credentialTypes;
const workflowHooks = WorkflowExecuteAdditionalData.getWorkflowHooksMain(data, executionId);

View file

@ -111,9 +111,22 @@ export class WorkflowRunnerProcess {
const externalHooks = ExternalHooks();
await externalHooks.init();
// This code has been split into 3 ifs just to make it easier to understand
// Credentials should now be loaded from database.
// We check if any node uses credentials. If it does, then
// init database.
let shouldInitializaDb = false;
inputData.workflowData.nodes.map(node => {
if (Object.keys(node.credentials === undefined ? {} : node.credentials).length > 0) {
shouldInitializaDb = true;
}
});
// This code has been split into 4 ifs just to make it easier to understand
// Can be made smaller but in the end it will make it impossible to read.
if (inputData.workflowData.settings !== undefined && inputData.workflowData.settings.saveExecutionProgress === true) {
if (shouldInitializaDb) {
// initialize db as we need to load credentials
await Db.init();
} else if (inputData.workflowData.settings !== undefined && inputData.workflowData.settings.saveExecutionProgress === true) {
// Workflow settings specifying it should save
await Db.init();
} else if (inputData.workflowData.settings !== undefined && inputData.workflowData.settings.saveExecutionProgress !== false && config.get('executions.saveExecutionProgress') as boolean) {
@ -135,7 +148,7 @@ export class WorkflowRunnerProcess {
}
this.workflow = new Workflow({ id: this.data.workflowData.id as string | undefined, name: this.data.workflowData.name, nodes: this.data.workflowData!.nodes, connections: this.data.workflowData!.connections, active: this.data.workflowData!.active, nodeTypes, staticData: this.data.workflowData!.staticData, settings: this.data.workflowData!.settings });
const additionalData = await WorkflowExecuteAdditionalData.getBase(this.data.credentials, undefined, workflowTimeout <= 0 ? undefined : Date.now() + workflowTimeout * 1000);
const additionalData = await WorkflowExecuteAdditionalData.getBase(undefined, workflowTimeout <= 0 ? undefined : Date.now() + workflowTimeout * 1000);
additionalData.hooks = this.getProcessForwardHooks();
additionalData.sendMessageToUI = async (source: string, message: any) => { // tslint:disable-line:no-any

View file

@ -155,8 +155,8 @@ export async function prepareBinaryData(binaryData: Buffer, filePath?: string, m
*
* @returns
*/
export function requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions, node: INode, additionalData: IWorkflowExecuteAdditionalData, oAuth2Options?: IOAuth2Options) {
const credentials = this.getCredentials(credentialsType) as ICredentialDataDecryptedObject;
export async function requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions, node: INode, additionalData: IWorkflowExecuteAdditionalData, oAuth2Options?: IOAuth2Options) {
const credentials = await this.getCredentials(credentialsType) as ICredentialDataDecryptedObject;
if (credentials === undefined) {
throw new Error('No credentials got returned!');
@ -244,8 +244,8 @@ export function requestOAuth2(this: IAllExecuteFunctions, credentialsType: strin
* @param {(OptionsWithUrl | requestPromise.RequestPromiseOptions)} requestOptionså
* @returns
*/
export function requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | OptionsWithUri | requestPromise.RequestPromiseOptions) {
const credentials = this.getCredentials(credentialsType) as ICredentialDataDecryptedObject;
export async function requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | OptionsWithUri | requestPromise.RequestPromiseOptions) {
const credentials = await this.getCredentials(credentialsType) as ICredentialDataDecryptedObject;
if (credentials === undefined) {
throw new Error('No credentials got returned!');
@ -332,7 +332,7 @@ export function returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExe
* @param {IWorkflowExecuteAdditionalData} additionalData
* @returns {(ICredentialDataDecryptedObject | undefined)}
*/
export function getCredentials(workflow: Workflow, node: INode, type: string, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, runExecutionData?: IRunExecutionData | null, runIndex?: number, connectionInputData?: INodeExecutionData[], itemIndex?: number): ICredentialDataDecryptedObject | undefined {
export async function getCredentials(workflow: Workflow, node: INode, type: string, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, runExecutionData?: IRunExecutionData | null, runIndex?: number, connectionInputData?: INodeExecutionData[], itemIndex?: number): Promise<ICredentialDataDecryptedObject | undefined> {
// Get the NodeType as it has the information if the credentials are required
const nodeType = workflow.nodeTypes.getByName(node.type);
@ -386,7 +386,7 @@ export function getCredentials(workflow: Workflow, node: INode, type: string, ad
const name = node.credentials[type];
const decryptedDataObject = additionalData.credentialsHelper.getDecrypted(name, type, mode, false, expressionResolveValues);
const decryptedDataObject = await additionalData.credentialsHelper.getDecrypted(name, type, mode, false, expressionResolveValues);
return decryptedDataObject;
}
@ -570,8 +570,8 @@ export function getExecutePollFunctions(workflow: Workflow, node: INode, additio
__emit: (data: INodeExecutionData[][]): void => {
throw new Error('Overwrite NodeExecuteFunctions.getExecutePullFunctions.__emit function!');
},
getCredentials(type: string): ICredentialDataDecryptedObject | undefined {
return getCredentials(workflow, node, type, additionalData, mode);
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
return await getCredentials(workflow, node, type, additionalData, mode);
},
getMode: (): WorkflowExecuteMode => {
return mode;
@ -636,8 +636,8 @@ export function getExecuteTriggerFunctions(workflow: Workflow, node: INode, addi
emit: (data: INodeExecutionData[][]): void => {
throw new Error('Overwrite NodeExecuteFunctions.getExecuteTriggerFunctions.emit function!');
},
getCredentials(type: string): ICredentialDataDecryptedObject | undefined {
return getCredentials(workflow, node, type, additionalData, mode);
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
return await getCredentials(workflow, node, type, additionalData, mode);
},
getNode: () => {
return getNode(node);
@ -714,8 +714,8 @@ export function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunEx
getContext(type: string): IContextObject {
return NodeHelpers.getContext(runExecutionData, type, node);
},
getCredentials(type: string, itemIndex?: number): ICredentialDataDecryptedObject | undefined {
return getCredentials(workflow, node, type, additionalData, mode, runExecutionData, runIndex, connectionInputData, itemIndex);
async getCredentials(type: string, itemIndex?: number): Promise<ICredentialDataDecryptedObject | undefined> {
return await getCredentials(workflow, node, type, additionalData, mode, runExecutionData, runIndex, connectionInputData, itemIndex);
},
getInputData: (inputIndex = 0, inputName = 'main') => {
@ -824,8 +824,8 @@ export function getExecuteSingleFunctions(workflow: Workflow, runExecutionData:
getContext(type: string): IContextObject {
return NodeHelpers.getContext(runExecutionData, type, node);
},
getCredentials(type: string): ICredentialDataDecryptedObject | undefined {
return getCredentials(workflow, node, type, additionalData, mode, runExecutionData, runIndex, connectionInputData, itemIndex);
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
return await getCredentials(workflow, node, type, additionalData, mode, runExecutionData, runIndex, connectionInputData, itemIndex);
},
getInputData: (inputIndex = 0, inputName = 'main') => {
if (!inputData.hasOwnProperty(inputName)) {
@ -904,8 +904,8 @@ export function getExecuteSingleFunctions(workflow: Workflow, runExecutionData:
export function getLoadOptionsFunctions(workflow: Workflow, node: INode, path: string, additionalData: IWorkflowExecuteAdditionalData): ILoadOptionsFunctions {
return ((workflow: Workflow, node: INode, path: string) => {
const that = {
getCredentials(type: string): ICredentialDataDecryptedObject | undefined {
return getCredentials(workflow, node, type, additionalData, 'internal');
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
return await getCredentials(workflow, node, type, additionalData, 'internal');
},
getCurrentNodeParameter: (parameterPath: string): NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[] | object | undefined => {
const nodeParameters = additionalData.currentNodeParameters;
@ -965,8 +965,8 @@ export function getLoadOptionsFunctions(workflow: Workflow, node: INode, path: s
export function getExecuteHookFunctions(workflow: Workflow, node: INode, additionalData: IWorkflowExecuteAdditionalData, mode: WorkflowExecuteMode, activation: WorkflowActivateMode, isTest?: boolean, webhookData?: IWebhookData): IHookFunctions {
return ((workflow: Workflow, node: INode) => {
const that = {
getCredentials(type: string): ICredentialDataDecryptedObject | undefined {
return getCredentials(workflow, node, type, additionalData, mode);
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
return await getCredentials(workflow, node, type, additionalData, mode);
},
getMode: (): WorkflowExecuteMode => {
return mode;
@ -1042,8 +1042,8 @@ export function getExecuteWebhookFunctions(workflow: Workflow, node: INode, addi
}
return additionalData.httpRequest.body;
},
getCredentials(type: string): ICredentialDataDecryptedObject | undefined {
return getCredentials(workflow, node, type, additionalData, mode);
async getCredentials(type: string): Promise<ICredentialDataDecryptedObject | undefined> {
return await getCredentials(workflow, node, type, additionalData, mode);
},
getHeaderData(): object {
if (additionalData.httpRequest === undefined) {

View file

@ -26,12 +26,14 @@ import {
export class CredentialsHelper extends ICredentialsHelper {
getDecrypted(name: string, type: string): ICredentialDataDecryptedObject {
return {};
getDecrypted(name: string, type: string): Promise<ICredentialDataDecryptedObject> {
return new Promise(res => res({}));
}
getCredentials(name: string, type: string): Credentials {
return new Credentials('', '', [], '');
getCredentials(name: string, type: string): Promise<Credentials> {
return new Promise(res => {
res(new Credentials('', '', [], ''));
});
}
async updateCredentials(name: string, type: string, data: ICredentialDataDecryptedObject): Promise<void> {}
@ -748,8 +750,7 @@ export function WorkflowExecuteAdditionalData(waitPromise: IDeferredPromise<IRun
};
return {
credentials: {},
credentialsHelper: new CredentialsHelper({}, ''),
credentialsHelper: new CredentialsHelper(''),
hooks: new WorkflowHooks(hookFunctions, 'trigger', '1', workflowData),
executeWorkflow: async (workflowInfo: IExecuteWorkflowInfo): Promise<any> => {}, // tslint:disable-line:no-any
sendMessageToUI: (message: string) => {},

View file

@ -35,7 +35,7 @@ export async function actionNetworkApiRequest(
body: IDataObject = {},
qs: IDataObject = {},
) {
const credentials = this.getCredentials('actionNetworkApi') as { apiKey: string } | undefined;
const credentials = await this.getCredentials('actionNetworkApi') as { apiKey: string } | undefined;
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -26,7 +26,7 @@ export interface IProduct {
* @returns {Promise<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 = this.getCredentials('activeCampaignApi');
const credentials = await this.getCredentials('activeCampaignApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -25,7 +25,7 @@ export async function acuitySchedulingApiRequest(this: IHookFunctions | IExecute
try {
if (authenticationMethod === 'apiKey') {
const credentials = this.getCredentials('acuitySchedulingApi');
const credentials = await this.getCredentials('acuitySchedulingApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -18,7 +18,7 @@ import {
export async function affinityApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('affinityApi');
const credentials = await this.getCredentials('affinityApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -17,7 +17,7 @@ import { IContactUpdate } from './ContactInterface';
export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('agileCrmApi');
const credentials = await this.getCredentials('agileCrmApi');
const options: OptionsWithUri = {
method,
headers: {
@ -46,7 +46,7 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction
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 = this.getCredentials('agileCrmApi');
const credentials = await this.getCredentials('agileCrmApi');
const baseUri = `https://${credentials!.subdomain}.agilecrm.com/dev/`;
const options: OptionsWithUri = {
method,

View file

@ -40,7 +40,7 @@ export interface IRecord {
* @returns {Promise<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 = this.getCredentials('airtableApi');
const credentials = await this.getCredentials('airtableApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -98,7 +98,7 @@ export class Amqp implements INodeType {
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
try {
const credentials = this.getCredentials('amqp');
const credentials = await this.getCredentials('amqp');
if (!credentials) {
throw new NodeOperationError(this.getNode(), 'Credentials are mandatory!');
}

View file

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

View file

@ -15,7 +15,7 @@ export async function apiTemplateIoApiRequest(
qs = {},
body = {},
) {
const { apiKey } = this.getCredentials('apiTemplateIoApi') as { apiKey: string };
const { apiKey } = await this.getCredentials('apiTemplateIoApi') as { apiKey: string };
const options: OptionsWithUri = {
headers: {

View file

@ -42,7 +42,7 @@ export async function asanaApiRequest(this: IHookFunctions | IExecuteFunctions |
try {
if (authenticationMethod === 'accessToken') {
const credentials = this.getCredentials('asanaApi');
const credentials = await this.getCredentials('asanaApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

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

View file

@ -16,7 +16,7 @@ import {
export async function autopilotApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('autopilotApi') as IDataObject;
const credentials = await this.getCredentials('autopilotApi') as IDataObject;
const apiKey = `${credentials.apiKey}`;

View file

@ -38,7 +38,7 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
}
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('aws');
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -36,7 +36,7 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
}
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: object | IRequestBody, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('aws');
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new Error('No credentials got returned!');
}

View file

@ -29,7 +29,7 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
}
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('aws');
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -36,7 +36,7 @@ import {
} from 'change-case';
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 = this.getCredentials('aws');
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -114,7 +114,7 @@ export class AwsS3 implements INodeType {
if (resource === 'bucket') {
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html
if (operation === 'create') {
const credentials = this.getCredentials('aws');
const credentials = await this.getCredentials('aws');
const name = this.getNodeParameter('name', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.acl) {

View file

@ -30,7 +30,7 @@ import {
} from 'n8n-workflow';
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 = this.getCredentials('aws');
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -30,7 +30,7 @@ import {
} from 'lodash';
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 = this.getCredentials('aws');
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -41,7 +41,7 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
}
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('aws');
const credentials = await this.getCredentials('aws');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -21,7 +21,7 @@ import {
export async function bannerbearApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('bannerbearApi');
const credentials = await this.getCredentials('bannerbearApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -114,7 +114,7 @@ export class Baserow implements INodeType {
methods = {
loadOptions: {
async getDatabaseIds(this: ILoadOptionsFunctions) {
const credentials = this.getCredentials('baserowApi') as BaserowCredentials;
const credentials = await this.getCredentials('baserowApi') as BaserowCredentials;
const jwtToken = await getJwtToken.call(this, credentials);
const endpoint = '/api/applications/';
const databases = await baserowApiRequest.call(this, 'GET', endpoint, {}, {}, jwtToken) as LoadedResource[];
@ -122,7 +122,7 @@ export class Baserow implements INodeType {
},
async getTableIds(this: ILoadOptionsFunctions) {
const credentials = this.getCredentials('baserowApi') as BaserowCredentials;
const credentials = await this.getCredentials('baserowApi') as BaserowCredentials;
const jwtToken = await getJwtToken.call(this, credentials);
const databaseId = this.getNodeParameter('databaseId', 0) as string;
const endpoint = `/api/database/tables/database/${databaseId}`;
@ -131,7 +131,7 @@ export class Baserow implements INodeType {
},
async getTableFields(this: ILoadOptionsFunctions) {
const credentials = this.getCredentials('baserowApi') as BaserowCredentials;
const credentials = await this.getCredentials('baserowApi') as BaserowCredentials;
const jwtToken = await getJwtToken.call(this, credentials);
const tableId = this.getNodeParameter('tableId', 0) as string;
const endpoint = `/api/database/fields/table/${tableId}/`;
@ -148,7 +148,7 @@ export class Baserow implements INodeType {
const operation = this.getNodeParameter('operation', 0) as Operation;
const tableId = this.getNodeParameter('tableId', 0) as string;
const credentials = this.getCredentials('baserowApi') as BaserowCredentials;
const credentials = await this.getCredentials('baserowApi') as BaserowCredentials;
const jwtToken = await getJwtToken.call(this, credentials);
const fields = await mapper.getTableFields.call(this, tableId, jwtToken);
mapper.createMappings(fields);

View file

@ -30,7 +30,7 @@ export async function baserowApiRequest(
qs: IDataObject = {},
jwtToken: string,
) {
const credentials = 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!');

View file

@ -16,7 +16,7 @@ import {
} from './GenericFunctions';
export async function createDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
const credentials = this.getCredentials('beeminderApi');
const credentials = await this.getCredentials('beeminderApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
@ -28,7 +28,7 @@ export async function createDatapoint(this: IExecuteFunctions | IWebhookFunction
}
export async function getAllDatapoints(this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
const credentials = this.getCredentials('beeminderApi');
const credentials = await this.getCredentials('beeminderApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
@ -44,7 +44,7 @@ export async function getAllDatapoints(this: IExecuteFunctions | IHookFunctions
}
export async function updateDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
const credentials = this.getCredentials('beeminderApi');
const credentials = await this.getCredentials('beeminderApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
@ -56,7 +56,7 @@ export async function updateDatapoint(this: IExecuteFunctions | IWebhookFunction
}
export async function deleteDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) {
const credentials = this.getCredentials('beeminderApi');
const credentials = await this.getCredentials('beeminderApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -306,7 +306,7 @@ export class Beeminder implements INodeType {
// select them easily
async getGoals(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const credentials = this.getCredentials('beeminderApi');
const credentials = await this.getCredentials('beeminderApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -18,7 +18,7 @@ const BEEMINDER_URI = 'https://www.beeminder.com/api/v1';
export async function beeminderApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('beeminderApi') as IDataObject;
const credentials = await this.getCredentials('beeminderApi') as IDataObject;
Object.assign(body, { auth_token: credentials.authToken });

View file

@ -221,7 +221,7 @@ export class BitbucketTrigger implements INodeType {
// Get all the repositories to display them to user so that he can
// select them easily
async getRepositories(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const credentials = this.getCredentials('bitbucketApi');
const credentials = await this.getCredentials('bitbucketApi');
const returnData: INodePropertyOptions[] = [];
const repositories = await bitbucketApiRequestAllItems.call(this, 'values', 'GET', `/repositories/${credentials!.username}`);
for (const repository of repositories) {
@ -261,7 +261,7 @@ export class BitbucketTrigger implements INodeType {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {
let endpoint = '';
const credentials = this.getCredentials('bitbucketApi');
const credentials = await this.getCredentials('bitbucketApi');
const resource = this.getNodeParameter('resource', 0) as string;
const webhookData = this.getWorkflowStaticData('node');
if (webhookData.webhookId === undefined) {
@ -292,7 +292,7 @@ export class BitbucketTrigger implements INodeType {
const webhookData = this.getWorkflowStaticData('node');
const events = this.getNodeParameter('events') as string[];
const resource = this.getNodeParameter('resource', 0) as string;
const credentials = this.getCredentials('bitbucketApi');
const credentials = await this.getCredentials('bitbucketApi');
if (resource === 'user') {
endpoint = `/users/${credentials!.username}/hooks`;
@ -318,7 +318,7 @@ export class BitbucketTrigger implements INodeType {
async delete(this: IHookFunctions): Promise<boolean> {
let endpoint = '';
const webhookData = this.getWorkflowStaticData('node');
const credentials = this.getCredentials('bitbucketApi');
const credentials = await this.getCredentials('bitbucketApi');
const resource = this.getNodeParameter('resource', 0) as string;
if (resource === 'user') {
endpoint = `/users/${credentials!.username}/hooks/${webhookData.webhookId}`;

View file

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

View file

@ -30,7 +30,7 @@ export async function bitlyApiRequest(this: IHookFunctions | IExecuteFunctions |
try{
if (authenticationMethod === 'accessToken') {
const credentials = this.getCredentials('bitlyApi');
const credentials = await this.getCredentials('bitlyApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -25,6 +25,7 @@ export async function bitwardenApiRequest(
token: string,
): Promise<any> { // tslint:disable-line:no-any
const baseUrl = await getBaseUrl.call(this);
const options: OptionsWithUri = {
headers: {
'user-agent': 'n8n',
@ -34,7 +35,7 @@ export async function bitwardenApiRequest(
method,
qs,
body,
uri: `${getBaseUrl.call(this)}${endpoint}`,
uri: `${baseUrl}${endpoint}`,
json: true,
};
@ -60,7 +61,7 @@ export async function getAccessToken(
this: IExecuteFunctions | ILoadOptionsFunctions,
): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('bitwardenApi') as IDataObject;
const credentials = await this.getCredentials('bitwardenApi') as IDataObject;
const options: OptionsWithUri = {
headers: {
@ -76,7 +77,7 @@ export async function getAccessToken(
deviceType: 2, // https://github.com/bitwarden/server/blob/master/src/Core/Enums/DeviceType.cs
deviceIdentifier: 'n8n',
},
uri: getTokenUrl.call(this),
uri: await getTokenUrl.call(this),
json: true,
};
@ -114,8 +115,8 @@ export async function handleGetAll(
/**
* Return the access token URL based on the user's environment.
*/
function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
const { environment, domain } = this.getCredentials('bitwardenApi') as IDataObject;
async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
const { environment, domain } = await this.getCredentials('bitwardenApi') as IDataObject;
return environment === 'cloudHosted'
? 'https://identity.bitwarden.com/connect/token'
@ -126,8 +127,8 @@ function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
/**
* Return the base API URL based on the user's environment.
*/
function getBaseUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
const { environment, domain } = this.getCredentials('bitwardenApi') as IDataObject;
async function getBaseUrl(this: IExecuteFunctions | ILoadOptionsFunctions) {
const { environment, domain } = await this.getCredentials('bitwardenApi') as IDataObject;
return environment === 'cloudHosted'
? 'https://api.bitwarden.com'

View file

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

View file

@ -24,7 +24,7 @@ export async function bubbleApiRequest(
qs: IDataObject,
) {
const { apiToken, appName, domain, environment, hosting } = this.getCredentials('bubbleApi') as {
const { apiToken, appName, domain, environment, hosting } = await this.getCredentials('bubbleApi') as {
apiToken: string,
appName: string,
domain: string,

View file

@ -15,7 +15,7 @@ import {
export async function calendlyApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('calendlyApi');
const credentials = await this.getCredentials('calendlyApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -488,7 +488,7 @@ export class Chargebee implements INodeType {
const returnData: IDataObject[] = [];
let item: INodeExecutionData;
const credentials = this.getCredentials('chargebeeApi');
const credentials = await this.getCredentials('chargebeeApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -14,7 +14,7 @@ import {
} from 'n8n-workflow';
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 = this.getCredentials('circleCiApi');
const credentials = await this.getCredentials('circleCiApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -8,6 +8,7 @@ import {
INodeType,
INodeTypeDescription,
IWebhookResponseData,
NodeOperationError,
} from 'n8n-workflow';
import {
@ -600,7 +601,11 @@ export class CiscoWebexTrigger implements INodeType {
const event = this.getNodeParameter('event') as string;
const resource = this.getNodeParameter('resource') as string;
const filters = this.getNodeParameter('filters', {}) as IDataObject;
const secret = getAutomaticSecret(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 filter = [];
for (const key of Object.keys(filters)) {
if (key !== 'ownedBy') {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -105,7 +105,7 @@ export class Contentful implements INodeType {
if (resource === 'space') {
if (operation === 'get') {
const credentials = this.getCredentials('contentfulApi');
const credentials = await this.getCredentials('contentfulApi');
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}`);
}
@ -113,7 +113,7 @@ export class Contentful implements INodeType {
if (resource === 'contentType') {
if (operation === 'get') {
const credentials = this.getCredentials('contentfulApi');
const credentials = await this.getCredentials('contentfulApi');
const env = this.getNodeParameter('environmentId', 0) as string;
@ -132,7 +132,7 @@ export class Contentful implements INodeType {
if (operation === 'get') {
const credentials = this.getCredentials('contentfulApi');
const credentials = await this.getCredentials('contentfulApi');
const env = this.getNodeParameter('environmentId', 0) as string;
@ -147,7 +147,7 @@ export class Contentful implements INodeType {
}
} else if (operation === 'getAll') {
const credentials = this.getCredentials('contentfulApi');
const credentials = await this.getCredentials('contentfulApi');
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
@ -214,7 +214,7 @@ export class Contentful implements INodeType {
if (resource === 'asset') {
if (operation === 'get') {
const credentials = this.getCredentials('contentfulApi');
const credentials = await this.getCredentials('contentfulApi');
const env = this.getNodeParameter('environmentId', 0) as string;
@ -230,7 +230,7 @@ export class Contentful implements INodeType {
} else if (operation === 'getAll') {
const credentials = this.getCredentials('contentfulApi');
const credentials = await this.getCredentials('contentfulApi');
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
@ -298,7 +298,7 @@ export class Contentful implements INodeType {
if (operation === 'getAll') {
const credentials = this.getCredentials('contentfulApi');
const credentials = await this.getCredentials('contentfulApi');
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;

View file

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

View file

@ -18,7 +18,7 @@ import {
export async function convertKitApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions,
method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('convertKitApi');
const credentials = await this.getCredentials('convertKitApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -133,7 +133,7 @@ export class CopperTrigger implements INodeType {
event,
};
const credentials = this.getCredentials('copperApi');
const credentials = await this.getCredentials('copperApi');
body.secret = {
secret: getAutomaticSecret(credentials!),
};
@ -157,7 +157,7 @@ export class CopperTrigger implements INodeType {
};
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const credentials = this.getCredentials('copperApi');
const credentials = await this.getCredentials('copperApi');
const req = this.getRequestObject();
// Check if the supplied secret matches. If not ignore request.

View file

@ -44,7 +44,7 @@ export async function copperApiRequest(
uri = '',
option: IDataObject = {},
) {
const credentials = this.getCredentials('copperApi') as { apiKey: string, email: string };
const credentials = await this.getCredentials('copperApi') as { apiKey: string, email: string };
let options: OptionsWithUri = {
headers: {

View file

@ -23,7 +23,7 @@ import * as moment from 'moment';
export async function cortexApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('cortexApi');
const credentials = await this.getCredentials('cortexApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

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

View file

@ -17,7 +17,7 @@ import {
} from 'lodash';
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 = this.getCredentials('customerIoApi');
const credentials = await this.getCredentials('customerIoApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -25,7 +25,7 @@ export async function deepLApiRequest(
const proApiEndpoint = 'https://api.deepl.com/v2';
const freeApiEndpoint = 'https://api-free.deepl.com/v2';
const credentials = this.getCredentials('deepLApi');
const credentials = await this.getCredentials('deepLApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
@ -51,6 +51,12 @@ export async function deepLApiRequest(
delete options.body;
}
const credentials = await this.getCredentials('deepLApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
options.qs.auth_key = credentials.apiKey;
return await this.helpers.request!(options);

View file

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

View file

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

View file

@ -16,7 +16,7 @@ export async function disqusApiRequest(
option: IDataObject = {},
): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('disqusApi') as IDataObject;
const credentials = await this.getCredentials('disqusApi') as IDataObject;
qs.api_key = credentials.accessToken;
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -35,7 +35,7 @@ export async function driftApiRequest(this: IExecuteFunctions | IWebhookFunction
try {
if (authenticationMethod === 'accessToken') {
const credentials = this.getCredentials('driftApi');
const credentials = await this.getCredentials('driftApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -796,7 +796,7 @@ export class Dropbox implements INodeType {
let simple = false;
const { accessType } = getCredentials.call(this);
const { accessType } = await getCredentials.call(this);
if (accessType === 'full') {
// get the root directory to set it as the default for all operations

View file

@ -42,7 +42,7 @@ export async function dropboxApiRequest(this: IHookFunctions | IExecuteFunctions
try {
if (authenticationMethod === 'accessToken') {
const credentials = this.getCredentials('dropboxApi') as IDataObject;
const credentials = await this.getCredentials('dropboxApi') as IDataObject;
options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
@ -101,12 +101,12 @@ export function simplify(data: IDataObject[]) {
return results;
}
export function getCredentials(this: IExecuteFunctions) {
export async function getCredentials(this: IExecuteFunctions) {
const authenticationMethod = this.getNodeParameter('authentication', 0) as string;
if (authenticationMethod === 'accessToken') {
return this.getCredentials('dropboxApi') as IDataObject;
return await this.getCredentials('dropboxApi') as IDataObject;
} else {
return this.getCredentials('dropboxOAuth2Api') as IDataObject;
return await this.getCredentials('dropboxOAuth2Api') as IDataObject;
}
}

View file

@ -24,7 +24,7 @@ export async function erpNextApiRequest(
uri?: string,
option: IDataObject = {},
) {
const credentials = this.getCredentials('erpNextApi') as ERPNextApiCredentials;
const credentials = await this.getCredentials('erpNextApi') as ERPNextApiCredentials;
const baseUrl = getBaseUrl(credentials);
if (credentials === undefined) {

View file

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

View file

@ -26,7 +26,7 @@ export async function elasticsearchApiRequest(
username,
password,
baseUrl,
} = this.getCredentials('elasticsearchApi') as ElasticsearchApiCredentials;
} = await this.getCredentials('elasticsearchApi') as ElasticsearchApiCredentials;
const token = Buffer.from(`${username}:${password}`).toString('base64');

View file

@ -177,7 +177,7 @@ export class EmailReadImap implements INodeType {
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
const credentials = this.getCredentials('imap');
const credentials = await this.getCredentials('imap');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -147,7 +147,7 @@ export class EmailSend implements INodeType {
const attachmentPropertyString = this.getNodeParameter('attachments', itemIndex) as string;
const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject;
const credentials = this.getCredentials('smtp');
const credentials = await this.getCredentials('smtp');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -35,7 +35,7 @@ export async function emeliaApiRequest(
body: object = {},
qs: object = {},
) {
const { apiKey } = this.getCredentials('emeliaApi') as { apiKey: string };
const { apiKey } = await this.getCredentials('emeliaApi') as { apiKey: string };
const options = {
headers: {

View file

@ -32,7 +32,7 @@ export async function eventbriteApiRequest(this: IHookFunctions | IExecuteFuncti
try {
if (authenticationMethod === 'privateKey') {
const credentials = this.getCredentials('eventbriteApi');
const credentials = await this.getCredentials('eventbriteApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -295,7 +295,7 @@ export class FacebookGraphApi implements INodeType {
const returnItems: INodeExecutionData[] = [];
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
const graphApiCredentials = this.getCredentials('facebookGraphApi');
const graphApiCredentials = await this.getCredentials('facebookGraphApi');
const hostUrl = this.getNodeParameter('hostUrl', itemIndex) as string;
const httpRequestMethod = this.getNodeParameter('httpRequestMethod', itemIndex) as string;

View file

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

View file

@ -23,9 +23,9 @@ export async function facebookApiRequest(this: IHookFunctions | IExecuteFunction
let credentials;
if (this.getNode().name.includes('Trigger')) {
credentials = this.getCredentials('facebookGraphAppApi') as IDataObject;
credentials = await this.getCredentials('facebookGraphAppApi') as IDataObject;
} else {
credentials = this.getCredentials('facebookGraphApi') as IDataObject;
credentials = await this.getCredentials('facebookGraphApi') as IDataObject;
}
qs.access_token = credentials!.accessToken;

View file

@ -773,7 +773,7 @@ export class FileMaker implements INodeType {
const items = this.getInputData();
const returnData: INodeExecutionData[] = [];
const credentials = this.getCredentials('fileMaker');
const credentials = await this.getCredentials('fileMaker');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -39,7 +39,7 @@ interface ScriptObject {
*/
export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<INodePropertyOptions[]> { // tslint:disable-line:no-any
const token = await getToken.call(this);
const credentials = this.getCredentials('fileMaker');
const credentials = await this.getCredentials('fileMaker');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
@ -89,7 +89,7 @@ function parseLayouts(layouts: LayoutObject[]): INodePropertyOptions[] {
*/
export async function getFields(this: ILoadOptionsFunctions): Promise<any> { // tslint:disable-line:no-any
const token = await getToken.call(this);
const credentials = this.getCredentials('fileMaker');
const credentials = await this.getCredentials('fileMaker');
const layout = this.getCurrentNodeParameter('layout') as string;
if (credentials === undefined) {
@ -125,7 +125,7 @@ export async function getFields(this: ILoadOptionsFunctions): Promise<any> { //
*/
export async function getPortals(this: ILoadOptionsFunctions): Promise<any> { // tslint:disable-line:no-any
const token = await getToken.call(this);
const credentials = this.getCredentials('fileMaker');
const credentials = await this.getCredentials('fileMaker');
const layout = this.getCurrentNodeParameter('layout') as string;
if (credentials === undefined) {
@ -161,7 +161,7 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise<any> { //
*/
export async function getScripts(this: ILoadOptionsFunctions): Promise<any> { // tslint:disable-line:no-any
const token = await getToken.call(this);
const credentials = this.getCredentials('fileMaker');
const credentials = await this.getCredentials('fileMaker');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
@ -207,7 +207,7 @@ function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] {
}
export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('fileMaker');
const credentials = await this.getCredentials('fileMaker');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
@ -256,7 +256,7 @@ export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions |
}
export async function logout(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions, token: string): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('fileMaker');
const credentials = await this.getCredentials('fileMaker');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

@ -63,7 +63,7 @@ export class Flow implements INodeType {
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const credentials = this.getCredentials('flowApi');
const credentials = await this.getCredentials('flowApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -109,7 +109,7 @@ export class FlowTrigger implements INodeType {
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {
const credentials = this.getCredentials('flowApi');
const credentials = await this.getCredentials('flowApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
@ -143,7 +143,7 @@ export class FlowTrigger implements INodeType {
return true;
},
async create(this: IHookFunctions): Promise<boolean> {
const credentials = this.getCredentials('flowApi');
const credentials = await this.getCredentials('flowApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
@ -187,7 +187,7 @@ export class FlowTrigger implements INodeType {
return true;
},
async delete(this: IHookFunctions): Promise<boolean> {
const credentials = this.getCredentials('flowApi');
const credentials = await this.getCredentials('flowApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

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

View file

@ -14,7 +14,7 @@ import {
export async function freshdeskApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = this.getCredentials('freshdeskApi');
const credentials = await this.getCredentials('freshdeskApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -31,7 +31,7 @@ export async function freshworksCrmApiRequest(
body: IDataObject = {},
qs: IDataObject = {},
) {
const { apiKey, domain } = this.getCredentials('freshworksCrmApi') as FreshworksCrmApiCredentials;
const { apiKey, domain } = await this.getCredentials('freshworksCrmApi') as FreshworksCrmApiCredentials;
const options: OptionsWithUri = {
headers: {

View file

@ -374,9 +374,9 @@ export class Ftp implements INodeType {
const protocol = this.getNodeParameter('protocol', 0) as string;
if (protocol === 'sftp') {
credentials = this.getCredentials('sftp');
credentials = await this.getCredentials('sftp');
} else {
credentials = this.getCredentials('ftp');
credentials = await this.getCredentials('ftp');
}
try {

View file

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

View file

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

View file

@ -206,11 +206,11 @@ export class Git implements INodeType {
const items = this.getInputData();
const prepareRepository = (repositoryPath: string): string => {
const prepareRepository = async (repositoryPath: string): Promise<string> => {
const authentication = this.getNodeParameter('authentication', 0) as string;
if (authentication === 'gitPassword') {
const gitCredentials = this.getCredentials('gitPassword') as IDataObject;
const gitCredentials = await this.getCredentials('gitPassword') as IDataObject;
const url = new URL(repositoryPath);
url.username = gitCredentials.username as string;
@ -284,7 +284,7 @@ export class Git implements INodeType {
// ----------------------------------
let sourceRepository = this.getNodeParameter('sourceRepository', itemIndex, '') as string;
sourceRepository = prepareRepository(sourceRepository);
sourceRepository = await prepareRepository(sourceRepository);
await git.clone(sourceRepository, '.');
@ -348,7 +348,7 @@ export class Git implements INodeType {
// ----------------------------------
if (options.repository) {
const targetRepository = prepareRepository(options.targetRepository as string);
const targetRepository = await prepareRepository(options.targetRepository as string);
await git.push(targetRepository);
} else {
const authentication = this.getNodeParameter('authentication', 0) as string;
@ -364,7 +364,7 @@ export class Git implements INodeType {
}
}
targetRepository = prepareRepository(targetRepository as string);
targetRepository = await prepareRepository(targetRepository as string);
await git.push(targetRepository);
} else {
await git.push();

View file

@ -39,7 +39,7 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions,
const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string;
if (authenticationMethod === 'accessToken') {
const credentials = this.getCredentials('githubApi');
const credentials = await this.getCredentials('githubApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
@ -50,7 +50,7 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions,
options.headers!.Authorization = `token ${credentials.accessToken}`;
return await this.helpers.request(options);
} else {
const credentials = this.getCredentials('githubOAuth2Api');
const credentials = await this.getCredentials('githubOAuth2Api');
const baseUrl = credentials!.server || 'https://api.github.com';
options.uri = `${baseUrl}${endpoint}`;

View file

@ -39,7 +39,7 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
try {
if (authenticationMethod === 'accessToken') {
const credentials = this.getCredentials('gitlabApi');
const credentials = await this.getCredentials('gitlabApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}
@ -50,7 +50,7 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions,
return await this.helpers.request(options);
} else {
const credentials = this.getCredentials('gitlabOAuth2Api');
const credentials = await this.getCredentials('gitlabOAuth2Api');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
}

View file

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

View file

@ -137,7 +137,7 @@ export async function handleGetAll(
}
export async function loadWebinars(this: ILoadOptionsFunctions) {
const { oauthTokenData } = this.getCredentials('goToWebinarOAuth2Api') as {
const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as {
oauthTokenData: { account_key: string }
};
@ -163,7 +163,7 @@ export async function loadWebinars(this: ILoadOptionsFunctions) {
}
export async function loadWebinarSessions(this: ILoadOptionsFunctions) {
const { oauthTokenData } = this.getCredentials('goToWebinarOAuth2Api') as {
const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as {
oauthTokenData: { organizer_key: string }
};
@ -186,7 +186,7 @@ export async function loadWebinarSessions(this: ILoadOptionsFunctions) {
}
export async function loadRegistranSimpleQuestions(this: ILoadOptionsFunctions) {
const { oauthTokenData } = this.getCredentials('goToWebinarOAuth2Api') as {
const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as {
oauthTokenData: { organizer_key: string }
};
@ -211,7 +211,7 @@ export async function loadRegistranSimpleQuestions(this: ILoadOptionsFunctions)
}
export async function loadAnswers(this: ILoadOptionsFunctions) {
const { oauthTokenData } = this.getCredentials('goToWebinarOAuth2Api') as {
const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as {
oauthTokenData: { organizer_key: string }
};
@ -240,7 +240,7 @@ export async function loadAnswers(this: ILoadOptionsFunctions) {
}
export async function loadRegistranMultiChoiceQuestions(this: ILoadOptionsFunctions) {
const { oauthTokenData } = this.getCredentials('goToWebinarOAuth2Api') as {
const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as {
oauthTokenData: { organizer_key: string }
};

View file

@ -158,7 +158,7 @@ export class GoToWebinar implements INodeType {
let responseData;
const returnData: IDataObject[] = [];
const { oauthTokenData } = this.getCredentials('goToWebinarOAuth2Api') as {
const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as {
oauthTokenData: { account_key: string, organizer_key: string }
};

View file

@ -37,7 +37,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
}
if (authenticationMethod === 'serviceAccount') {
const credentials = this.getCredentials('googleApi');
const credentials = await this.getCredentials('googleApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -44,7 +44,7 @@ export async function googleApiRequest(
try {
if (authenticationMethod === 'serviceAccount') {
const credentials = this.getCredentials('googleApi');
const credentials = await this.getCredentials('googleApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -36,7 +36,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
}
if (authenticationMethod === 'serviceAccount') {
const credentials = this.getCredentials('googleApi');
const credentials = await this.getCredentials('googleApi');
if (credentials === undefined) {
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

View file

@ -98,7 +98,7 @@
// const resourceId = this.getNodeParameter('resourceId') as string;
// const credentials = this.getCredentials('googleApi');
// const credentials = await this.getCredentials('googleApi');
// if (credentials === undefined) {
// throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
@ -190,7 +190,7 @@
// const resourceId = this.getNodeParameter('resourceId') as string;
// const credentials = this.getCredentials('googleApi');
// const credentials = await this.getCredentials('googleApi');
// if (credentials === undefined) {
// throw new NodeOperationError(this.getNode(), 'No credentials got returned!');

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