Skip to content

Commit

Permalink
fix(core): Fix issue that some predefined credentials do not show up …
Browse files Browse the repository at this point in the history
…on HTTP Request Node (#3556)

* 🐛 Fix issue with credentials that define authenticate method

* ⚡ Small improvement

* ⚡ Fix typo

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
  • Loading branch information
RicardoE105 and janober authored Jun 18, 2022
1 parent c4b63fa commit d417ea7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/cli/src/LoadNodesAndCredentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:')) {
Expand Down

0 comments on commit d417ea7

Please sign in to comment.