From d417ea7ffad9e2210f3b2b5e7122ffbe70f2ba27 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Sat, 18 Jun 2022 17:37:37 -0400 Subject: [PATCH] fix(core): Fix issue that some predefined credentials do not show up on HTTP Request Node (#3556) * :bug: Fix issue with credentials that define authenticate method * :zap: Small improvement * :zap: Fix typo Co-authored-by: Jan Oberhauser --- packages/cli/src/LoadNodesAndCredentials.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/cli/src/LoadNodesAndCredentials.ts b/packages/cli/src/LoadNodesAndCredentials.ts index c1178c9058ece..c154256d7479f 100644 --- a/packages/cli/src/LoadNodesAndCredentials.ts +++ b/packages/cli/src/LoadNodesAndCredentials.ts @@ -150,6 +150,19 @@ class LoadNodesAndCredentialsClass { let tempCredential: ICredentialType; try { + // Add serializer method "toJSON" to the class so that authenticate method (if defined) + // gets mapped to the authenticate attribute before it is sent to the client. + // The authenticate property is used by the client to decide whether or not to + // include the credential type in the predifined credentials (HTTP node) + // eslint-disable-next-line func-names + tempModule[credentialName].prototype.toJSON = function () { + // eslint-disable-next-line @typescript-eslint/no-unsafe-return + return { + ...this, + authenticate: typeof this.authenticate === 'function' ? {} : this.authenticate, + }; + }; + tempCredential = new tempModule[credentialName]() as ICredentialType; if (tempCredential.icon && tempCredential.icon.startsWith('file:')) {