fix[gmail]: removed search & read gmail since they rely on restricted scopes & a security assessment

This commit is contained in:
Waleed Latif
2025-03-20 13:02:04 -07:00
parent 7b7cca786f
commit df0b2d2d2d
6 changed files with 74 additions and 68 deletions
+66 -63
View File
@@ -5,9 +5,9 @@ import { BlockConfig } from '../types'
export const GmailBlock: BlockConfig<GmailToolResponse> = {
type: 'gmail',
name: 'Gmail',
description: 'Send, read, and search Gmail',
description: 'Send Gmail',
longDescription:
'Integrate Gmail functionality to send, read, and search email messages within your workflow. Automate email communications and process email content using OAuth authentication.',
'Integrate Gmail functionality to send email messages within your workflow. Automate email communications and process email content using OAuth authentication.',
category: 'tools',
bgColor: '#E0E0E0',
icon: GmailIcon,
@@ -20,8 +20,8 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
layout: 'full',
options: [
{ label: 'Send Email', id: 'send_gmail' },
{ label: 'Read Email', id: 'read_gmail' },
{ label: 'Search Emails', id: 'search_gmail' },
// { label: 'Read Email', id: 'read_gmail' },
// { label: 'Search Emails', id: 'search_gmail' },
],
},
// Gmail Credentials
@@ -34,7 +34,7 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
serviceId: 'gmail',
requiredScopes: [
'https://www.googleapis.com/auth/gmail.send',
'https://www.googleapis.com/auth/gmail.readonly',
// 'https://www.googleapis.com/auth/gmail.readonly',
'https://www.googleapis.com/auth/gmail.labels',
],
placeholder: 'Select Gmail account',
@@ -65,64 +65,67 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
condition: { field: 'operation', value: 'send_gmail' },
},
// Read Email Fields - Add folder selector
{
id: 'folder',
title: 'Label',
type: 'folder-selector',
layout: 'full',
provider: 'google-email',
serviceId: 'gmail',
requiredScopes: ['https://www.googleapis.com/auth/gmail.readonly'],
placeholder: 'Select Gmail label/folder',
condition: { field: 'operation', value: 'read_gmail' },
},
{
id: 'unreadOnly',
title: 'Unread Only',
type: 'switch',
layout: 'full',
condition: { field: 'operation', value: 'read_gmail' },
},
{
id: 'maxResults',
title: 'Number of Emails',
type: 'short-input',
layout: 'full',
placeholder: 'Number of emails to retrieve (default: 1, max: 10)',
condition: { field: 'operation', value: 'read_gmail' },
},
{
id: 'messageId',
title: 'Message ID',
type: 'short-input',
layout: 'full',
placeholder: 'Enter message ID to read (optional)',
condition: {
field: 'operation',
value: 'read_gmail',
and: {
field: 'folder',
value: '',
},
},
},
// Search Fields
{
id: 'query',
title: 'Search Query',
type: 'short-input',
layout: 'full',
placeholder: 'Enter search terms',
condition: { field: 'operation', value: 'search_gmail' },
},
{
id: 'maxResults',
title: 'Max Results',
type: 'short-input',
layout: 'full',
placeholder: 'Maximum number of results (default: 10)',
condition: { field: 'operation', value: 'search_gmail' },
},
// {
// id: 'folder',
// title: 'Label',
// type: 'folder-selector',
// layout: 'full',
// provider: 'google-email',
// serviceId: 'gmail',
// requiredScopes: [
// // 'https://www.googleapis.com/auth/gmail.readonly',
// 'https://www.googleapis.com/auth/gmail.labels',
// ],
// placeholder: 'Select Gmail label/folder',
// condition: { field: 'operation', value: 'read_gmail' },
// },
// {
// id: 'unreadOnly',
// title: 'Unread Only',
// type: 'switch',
// layout: 'full',
// condition: { field: 'operation', value: 'read_gmail' },
// },
// {
// id: 'maxResults',
// title: 'Number of Emails',
// type: 'short-input',
// layout: 'full',
// placeholder: 'Number of emails to retrieve (default: 1, max: 10)',
// condition: { field: 'operation', value: 'read_gmail' },
// },
// {
// id: 'messageId',
// title: 'Message ID',
// type: 'short-input',
// layout: 'full',
// placeholder: 'Enter message ID to read (optional)',
// condition: {
// field: 'operation',
// value: 'read_gmail',
// and: {
// field: 'folder',
// value: '',
// },
// },
// },
// // Search Fields
// {
// id: 'query',
// title: 'Search Query',
// type: 'short-input',
// layout: 'full',
// placeholder: 'Enter search terms',
// condition: { field: 'operation', value: 'search_gmail' },
// },
// {
// id: 'maxResults',
// title: 'Max Results',
// type: 'short-input',
// layout: 'full',
// placeholder: 'Maximum number of results (default: 10)',
// condition: { field: 'operation', value: 'search_gmail' },
// },
],
tools: {
access: ['gmail_send', 'gmail_read', 'gmail_search'],
+1 -1
View File
@@ -176,7 +176,7 @@ export const auth = betterAuth({
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/gmail.send',
'https://www.googleapis.com/auth/gmail.readonly',
// 'https://www.googleapis.com/auth/gmail.readonly',
'https://www.googleapis.com/auth/gmail.labels',
],
prompt: 'consent',
+1 -1
View File
@@ -62,7 +62,7 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig> = {
baseProviderIcon: (props) => GoogleIcon(props),
scopes: [
'https://www.googleapis.com/auth/gmail.send',
'https://www.googleapis.com/auth/gmail.readonly',
// 'https://www.googleapis.com/auth/gmail.readonly',
'https://www.googleapis.com/auth/gmail.labels',
],
},
+1 -1
View File
@@ -13,7 +13,7 @@ export const gmailReadTool: ToolConfig<GmailReadParams, GmailToolResponse> = {
required: true,
provider: 'google-email',
additionalScopes: [
'https://www.googleapis.com/auth/gmail.readonly',
// 'https://www.googleapis.com/auth/gmail.readonly',
'https://www.googleapis.com/auth/gmail.labels',
],
},
+4 -1
View File
@@ -12,7 +12,10 @@ export const gmailSearchTool: ToolConfig<GmailSearchParams, GmailToolResponse> =
oauth: {
required: true,
provider: 'google-email',
additionalScopes: ['https://www.googleapis.com/auth/gmail.readonly'],
additionalScopes: [
// 'https://www.googleapis.com/auth/gmail.readonly',
'https://www.googleapis.com/auth/gmail.labels',
],
},
params: {
@@ -35,7 +35,7 @@ export interface OAuthRequiredModalProps {
// Map of OAuth scopes to user-friendly descriptions
const SCOPE_DESCRIPTIONS: Record<string, string> = {
'https://www.googleapis.com/auth/gmail.send': 'Send emails on your behalf',
'https://www.googleapis.com/auth/gmail.readonly': 'View and read your email messages',
// 'https://www.googleapis.com/auth/gmail.readonly': 'View and read your email messages',
'https://www.googleapis.com/auth/drive': 'View and manage your Google Drive files',
'https://www.googleapis.com/auth/drive.file': 'View and manage your Google Drive files',
'https://www.googleapis.com/auth/documents': 'View and manage your Google Docs',