mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
⚡ Automatically remove new lines from Google credentials
This commit is contained in:
@@ -87,6 +87,8 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||||||
|
|
||||||
const now = moment().unix();
|
const now = moment().unix();
|
||||||
|
|
||||||
|
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||||
|
|
||||||
const signature = jwt.sign(
|
const signature = jwt.sign(
|
||||||
{
|
{
|
||||||
'iss': credentials.email as string,
|
'iss': credentials.email as string,
|
||||||
@@ -96,11 +98,11 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||||||
'iat': now,
|
'iat': now,
|
||||||
'exp': now + 3600,
|
'exp': now + 3600,
|
||||||
},
|
},
|
||||||
credentials.privateKey as string,
|
privateKey as string,
|
||||||
{
|
{
|
||||||
algorithm: 'RS256',
|
algorithm: 'RS256',
|
||||||
header: {
|
header: {
|
||||||
'kid': credentials.privateKey as string,
|
'kid': privateKey as string,
|
||||||
'typ': 'JWT',
|
'typ': 'JWT',
|
||||||
'alg': 'RS256',
|
'alg': 'RS256',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ function getAccessToken(this: IExecuteFunctions | ILoadOptionsFunctions, credent
|
|||||||
|
|
||||||
const now = moment().unix();
|
const now = moment().unix();
|
||||||
|
|
||||||
|
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||||
|
|
||||||
const signature = jwt.sign(
|
const signature = jwt.sign(
|
||||||
{
|
{
|
||||||
'iss': credentials.email as string,
|
'iss': credentials.email as string,
|
||||||
@@ -104,11 +106,11 @@ function getAccessToken(this: IExecuteFunctions | ILoadOptionsFunctions, credent
|
|||||||
'iat': now,
|
'iat': now,
|
||||||
'exp': now + 3600,
|
'exp': now + 3600,
|
||||||
},
|
},
|
||||||
credentials.privateKey as string,
|
privateKey as string,
|
||||||
{
|
{
|
||||||
algorithm: 'RS256',
|
algorithm: 'RS256',
|
||||||
header: {
|
header: {
|
||||||
'kid': credentials.privateKey as string,
|
'kid': privateKey as string,
|
||||||
'typ': 'JWT',
|
'typ': 'JWT',
|
||||||
'alg': 'RS256',
|
'alg': 'RS256',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
|
|||||||
uri: uri || `https://www.googleapis.com${resource}`,
|
uri: uri || `https://www.googleapis.com${resource}`,
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
options = Object.assign({}, options, option);
|
options = Object.assign({}, options, option);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -94,6 +94,8 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||||||
|
|
||||||
const now = moment().unix();
|
const now = moment().unix();
|
||||||
|
|
||||||
|
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||||
|
|
||||||
const signature = jwt.sign(
|
const signature = jwt.sign(
|
||||||
{
|
{
|
||||||
'iss': credentials.email as string,
|
'iss': credentials.email as string,
|
||||||
@@ -103,11 +105,11 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||||||
'iat': now,
|
'iat': now,
|
||||||
'exp': now + 3600,
|
'exp': now + 3600,
|
||||||
},
|
},
|
||||||
credentials.privateKey as string,
|
privateKey as string,
|
||||||
{
|
{
|
||||||
algorithm: 'RS256',
|
algorithm: 'RS256',
|
||||||
header: {
|
header: {
|
||||||
'kid': credentials.privateKey as string,
|
'kid': privateKey as string,
|
||||||
'typ': 'JWT',
|
'typ': 'JWT',
|
||||||
'alg': 'RS256',
|
'alg': 'RS256',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -216,6 +216,8 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||||||
|
|
||||||
const now = moment().unix();
|
const now = moment().unix();
|
||||||
|
|
||||||
|
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||||
|
|
||||||
const signature = jwt.sign(
|
const signature = jwt.sign(
|
||||||
{
|
{
|
||||||
'iss': credentials.email as string,
|
'iss': credentials.email as string,
|
||||||
@@ -225,11 +227,11 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||||||
'iat': now,
|
'iat': now,
|
||||||
'exp': now + 3600,
|
'exp': now + 3600,
|
||||||
},
|
},
|
||||||
credentials.privateKey as string,
|
privateKey,
|
||||||
{
|
{
|
||||||
algorithm: 'RS256',
|
algorithm: 'RS256',
|
||||||
header: {
|
header: {
|
||||||
'kid': credentials.privateKey as string,
|
'kid': privateKey,
|
||||||
'typ': 'JWT',
|
'typ': 'JWT',
|
||||||
'alg': 'RS256',
|
'alg': 'RS256',
|
||||||
},
|
},
|
||||||
@@ -252,4 +254,3 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
return this.helpers.request(options);
|
return this.helpers.request(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ export function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions
|
|||||||
|
|
||||||
const now = moment().unix();
|
const now = moment().unix();
|
||||||
|
|
||||||
|
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||||
|
|
||||||
const signature = jwt.sign(
|
const signature = jwt.sign(
|
||||||
{
|
{
|
||||||
'iss': credentials.email as string,
|
'iss': credentials.email as string,
|
||||||
@@ -102,11 +104,11 @@ export function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions
|
|||||||
'iat': now,
|
'iat': now,
|
||||||
'exp': now + 3600,
|
'exp': now + 3600,
|
||||||
},
|
},
|
||||||
credentials.privateKey as string,
|
privateKey,
|
||||||
{
|
{
|
||||||
algorithm: 'RS256',
|
algorithm: 'RS256',
|
||||||
header: {
|
header: {
|
||||||
'kid': credentials.privateKey as string,
|
'kid': privateKey,
|
||||||
'typ': 'JWT',
|
'typ': 'JWT',
|
||||||
'alg': 'RS256',
|
'alg': 'RS256',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
ICredentialDataDecryptedObject,
|
||||||
IDataObject,
|
IDataObject,
|
||||||
NodeApiError,
|
NodeApiError,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -64,7 +65,7 @@ export async function googleApiRequest(
|
|||||||
|
|
||||||
function getAccessToken(
|
function getAccessToken(
|
||||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||||
{ email, privateKey }: { email: string, privateKey: string },
|
credentials: ICredentialDataDecryptedObject,
|
||||||
) {
|
) {
|
||||||
// https://developers.google.com/identity/protocols/oauth2/service-account#httprest
|
// https://developers.google.com/identity/protocols/oauth2/service-account#httprest
|
||||||
|
|
||||||
@@ -75,10 +76,12 @@ function getAccessToken(
|
|||||||
|
|
||||||
const now = moment().unix();
|
const now = moment().unix();
|
||||||
|
|
||||||
|
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||||
|
|
||||||
const signature = jwt.sign(
|
const signature = jwt.sign(
|
||||||
{
|
{
|
||||||
iss: email,
|
iss: credentials.email,
|
||||||
sub: email,
|
sub: credentials.email,
|
||||||
scope: scopes.join(' '),
|
scope: scopes.join(' '),
|
||||||
aud: 'https://oauth2.googleapis.com/token',
|
aud: 'https://oauth2.googleapis.com/token',
|
||||||
iat: now,
|
iat: now,
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||||||
|
|
||||||
const now = moment().unix();
|
const now = moment().unix();
|
||||||
|
|
||||||
|
const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n');
|
||||||
|
|
||||||
const signature = jwt.sign(
|
const signature = jwt.sign(
|
||||||
{
|
{
|
||||||
'iss': credentials.email as string,
|
'iss': credentials.email as string,
|
||||||
@@ -95,11 +97,11 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
|
|||||||
'iat': now,
|
'iat': now,
|
||||||
'exp': now + 3600,
|
'exp': now + 3600,
|
||||||
},
|
},
|
||||||
credentials.privateKey as string,
|
privateKey as string,
|
||||||
{
|
{
|
||||||
algorithm: 'RS256',
|
algorithm: 'RS256',
|
||||||
header: {
|
header: {
|
||||||
'kid': credentials.privateKey as string,
|
'kid': privateKey as string,
|
||||||
'typ': 'JWT',
|
'typ': 'JWT',
|
||||||
'alg': 'RS256',
|
'alg': 'RS256',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user