feat(core): Replace client-oauth2 with an in-repo package (#6056)

Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-05-16 14:31:11 +00:00
committed by GitHub
parent a4224649c5
commit 77ac953eaf
27 changed files with 986 additions and 163 deletions

View File

@@ -1,15 +1,15 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
import type clientOAuth2 from 'client-oauth2';
import type { ClientOAuth2, ClientOAuth2Options, ClientOAuth2Token } from '@n8n/client-oauth2';
export const getClientCredentialsToken = async (
oAuth2Client: clientOAuth2,
oAuth2Client: ClientOAuth2,
credentials: ICredentialDataDecryptedObject,
): Promise<clientOAuth2.Token> => {
): Promise<ClientOAuth2Token> => {
const options = {};
if (credentials.authentication === 'body') {
Object.assign(options, {
headers: {
// eslint-disable-next-line @typescript-eslint/naming-convention
Authorization: '',
},
body: {
@@ -18,5 +18,5 @@ export const getClientCredentialsToken = async (
},
});
}
return oAuth2Client.credentials.getToken(options);
return oAuth2Client.credentials.getToken(options as ClientOAuth2Options);
};