mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 20:29:08 +00:00
refactor(core): Deduplicate encryption logic (#3434)
* ⚡ added function to credentials helper * Refactor function name * Fix lint issues Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import { RESPONSE_ERROR_MESSAGES } from '../constants';
|
||||
import { CredentialsEntity } from '../databases/entities/CredentialsEntity';
|
||||
import { SharedCredentials } from '../databases/entities/SharedCredentials';
|
||||
import { validateEntity } from '../GenericHelpers';
|
||||
import { createCredentiasFromCredentialsEntity } from '../CredentialsHelper';
|
||||
import type { CredentialRequest } from '../requests';
|
||||
import * as config from '../../config';
|
||||
import { externalHooks } from '../Server';
|
||||
@@ -165,11 +166,7 @@ credentialsController.post(
|
||||
}
|
||||
|
||||
// Encrypt the data
|
||||
const coreCredential = new Credentials(
|
||||
{ id: null, name: newCredential.name },
|
||||
newCredential.type,
|
||||
newCredential.nodesAccess,
|
||||
);
|
||||
const coreCredential = createCredentiasFromCredentialsEntity(newCredential, true);
|
||||
|
||||
// @ts-ignore
|
||||
coreCredential.setData(newCredential.data, encryptionKey);
|
||||
@@ -301,12 +298,7 @@ credentialsController.patch(
|
||||
);
|
||||
}
|
||||
|
||||
const coreCredential = new Credentials(
|
||||
{ id: credential.id.toString(), name: credential.name },
|
||||
credential.type,
|
||||
credential.nodesAccess,
|
||||
credential.data,
|
||||
);
|
||||
const coreCredential = createCredentiasFromCredentialsEntity(credential);
|
||||
|
||||
const decryptedData = coreCredential.getData(encryptionKey);
|
||||
|
||||
@@ -410,12 +402,7 @@ credentialsController.get(
|
||||
);
|
||||
}
|
||||
|
||||
const coreCredential = new Credentials(
|
||||
{ id: credential.id.toString(), name: credential.name },
|
||||
credential.type,
|
||||
credential.nodesAccess,
|
||||
credential.data,
|
||||
);
|
||||
const coreCredential = createCredentiasFromCredentialsEntity(credential);
|
||||
|
||||
return {
|
||||
id: id.toString(),
|
||||
|
||||
Reference in New Issue
Block a user