Enable esModuleInterop compiler option and upgrade to TypeScript 4.6 (#3106)

*  Enable `esModuleInterop` for /core

*  Adjust imports in /core

*  Enable `esModuleInterop` for /cli

*  Adjust imports in /cli

*  Enable `esModuleInterop` for /nodes-base

*  Adjust imports in /nodes-base

*  Make imports consistent

* ⬆️ Upgrade TypeScript to 4.6 (#3109)

* ⬆️ Upgrade TypeScript to 4.6

* 📦 Update package-lock.json

* 🔧 Avoid erroring on untyped errors

* 📘 Fix type error

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Iván Ovejero 2022-04-08 23:32:08 +02:00 committed by GitHub
parent 37a6e329af
commit 027dfb2f0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
198 changed files with 1034 additions and 1169 deletions

1433
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,7 @@ import {
} from '../src'; } from '../src';
import { getLogger } from '../src/Logger'; import { getLogger } from '../src/Logger';
import config = require('../config'); import config from '../config';
import { getInstanceOwner } from '../src/UserManagement/UserManagementHelper'; import { getInstanceOwner } from '../src/UserManagement/UserManagementHelper';
export class Execute extends Command { export class Execute extends Command {

View file

@ -6,7 +6,7 @@
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
/* eslint-disable @typescript-eslint/unbound-method */ /* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable no-console */ /* eslint-disable no-console */
import * as fs from 'fs'; import fs from 'fs';
import { Command, flags } from '@oclif/command'; import { Command, flags } from '@oclif/command';
import { BinaryDataManager, UserSettings } from 'n8n-core'; import { BinaryDataManager, UserSettings } from 'n8n-core';
@ -36,7 +36,7 @@ import {
NodeTypes, NodeTypes,
WorkflowRunner, WorkflowRunner,
} from '../src'; } from '../src';
import config = require('../config'); import config from '../config';
import { User } from '../src/databases/entities/User'; import { User } from '../src/databases/entities/User';
import { getInstanceOwner } from '../src/UserManagement/UserManagementHelper'; import { getInstanceOwner } from '../src/UserManagement/UserManagementHelper';

View file

@ -7,8 +7,8 @@ import { Credentials, UserSettings } from 'n8n-core';
import { IDataObject, LoggerProxy } from 'n8n-workflow'; import { IDataObject, LoggerProxy } from 'n8n-workflow';
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import { getLogger } from '../../src/Logger'; import { getLogger } from '../../src/Logger';
import { Db, ICredentialsDecryptedDb } from '../../src'; import { Db, ICredentialsDecryptedDb } from '../../src';

View file

@ -4,8 +4,8 @@ import { Command, flags } from '@oclif/command';
import { IDataObject, LoggerProxy } from 'n8n-workflow'; import { IDataObject, LoggerProxy } from 'n8n-workflow';
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import { getLogger } from '../../src/Logger'; import { getLogger } from '../../src/Logger';
import { Db } from '../../src'; import { Db } from '../../src';

View file

@ -12,9 +12,9 @@ import { Credentials, UserSettings } from 'n8n-core';
import { LoggerProxy } from 'n8n-workflow'; import { LoggerProxy } from 'n8n-workflow';
import * as fs from 'fs'; import fs from 'fs';
import * as glob from 'fast-glob'; import glob from 'fast-glob';
import * as path from 'path'; import path from 'path';
import { EntityManager, getConnection } from 'typeorm'; import { EntityManager, getConnection } from 'typeorm';
import { getLogger } from '../../src/Logger'; import { getLogger } from '../../src/Logger';
import { Db } from '../../src'; import { Db } from '../../src';

View file

@ -12,8 +12,8 @@ import { Command, flags } from '@oclif/command';
import { INode, INodeCredentialsDetails, LoggerProxy } from 'n8n-workflow'; import { INode, INodeCredentialsDetails, LoggerProxy } from 'n8n-workflow';
import * as fs from 'fs'; import fs from 'fs';
import * as glob from 'fast-glob'; import glob from 'fast-glob';
import { UserSettings } from 'n8n-core'; import { UserSettings } from 'n8n-core';
import { EntityManager, getConnection } from 'typeorm'; import { EntityManager, getConnection } from 'typeorm';
import { getLogger } from '../../src/Logger'; import { getLogger } from '../../src/Logger';

View file

@ -6,15 +6,15 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
import * as localtunnel from 'localtunnel'; import localtunnel from 'localtunnel';
import { BinaryDataManager, TUNNEL_SUBDOMAIN_ENV, UserSettings } from 'n8n-core'; import { BinaryDataManager, TUNNEL_SUBDOMAIN_ENV, UserSettings } from 'n8n-core';
import { Command, flags } from '@oclif/command'; import { Command, flags } from '@oclif/command';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import * as Redis from 'ioredis'; import Redis from 'ioredis';
import { IDataObject, LoggerProxy } from 'n8n-workflow'; import { IDataObject, LoggerProxy } from 'n8n-workflow';
import { createHash } from 'crypto'; import { createHash } from 'crypto';
import * as config from '../config'; import config from '../config';
import { import {
ActiveExecutions, ActiveExecutions,
ActiveWorkflowRunner, ActiveWorkflowRunner,

View file

@ -6,10 +6,10 @@
import { BinaryDataManager, UserSettings } from 'n8n-core'; import { BinaryDataManager, UserSettings } from 'n8n-core';
import { Command, flags } from '@oclif/command'; import { Command, flags } from '@oclif/command';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import * as Redis from 'ioredis'; import Redis from 'ioredis';
import { IDataObject, LoggerProxy } from 'n8n-workflow'; import { IDataObject, LoggerProxy } from 'n8n-workflow';
import * as config from '../config'; import config from '../config';
import { import {
ActiveExecutions, ActiveExecutions,
ActiveWorkflowRunner, ActiveWorkflowRunner,

View file

@ -7,9 +7,9 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-unused-vars */
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import * as express from 'express'; import express from 'express';
import * as http from 'http'; import http from 'http';
import * as PCancelable from 'p-cancelable'; import PCancelable from 'p-cancelable';
import { Command, flags } from '@oclif/command'; import { Command, flags } from '@oclif/command';
import { BinaryDataManager, IBinaryDataConfig, UserSettings, WorkflowExecute } from 'n8n-core'; import { BinaryDataManager, IBinaryDataConfig, UserSettings, WorkflowExecute } from 'n8n-core';
@ -18,7 +18,7 @@ import { IExecuteResponsePromiseData, INodeTypes, IRun, Workflow, LoggerProxy }
import { FindOneOptions, getConnectionManager } from 'typeorm'; import { FindOneOptions, getConnectionManager } from 'typeorm';
import * as Bull from 'bull'; import Bull from 'bull';
import { import {
CredentialsOverwrites, CredentialsOverwrites,
CredentialTypes, CredentialTypes,
@ -39,7 +39,7 @@ import {
import { getLogger } from '../src/Logger'; import { getLogger } from '../src/Logger';
import * as config from '../config'; import config from '../config';
import * as Queue from '../src/Queue'; import * as Queue from '../src/Queue';
import { import {
checkPermissionsForExecution, checkPermissionsForExecution,

View file

@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/unbound-method */ /* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable no-console */ /* eslint-disable no-console */
import convict from 'convict';
import * as convict from 'convict'; import dotenv from 'dotenv';
import * as dotenv from 'dotenv';
import { schema } from './schema'; import { schema } from './schema';
dotenv.config(); dotenv.config();

View file

@ -1,7 +1,7 @@
/* eslint-disable no-restricted-syntax */ /* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
import * as path from 'path'; import path from 'path';
import * as core from 'n8n-core'; import * as core from 'n8n-core';
export const schema = { export const schema = {

View file

@ -1,4 +1,4 @@
import * as path from 'path'; import path from 'path';
import { UserSettings } from 'n8n-core'; import { UserSettings } from 'n8n-core';
import { entities } from '../src/databases/entities'; import { entities } from '../src/databases/entities';

View file

@ -89,7 +89,7 @@
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"ts-node": "^8.9.1", "ts-node": "^8.9.1",
"tslint": "^6.1.2", "tslint": "^6.1.2",
"typescript": "~4.3.5" "typescript": "~4.6.0"
}, },
"dependencies": { "dependencies": {
"@oclif/command": "^1.5.18", "@oclif/command": "^1.5.18",

View file

@ -15,7 +15,7 @@ import {
import { ChildProcess } from 'child_process'; import { ChildProcess } from 'child_process';
import { stringify } from 'flatted'; import { stringify } from 'flatted';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import * as PCancelable from 'p-cancelable'; import PCancelable from 'p-cancelable';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { import {
Db, Db,

View file

@ -30,7 +30,7 @@ import {
LoggerProxy as Logger, LoggerProxy as Logger,
} from 'n8n-workflow'; } from 'n8n-workflow';
import * as express from 'express'; import express from 'express';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { import {
@ -48,7 +48,7 @@ import {
WorkflowRunner, WorkflowRunner,
ExternalHooks, ExternalHooks,
} from '.'; } from '.';
import config = require('../config'); import config from '../config';
import { User } from './databases/entities/User'; import { User } from './databases/entities/User';
import { whereClause } from './WorkflowHelpers'; import { whereClause } from './WorkflowHelpers';
import { WorkflowEntity } from './databases/entities/WorkflowEntity'; import { WorkflowEntity } from './databases/entities/WorkflowEntity';

View file

@ -15,11 +15,11 @@ import {
Repository, Repository,
} from 'typeorm'; } from 'typeorm';
import { TlsOptions } from 'tls'; import { TlsOptions } from 'tls';
import * as path from 'path'; import path from 'path';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { DatabaseType, GenericHelpers, IDatabaseCollections } from '.'; import { DatabaseType, GenericHelpers, IDatabaseCollections } from '.';
import * as config from '../config'; import config from '../config';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { entities } from './databases/entities'; import { entities } from './databases/entities';

View file

@ -4,7 +4,7 @@
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { Db, IExternalHooksClass, IExternalHooksFileData, IExternalHooksFunctions } from '.'; import { Db, IExternalHooksClass, IExternalHooksFileData, IExternalHooksFunctions } from '.';
import * as config from '../config'; import config from '../config';
class ExternalHooksClass implements IExternalHooksClass { class ExternalHooksClass implements IExternalHooksClass {
externalHooks: { externalHooks: {

View file

@ -5,12 +5,12 @@
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
/* eslint-disable no-underscore-dangle */ /* eslint-disable no-underscore-dangle */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
import * as express from 'express'; import express from 'express';
import { join as pathJoin } from 'path'; import { join as pathJoin } from 'path';
import { readFile as fsReadFile } from 'fs/promises'; import { readFile as fsReadFile } from 'fs/promises';
import { IDataObject } from 'n8n-workflow'; import { IDataObject } from 'n8n-workflow';
import { validate } from 'class-validator'; import { validate } from 'class-validator';
import * as config from '../config'; import config from '../config';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { Db, ICredentialsDb, IPackageVersions, ResponseHelper } from '.'; import { Db, ICredentialsDb, IPackageVersions, ResponseHelper } from '.';

View file

@ -21,7 +21,7 @@ import {
import { WorkflowExecute } from 'n8n-core'; import { WorkflowExecute } from 'n8n-core';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import * as PCancelable from 'p-cancelable'; import PCancelable from 'p-cancelable';
import { Repository } from 'typeorm'; import { Repository } from 'typeorm';
import { ChildProcess } from 'child_process'; import { ChildProcess } from 'child_process';

View file

@ -26,10 +26,10 @@ import {
readFile as fsReadFile, readFile as fsReadFile,
stat as fsStat, stat as fsStat,
} from 'fs/promises'; } from 'fs/promises';
import * as glob from 'fast-glob'; import glob from 'fast-glob';
import * as path from 'path'; import path from 'path';
import { getLogger } from './Logger'; import { getLogger } from './Logger';
import * as config from '../config'; import config from '../config';
const CUSTOM_NODES_CATEGORY = 'Custom Nodes'; const CUSTOM_NODES_CATEGORY = 'Custom Nodes';

View file

@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/no-shadow */ /* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
import * as winston from 'winston'; import winston from 'winston';
import { IDataObject, ILogger, LogTypes } from 'n8n-workflow'; import { IDataObject, ILogger, LogTypes } from 'n8n-workflow';
import * as callsites from 'callsites'; import callsites from 'callsites';
import { basename } from 'path'; import { basename } from 'path';
import config = require('../config'); import config from '../config';
class Logger implements ILogger { class Logger implements ILogger {
private logger: winston.Logger; private logger: winston.Logger;

View file

@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
// @ts-ignore // @ts-ignore
import * as sseChannel from 'sse-channel'; import sseChannel from 'sse-channel';
import * as express from 'express'; import express from 'express';
import { LoggerProxy as Logger } from 'n8n-workflow'; import { LoggerProxy as Logger } from 'n8n-workflow';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle

View file

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
import * as Bull from 'bull'; import Bull from 'bull';
import * as config from '../config'; import config from '../config';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { IBullJobData, IBullWebhookResponse } from './Interfaces'; import { IBullJobData, IBullWebhookResponse } from './Interfaces';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle

View file

@ -29,10 +29,10 @@
/* eslint-disable import/no-dynamic-require */ /* eslint-disable import/no-dynamic-require */
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
import * as express from 'express'; import express from 'express';
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';
import { readFile } from 'fs/promises'; import { readFile } from 'fs/promises';
import { cloneDeep } from 'lodash'; import _, { cloneDeep } from 'lodash';
import { dirname as pathDirname, join as pathJoin, resolve as pathResolve } from 'path'; import { dirname as pathDirname, join as pathJoin, resolve as pathResolve } from 'path';
import { import {
FindConditions, FindConditions,
@ -47,22 +47,19 @@ import {
Not, Not,
Raw, Raw,
} from 'typeorm'; } from 'typeorm';
import * as bodyParser from 'body-parser'; import bodyParser from 'body-parser';
import * as cookieParser from 'cookie-parser'; import cookieParser from 'cookie-parser';
import * as history from 'connect-history-api-fallback'; import history from 'connect-history-api-fallback';
import * as os from 'os'; import os from 'os';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import * as _ from 'lodash'; import clientOAuth2 from 'client-oauth2';
import * as clientOAuth2 from 'client-oauth2'; import clientOAuth1, { RequestOptions } from 'oauth-1.0a';
import * as clientOAuth1 from 'oauth-1.0a'; import csrf from 'csrf';
import { RequestOptions } from 'oauth-1.0a'; import requestPromise, { OptionsWithUrl } from 'request-promise-native';
import * as csrf from 'csrf';
import * as requestPromise from 'request-promise-native';
import { createHmac } from 'crypto'; import { createHmac } from 'crypto';
// IMPORTANT! Do not switch to anther bcrypt library unless really necessary and // IMPORTANT! Do not switch to anther bcrypt library unless really necessary and
// tested with all possible systems like Windows, Alpine on ARM, FreeBSD, ... // tested with all possible systems like Windows, Alpine on ARM, FreeBSD, ...
import { compare } from 'bcryptjs'; import { compare } from 'bcryptjs';
import * as promClient from 'prom-client';
import { import {
BinaryDataManager, BinaryDataManager,
@ -91,16 +88,15 @@ import {
WorkflowExecuteMode, WorkflowExecuteMode,
} from 'n8n-workflow'; } from 'n8n-workflow';
import * as basicAuth from 'basic-auth'; import basicAuth from 'basic-auth';
import * as compression from 'compression'; import compression from 'compression';
import * as jwt from 'jsonwebtoken'; import jwt from 'jsonwebtoken';
import * as jwks from 'jwks-rsa'; import jwks from 'jwks-rsa';
// @ts-ignore // @ts-ignore
import * as timezones from 'google-timezones-json'; import timezones from 'google-timezones-json';
import * as parseUrl from 'parseurl'; import parseUrl from 'parseurl';
import * as querystring from 'querystring'; import querystring from 'querystring';
import { OptionsWithUrl } from 'request-promise-native'; import promClient, { Registry } from 'prom-client';
import { Registry } from 'prom-client';
import * as Queue from './Queue'; import * as Queue from './Queue';
import { import {
ActiveExecutions, ActiveExecutions,
@ -143,7 +139,7 @@ import {
getCredentialForUser, getCredentialForUser,
} from '.'; } from '.';
import * as config from '../config'; import config from '../config';
import * as TagHelpers from './TagHelpers'; import * as TagHelpers from './TagHelpers';

View file

@ -1,7 +1,7 @@
/* eslint-disable consistent-return */ /* eslint-disable consistent-return */
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
import * as express from 'express'; import express from 'express';
import { ActiveWebhooks } from 'n8n-core'; import { ActiveWebhooks } from 'n8n-core';

View file

@ -2,8 +2,8 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable import/no-cycle */ /* eslint-disable import/no-cycle */
import { Workflow } from 'n8n-workflow'; import { Workflow } from 'n8n-workflow';
import { In, IsNull, Not } from 'typeorm'; import { In } from 'typeorm';
import express = require('express'); import express from 'express';
import { compare, genSaltSync, hash } from 'bcryptjs'; import { compare, genSaltSync, hash } from 'bcryptjs';
import { PublicUser } from './Interfaces'; import { PublicUser } from './Interfaces';
@ -11,7 +11,7 @@ import { Db, ResponseHelper } from '..';
import { MAX_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH, User } from '../databases/entities/User'; import { MAX_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH, User } from '../databases/entities/User';
import { Role } from '../databases/entities/Role'; import { Role } from '../databases/entities/Role';
import { AuthenticatedRequest } from '../requests'; import { AuthenticatedRequest } from '../requests';
import config = require('../../config'); import * as config from '../../config';
import { getWebhookBaseUrl } from '../WebhookHelpers'; import { getWebhookBaseUrl } from '../WebhookHelpers';
export async function getWorkflowOwner(workflowId: string | number): Promise<User> { export async function getWorkflowOwner(workflowId: string | number): Promise<User> {

View file

@ -1,14 +1,14 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable import/no-cycle */ /* eslint-disable import/no-cycle */
import * as jwt from 'jsonwebtoken'; import jwt from 'jsonwebtoken';
import { Response } from 'express'; import { Response } from 'express';
import { createHash } from 'crypto'; import { createHash } from 'crypto';
import { Db } from '../..'; import { Db } from '../..';
import { AUTH_COOKIE_NAME } from '../../constants'; import { AUTH_COOKIE_NAME } from '../../constants';
import { JwtToken, JwtPayload } from '../Interfaces'; import { JwtToken, JwtPayload } from '../Interfaces';
import { User } from '../../databases/entities/User'; import { User } from '../../databases/entities/User';
import config = require('../../../config'); import * as config from '../../../config';
export function issueJWT(user: User): JwtToken { export function issueJWT(user: User): JwtToken {
const { id, email, password } = user; const { id, email, password } = user;

View file

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { createTransport, Transporter } from 'nodemailer'; import { createTransport, Transporter } from 'nodemailer';
import { LoggerProxy as Logger } from 'n8n-workflow'; import { LoggerProxy as Logger } from 'n8n-workflow';
import config = require('../../../config'); import * as config from '../../../config';
import { MailData, SendEmailResult, UserManagementMailerImplementation } from './Interfaces'; import { MailData, SendEmailResult, UserManagementMailerImplementation } from './Interfaces';
export class NodeMailer implements UserManagementMailerImplementation { export class NodeMailer implements UserManagementMailerImplementation {

View file

@ -3,7 +3,7 @@ import { existsSync, readFileSync } from 'fs';
import { IDataObject } from 'n8n-workflow'; import { IDataObject } from 'n8n-workflow';
import { join as pathJoin } from 'path'; import { join as pathJoin } from 'path';
import { GenericHelpers } from '../..'; import { GenericHelpers } from '../..';
import config = require('../../../config'); import * as config from '../../../config';
import { import {
InviteEmailData, InviteEmailData,
PasswordResetData, PasswordResetData,

View file

@ -2,16 +2,16 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable import/no-cycle */ /* eslint-disable import/no-cycle */
import cookieParser = require('cookie-parser'); import cookieParser from 'cookie-parser';
import * as passport from 'passport'; import passport from 'passport';
import { Strategy } from 'passport-jwt'; import { Strategy } from 'passport-jwt';
import { NextFunction, Request, Response } from 'express'; import { NextFunction, Request, Response } from 'express';
import * as jwt from 'jsonwebtoken'; import jwt from 'jsonwebtoken';
import { LoggerProxy as Logger } from 'n8n-workflow'; import { LoggerProxy as Logger } from 'n8n-workflow';
import { JwtPayload, N8nApp } from '../Interfaces'; import { JwtPayload, N8nApp } from '../Interfaces';
import { authenticationMethods } from './auth'; import { authenticationMethods } from './auth';
import config = require('../../../config'); import * as config from '../../../config';
import { AUTH_COOKIE_NAME } from '../../constants'; import { AUTH_COOKIE_NAME } from '../../constants';
import { issueCookie, resolveJwtContent } from '../auth/jwt'; import { issueCookie, resolveJwtContent } from '../auth/jwt';
import { meNamespace } from './me'; import { meNamespace } from './me';

View file

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable import/no-cycle */ /* eslint-disable import/no-cycle */
import express = require('express'); import express from 'express';
import validator from 'validator'; import validator from 'validator';
import { LoggerProxy as Logger } from 'n8n-workflow'; import { LoggerProxy as Logger } from 'n8n-workflow';

View file

@ -1,11 +1,11 @@
/* eslint-disable import/no-cycle */ /* eslint-disable import/no-cycle */
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
import * as express from 'express'; import express from 'express';
import validator from 'validator'; import validator from 'validator';
import { LoggerProxy as Logger } from 'n8n-workflow'; import { LoggerProxy as Logger } from 'n8n-workflow';
import { Db, InternalHooksManager, ResponseHelper } from '../..'; import { Db, InternalHooksManager, ResponseHelper } from '../..';
import config = require('../../../config'); import * as config from '../../../config';
import { validateEntity } from '../../GenericHelpers'; import { validateEntity } from '../../GenericHelpers';
import { AuthenticatedRequest, OwnerRequest } from '../../requests'; import { AuthenticatedRequest, OwnerRequest } from '../../requests';
import { issueCookie } from '../auth/jwt'; import { issueCookie } from '../auth/jwt';

View file

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable import/no-cycle */ /* eslint-disable import/no-cycle */
import express = require('express'); import express from 'express';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import { URL } from 'url'; import { URL } from 'url';
import validator from 'validator'; import validator from 'validator';
@ -14,7 +14,7 @@ import { getInstanceBaseUrl, hashPassword, validatePassword } from '../UserManag
import * as UserManagementMailer from '../email'; import * as UserManagementMailer from '../email';
import type { PasswordResetRequest } from '../../requests'; import type { PasswordResetRequest } from '../../requests';
import { issueCookie } from '../auth/jwt'; import { issueCookie } from '../auth/jwt';
import config = require('../../../config'); import * as config from '../../../config';
export function passwordResetNamespace(this: N8nApp): void { export function passwordResetNamespace(this: N8nApp): void {
/** /**

View file

@ -21,7 +21,7 @@ import { SharedWorkflow } from '../../databases/entities/SharedWorkflow';
import { SharedCredentials } from '../../databases/entities/SharedCredentials'; import { SharedCredentials } from '../../databases/entities/SharedCredentials';
import * as UserManagementMailer from '../email/UserManagementMailer'; import * as UserManagementMailer from '../email/UserManagementMailer';
import config = require('../../../config'); import * as config from '../../../config';
import { issueCookie } from '../auth/jwt'; import { issueCookie } from '../auth/jwt';
export function usersNamespace(this: N8nApp): void { export function usersNamespace(this: N8nApp): void {

View file

@ -12,7 +12,7 @@ import {
LoggerProxy as Logger, LoggerProxy as Logger,
} from 'n8n-workflow'; } from 'n8n-workflow';
import * as express from 'express'; import express from 'express';
import { import {
Db, Db,

View file

@ -13,7 +13,7 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable prefer-destructuring */ /* eslint-disable prefer-destructuring */
import * as express from 'express'; import express from 'express';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import { get } from 'lodash'; import { get } from 'lodash';

View file

@ -6,16 +6,16 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
import * as express from 'express'; import express from 'express';
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import * as bodyParser from 'body-parser'; import bodyParser from 'body-parser';
// eslint-disable-next-line import/no-extraneous-dependencies, @typescript-eslint/no-unused-vars // eslint-disable-next-line import/no-extraneous-dependencies, @typescript-eslint/no-unused-vars
import * as _ from 'lodash'; import _ from 'lodash';
import * as compression from 'compression'; import compression from 'compression';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import * as parseUrl from 'parseurl'; import parseUrl from 'parseurl';
import { WebhookHttpMethod } from 'n8n-workflow'; import { WebhookHttpMethod } from 'n8n-workflow';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { import {
@ -31,7 +31,7 @@ import {
WaitingWebhooks, WaitingWebhooks,
} from '.'; } from '.';
import * as config from '../config'; import config from '../config';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { WEBHOOK_METHODS } from './WebhookHelpers'; import { WEBHOOK_METHODS } from './WebhookHelpers';

View file

@ -39,7 +39,7 @@ import {
import { LessThanOrEqual } from 'typeorm'; import { LessThanOrEqual } from 'typeorm';
import { DateUtils } from 'typeorm/util/DateUtils'; import { DateUtils } from 'typeorm/util/DateUtils';
import * as config from '../config'; import config from '../config';
import { import {
ActiveExecutions, ActiveExecutions,
CredentialsHelper, CredentialsHelper,

View file

@ -33,7 +33,7 @@ import {
WorkflowRunner, WorkflowRunner,
} from '.'; } from '.';
import * as config from '../config'; import config from '../config';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { WorkflowEntity } from './databases/entities/WorkflowEntity'; import { WorkflowEntity } from './databases/entities/WorkflowEntity';
import { User } from './databases/entities/User'; import { User } from './databases/entities/User';

View file

@ -26,12 +26,12 @@ import {
} from 'n8n-workflow'; } from 'n8n-workflow';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import * as PCancelable from 'p-cancelable'; import PCancelable from 'p-cancelable';
import { join as pathJoin } from 'path'; import { join as pathJoin } from 'path';
import { fork } from 'child_process'; import { fork } from 'child_process';
import * as Bull from 'bull'; import Bull from 'bull';
import * as config from '../config'; import config from '../config';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { import {
ActiveExecutions, ActiveExecutions,

View file

@ -44,7 +44,7 @@ import {
import { getLogger } from './Logger'; import { getLogger } from './Logger';
import * as config from '../config'; import config from '../config';
import { InternalHooksManager } from './InternalHooksManager'; import { InternalHooksManager } from './InternalHooksManager';
import { checkPermissionsForExecution } from './UserManagement/UserManagementHelper'; import { checkPermissionsForExecution } from './UserManagement/UserManagementHelper';

View file

@ -3,7 +3,7 @@
/* eslint-disable no-restricted-syntax */ /* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable import/no-cycle */ /* eslint-disable import/no-cycle */
import express = require('express'); import express from 'express';
import { In } from 'typeorm'; import { In } from 'typeorm';
import { UserSettings, Credentials } from 'n8n-core'; import { UserSettings, Credentials } from 'n8n-core';
import { INodeCredentialTestResult, LoggerProxy } from 'n8n-workflow'; import { INodeCredentialTestResult, LoggerProxy } from 'n8n-workflow';
@ -24,7 +24,7 @@ import { CredentialsEntity } from '../databases/entities/CredentialsEntity';
import { SharedCredentials } from '../databases/entities/SharedCredentials'; import { SharedCredentials } from '../databases/entities/SharedCredentials';
import { validateEntity } from '../GenericHelpers'; import { validateEntity } from '../GenericHelpers';
import type { CredentialRequest } from '../requests'; import type { CredentialRequest } from '../requests';
import config = require('../../config'); import * as config from '../../config';
import { externalHooks } from '../Server'; import { externalHooks } from '../Server';
export const credentialsController = express.Router(); export const credentialsController = express.Router();

View file

@ -14,7 +14,7 @@ import {
} from 'typeorm'; } from 'typeorm';
import { IsArray, IsObject, IsString, Length } from 'class-validator'; import { IsArray, IsObject, IsString, Length } from 'class-validator';
import config = require('../../../config'); import * as config from '../../../config';
import { DatabaseType, ICredentialsDb } from '../..'; import { DatabaseType, ICredentialsDb } from '../..';
import { SharedCredentials } from './SharedCredentials'; import { SharedCredentials } from './SharedCredentials';

View file

@ -2,7 +2,7 @@
import { WorkflowExecuteMode } from 'n8n-workflow'; import { WorkflowExecuteMode } from 'n8n-workflow';
import { Column, ColumnOptions, Entity, Index, PrimaryGeneratedColumn } from 'typeorm'; import { Column, ColumnOptions, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
import config = require('../../../config'); import * as config from '../../../config';
import { DatabaseType, IExecutionFlattedDb, IWorkflowDb } from '../..'; import { DatabaseType, IExecutionFlattedDb, IWorkflowDb } from '../..';
function resolveDataType(dataType: string) { function resolveDataType(dataType: string) {

View file

@ -11,7 +11,7 @@ import {
} from 'typeorm'; } from 'typeorm';
import { IsDate, IsOptional, IsString, Length } from 'class-validator'; import { IsDate, IsOptional, IsString, Length } from 'class-validator';
import config = require('../../../config'); import * as config from '../../../config';
import { DatabaseType } from '../../index'; import { DatabaseType } from '../../index';
import { User } from './User'; import { User } from './User';
import { SharedWorkflow } from './SharedWorkflow'; import { SharedWorkflow } from './SharedWorkflow';

View file

@ -9,7 +9,7 @@ import {
} from 'typeorm'; } from 'typeorm';
import { IsDate, IsOptional } from 'class-validator'; import { IsDate, IsOptional } from 'class-validator';
import config = require('../../../config'); import * as config from '../../../config';
import { DatabaseType } from '../../index'; import { DatabaseType } from '../../index';
import { CredentialsEntity } from './CredentialsEntity'; import { CredentialsEntity } from './CredentialsEntity';
import { User } from './User'; import { User } from './User';

View file

@ -9,7 +9,7 @@ import {
} from 'typeorm'; } from 'typeorm';
import { IsDate, IsOptional } from 'class-validator'; import { IsDate, IsOptional } from 'class-validator';
import config = require('../../../config'); import * as config from '../../../config';
import { DatabaseType } from '../../index'; import { DatabaseType } from '../../index';
import { WorkflowEntity } from './WorkflowEntity'; import { WorkflowEntity } from './WorkflowEntity';
import { User } from './User'; import { User } from './User';

View file

@ -13,7 +13,7 @@ import {
} from 'typeorm'; } from 'typeorm';
import { IsDate, IsOptional, IsString, Length } from 'class-validator'; import { IsDate, IsOptional, IsString, Length } from 'class-validator';
import config = require('../../../config'); import * as config from '../../../config';
import { DatabaseType } from '../../index'; import { DatabaseType } from '../../index';
import { ITagDb } from '../../Interfaces'; import { ITagDb } from '../../Interfaces';
import { idStringifier } from '../utils/transformers'; import { idStringifier } from '../utils/transformers';

View file

@ -14,7 +14,7 @@ import {
UpdateDateColumn, UpdateDateColumn,
} from 'typeorm'; } from 'typeorm';
import { IsEmail, IsString, Length } from 'class-validator'; import { IsEmail, IsString, Length } from 'class-validator';
import config = require('../../../config'); import * as config from '../../../config';
import { DatabaseType, IPersonalizationSurveyAnswers } from '../..'; import { DatabaseType, IPersonalizationSurveyAnswers } from '../..';
import { Role } from './Role'; import { Role } from './Role';
import { SharedWorkflow } from './SharedWorkflow'; import { SharedWorkflow } from './SharedWorkflow';

View file

@ -18,7 +18,7 @@ import {
UpdateDateColumn, UpdateDateColumn,
} from 'typeorm'; } from 'typeorm';
import config = require('../../../config'); import * as config from '../../../config';
import { DatabaseType, IWorkflowDb } from '../..'; import { DatabaseType, IWorkflowDb } from '../..';
import { TagEntity } from './TagEntity'; import { TagEntity } from './TagEntity';
import { SharedWorkflow } from './SharedWorkflow'; import { SharedWorkflow } from './SharedWorkflow';

View file

@ -1,5 +1,5 @@
import {MigrationInterface, QueryRunner} from "typeorm"; import {MigrationInterface, QueryRunner} from "typeorm";
import config = require("../../../../config"); import * as config from '../../../../config';
export class UniqueWorkflowNames1620826335440 implements MigrationInterface { export class UniqueWorkflowNames1620826335440 implements MigrationInterface {
name = 'UniqueWorkflowNames1620826335440'; name = 'UniqueWorkflowNames1620826335440';

View file

@ -1,5 +1,5 @@
import { MigrationInterface, QueryRunner } from 'typeorm'; import { MigrationInterface, QueryRunner } from 'typeorm';
import config = require('../../../../config'); import * as config from '../../../../config';
export class CertifyCorrectCollation1623936588000 implements MigrationInterface { export class CertifyCorrectCollation1623936588000 implements MigrationInterface {
name = 'CertifyCorrectCollation1623936588000'; name = 'CertifyCorrectCollation1623936588000';

View file

@ -1,5 +1,5 @@
import { MigrationInterface, QueryRunner } from 'typeorm'; import { MigrationInterface, QueryRunner } from 'typeorm';
import config = require('../../../../config'); import * as config from '../../../../config';
import { MigrationHelpers } from '../../MigrationHelpers'; import { MigrationHelpers } from '../../MigrationHelpers';
// replacing the credentials in workflows and execution // replacing the credentials in workflows and execution

View file

@ -1,6 +1,6 @@
import { MigrationInterface, QueryRunner } from 'typeorm'; import { MigrationInterface, QueryRunner } from 'typeorm';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import config = require('../../../../config'); import * as config from '../../../../config';
import { loadSurveyFromDisk } from '../../utils/migrationHelpers'; import { loadSurveyFromDisk } from '../../utils/migrationHelpers';
export class CreateUserManagement1646992772331 implements MigrationInterface { export class CreateUserManagement1646992772331 implements MigrationInterface {

View file

@ -1,5 +1,5 @@
import { MigrationInterface, QueryRunner } from 'typeorm'; import { MigrationInterface, QueryRunner } from 'typeorm';
import config = require('../../../../config'); import * as config from '../../../../config';
export class UniqueWorkflowNames1620824779533 implements MigrationInterface { export class UniqueWorkflowNames1620824779533 implements MigrationInterface {
name = 'UniqueWorkflowNames1620824779533'; name = 'UniqueWorkflowNames1620824779533';

View file

@ -1,5 +1,5 @@
import { MigrationInterface, QueryRunner } from 'typeorm'; import { MigrationInterface, QueryRunner } from 'typeorm';
import config = require('../../../../config'); import * as config from '../../../../config';
import { MigrationHelpers } from '../../MigrationHelpers'; import { MigrationHelpers } from '../../MigrationHelpers';
// replacing the credentials in workflows and execution // replacing the credentials in workflows and execution

View file

@ -3,7 +3,7 @@ import {
QueryRunner, QueryRunner,
} from 'typeorm'; } from 'typeorm';
import config = require('../../../../config'); import * as config from '../../../../config';
export class IncreaseTypeVarcharLimit1646834195327 implements MigrationInterface { export class IncreaseTypeVarcharLimit1646834195327 implements MigrationInterface {
name = 'IncreaseTypeVarcharLimit1646834195327'; name = 'IncreaseTypeVarcharLimit1646834195327';

View file

@ -1,6 +1,6 @@
import { MigrationInterface, QueryRunner } from 'typeorm'; import { MigrationInterface, QueryRunner } from 'typeorm';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import config = require('../../../../config'); import config from '../../../../config';
import { loadSurveyFromDisk } from '../../utils/migrationHelpers'; import { loadSurveyFromDisk } from '../../utils/migrationHelpers';
export class CreateUserManagement1646992772331 implements MigrationInterface { export class CreateUserManagement1646992772331 implements MigrationInterface {

View file

@ -1,5 +1,5 @@
import { MigrationInterface, QueryRunner } from 'typeorm'; import { MigrationInterface, QueryRunner } from 'typeorm';
import config = require('../../../../config'); import * as config from '../../../../config';
import { logMigrationEnd, logMigrationStart } from '../../utils/migrationHelpers'; import { logMigrationEnd, logMigrationStart } from '../../utils/migrationHelpers';
export class UniqueWorkflowNames1620821879465 implements MigrationInterface { export class UniqueWorkflowNames1620821879465 implements MigrationInterface {

View file

@ -1,5 +1,5 @@
import { MigrationInterface, QueryRunner } from 'typeorm'; import { MigrationInterface, QueryRunner } from 'typeorm';
import config = require('../../../../config'); import * as config from '../../../../config';
import { MigrationHelpers } from '../../MigrationHelpers'; import { MigrationHelpers } from '../../MigrationHelpers';
import { logMigrationEnd, logMigrationStart } from '../../utils/migrationHelpers'; import { logMigrationEnd, logMigrationStart } from '../../utils/migrationHelpers';

View file

@ -1,6 +1,6 @@
import { MigrationInterface, QueryRunner } from 'typeorm'; import { MigrationInterface, QueryRunner } from 'typeorm';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import config = require('../../../../config'); import * as config from '../../../../config';
import { import {
loadSurveyFromDisk, loadSurveyFromDisk,
logMigrationEnd, logMigrationEnd,

View file

@ -1,4 +1,4 @@
import config = require('../../../../config'); import config from '../../../../config';
import { InitialMigration1588102412422 } from './1588102412422-InitialMigration'; import { InitialMigration1588102412422 } from './1588102412422-InitialMigration';
import { WebhookModel1592445003908 } from './1592445003908-WebhookModel'; import { WebhookModel1592445003908 } from './1592445003908-WebhookModel';

View file

@ -1,5 +1,5 @@
/* eslint-disable import/no-cycle */ /* eslint-disable import/no-cycle */
import express = require('express'); import express from 'express';
import { import {
IConnections, IConnections,
ICredentialDataDecryptedObject, ICredentialDataDecryptedObject,

View file

@ -1,9 +1,9 @@
/* eslint-disable import/no-cycle */ /* eslint-disable import/no-cycle */
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
import TelemetryClient = require('@rudderstack/rudder-sdk-node'); import TelemetryClient from '@rudderstack/rudder-sdk-node';
import { IDataObject, LoggerProxy } from 'n8n-workflow'; import { IDataObject, LoggerProxy } from 'n8n-workflow';
import config = require('../../config'); import * as config from '../../config';
import { getLogger } from '../Logger'; import { getLogger } from '../Logger';
type CountBufferItemKey = type CountBufferItemKey =

View file

@ -0,0 +1,149 @@
import { hashSync, genSaltSync } from 'bcryptjs';
import express from 'express';
import validator from 'validator';
import { v4 as uuid } from 'uuid';
import * as config from '../../config';
import * as utils from './shared/utils';
import { LOGGED_OUT_RESPONSE_BODY } from './shared/constants';
import { Db } from '../../src';
import { Role } from '../../src/databases/entities/Role';
import { randomEmail, randomValidPassword, randomName } from './shared/random';
import { getGlobalOwnerRole } from './shared/testDb';
import * as testDb from './shared/testDb';
jest.mock('../../src/telemetry');
let globalOwnerRole: Role;
let app: express.Application;
let testDbName = '';
beforeAll(async () => {
app = utils.initTestServer({ endpointGroups: ['auth'], applyAuth: true });
const initResult = await testDb.init();
testDbName = initResult.testDbName;
await testDb.truncate(['User'], testDbName);
globalOwnerRole = await getGlobalOwnerRole();
utils.initTestLogger();
utils.initTestTelemetry();
});
beforeEach(async () => {
await testDb.createUser({
id: uuid(),
email: TEST_USER.email,
firstName: TEST_USER.firstName,
lastName: TEST_USER.lastName,
password: TEST_USER.password,
globalRole: globalOwnerRole,
});
config.set('userManagement.isInstanceOwnerSetUp', true);
await Db.collections.Settings!.update(
{ key: 'userManagement.isInstanceOwnerSetUp' },
{ value: JSON.stringify(true) },
);
});
afterEach(async () => {
await testDb.truncate(['User'], testDbName);
});
afterAll(async () => {
await testDb.terminate(testDbName);
});
test('POST /login should log user in', async () => {
const authlessAgent = utils.createAgent(app);
const response = await authlessAgent.post('/login').send({
email: TEST_USER.email,
password: TEST_USER.password,
});
expect(response.statusCode).toBe(200);
const {
id,
email,
firstName,
lastName,
password,
personalizationAnswers,
globalRole,
resetPasswordToken,
} = response.body.data;
expect(validator.isUUID(id)).toBe(true);
expect(email).toBe(TEST_USER.email);
expect(firstName).toBe(TEST_USER.firstName);
expect(lastName).toBe(TEST_USER.lastName);
expect(password).toBeUndefined();
expect(personalizationAnswers).toBeNull();
expect(password).toBeUndefined();
expect(resetPasswordToken).toBeUndefined();
expect(globalRole).toBeDefined();
expect(globalRole.name).toBe('owner');
expect(globalRole.scope).toBe('global');
const authToken = utils.getAuthToken(response);
expect(authToken).toBeDefined();
});
test('GET /login should receive logged in user', async () => {
const owner = await Db.collections.User!.findOneOrFail();
const authOwnerAgent = utils.createAgent(app, { auth: true, user: owner });
const response = await authOwnerAgent.get('/login');
expect(response.statusCode).toBe(200);
const {
id,
email,
firstName,
lastName,
password,
personalizationAnswers,
globalRole,
resetPasswordToken,
} = response.body.data;
expect(validator.isUUID(id)).toBe(true);
expect(email).toBe(TEST_USER.email);
expect(firstName).toBe(TEST_USER.firstName);
expect(lastName).toBe(TEST_USER.lastName);
expect(password).toBeUndefined();
expect(personalizationAnswers).toBeNull();
expect(password).toBeUndefined();
expect(resetPasswordToken).toBeUndefined();
expect(globalRole).toBeDefined();
expect(globalRole.name).toBe('owner');
expect(globalRole.scope).toBe('global');
expect(response.headers['set-cookie']).toBeUndefined();
});
test('POST /logout should log user out', async () => {
const owner = await Db.collections.User!.findOneOrFail();
const authOwnerAgent = utils.createAgent(app, { auth: true, user: owner });
const response = await authOwnerAgent.post('/logout');
expect(response.statusCode).toBe(200);
expect(response.body).toEqual(LOGGED_OUT_RESPONSE_BODY);
const authToken = utils.getAuthToken(response);
expect(authToken).toBeUndefined();
});
const TEST_USER = {
email: randomEmail(),
password: randomValidPassword(),
firstName: randomName(),
lastName: randomName(),
};

View file

@ -1,6 +1,6 @@
import express = require('express'); import express from 'express';
import * as request from 'supertest'; import request from 'supertest';
import { import {
REST_PATH_SEGMENT, REST_PATH_SEGMENT,
ROUTES_REQUIRING_AUTHORIZATION, ROUTES_REQUIRING_AUTHORIZATION,

View file

@ -1,4 +1,4 @@
import express = require('express'); import express from 'express';
import { UserSettings } from 'n8n-core'; import { UserSettings } from 'n8n-core';
import { Db } from '../../src'; import { Db } from '../../src';
import { randomName, randomString } from './shared/random'; import { randomName, randomString } from './shared/random';

View file

@ -1,8 +1,8 @@
import express = require('express'); import express from 'express';
import validator from 'validator'; import validator from 'validator';
import { IsNull } from 'typeorm'; import { IsNull } from 'typeorm';
import config = require('../../config'); import config from '../../config';
import * as utils from './shared/utils'; import * as utils from './shared/utils';
import { SUCCESS_RESPONSE_BODY } from './shared/constants'; import { SUCCESS_RESPONSE_BODY } from './shared/constants';
import { Db } from '../../src'; import { Db } from '../../src';

View file

@ -1,10 +1,10 @@
import express = require('express'); import express from 'express';
import validator from 'validator'; import validator from 'validator';
import * as utils from './shared/utils'; import * as utils from './shared/utils';
import * as testDb from './shared/testDb'; import * as testDb from './shared/testDb';
import { Db } from '../../src'; import { Db } from '../../src';
import config = require('../../config'); import config from '../../config';
import { import {
randomEmail, randomEmail,
randomName, randomName,

View file

@ -1,9 +1,9 @@
import express = require('express'); import express from 'express';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import * as utils from './shared/utils'; import * as utils from './shared/utils';
import { Db } from '../../src'; import { Db } from '../../src';
import config = require('../../config'); import config from '../../config';
import { compare } from 'bcryptjs'; import { compare } from 'bcryptjs';
import { import {
randomEmail, randomEmail,

View file

@ -1,4 +1,4 @@
import config = require('../../../config'); import config from '../../../config';
export const REST_PATH_SEGMENT = config.getEnv('endpoints.rest') as Readonly<string>; export const REST_PATH_SEGMENT = config.getEnv('endpoints.rest') as Readonly<string>;

View file

@ -1,7 +1,7 @@
import { createConnection, getConnection, ConnectionOptions, Connection } from 'typeorm'; import { createConnection, getConnection, ConnectionOptions, Connection } from 'typeorm';
import { Credentials, UserSettings } from 'n8n-core'; import { Credentials, UserSettings } from 'n8n-core';
import config = require('../../../config'); import config from '../../../config';
import { BOOTSTRAP_MYSQL_CONNECTION_NAME, BOOTSTRAP_POSTGRES_CONNECTION_NAME } from './constants'; import { BOOTSTRAP_MYSQL_CONNECTION_NAME, BOOTSTRAP_POSTGRES_CONNECTION_NAME } from './constants';
import { DatabaseType, Db, ICredentialsDb, IDatabaseCollections } from '../../../src'; import { DatabaseType, Db, ICredentialsDb, IDatabaseCollections } from '../../../src';
import { randomEmail, randomName, randomString, randomValidPassword } from './random'; import { randomEmail, randomName, randomString, randomValidPassword } from './random';

View file

@ -1,16 +1,16 @@
import { randomBytes } from 'crypto'; import { randomBytes } from 'crypto';
import { existsSync } from 'fs'; import { existsSync } from 'fs';
import express = require('express'); import express from 'express';
import * as superagent from 'superagent'; import superagent from 'superagent';
import * as request from 'supertest'; import request from 'supertest';
import { URL } from 'url'; import { URL } from 'url';
import bodyParser = require('body-parser'); import bodyParser from 'body-parser';
import * as util from 'util'; import util from 'util';
import { createTestAccount } from 'nodemailer'; import { createTestAccount } from 'nodemailer';
import { INodeTypes, LoggerProxy } from 'n8n-workflow'; import { INodeTypes, LoggerProxy } from 'n8n-workflow';
import { UserSettings } from 'n8n-core'; import { UserSettings } from 'n8n-core';
import config = require('../../../config'); import config from '../../../config';
import { AUTHLESS_ENDPOINTS, REST_PATH_SEGMENT } from './constants'; import { AUTHLESS_ENDPOINTS, REST_PATH_SEGMENT } from './constants';
import { AUTH_COOKIE_NAME } from '../../../src/constants'; import { AUTH_COOKIE_NAME } from '../../../src/constants';
import { addRoutes as authMiddleware } from '../../../src/UserManagement/routes'; import { addRoutes as authMiddleware } from '../../../src/UserManagement/routes';

View file

@ -1,9 +1,9 @@
import express = require('express'); import express from 'express';
import validator from 'validator'; import validator from 'validator';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import { Db } from '../../src'; import { Db } from '../../src';
import config = require('../../config'); import config from '../../config';
import { SUCCESS_RESPONSE_BODY } from './shared/constants'; import { SUCCESS_RESPONSE_BODY } from './shared/constants';
import { import {
randomEmail, randomEmail,

View file

@ -1,7 +1,7 @@
import { exec as callbackExec } from 'child_process'; import { exec as callbackExec } from 'child_process';
import { promisify } from 'util'; import { promisify } from 'util';
import config = require('../config'); import config from '../config';
import { BOOTSTRAP_MYSQL_CONNECTION_NAME } from './integration/shared/constants'; import { BOOTSTRAP_MYSQL_CONNECTION_NAME } from './integration/shared/constants';
const exec = promisify(callbackExec); const exec = promisify(callbackExec);

View file

@ -1,5 +1,5 @@
import { createConnection } from 'typeorm'; import { createConnection } from 'typeorm';
import config = require('../config'); import config from '../config';
import { exec } from 'child_process'; import { exec } from 'child_process';
import { getBootstrapMySqlOptions, getBootstrapPostgresOptions } from './integration/shared/testDb'; import { getBootstrapMySqlOptions, getBootstrapPostgresOptions } from './integration/shared/testDb';
import { BOOTSTRAP_MYSQL_CONNECTION_NAME } from './integration/shared/constants'; import { BOOTSTRAP_MYSQL_CONNECTION_NAME } from './integration/shared/constants';

View file

@ -20,7 +20,8 @@
"target": "es2017", "target": "es2017",
"sourceMap": true, "sourceMap": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true "experimentalDecorators": true,
"esModuleInterop": true
}, },
"include": [ "include": [
"**/*.d.ts", "**/*.d.ts",

View file

@ -40,7 +40,7 @@
"source-map-support": "^0.5.9", "source-map-support": "^0.5.9",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"tslint": "^6.1.2", "tslint": "^6.1.2",
"typescript": "~4.3.5" "typescript": "~4.6.0"
}, },
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "^0.21.1",

View file

@ -1,5 +1,5 @@
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import * as path from 'path'; import path from 'path';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import { IBinaryDataConfig, IBinaryDataManager } from '../Interfaces'; import { IBinaryDataConfig, IBinaryDataManager } from '../Interfaces';

View file

@ -23,7 +23,7 @@ import {
} from 'n8n-workflow'; } from 'n8n-workflow';
import { OptionsWithUri, OptionsWithUrl } from 'request'; import { OptionsWithUri, OptionsWithUrl } from 'request';
import * as requestPromise from 'request-promise-native'; import requestPromise from 'request-promise-native';
interface Constructable<T> { interface Constructable<T> {
new (): T; new (): T;

View file

@ -60,20 +60,17 @@ import {
import { Agent } from 'https'; import { Agent } from 'https';
import { stringify } from 'qs'; import { stringify } from 'qs';
import * as clientOAuth1 from 'oauth-1.0a'; import clientOAuth1, { Token } from 'oauth-1.0a';
import { Token } from 'oauth-1.0a'; import clientOAuth2 from 'client-oauth2';
import * as clientOAuth2 from 'client-oauth2'; import crypto, { createHmac } from 'crypto';
import * as crypto from 'crypto';
import * as url from 'url';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import { get } from 'lodash'; import { get } from 'lodash';
// eslint-disable-next-line import/no-extraneous-dependencies // eslint-disable-next-line import/no-extraneous-dependencies
import * as express from 'express'; import express from 'express';
import * as FormData from 'form-data'; import FormData from 'form-data';
import * as path from 'path'; import path from 'path';
import { OptionsWithUri, OptionsWithUrl } from 'request'; import { OptionsWithUri, OptionsWithUrl } from 'request';
import * as requestPromise from 'request-promise-native'; import requestPromise from 'request-promise-native';
import { createHmac } from 'crypto';
import { fromBuffer } from 'file-type'; import { fromBuffer } from 'file-type';
import { lookup } from 'mime-types'; import { lookup } from 'mime-types';
@ -84,7 +81,7 @@ import axios, {
AxiosResponse, AxiosResponse,
Method, Method,
} from 'axios'; } from 'axios';
import { URL, URLSearchParams } from 'url'; import url, { URL, URLSearchParams } from 'url';
import { BinaryDataManager } from './BinaryDataManager'; import { BinaryDataManager } from './BinaryDataManager';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { import {

View file

@ -2,8 +2,8 @@
/* eslint-disable @typescript-eslint/no-use-before-define */ /* eslint-disable @typescript-eslint/no-use-before-define */
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
import * as fs from 'fs'; import fs from 'fs';
import * as path from 'path'; import path from 'path';
import { createHash, randomBytes } from 'crypto'; import { createHash, randomBytes } from 'crypto';
// eslint-disable-next-line import/no-cycle // eslint-disable-next-line import/no-cycle
import { import {

View file

@ -9,7 +9,7 @@
/* eslint-disable no-restricted-syntax */ /* eslint-disable no-restricted-syntax */
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
import * as PCancelable from 'p-cancelable'; import PCancelable from 'p-cancelable';
import { import {
ExecutionError, ExecutionError,

View file

@ -17,7 +17,9 @@
"declaration": true, "declaration": true,
"outDir": "./dist/", "outDir": "./dist/",
"target": "es2019", "target": "es2019",
"sourceMap": true "sourceMap": true,
"esModuleInterop": true,
"useUnknownInCatchVariables": false,
}, },
"include": [ "include": [
"**/*.d.ts", "**/*.d.ts",

View file

@ -73,7 +73,7 @@
"storybook-addon-designs": "^6.0.1", "storybook-addon-designs": "^6.0.1",
"storybook-addon-themes": "^6.1.0", "storybook-addon-themes": "^6.1.0",
"trim": ">=0.0.3", "trim": ">=0.0.3",
"typescript": "~4.3.5", "typescript": "~4.6.0",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-class-component": "^7.2.3", "vue-class-component": "^7.2.3",
"vue-loader": "^15.9.7", "vue-loader": "^15.9.7",

View file

@ -88,7 +88,7 @@
"string-template-parser": "^1.2.6", "string-template-parser": "^1.2.6",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"tslint": "^6.1.2", "tslint": "^6.1.2",
"typescript": "~4.3.5", "typescript": "~4.6.0",
"uuid": "^8.3.2", "uuid": "^8.3.2",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-agile": "^2.0.0", "vue-agile": "^2.0.0",

View file

@ -3,8 +3,8 @@ import Vue from 'vue';
export const deviceSupportHelpers = Vue.extend({ export const deviceSupportHelpers = Vue.extend({
data() { data() {
return { return {
isTouchDevice: 'ontouchstart' in window || navigator.msMaxTouchPoints, isTouchDevice: 'ontouchstart' in window || navigator.maxTouchPoints,
isMacOs: /(ipad|iphone|ipod|mac)/i.test(navigator.platform), isMacOs: /(ipad|iphone|ipod|mac)/i.test(navigator.platform), // TODO: `platform` deprecated
}; };
}, },
computed: { computed: {

View file

@ -12,6 +12,7 @@
"moduleResolution": "node", "moduleResolution": "node",
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"useUnknownInCatchVariables": false,
"sourceMap": true, "sourceMap": true,
"baseUrl": ".", "baseUrl": ".",
"types": [ "types": [

View file

@ -67,6 +67,6 @@
"replace-in-file": "^6.0.0", "replace-in-file": "^6.0.0",
"request": "^2.88.2", "request": "^2.88.2",
"tmp-promise": "^3.0.2", "tmp-promise": "^3.0.2",
"typescript": "~4.3.5" "typescript": "~4.6.0"
} }
} }

View file

@ -4,7 +4,7 @@ import {
INodePropertyOptions, INodePropertyOptions,
} from 'n8n-workflow'; } from 'n8n-workflow';
import * as moment from 'moment-timezone'; import moment from 'moment-timezone';
// Get options for timezones // Get options for timezones
const timezones: INodePropertyOptions[] = moment.tz.countries().reduce( (timezones: INodePropertyOptions[], country: string) => { const timezones: INodePropertyOptions[] = moment.tz.countries().reduce( (timezones: INodePropertyOptions[], country: string) => {

View file

@ -15,7 +15,7 @@ import {
downloadRecordAttachments, downloadRecordAttachments,
} from './GenericFunctions'; } from './GenericFunctions';
import * as moment from 'moment'; import moment from 'moment';
export class AirtableTrigger implements INodeType { export class AirtableTrigger implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {

View file

@ -20,7 +20,7 @@ import {
getWorkspaces, getWorkspaces,
} from './GenericFunctions'; } from './GenericFunctions';
import * as moment from 'moment-timezone'; import moment from 'moment-timezone';
import { snakeCase } from 'change-case'; import { snakeCase } from 'change-case';

View file

@ -11,9 +11,9 @@ import {
apiRequest, apiRequest,
} from '../../../transport'; } from '../../../transport';
import * as moment from 'moment'; import moment from 'moment';
import { import {
capitalCase capitalCase
} from 'change-case'; } from 'change-case';
@ -96,4 +96,4 @@ export async function create(this: IExecuteFunctions, index: number): Promise<IN
//return //return
return this.helpers.returnJsonArray({ id: employeeId }); return this.helpers.returnJsonArray({ id: employeeId });
} }

View file

@ -12,7 +12,7 @@ import {
apiRequest, apiRequest,
} from '../../../transport'; } from '../../../transport';
import * as moment from 'moment'; import moment from 'moment';
import { import {
capitalCase, capitalCase,
@ -54,7 +54,7 @@ export async function update(this: IExecuteFunctions, index: number): Promise<IN
body.preferredName = this.getNodeParameter('preferredName', index) as string; body.preferredName = this.getNodeParameter('preferredName', index) as string;
body.ssn = this.getNodeParameter('ssn', index) as string; body.ssn = this.getNodeParameter('ssn', index) as string;
} else { } else {
if (!Object.keys(updateFields).length) { if (!Object.keys(updateFields).length) {
throw new NodeOperationError(this.getNode(), 'At least one fields must be updated'); throw new NodeOperationError(this.getNode(), 'At least one fields must be updated');
} }

View file

@ -24,7 +24,7 @@ import {
beeminderApiRequest, beeminderApiRequest,
} from './GenericFunctions'; } from './GenericFunctions';
import * as moment from 'moment-timezone'; import moment from 'moment-timezone';
export class Beeminder implements INodeType { export class Beeminder implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {

View file

@ -26,7 +26,7 @@ import {
folderOperations, folderOperations,
} from './FolderDescription'; } from './FolderDescription';
import * as moment from 'moment-timezone'; import moment from 'moment-timezone';
import { import {
noCase, noCase,

View file

@ -28,7 +28,7 @@ import {
messageOperations, messageOperations,
} from './descriptions'; } from './descriptions';
import * as moment from 'moment-timezone'; import moment from 'moment-timezone';
export class CiscoWebex implements INodeType { export class CiscoWebex implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {

View file

@ -101,7 +101,7 @@ import {
IList, IList,
} from './ListInterface'; } from './ListInterface';
import * as moment from 'moment-timezone'; import moment from 'moment-timezone';
export class ClickUp implements INodeType { export class ClickUp implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {

View file

@ -49,7 +49,7 @@ import {
timeEntryOperations, timeEntryOperations,
} from './TimeEntryDescription'; } from './TimeEntryDescription';
import * as moment from 'moment-timezone'; import moment from 'moment-timezone';
export class Clockify implements INodeType { export class Clockify implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {

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