Some minor improvements

This commit is contained in:
Jan Oberhauser 2020-06-13 13:47:49 +02:00
parent fbfdd7ceb5
commit 094614508d
3 changed files with 21 additions and 21 deletions

View file

@ -1,6 +1,6 @@
import { import {
OptionsWithUri, OptionsWithUri,
} from 'request'; } from 'request';
import { import {
IExecuteFunctions, IExecuteFunctions,
@ -64,7 +64,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
errorMessages = errorMessages.join('|'); errorMessages = errorMessages.join('|');
} else if (error.response.body.error.message){ } else if (error.response.body.error.message) {
errorMessages = error.response.body.error.message; errorMessages = error.response.body.error.message;
} }
@ -74,7 +74,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
} }
} }
export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const returnData: IDataObject[] = []; const returnData: IDataObject[] = [];
@ -93,7 +93,7 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp
return returnData; return returnData;
} }
function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, credentials: IDataObject) : Promise<IDataObject> { function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, credentials: IDataObject): Promise<IDataObject> {
//https://developers.google.com/identity/protocols/oauth2/service-account#httprest //https://developers.google.com/identity/protocols/oauth2/service-account#httprest
const scopes = [ const scopes = [
@ -106,25 +106,25 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa
const signature = jwt.sign( const signature = jwt.sign(
{ {
'iss': credentials.email as string, 'iss': credentials.email as string,
'sub': credentials.email as string, 'sub': credentials.email as string,
'scope': scopes.join(' '), 'scope': scopes.join(' '),
'aud': `https://oauth2.googleapis.com/token`, 'aud': `https://oauth2.googleapis.com/token`,
'iat': now, 'iat': now,
'exp': now + 3600, 'exp': now + 3600,
}, },
credentials.privateKey as string, credentials.privateKey as string,
{ {
algorithm: 'RS256', algorithm: 'RS256',
header: { header: {
'kid': credentials.privateKey as string, 'kid': credentials.privateKey as string,
'typ': 'JWT', 'typ': 'JWT',
'alg': 'RS256', 'alg': 'RS256',
}, },
} }
); );
const options: OptionsWithUri = { const options: OptionsWithUri = {
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
}, },

View file

@ -797,7 +797,7 @@ export class GoogleDrive implements INodeType {
{ {
name: 'domain', name: 'domain',
value: 'domain', value: 'domain',
description:"All files shared to the user's domain that are searchable", description: 'All files shared to the user\'s domain that are searchable',
}, },
{ {
name: 'drive', name: 'drive',
@ -945,7 +945,7 @@ export class GoogleDrive implements INodeType {
queryCorpora = options.corpora as string; queryCorpora = options.corpora as string;
} }
let driveId : string | undefined; let driveId: string | undefined;
driveId = options.driveId as string; driveId = options.driveId as string;
if (driveId === '') { if (driveId === '') {
driveId = undefined; driveId = undefined;

View file

@ -138,7 +138,7 @@ export class Twitter implements INodeType {
const isImage = binaryData[binaryPropertyName].mimeType.includes('image'); const isImage = binaryData[binaryPropertyName].mimeType.includes('image');
if (isImage && isAnimatedWebp) { if (isImage && isAnimatedWebp) {
throw new Error('Animated .webp images are not supported use .git instead'); throw new Error('Animated .webp images are not supported use .gif instead');
} }
if (isImage) { if (isImage) {