veryfront 0.0.49 → 0.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/components.js +260 -56
- package/dist/ai/components.js.map +4 -4
- package/dist/ai/index.d.ts +1 -0
- package/dist/ai/index.js +12 -4
- package/dist/ai/index.js.map +2 -2
- package/dist/ai/primitives.js +55 -10
- package/dist/ai/primitives.js.map +3 -3
- package/dist/ai/react.js +140 -1
- package/dist/ai/react.js.map +3 -3
- package/dist/ai/workflow-react.js +458 -0
- package/dist/ai/workflow-react.js.map +7 -0
- package/dist/ai/workflow.js +5422 -0
- package/dist/ai/workflow.js.map +7 -0
- package/dist/cli.js +957 -215
- package/dist/components.js +12 -4
- package/dist/components.js.map +2 -2
- package/dist/config.js +12 -4
- package/dist/config.js.map +2 -2
- package/dist/data.js +12 -4
- package/dist/data.js.map +2 -2
- package/dist/index.js +12 -4
- package/dist/index.js.map +2 -2
- package/dist/integrations/_base/files/SETUP.md +667 -98
- package/dist/integrations/_base/files/app/api/integrations/status/route.ts +3 -3
- package/dist/integrations/_base/files/app/api/integrations/token-storage/route.ts +26 -0
- package/dist/integrations/_base/files/app/components/ServiceConnections.tsx +2 -1
- package/dist/integrations/_base/files/app/setup/page.tsx +869 -55
- package/dist/integrations/_base/files/lib/token-store-examples.ts +435 -0
- package/dist/integrations/_base/files/lib/token-store.ts +273 -23
- package/dist/integrations/airtable/connector.json +99 -0
- package/dist/integrations/airtable/files/ai/tools/create-record.ts +25 -0
- package/dist/integrations/airtable/files/ai/tools/get-base.ts +34 -0
- package/dist/integrations/airtable/files/ai/tools/get-record.ts +23 -0
- package/dist/integrations/airtable/files/ai/tools/list-bases.ts +19 -0
- package/dist/integrations/airtable/files/ai/tools/list-records.ts +47 -0
- package/dist/integrations/airtable/files/app/api/auth/airtable/callback/route.ts +11 -0
- package/dist/integrations/airtable/files/app/api/auth/airtable/route.ts +9 -0
- package/dist/integrations/airtable/files/lib/airtable-client.ts +244 -0
- package/dist/integrations/anthropic/README.md +181 -0
- package/dist/integrations/anthropic/connector.json +88 -0
- package/dist/integrations/anthropic/files/_env.example +4 -0
- package/dist/integrations/anthropic/files/ai/tools/get-organization.ts +36 -0
- package/dist/integrations/anthropic/files/ai/tools/get-usage.ts +100 -0
- package/dist/integrations/anthropic/files/ai/tools/list-api-keys.ts +64 -0
- package/dist/integrations/anthropic/files/ai/tools/list-members.ts +65 -0
- package/dist/integrations/anthropic/files/ai/tools/list-workspaces.ts +35 -0
- package/dist/integrations/anthropic/files/lib/anthropic-admin-client.ts +264 -0
- package/dist/integrations/asana/connector.json +85 -0
- package/dist/integrations/asana/files/_env.example +4 -0
- package/dist/integrations/asana/files/ai/tools/create-task.ts +34 -0
- package/dist/integrations/asana/files/ai/tools/get-task.ts +26 -0
- package/dist/integrations/asana/files/ai/tools/list-projects.ts +26 -0
- package/dist/integrations/asana/files/ai/tools/list-tasks.ts +50 -0
- package/dist/integrations/asana/files/ai/tools/update-task.ts +36 -0
- package/dist/integrations/asana/files/app/api/auth/asana/callback/route.ts +11 -0
- package/dist/integrations/asana/files/app/api/auth/asana/route.ts +7 -0
- package/dist/integrations/asana/files/lib/asana-client.ts +162 -0
- package/dist/integrations/aws/connector.json +72 -0
- package/dist/integrations/aws/files/_env.example +10 -0
- package/dist/integrations/aws/files/ai/tools/get-s3-object.ts +62 -0
- package/dist/integrations/aws/files/ai/tools/list-ec2-instances.ts +56 -0
- package/dist/integrations/aws/files/ai/tools/list-lambda-functions.ts +57 -0
- package/dist/integrations/aws/files/ai/tools/list-s3-buckets.ts +44 -0
- package/dist/integrations/aws/files/ai/tools/list-s3-objects.ts +58 -0
- package/dist/integrations/aws/files/lib/aws-client.ts +255 -0
- package/dist/integrations/bitbucket/connector.json +85 -0
- package/dist/integrations/bitbucket/files/_env.example +9 -0
- package/dist/integrations/bitbucket/files/ai/tools/create-pull-request.ts +83 -0
- package/dist/integrations/bitbucket/files/ai/tools/list-issues.ts +112 -0
- package/dist/integrations/bitbucket/files/ai/tools/list-pull-requests.ts +91 -0
- package/dist/integrations/bitbucket/files/ai/tools/list-repositories.ts +78 -0
- package/dist/integrations/bitbucket/files/app/api/auth/bitbucket/callback/route.ts +11 -0
- package/dist/integrations/bitbucket/files/app/api/auth/bitbucket/route.ts +9 -0
- package/dist/integrations/bitbucket/files/lib/bitbucket-client.ts +316 -0
- package/dist/integrations/box/connector.json +85 -0
- package/dist/integrations/box/files/_env.example +4 -0
- package/dist/integrations/box/files/ai/tools/create-folder.ts +28 -0
- package/dist/integrations/box/files/ai/tools/get-file.ts +29 -0
- package/dist/integrations/box/files/ai/tools/list-files.ts +33 -0
- package/dist/integrations/box/files/ai/tools/search-files.ts +35 -0
- package/dist/integrations/box/files/ai/tools/upload-file.ts +32 -0
- package/dist/integrations/box/files/app/api/auth/box/callback/route.ts +11 -0
- package/dist/integrations/box/files/app/api/auth/box/route.ts +7 -0
- package/dist/integrations/box/files/lib/box-client.ts +280 -0
- package/dist/integrations/calendar/files/app/api/auth/calendar/callback/route.ts +7 -110
- package/dist/integrations/calendar/files/app/api/auth/calendar/route.ts +5 -25
- package/dist/integrations/clickup/connector.json +85 -0
- package/dist/integrations/clickup/files/_env.example +4 -0
- package/dist/integrations/clickup/files/ai/tools/create-task.ts +64 -0
- package/dist/integrations/clickup/files/ai/tools/get-task.ts +59 -0
- package/dist/integrations/clickup/files/ai/tools/list-lists.ts +109 -0
- package/dist/integrations/clickup/files/ai/tools/list-tasks.ts +95 -0
- package/dist/integrations/clickup/files/ai/tools/update-task.ts +85 -0
- package/dist/integrations/clickup/files/app/api/auth/clickup/callback/route.ts +11 -0
- package/dist/integrations/clickup/files/app/api/auth/clickup/route.ts +7 -0
- package/dist/integrations/clickup/files/lib/clickup-client.ts +439 -0
- package/dist/integrations/confluence/README.md +246 -0
- package/dist/integrations/confluence/connector.json +104 -0
- package/dist/integrations/confluence/files/_env.example +4 -0
- package/dist/integrations/confluence/files/ai/tools/create-page.ts +43 -0
- package/dist/integrations/confluence/files/ai/tools/get-page.ts +30 -0
- package/dist/integrations/confluence/files/ai/tools/list-spaces.ts +31 -0
- package/dist/integrations/confluence/files/ai/tools/search-content.ts +38 -0
- package/dist/integrations/confluence/files/ai/tools/update-page.ts +45 -0
- package/dist/integrations/confluence/files/app/api/auth/confluence/callback/route.ts +11 -0
- package/dist/integrations/confluence/files/app/api/auth/confluence/route.ts +9 -0
- package/dist/integrations/confluence/files/lib/confluence-client.ts +281 -0
- package/dist/integrations/discord/connector.json +100 -0
- package/dist/integrations/discord/files/_env.example +12 -0
- package/dist/integrations/discord/files/ai/tools/get-messages.ts +55 -0
- package/dist/integrations/discord/files/ai/tools/get-user.ts +32 -0
- package/dist/integrations/discord/files/ai/tools/list-channels.ts +32 -0
- package/dist/integrations/discord/files/ai/tools/list-guilds.ts +24 -0
- package/dist/integrations/discord/files/ai/tools/send-message.ts +33 -0
- package/dist/integrations/discord/files/app/api/auth/discord/callback/route.ts +11 -0
- package/dist/integrations/discord/files/app/api/auth/discord/route.ts +9 -0
- package/dist/integrations/discord/files/lib/discord-client.ts +273 -0
- package/dist/integrations/docs-google/connector.json +101 -0
- package/dist/integrations/docs-google/files/_env.example +8 -0
- package/dist/integrations/docs-google/files/ai/tools/create-document.ts +46 -0
- package/dist/integrations/docs-google/files/ai/tools/get-document.ts +46 -0
- package/dist/integrations/docs-google/files/ai/tools/list-documents.ts +42 -0
- package/dist/integrations/docs-google/files/ai/tools/search-documents.ts +38 -0
- package/dist/integrations/docs-google/files/ai/tools/update-document.ts +131 -0
- package/dist/integrations/docs-google/files/app/api/auth/docs-google/callback/route.ts +11 -0
- package/dist/integrations/docs-google/files/app/api/auth/docs-google/route.ts +9 -0
- package/dist/integrations/docs-google/files/lib/docs-client.ts +582 -0
- package/dist/integrations/drive/connector.json +134 -0
- package/dist/integrations/drive/files/_env.example +9 -0
- package/dist/integrations/drive/files/ai/tools/create-folder.ts +47 -0
- package/dist/integrations/drive/files/ai/tools/get-file.ts +55 -0
- package/dist/integrations/drive/files/ai/tools/list-files.ts +78 -0
- package/dist/integrations/drive/files/ai/tools/search-files.ts +79 -0
- package/dist/integrations/drive/files/ai/tools/upload-file.ts +59 -0
- package/dist/integrations/drive/files/app/api/auth/drive/callback/route.ts +11 -0
- package/dist/integrations/drive/files/app/api/auth/drive/route.ts +9 -0
- package/dist/integrations/drive/files/lib/drive-client.ts +359 -0
- package/dist/integrations/dropbox/connector.json +107 -0
- package/dist/integrations/dropbox/files/_env.example +24 -0
- package/dist/integrations/dropbox/files/ai/tools/get-account.ts +58 -0
- package/dist/integrations/dropbox/files/ai/tools/get-file.ts +61 -0
- package/dist/integrations/dropbox/files/ai/tools/list-files.ts +56 -0
- package/dist/integrations/dropbox/files/ai/tools/search-files.ts +70 -0
- package/dist/integrations/dropbox/files/ai/tools/upload-file.ts +48 -0
- package/dist/integrations/dropbox/files/app/api/auth/dropbox/callback/route.ts +11 -0
- package/dist/integrations/dropbox/files/app/api/auth/dropbox/route.ts +9 -0
- package/dist/integrations/dropbox/files/lib/dropbox-client.ts +397 -0
- package/dist/integrations/figma/INTEGRATION_SUMMARY.md +436 -0
- package/dist/integrations/figma/README.md +287 -0
- package/dist/integrations/figma/connector.json +100 -0
- package/dist/integrations/figma/files/_env.example +5 -0
- package/dist/integrations/figma/files/ai/tools/get-comments.ts +72 -0
- package/dist/integrations/figma/files/ai/tools/get-file.ts +54 -0
- package/dist/integrations/figma/files/ai/tools/list-files.ts +39 -0
- package/dist/integrations/figma/files/ai/tools/list-projects.ts +69 -0
- package/dist/integrations/figma/files/ai/tools/post-comment.ts +54 -0
- package/dist/integrations/figma/files/app/api/auth/figma/callback/route.ts +11 -0
- package/dist/integrations/figma/files/app/api/auth/figma/route.ts +9 -0
- package/dist/integrations/figma/files/lib/figma-client.ts +355 -0
- package/dist/integrations/figma/files/lib/types.ts +503 -0
- package/dist/integrations/freshdesk/connector.json +85 -0
- package/dist/integrations/freshdesk/files/_env.example +4 -0
- package/dist/integrations/freshdesk/files/ai/tools/create-ticket.ts +60 -0
- package/dist/integrations/freshdesk/files/ai/tools/get-ticket.ts +46 -0
- package/dist/integrations/freshdesk/files/ai/tools/list-contacts.ts +37 -0
- package/dist/integrations/freshdesk/files/ai/tools/list-tickets.ts +59 -0
- package/dist/integrations/freshdesk/files/ai/tools/update-ticket.ts +61 -0
- package/dist/integrations/freshdesk/files/app/api/auth/freshdesk/callback/route.ts +11 -0
- package/dist/integrations/freshdesk/files/app/api/auth/freshdesk/route.ts +7 -0
- package/dist/integrations/freshdesk/files/lib/freshdesk-client.ts +178 -0
- package/dist/integrations/github/files/app/api/auth/github/callback/route.ts +6 -127
- package/dist/integrations/github/files/app/api/auth/github/route.ts +4 -24
- package/dist/integrations/gitlab/connector.json +100 -0
- package/dist/integrations/gitlab/files/_env.example +7 -0
- package/dist/integrations/gitlab/files/ai/tools/create-issue.ts +49 -0
- package/dist/integrations/gitlab/files/ai/tools/get-issue.ts +56 -0
- package/dist/integrations/gitlab/files/ai/tools/list-merge-requests.ts +75 -0
- package/dist/integrations/gitlab/files/ai/tools/list-projects.ts +51 -0
- package/dist/integrations/gitlab/files/ai/tools/search-issues.ts +67 -0
- package/dist/integrations/gitlab/files/app/api/auth/gitlab/callback/route.ts +11 -0
- package/dist/integrations/gitlab/files/app/api/auth/gitlab/route.ts +9 -0
- package/dist/integrations/gitlab/files/lib/gitlab-client.ts +366 -0
- package/dist/integrations/gmail/files/app/api/auth/gmail/callback/route.ts +7 -108
- package/dist/integrations/gmail/files/app/api/auth/gmail/route.ts +5 -23
- package/dist/integrations/gmail/files/lib/gmail-client.ts +16 -55
- package/dist/integrations/hubspot/connector.json +98 -0
- package/dist/integrations/hubspot/files/_env.example +5 -0
- package/dist/integrations/hubspot/files/ai/tools/create-contact.ts +41 -0
- package/dist/integrations/hubspot/files/ai/tools/create-deal.ts +41 -0
- package/dist/integrations/hubspot/files/ai/tools/get-contact.ts +39 -0
- package/dist/integrations/hubspot/files/ai/tools/list-contacts.ts +43 -0
- package/dist/integrations/hubspot/files/ai/tools/list-deals.ts +41 -0
- package/dist/integrations/hubspot/files/app/api/auth/hubspot/callback/route.ts +11 -0
- package/dist/integrations/hubspot/files/app/api/auth/hubspot/route.ts +9 -0
- package/dist/integrations/hubspot/files/lib/hubspot-client.ts +393 -0
- package/dist/integrations/intercom/connector.json +85 -0
- package/dist/integrations/intercom/files/_env.example +4 -0
- package/dist/integrations/intercom/files/ai/tools/get-contact.ts +35 -0
- package/dist/integrations/intercom/files/ai/tools/get-conversation.ts +55 -0
- package/dist/integrations/intercom/files/ai/tools/list-contacts.ts +35 -0
- package/dist/integrations/intercom/files/ai/tools/list-conversations.ts +49 -0
- package/dist/integrations/intercom/files/ai/tools/send-message.ts +34 -0
- package/dist/integrations/intercom/files/app/api/auth/intercom/callback/route.ts +11 -0
- package/dist/integrations/intercom/files/app/api/auth/intercom/route.ts +7 -0
- package/dist/integrations/intercom/files/lib/intercom-client.ts +308 -0
- package/dist/integrations/jira/connector.json +109 -0
- package/dist/integrations/jira/files/ai/tools/create-issue.ts +47 -0
- package/dist/integrations/jira/files/ai/tools/get-issue.ts +57 -0
- package/dist/integrations/jira/files/ai/tools/list-projects.ts +30 -0
- package/dist/integrations/jira/files/ai/tools/search-issues.ts +49 -0
- package/dist/integrations/jira/files/ai/tools/update-issue.ts +81 -0
- package/dist/integrations/jira/files/app/api/auth/jira/callback/route.ts +11 -0
- package/dist/integrations/jira/files/app/api/auth/jira/route.ts +9 -0
- package/dist/integrations/jira/files/lib/jira-client.ts +338 -0
- package/dist/integrations/linear/connector.json +100 -0
- package/dist/integrations/linear/files/_env.example +6 -0
- package/dist/integrations/linear/files/ai/tools/create-issue.ts +71 -0
- package/dist/integrations/linear/files/ai/tools/get-issue.ts +55 -0
- package/dist/integrations/linear/files/ai/tools/list-projects.ts +43 -0
- package/dist/integrations/linear/files/ai/tools/search-issues.ts +54 -0
- package/dist/integrations/linear/files/ai/tools/update-issue.ts +71 -0
- package/dist/integrations/linear/files/app/api/auth/linear/callback/route.ts +11 -0
- package/dist/integrations/linear/files/app/api/auth/linear/route.ts +9 -0
- package/dist/integrations/linear/files/lib/linear-client.ts +464 -0
- package/dist/integrations/mailchimp/connector.json +85 -0
- package/dist/integrations/mailchimp/files/_env.example +4 -0
- package/dist/integrations/mailchimp/files/ai/tools/get-campaign.ts +45 -0
- package/dist/integrations/mailchimp/files/ai/tools/get-list.ts +51 -0
- package/dist/integrations/mailchimp/files/ai/tools/list-campaigns.ts +46 -0
- package/dist/integrations/mailchimp/files/ai/tools/list-lists.ts +46 -0
- package/dist/integrations/mailchimp/files/ai/tools/list-members.ts +58 -0
- package/dist/integrations/mailchimp/files/app/api/auth/mailchimp/callback/route.ts +11 -0
- package/dist/integrations/mailchimp/files/app/api/auth/mailchimp/route.ts +7 -0
- package/dist/integrations/mailchimp/files/lib/mailchimp-client.ts +267 -0
- package/dist/integrations/mixpanel/connector.json +96 -0
- package/dist/integrations/mixpanel/files/_env.example +11 -0
- package/dist/integrations/mixpanel/files/ai/tools/get-funnel.ts +46 -0
- package/dist/integrations/mixpanel/files/ai/tools/get-retention.ts +64 -0
- package/dist/integrations/mixpanel/files/ai/tools/list-cohorts.ts +46 -0
- package/dist/integrations/mixpanel/files/ai/tools/query-events.ts +43 -0
- package/dist/integrations/mixpanel/files/ai/tools/track-event.ts +41 -0
- package/dist/integrations/mixpanel/files/lib/mixpanel-client.ts +319 -0
- package/dist/integrations/monday/connector.json +85 -0
- package/dist/integrations/monday/files/_env.example +4 -0
- package/dist/integrations/monday/files/ai/tools/create-item.ts +36 -0
- package/dist/integrations/monday/files/ai/tools/get-item.ts +31 -0
- package/dist/integrations/monday/files/ai/tools/list-boards.ts +29 -0
- package/dist/integrations/monday/files/ai/tools/list-items.ts +36 -0
- package/dist/integrations/monday/files/ai/tools/update-item.ts +36 -0
- package/dist/integrations/monday/files/app/api/auth/monday/callback/route.ts +11 -0
- package/dist/integrations/monday/files/app/api/auth/monday/route.ts +7 -0
- package/dist/integrations/monday/files/lib/monday-client.ts +329 -0
- package/dist/integrations/neon/connector.json +89 -0
- package/dist/integrations/neon/files/_env.example +6 -0
- package/dist/integrations/neon/files/ai/tools/describe-table.ts +38 -0
- package/dist/integrations/neon/files/ai/tools/list-branches.ts +35 -0
- package/dist/integrations/neon/files/ai/tools/list-projects.ts +31 -0
- package/dist/integrations/neon/files/ai/tools/list-tables.ts +49 -0
- package/dist/integrations/neon/files/ai/tools/query-database.ts +33 -0
- package/dist/integrations/neon/files/app/api/auth/neon/route.ts +51 -0
- package/dist/integrations/neon/files/lib/neon-client.ts +294 -0
- package/dist/integrations/notion/connector.json +87 -0
- package/dist/integrations/notion/files/_env.example +6 -0
- package/dist/integrations/notion/files/ai/tools/create-page.ts +32 -0
- package/dist/integrations/notion/files/ai/tools/query-database.ts +44 -0
- package/dist/integrations/notion/files/ai/tools/read-page.ts +34 -0
- package/dist/integrations/notion/files/ai/tools/search-notion.ts +51 -0
- package/dist/integrations/notion/files/app/api/auth/notion/callback/route.ts +11 -0
- package/dist/integrations/notion/files/app/api/auth/notion/route.ts +9 -0
- package/dist/integrations/notion/files/lib/notion-client.ts +218 -0
- package/dist/integrations/onedrive/connector.json +100 -0
- package/dist/integrations/onedrive/files/_env.example +23 -0
- package/dist/integrations/onedrive/files/ai/tools/download-file.ts +38 -0
- package/dist/integrations/onedrive/files/ai/tools/list-files.ts +63 -0
- package/dist/integrations/onedrive/files/ai/tools/search-files.ts +59 -0
- package/dist/integrations/onedrive/files/ai/tools/upload-file.ts +43 -0
- package/dist/integrations/onedrive/files/app/api/auth/onedrive/callback/route.ts +11 -0
- package/dist/integrations/onedrive/files/app/api/auth/onedrive/route.ts +9 -0
- package/dist/integrations/onedrive/files/lib/onedrive-client.ts +314 -0
- package/dist/integrations/outlook/README.md +308 -0
- package/dist/integrations/outlook/connector.json +98 -0
- package/dist/integrations/outlook/files/_env.example +8 -0
- package/dist/integrations/outlook/files/ai/tools/get-email.ts +47 -0
- package/dist/integrations/outlook/files/ai/tools/list-emails.ts +46 -0
- package/dist/integrations/outlook/files/ai/tools/list-folders.ts +22 -0
- package/dist/integrations/outlook/files/ai/tools/search-emails.ts +41 -0
- package/dist/integrations/outlook/files/ai/tools/send-email.ts +41 -0
- package/dist/integrations/outlook/files/app/api/auth/outlook/callback/route.ts +11 -0
- package/dist/integrations/outlook/files/app/api/auth/outlook/route.ts +9 -0
- package/dist/integrations/outlook/files/lib/outlook-client.ts +204 -0
- package/dist/integrations/pipedrive/connector.json +85 -0
- package/dist/integrations/pipedrive/files/_env.example +4 -0
- package/dist/integrations/pipedrive/files/ai/tools/create-deal.ts +44 -0
- package/dist/integrations/pipedrive/files/ai/tools/get-deal.ts +34 -0
- package/dist/integrations/pipedrive/files/ai/tools/list-deals.ts +40 -0
- package/dist/integrations/pipedrive/files/ai/tools/list-persons.ts +33 -0
- package/dist/integrations/pipedrive/files/ai/tools/update-deal.ts +46 -0
- package/dist/integrations/pipedrive/files/app/api/auth/pipedrive/callback/route.ts +11 -0
- package/dist/integrations/pipedrive/files/app/api/auth/pipedrive/route.ts +7 -0
- package/dist/integrations/pipedrive/files/lib/pipedrive-client.ts +259 -0
- package/dist/integrations/posthog/connector.json +84 -0
- package/dist/integrations/posthog/files/_env.example +6 -0
- package/dist/integrations/posthog/files/ai/tools/capture-event.ts +37 -0
- package/dist/integrations/posthog/files/ai/tools/get-trends.ts +44 -0
- package/dist/integrations/posthog/files/ai/tools/list-feature-flags.ts +38 -0
- package/dist/integrations/posthog/files/ai/tools/list-persons.ts +32 -0
- package/dist/integrations/posthog/files/lib/posthog-client.ts +286 -0
- package/dist/integrations/quickbooks/connector.json +85 -0
- package/dist/integrations/quickbooks/files/_env.example +4 -0
- package/dist/integrations/quickbooks/files/ai/tools/create-invoice.ts +48 -0
- package/dist/integrations/quickbooks/files/ai/tools/get-customer.ts +36 -0
- package/dist/integrations/quickbooks/files/ai/tools/get-invoice.ts +46 -0
- package/dist/integrations/quickbooks/files/ai/tools/list-customers.ts +37 -0
- package/dist/integrations/quickbooks/files/ai/tools/list-invoices.ts +40 -0
- package/dist/integrations/quickbooks/files/app/api/auth/quickbooks/callback/route.ts +11 -0
- package/dist/integrations/quickbooks/files/app/api/auth/quickbooks/route.ts +7 -0
- package/dist/integrations/quickbooks/files/lib/quickbooks-client.ts +252 -0
- package/dist/integrations/salesforce/connector.json +104 -0
- package/dist/integrations/salesforce/files/ai/tools/create-lead.ts +101 -0
- package/dist/integrations/salesforce/files/ai/tools/get-account.ts +53 -0
- package/dist/integrations/salesforce/files/ai/tools/list-accounts.ts +50 -0
- package/dist/integrations/salesforce/files/ai/tools/list-contacts.ts +54 -0
- package/dist/integrations/salesforce/files/ai/tools/list-opportunities.ts +55 -0
- package/dist/integrations/salesforce/files/app/api/auth/salesforce/callback/route.ts +11 -0
- package/dist/integrations/salesforce/files/app/api/auth/salesforce/route.ts +9 -0
- package/dist/integrations/salesforce/files/lib/salesforce-client.ts +539 -0
- package/dist/integrations/sentry/connector.json +84 -0
- package/dist/integrations/sentry/files/_env.example +6 -0
- package/dist/integrations/sentry/files/ai/tools/get-issue.ts +66 -0
- package/dist/integrations/sentry/files/ai/tools/list-issues.ts +57 -0
- package/dist/integrations/sentry/files/ai/tools/list-projects.ts +32 -0
- package/dist/integrations/sentry/files/ai/tools/resolve-issue.ts +28 -0
- package/dist/integrations/sentry/files/lib/sentry-client.ts +268 -0
- package/dist/integrations/servicenow/connector.json +66 -0
- package/dist/integrations/servicenow/files/_env.example +5 -0
- package/dist/integrations/servicenow/files/ai/tools/create-incident.ts +58 -0
- package/dist/integrations/servicenow/files/ai/tools/get-incident.ts +59 -0
- package/dist/integrations/servicenow/files/ai/tools/list-incidents.ts +72 -0
- package/dist/integrations/servicenow/files/ai/tools/search-knowledge.ts +48 -0
- package/dist/integrations/servicenow/files/ai/tools/update-incident.ts +60 -0
- package/dist/integrations/servicenow/files/app/api/auth/servicenow/callback/route.ts +89 -0
- package/dist/integrations/servicenow/files/app/api/auth/servicenow/route.ts +42 -0
- package/dist/integrations/servicenow/files/lib/servicenow-client.ts +239 -0
- package/dist/integrations/sharepoint/connector.json +99 -0
- package/dist/integrations/sharepoint/files/ai/tools/get-file.ts +93 -0
- package/dist/integrations/sharepoint/files/ai/tools/get-site.ts +51 -0
- package/dist/integrations/sharepoint/files/ai/tools/list-files.ts +63 -0
- package/dist/integrations/sharepoint/files/ai/tools/list-sites.ts +28 -0
- package/dist/integrations/sharepoint/files/ai/tools/upload-file.ts +72 -0
- package/dist/integrations/sharepoint/files/app/api/auth/sharepoint/callback/route.ts +11 -0
- package/dist/integrations/sharepoint/files/app/api/auth/sharepoint/route.ts +9 -0
- package/dist/integrations/sharepoint/files/lib/sharepoint-client.ts +420 -0
- package/dist/integrations/sheets/README.md +331 -0
- package/dist/integrations/sheets/connector.json +99 -0
- package/dist/integrations/sheets/files/_env.example +8 -0
- package/dist/integrations/sheets/files/ai/tools/create-spreadsheet.ts +85 -0
- package/dist/integrations/sheets/files/ai/tools/get-spreadsheet.ts +39 -0
- package/dist/integrations/sheets/files/ai/tools/list-spreadsheets.ts +41 -0
- package/dist/integrations/sheets/files/ai/tools/read-range.ts +35 -0
- package/dist/integrations/sheets/files/ai/tools/write-range.ts +51 -0
- package/dist/integrations/sheets/files/app/api/auth/sheets/callback/route.ts +11 -0
- package/dist/integrations/sheets/files/app/api/auth/sheets/route.ts +9 -0
- package/dist/integrations/sheets/files/lib/sheets-client.ts +425 -0
- package/dist/integrations/shopify/connector.json +99 -0
- package/dist/integrations/shopify/files/_env.example +5 -0
- package/dist/integrations/shopify/files/ai/tools/get-order.ts +49 -0
- package/dist/integrations/shopify/files/ai/tools/get-product.ts +39 -0
- package/dist/integrations/shopify/files/ai/tools/list-customers.ts +40 -0
- package/dist/integrations/shopify/files/ai/tools/list-orders.ts +52 -0
- package/dist/integrations/shopify/files/ai/tools/list-products.ts +39 -0
- package/dist/integrations/shopify/files/app/api/auth/shopify/callback/route.ts +11 -0
- package/dist/integrations/shopify/files/app/api/auth/shopify/route.ts +7 -0
- package/dist/integrations/shopify/files/lib/shopify-client.ts +198 -0
- package/dist/integrations/slack/files/app/api/auth/slack/callback/route.ts +6 -127
- package/dist/integrations/slack/files/app/api/auth/slack/route.ts +4 -24
- package/dist/integrations/snowflake/connector.json +151 -0
- package/dist/integrations/snowflake/files/_env.example +16 -0
- package/dist/integrations/snowflake/files/ai/tools/describe-table.ts +57 -0
- package/dist/integrations/snowflake/files/ai/tools/list-databases.ts +34 -0
- package/dist/integrations/snowflake/files/ai/tools/list-schemas.ts +40 -0
- package/dist/integrations/snowflake/files/ai/tools/list-tables.ts +49 -0
- package/dist/integrations/snowflake/files/ai/tools/run-query.ts +119 -0
- package/dist/integrations/snowflake/files/lib/snowflake-client.ts +389 -0
- package/dist/integrations/stripe/connector.json +97 -0
- package/dist/integrations/stripe/files/_env.example +6 -0
- package/dist/integrations/stripe/files/ai/tools/get-balance.ts +28 -0
- package/dist/integrations/stripe/files/ai/tools/get-customer.ts +26 -0
- package/dist/integrations/stripe/files/ai/tools/list-customers.ts +42 -0
- package/dist/integrations/stripe/files/ai/tools/list-payments.ts +45 -0
- package/dist/integrations/stripe/files/ai/tools/list-subscriptions.ts +67 -0
- package/dist/integrations/stripe/files/app/api/auth/stripe/route.ts +71 -0
- package/dist/integrations/stripe/files/lib/stripe-client.ts +376 -0
- package/dist/integrations/supabase/connector.json +101 -0
- package/dist/integrations/supabase/files/_env.example +6 -0
- package/dist/integrations/supabase/files/ai/tools/delete-row.ts +77 -0
- package/dist/integrations/supabase/files/ai/tools/insert-row.ts +35 -0
- package/dist/integrations/supabase/files/ai/tools/list-tables.ts +60 -0
- package/dist/integrations/supabase/files/ai/tools/query-table.ts +48 -0
- package/dist/integrations/supabase/files/ai/tools/update-row.ts +64 -0
- package/dist/integrations/supabase/files/app/api/auth/supabase/route.ts +91 -0
- package/dist/integrations/supabase/files/lib/supabase-client.ts +296 -0
- package/dist/integrations/teams/README.md +256 -0
- package/dist/integrations/teams/connector.json +99 -0
- package/dist/integrations/teams/files/ai/tools/get-messages.ts +55 -0
- package/dist/integrations/teams/files/ai/tools/list-channels.ts +28 -0
- package/dist/integrations/teams/files/ai/tools/list-chats.ts +41 -0
- package/dist/integrations/teams/files/ai/tools/list-teams.ts +27 -0
- package/dist/integrations/teams/files/ai/tools/send-message.ts +61 -0
- package/dist/integrations/teams/files/app/api/auth/teams/callback/route.ts +11 -0
- package/dist/integrations/teams/files/app/api/auth/teams/route.ts +9 -0
- package/dist/integrations/teams/files/lib/teams-client.ts +345 -0
- package/dist/integrations/trello/connector.json +85 -0
- package/dist/integrations/trello/files/_env.example +4 -0
- package/dist/integrations/trello/files/ai/tools/create-card.ts +54 -0
- package/dist/integrations/trello/files/ai/tools/get-card.ts +33 -0
- package/dist/integrations/trello/files/ai/tools/list-boards.ts +29 -0
- package/dist/integrations/trello/files/ai/tools/list-cards.ts +52 -0
- package/dist/integrations/trello/files/ai/tools/update-card.ts +65 -0
- package/dist/integrations/trello/files/app/api/auth/trello/callback/route.ts +11 -0
- package/dist/integrations/trello/files/app/api/auth/trello/route.ts +7 -0
- package/dist/integrations/trello/files/lib/trello-client.ts +202 -0
- package/dist/integrations/twilio/connector.json +146 -0
- package/dist/integrations/twilio/files/_env.example +14 -0
- package/dist/integrations/twilio/files/ai/tools/get-message.ts +58 -0
- package/dist/integrations/twilio/files/ai/tools/list-calls.ts +129 -0
- package/dist/integrations/twilio/files/ai/tools/list-messages.ts +97 -0
- package/dist/integrations/twilio/files/ai/tools/send-sms.ts +75 -0
- package/dist/integrations/twilio/files/ai/tools/send-whatsapp.ts +81 -0
- package/dist/integrations/twilio/files/lib/twilio-client.ts +375 -0
- package/dist/integrations/twitter/connector.json +87 -0
- package/dist/integrations/twitter/files/_env.example +6 -0
- package/dist/integrations/twitter/files/ai/tools/get-timeline.ts +59 -0
- package/dist/integrations/twitter/files/ai/tools/post-tweet.ts +49 -0
- package/dist/integrations/twitter/files/ai/tools/search-tweets.ts +71 -0
- package/dist/integrations/twitter/files/app/api/auth/twitter/callback/route.ts +11 -0
- package/dist/integrations/twitter/files/app/api/auth/twitter/route.ts +9 -0
- package/dist/integrations/twitter/files/lib/twitter-client.ts +236 -0
- package/dist/integrations/webex/connector.json +85 -0
- package/dist/integrations/webex/files/_env.example +4 -0
- package/dist/integrations/webex/files/ai/tools/create-meeting.ts +69 -0
- package/dist/integrations/webex/files/ai/tools/get-meeting.ts +31 -0
- package/dist/integrations/webex/files/ai/tools/list-meetings.ts +44 -0
- package/dist/integrations/webex/files/ai/tools/list-rooms.ts +35 -0
- package/dist/integrations/webex/files/ai/tools/send-message.ts +51 -0
- package/dist/integrations/webex/files/app/api/auth/webex/callback/route.ts +11 -0
- package/dist/integrations/webex/files/app/api/auth/webex/route.ts +7 -0
- package/dist/integrations/webex/files/lib/webex-client.ts +279 -0
- package/dist/integrations/xero/connector.json +85 -0
- package/dist/integrations/xero/files/_env.example +4 -0
- package/dist/integrations/xero/files/ai/tools/create-invoice.ts +65 -0
- package/dist/integrations/xero/files/ai/tools/get-contact.ts +40 -0
- package/dist/integrations/xero/files/ai/tools/get-invoice.ts +44 -0
- package/dist/integrations/xero/files/ai/tools/list-contacts.ts +54 -0
- package/dist/integrations/xero/files/ai/tools/list-invoices.ts +54 -0
- package/dist/integrations/xero/files/app/api/auth/xero/callback/route.ts +11 -0
- package/dist/integrations/xero/files/app/api/auth/xero/route.ts +7 -0
- package/dist/integrations/xero/files/lib/xero-client.ts +292 -0
- package/dist/integrations/zendesk/connector.json +61 -0
- package/dist/integrations/zendesk/files/_env.example +5 -0
- package/dist/integrations/zendesk/files/ai/tools/create-ticket.ts +82 -0
- package/dist/integrations/zendesk/files/ai/tools/get-ticket.ts +53 -0
- package/dist/integrations/zendesk/files/ai/tools/list-tickets.ts +60 -0
- package/dist/integrations/zendesk/files/ai/tools/search-tickets.ts +56 -0
- package/dist/integrations/zendesk/files/app/api/auth/zendesk/callback/route.ts +91 -0
- package/dist/integrations/zendesk/files/app/api/auth/zendesk/route.ts +41 -0
- package/dist/integrations/zendesk/files/lib/zendesk-client.ts +265 -0
- package/dist/integrations/zoom/connector.json +85 -0
- package/dist/integrations/zoom/files/_env.example +4 -0
- package/dist/integrations/zoom/files/ai/tools/create-meeting.ts +106 -0
- package/dist/integrations/zoom/files/ai/tools/delete-meeting.ts +32 -0
- package/dist/integrations/zoom/files/ai/tools/get-meeting.ts +44 -0
- package/dist/integrations/zoom/files/ai/tools/list-meetings.ts +47 -0
- package/dist/integrations/zoom/files/ai/tools/update-meeting.ts +111 -0
- package/dist/integrations/zoom/files/app/api/auth/zoom/callback/route.ts +11 -0
- package/dist/integrations/zoom/files/app/api/auth/zoom/route.ts +7 -0
- package/dist/integrations/zoom/files/lib/zoom-client.ts +228 -0
- package/dist/oauth/handlers.js +554 -0
- package/dist/oauth/handlers.js.map +7 -0
- package/dist/oauth/index.js +1157 -0
- package/dist/oauth/index.js.map +7 -0
- package/dist/oauth/providers.js +927 -0
- package/dist/oauth/providers.js.map +7 -0
- package/dist/oauth/token-store.js +82 -0
- package/dist/oauth/token-store.js.map +7 -0
- package/package.json +25 -1
- package/dist/integrations/calendar/files/lib/token-store.ts +0 -113
- package/dist/integrations/github/files/lib/token-store.ts +0 -113
- package/dist/integrations/gmail/files/lib/oauth.ts +0 -145
- package/dist/integrations/gmail/files/lib/token-store.ts +0 -113
- package/dist/integrations/slack/files/lib/oauth.ts +0 -145
- package/dist/integrations/slack/files/lib/token-store.ts +0 -113
- /package/dist/integrations/{calendar → docs-google}/files/lib/oauth.ts +0 -0
- /package/dist/integrations/{github → drive}/files/lib/oauth.ts +0 -0
|
@@ -0,0 +1,1157 @@
|
|
|
1
|
+
// src/platform/compat/runtime.ts
|
|
2
|
+
var isDeno = typeof Deno !== "undefined";
|
|
3
|
+
var isNode = typeof globalThis.process !== "undefined" && globalThis.process?.versions?.node !== void 0;
|
|
4
|
+
var isBun = typeof globalThis.Bun !== "undefined";
|
|
5
|
+
var isCloudflare = typeof globalThis !== "undefined" && "caches" in globalThis && "WebSocketPair" in globalThis;
|
|
6
|
+
|
|
7
|
+
// src/platform/compat/process.ts
|
|
8
|
+
var nodeProcess = globalThis.process;
|
|
9
|
+
var hasNodeProcess = !!nodeProcess?.versions?.node;
|
|
10
|
+
function getEnv(key) {
|
|
11
|
+
if (isDeno) {
|
|
12
|
+
return process.env(key);
|
|
13
|
+
}
|
|
14
|
+
if (hasNodeProcess) {
|
|
15
|
+
return nodeProcess.env[key];
|
|
16
|
+
}
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// src/core/oauth/providers/base.ts
|
|
21
|
+
function generateRandomString(length) {
|
|
22
|
+
const array = new Uint8Array(length);
|
|
23
|
+
crypto.getRandomValues(array);
|
|
24
|
+
return Array.from(array, (byte) => byte.toString(16).padStart(2, "0")).join("").slice(0, length);
|
|
25
|
+
}
|
|
26
|
+
function generateCodeVerifier() {
|
|
27
|
+
return generateRandomString(64);
|
|
28
|
+
}
|
|
29
|
+
async function generateCodeChallenge(verifier) {
|
|
30
|
+
const encoder = new TextEncoder();
|
|
31
|
+
const data = encoder.encode(verifier);
|
|
32
|
+
const hash = await crypto.subtle.digest("SHA-256", data);
|
|
33
|
+
return btoa(String.fromCharCode(...new Uint8Array(hash))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
34
|
+
}
|
|
35
|
+
var OAuthProvider = class {
|
|
36
|
+
constructor(config) {
|
|
37
|
+
this.config = config;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get client ID from environment
|
|
41
|
+
*/
|
|
42
|
+
getClientId() {
|
|
43
|
+
return getEnv(this.config.clientIdEnvVar) || null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get client secret from environment
|
|
47
|
+
*/
|
|
48
|
+
getClientSecret() {
|
|
49
|
+
return getEnv(this.config.clientSecretEnvVar) || null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check if provider is configured
|
|
53
|
+
*/
|
|
54
|
+
isConfigured() {
|
|
55
|
+
return !!(this.getClientId() && this.getClientSecret());
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create authorization URL
|
|
59
|
+
*/
|
|
60
|
+
async createAuthorizationUrl(options = {}) {
|
|
61
|
+
const clientId = this.getClientId();
|
|
62
|
+
if (!clientId) {
|
|
63
|
+
throw new Error(`${this.config.clientIdEnvVar} not configured`);
|
|
64
|
+
}
|
|
65
|
+
const state = options.state || generateRandomString(32);
|
|
66
|
+
const scopes = options.scopes || options.defaultScopes || [];
|
|
67
|
+
const redirectUri = options.redirectUri || "";
|
|
68
|
+
const usePkce = options.usePkce !== false;
|
|
69
|
+
let codeVerifier;
|
|
70
|
+
let codeChallenge;
|
|
71
|
+
if (usePkce) {
|
|
72
|
+
codeVerifier = generateCodeVerifier();
|
|
73
|
+
codeChallenge = await generateCodeChallenge(codeVerifier);
|
|
74
|
+
}
|
|
75
|
+
const params = new URLSearchParams({
|
|
76
|
+
client_id: clientId,
|
|
77
|
+
redirect_uri: redirectUri,
|
|
78
|
+
response_type: "code",
|
|
79
|
+
state,
|
|
80
|
+
...scopes.length > 0 && { scope: scopes.join(" ") },
|
|
81
|
+
...codeChallenge && {
|
|
82
|
+
code_challenge: codeChallenge,
|
|
83
|
+
code_challenge_method: "S256"
|
|
84
|
+
},
|
|
85
|
+
...this.config.additionalAuthParams,
|
|
86
|
+
...options.additionalParams
|
|
87
|
+
});
|
|
88
|
+
const oauthState = {
|
|
89
|
+
state,
|
|
90
|
+
codeVerifier,
|
|
91
|
+
redirectUri,
|
|
92
|
+
scopes,
|
|
93
|
+
createdAt: Date.now()
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
url: `${this.config.authorizationUrl}?${params.toString()}`,
|
|
97
|
+
state: oauthState
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Exchange authorization code for tokens
|
|
102
|
+
*/
|
|
103
|
+
async exchangeCode(options) {
|
|
104
|
+
const clientId = this.getClientId();
|
|
105
|
+
const clientSecret = this.getClientSecret();
|
|
106
|
+
if (!clientId || !clientSecret) {
|
|
107
|
+
return {
|
|
108
|
+
success: false,
|
|
109
|
+
error: "OAuth not configured",
|
|
110
|
+
errorDescription: `Missing ${this.config.clientIdEnvVar} or ${this.config.clientSecretEnvVar}`
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const body = new URLSearchParams({
|
|
114
|
+
grant_type: "authorization_code",
|
|
115
|
+
code: options.code,
|
|
116
|
+
redirect_uri: options.redirectUri,
|
|
117
|
+
...options.codeVerifier && { code_verifier: options.codeVerifier },
|
|
118
|
+
...!this.config.useBasicAuth && {
|
|
119
|
+
client_id: clientId,
|
|
120
|
+
client_secret: clientSecret
|
|
121
|
+
},
|
|
122
|
+
...this.config.additionalTokenParams
|
|
123
|
+
});
|
|
124
|
+
const headers = {
|
|
125
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
126
|
+
Accept: "application/json"
|
|
127
|
+
};
|
|
128
|
+
if (this.config.useBasicAuth) {
|
|
129
|
+
const credentials = btoa(`${clientId}:${clientSecret}`);
|
|
130
|
+
headers.Authorization = `Basic ${credentials}`;
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const response = await fetch(this.config.tokenUrl, {
|
|
134
|
+
method: "POST",
|
|
135
|
+
headers,
|
|
136
|
+
body: body.toString()
|
|
137
|
+
});
|
|
138
|
+
const data = await response.json();
|
|
139
|
+
if (!response.ok) {
|
|
140
|
+
return {
|
|
141
|
+
success: false,
|
|
142
|
+
error: data.error || "token_exchange_failed",
|
|
143
|
+
errorDescription: data.error_description || `Status ${response.status}`
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const mapping = this.config.tokenResponseMapping || {};
|
|
147
|
+
const tokens = {
|
|
148
|
+
accessToken: data[mapping.accessToken || "access_token"],
|
|
149
|
+
refreshToken: data[mapping.refreshToken || "refresh_token"],
|
|
150
|
+
tokenType: data[mapping.tokenType || "token_type"],
|
|
151
|
+
scope: data[mapping.scope || "scope"],
|
|
152
|
+
idToken: data.id_token
|
|
153
|
+
};
|
|
154
|
+
const expiresIn = data[mapping.expiresIn || "expires_in"];
|
|
155
|
+
if (expiresIn) {
|
|
156
|
+
tokens.expiresAt = Date.now() + expiresIn * 1e3;
|
|
157
|
+
}
|
|
158
|
+
return { success: true, tokens };
|
|
159
|
+
} catch (error) {
|
|
160
|
+
return {
|
|
161
|
+
success: false,
|
|
162
|
+
error: "network_error",
|
|
163
|
+
errorDescription: error instanceof Error ? error.message : "Unknown error"
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Refresh access token
|
|
169
|
+
*/
|
|
170
|
+
async refreshTokens(refreshToken) {
|
|
171
|
+
const clientId = this.getClientId();
|
|
172
|
+
const clientSecret = this.getClientSecret();
|
|
173
|
+
if (!clientId || !clientSecret) {
|
|
174
|
+
return {
|
|
175
|
+
success: false,
|
|
176
|
+
error: "OAuth not configured"
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const body = new URLSearchParams({
|
|
180
|
+
grant_type: "refresh_token",
|
|
181
|
+
refresh_token: refreshToken,
|
|
182
|
+
...!this.config.useBasicAuth && {
|
|
183
|
+
client_id: clientId,
|
|
184
|
+
client_secret: clientSecret
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
const headers = {
|
|
188
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
189
|
+
Accept: "application/json"
|
|
190
|
+
};
|
|
191
|
+
if (this.config.useBasicAuth) {
|
|
192
|
+
const credentials = btoa(`${clientId}:${clientSecret}`);
|
|
193
|
+
headers.Authorization = `Basic ${credentials}`;
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
const response = await fetch(this.config.tokenUrl, {
|
|
197
|
+
method: "POST",
|
|
198
|
+
headers,
|
|
199
|
+
body: body.toString()
|
|
200
|
+
});
|
|
201
|
+
const data = await response.json();
|
|
202
|
+
if (!response.ok) {
|
|
203
|
+
return {
|
|
204
|
+
success: false,
|
|
205
|
+
error: data.error || "refresh_failed",
|
|
206
|
+
errorDescription: data.error_description
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const mapping = this.config.tokenResponseMapping || {};
|
|
210
|
+
const tokens = {
|
|
211
|
+
accessToken: data[mapping.accessToken || "access_token"],
|
|
212
|
+
refreshToken: data[mapping.refreshToken || "refresh_token"] || refreshToken,
|
|
213
|
+
tokenType: data[mapping.tokenType || "token_type"],
|
|
214
|
+
scope: data[mapping.scope || "scope"]
|
|
215
|
+
};
|
|
216
|
+
const expiresIn = data[mapping.expiresIn || "expires_in"];
|
|
217
|
+
if (expiresIn) {
|
|
218
|
+
tokens.expiresAt = Date.now() + expiresIn * 1e3;
|
|
219
|
+
}
|
|
220
|
+
return { success: true, tokens };
|
|
221
|
+
} catch (error) {
|
|
222
|
+
return {
|
|
223
|
+
success: false,
|
|
224
|
+
error: "network_error",
|
|
225
|
+
errorDescription: error instanceof Error ? error.message : "Unknown error"
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Revoke tokens
|
|
231
|
+
*/
|
|
232
|
+
async revokeToken(token) {
|
|
233
|
+
if (!this.config.revocationUrl) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
const response = await fetch(this.config.revocationUrl, {
|
|
238
|
+
method: "POST",
|
|
239
|
+
headers: {
|
|
240
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
241
|
+
},
|
|
242
|
+
body: new URLSearchParams({ token }).toString()
|
|
243
|
+
});
|
|
244
|
+
return response.ok;
|
|
245
|
+
} catch {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
var OAuthService = class extends OAuthProvider {
|
|
251
|
+
constructor(config, tokenStore) {
|
|
252
|
+
super(config);
|
|
253
|
+
this.serviceConfig = config;
|
|
254
|
+
this.tokenStore = tokenStore;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Get service ID
|
|
258
|
+
*/
|
|
259
|
+
get serviceId() {
|
|
260
|
+
return this.serviceConfig.serviceId;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Get API base URL
|
|
264
|
+
*/
|
|
265
|
+
get apiBaseUrl() {
|
|
266
|
+
return this.serviceConfig.apiBaseUrl;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Create authorization URL with service defaults
|
|
270
|
+
*/
|
|
271
|
+
createAuthorizationUrl(options = {}) {
|
|
272
|
+
return super.createAuthorizationUrl({
|
|
273
|
+
...options,
|
|
274
|
+
defaultScopes: this.serviceConfig.defaultScopes
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Get valid access token (refreshing if needed)
|
|
279
|
+
*/
|
|
280
|
+
async getAccessToken() {
|
|
281
|
+
if (!this.tokenStore) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
const tokens = await this.tokenStore.getTokens(this.serviceId);
|
|
285
|
+
if (!tokens) {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
if (tokens.expiresAt && Date.now() > tokens.expiresAt - 3e5) {
|
|
289
|
+
if (tokens.refreshToken) {
|
|
290
|
+
const result = await this.refreshTokens(tokens.refreshToken);
|
|
291
|
+
if (result.success && result.tokens) {
|
|
292
|
+
await this.tokenStore.setTokens(this.serviceId, result.tokens);
|
|
293
|
+
return result.tokens.accessToken;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
return tokens.accessToken;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Make authenticated API request
|
|
302
|
+
*/
|
|
303
|
+
async fetch(endpoint, options = {}) {
|
|
304
|
+
const token = await this.getAccessToken();
|
|
305
|
+
if (!token) {
|
|
306
|
+
throw new Error(`Not authenticated with ${this.serviceConfig.displayName}`);
|
|
307
|
+
}
|
|
308
|
+
const url = endpoint.startsWith("http") ? endpoint : `${this.apiBaseUrl}${endpoint}`;
|
|
309
|
+
const response = await fetch(url, {
|
|
310
|
+
...options,
|
|
311
|
+
headers: {
|
|
312
|
+
Authorization: `Bearer ${token}`,
|
|
313
|
+
"Content-Type": "application/json",
|
|
314
|
+
...options.headers
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
if (!response.ok) {
|
|
318
|
+
const error = await response.text();
|
|
319
|
+
throw new Error(`${this.serviceConfig.displayName} API error: ${response.status} ${error}`);
|
|
320
|
+
}
|
|
321
|
+
return response.json();
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// src/core/oauth/providers/google.ts
|
|
326
|
+
var googleBase = {
|
|
327
|
+
providerId: "google",
|
|
328
|
+
displayName: "Google",
|
|
329
|
+
authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth",
|
|
330
|
+
tokenUrl: "https://oauth2.googleapis.com/token",
|
|
331
|
+
userInfoUrl: "https://www.googleapis.com/oauth2/v2/userinfo",
|
|
332
|
+
revocationUrl: "https://oauth2.googleapis.com/revoke",
|
|
333
|
+
clientIdEnvVar: "GOOGLE_CLIENT_ID",
|
|
334
|
+
clientSecretEnvVar: "GOOGLE_CLIENT_SECRET",
|
|
335
|
+
additionalAuthParams: {
|
|
336
|
+
access_type: "offline",
|
|
337
|
+
prompt: "consent"
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
var gmailConfig = {
|
|
341
|
+
...googleBase,
|
|
342
|
+
serviceId: "gmail",
|
|
343
|
+
displayName: "Gmail",
|
|
344
|
+
apiBaseUrl: "https://gmail.googleapis.com/gmail/v1",
|
|
345
|
+
defaultScopes: [
|
|
346
|
+
"https://www.googleapis.com/auth/gmail.readonly",
|
|
347
|
+
"https://www.googleapis.com/auth/gmail.send",
|
|
348
|
+
"https://www.googleapis.com/auth/gmail.compose",
|
|
349
|
+
"https://www.googleapis.com/auth/gmail.labels"
|
|
350
|
+
]
|
|
351
|
+
};
|
|
352
|
+
var calendarConfig = {
|
|
353
|
+
...googleBase,
|
|
354
|
+
serviceId: "calendar",
|
|
355
|
+
displayName: "Google Calendar",
|
|
356
|
+
apiBaseUrl: "https://www.googleapis.com/calendar/v3",
|
|
357
|
+
defaultScopes: [
|
|
358
|
+
"https://www.googleapis.com/auth/calendar.readonly",
|
|
359
|
+
"https://www.googleapis.com/auth/calendar.events"
|
|
360
|
+
]
|
|
361
|
+
};
|
|
362
|
+
var sheetsConfig = {
|
|
363
|
+
...googleBase,
|
|
364
|
+
serviceId: "sheets",
|
|
365
|
+
displayName: "Google Sheets",
|
|
366
|
+
apiBaseUrl: "https://sheets.googleapis.com/v4",
|
|
367
|
+
defaultScopes: [
|
|
368
|
+
"https://www.googleapis.com/auth/spreadsheets.readonly",
|
|
369
|
+
"https://www.googleapis.com/auth/spreadsheets"
|
|
370
|
+
]
|
|
371
|
+
};
|
|
372
|
+
var driveConfig = {
|
|
373
|
+
...googleBase,
|
|
374
|
+
serviceId: "drive",
|
|
375
|
+
displayName: "Google Drive",
|
|
376
|
+
apiBaseUrl: "https://www.googleapis.com/drive/v3",
|
|
377
|
+
defaultScopes: [
|
|
378
|
+
"https://www.googleapis.com/auth/drive.readonly",
|
|
379
|
+
"https://www.googleapis.com/auth/drive.file"
|
|
380
|
+
]
|
|
381
|
+
};
|
|
382
|
+
var googleServices = {
|
|
383
|
+
gmail: gmailConfig,
|
|
384
|
+
calendar: calendarConfig,
|
|
385
|
+
sheets: sheetsConfig,
|
|
386
|
+
drive: driveConfig
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// src/core/oauth/providers/microsoft.ts
|
|
390
|
+
var microsoftBase = {
|
|
391
|
+
providerId: "microsoft",
|
|
392
|
+
displayName: "Microsoft",
|
|
393
|
+
authorizationUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
|
|
394
|
+
tokenUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/token",
|
|
395
|
+
userInfoUrl: "https://graph.microsoft.com/v1.0/me",
|
|
396
|
+
clientIdEnvVar: "MICROSOFT_CLIENT_ID",
|
|
397
|
+
clientSecretEnvVar: "MICROSOFT_CLIENT_SECRET",
|
|
398
|
+
additionalAuthParams: {
|
|
399
|
+
response_mode: "query"
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
var outlookConfig = {
|
|
403
|
+
...microsoftBase,
|
|
404
|
+
serviceId: "outlook",
|
|
405
|
+
displayName: "Outlook",
|
|
406
|
+
apiBaseUrl: "https://graph.microsoft.com/v1.0",
|
|
407
|
+
defaultScopes: [
|
|
408
|
+
"Mail.Read",
|
|
409
|
+
"Mail.Send",
|
|
410
|
+
"Mail.ReadWrite",
|
|
411
|
+
"Calendars.Read",
|
|
412
|
+
"Calendars.ReadWrite",
|
|
413
|
+
"User.Read",
|
|
414
|
+
"offline_access"
|
|
415
|
+
]
|
|
416
|
+
};
|
|
417
|
+
var teamsConfig = {
|
|
418
|
+
...microsoftBase,
|
|
419
|
+
serviceId: "teams",
|
|
420
|
+
displayName: "Microsoft Teams",
|
|
421
|
+
apiBaseUrl: "https://graph.microsoft.com/v1.0",
|
|
422
|
+
defaultScopes: [
|
|
423
|
+
"Team.ReadBasic.All",
|
|
424
|
+
"Channel.ReadBasic.All",
|
|
425
|
+
"Chat.Read",
|
|
426
|
+
"Chat.ReadWrite",
|
|
427
|
+
"ChannelMessage.Read.All",
|
|
428
|
+
"User.Read",
|
|
429
|
+
"offline_access"
|
|
430
|
+
]
|
|
431
|
+
};
|
|
432
|
+
var sharePointConfig = {
|
|
433
|
+
...microsoftBase,
|
|
434
|
+
serviceId: "sharepoint",
|
|
435
|
+
displayName: "SharePoint",
|
|
436
|
+
apiBaseUrl: "https://graph.microsoft.com/v1.0",
|
|
437
|
+
defaultScopes: [
|
|
438
|
+
"Sites.Read.All",
|
|
439
|
+
"Sites.ReadWrite.All",
|
|
440
|
+
"Files.Read.All",
|
|
441
|
+
"Files.ReadWrite.All",
|
|
442
|
+
"User.Read",
|
|
443
|
+
"offline_access"
|
|
444
|
+
]
|
|
445
|
+
};
|
|
446
|
+
var oneDriveConfig = {
|
|
447
|
+
...microsoftBase,
|
|
448
|
+
serviceId: "onedrive",
|
|
449
|
+
displayName: "OneDrive",
|
|
450
|
+
apiBaseUrl: "https://graph.microsoft.com/v1.0",
|
|
451
|
+
defaultScopes: [
|
|
452
|
+
"Files.Read",
|
|
453
|
+
"Files.ReadWrite",
|
|
454
|
+
"Files.Read.All",
|
|
455
|
+
"Files.ReadWrite.All",
|
|
456
|
+
"User.Read",
|
|
457
|
+
"offline_access"
|
|
458
|
+
]
|
|
459
|
+
};
|
|
460
|
+
var microsoftServices = {
|
|
461
|
+
outlook: outlookConfig,
|
|
462
|
+
teams: teamsConfig,
|
|
463
|
+
sharepoint: sharePointConfig,
|
|
464
|
+
onedrive: oneDriveConfig
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
// src/core/oauth/providers/atlassian.ts
|
|
468
|
+
var atlassianBase = {
|
|
469
|
+
providerId: "atlassian",
|
|
470
|
+
displayName: "Atlassian",
|
|
471
|
+
authorizationUrl: "https://auth.atlassian.com/authorize",
|
|
472
|
+
tokenUrl: "https://auth.atlassian.com/oauth/token",
|
|
473
|
+
userInfoUrl: "https://api.atlassian.com/me",
|
|
474
|
+
clientIdEnvVar: "ATLASSIAN_CLIENT_ID",
|
|
475
|
+
clientSecretEnvVar: "ATLASSIAN_CLIENT_SECRET",
|
|
476
|
+
additionalAuthParams: {
|
|
477
|
+
audience: "api.atlassian.com",
|
|
478
|
+
prompt: "consent"
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
var jiraConfig = {
|
|
482
|
+
...atlassianBase,
|
|
483
|
+
serviceId: "jira",
|
|
484
|
+
displayName: "Jira",
|
|
485
|
+
apiBaseUrl: "https://api.atlassian.com/ex/jira",
|
|
486
|
+
defaultScopes: [
|
|
487
|
+
"read:jira-work",
|
|
488
|
+
"write:jira-work",
|
|
489
|
+
"read:jira-user",
|
|
490
|
+
"offline_access"
|
|
491
|
+
]
|
|
492
|
+
};
|
|
493
|
+
var confluenceConfig = {
|
|
494
|
+
...atlassianBase,
|
|
495
|
+
serviceId: "confluence",
|
|
496
|
+
displayName: "Confluence",
|
|
497
|
+
apiBaseUrl: "https://api.atlassian.com/ex/confluence",
|
|
498
|
+
defaultScopes: [
|
|
499
|
+
"read:confluence-content.all",
|
|
500
|
+
"write:confluence-content",
|
|
501
|
+
"read:confluence-space.summary",
|
|
502
|
+
"read:confluence-user",
|
|
503
|
+
"offline_access"
|
|
504
|
+
]
|
|
505
|
+
};
|
|
506
|
+
var bitbucketConfig = {
|
|
507
|
+
...atlassianBase,
|
|
508
|
+
serviceId: "bitbucket",
|
|
509
|
+
displayName: "Bitbucket",
|
|
510
|
+
// Bitbucket has its own OAuth endpoints
|
|
511
|
+
authorizationUrl: "https://bitbucket.org/site/oauth2/authorize",
|
|
512
|
+
tokenUrl: "https://bitbucket.org/site/oauth2/access_token",
|
|
513
|
+
clientIdEnvVar: "BITBUCKET_CLIENT_ID",
|
|
514
|
+
clientSecretEnvVar: "BITBUCKET_CLIENT_SECRET",
|
|
515
|
+
apiBaseUrl: "https://api.bitbucket.org/2.0",
|
|
516
|
+
additionalAuthParams: {},
|
|
517
|
+
defaultScopes: [
|
|
518
|
+
"repository",
|
|
519
|
+
"repository:write",
|
|
520
|
+
"pullrequest",
|
|
521
|
+
"pullrequest:write",
|
|
522
|
+
"account"
|
|
523
|
+
]
|
|
524
|
+
};
|
|
525
|
+
var atlassianServices = {
|
|
526
|
+
jira: jiraConfig,
|
|
527
|
+
confluence: confluenceConfig,
|
|
528
|
+
bitbucket: bitbucketConfig
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
// src/core/oauth/providers/common.ts
|
|
532
|
+
var githubConfig = {
|
|
533
|
+
providerId: "github",
|
|
534
|
+
serviceId: "github",
|
|
535
|
+
displayName: "GitHub",
|
|
536
|
+
authorizationUrl: "https://github.com/login/oauth/authorize",
|
|
537
|
+
tokenUrl: "https://github.com/login/oauth/access_token",
|
|
538
|
+
clientIdEnvVar: "GITHUB_CLIENT_ID",
|
|
539
|
+
clientSecretEnvVar: "GITHUB_CLIENT_SECRET",
|
|
540
|
+
apiBaseUrl: "https://api.github.com",
|
|
541
|
+
defaultScopes: ["repo", "user"],
|
|
542
|
+
additionalAuthParams: {}
|
|
543
|
+
};
|
|
544
|
+
var slackConfig = {
|
|
545
|
+
providerId: "slack",
|
|
546
|
+
serviceId: "slack",
|
|
547
|
+
displayName: "Slack",
|
|
548
|
+
authorizationUrl: "https://slack.com/oauth/v2/authorize",
|
|
549
|
+
tokenUrl: "https://slack.com/api/oauth.v2.access",
|
|
550
|
+
clientIdEnvVar: "SLACK_CLIENT_ID",
|
|
551
|
+
clientSecretEnvVar: "SLACK_CLIENT_SECRET",
|
|
552
|
+
apiBaseUrl: "https://slack.com/api",
|
|
553
|
+
defaultScopes: ["channels:read", "chat:write", "users:read"],
|
|
554
|
+
additionalAuthParams: {}
|
|
555
|
+
};
|
|
556
|
+
var notionConfig = {
|
|
557
|
+
providerId: "notion",
|
|
558
|
+
serviceId: "notion",
|
|
559
|
+
displayName: "Notion",
|
|
560
|
+
authorizationUrl: "https://api.notion.com/v1/oauth/authorize",
|
|
561
|
+
tokenUrl: "https://api.notion.com/v1/oauth/token",
|
|
562
|
+
clientIdEnvVar: "NOTION_CLIENT_ID",
|
|
563
|
+
clientSecretEnvVar: "NOTION_CLIENT_SECRET",
|
|
564
|
+
apiBaseUrl: "https://api.notion.com/v1",
|
|
565
|
+
defaultScopes: [],
|
|
566
|
+
useBasicAuth: true,
|
|
567
|
+
additionalAuthParams: {
|
|
568
|
+
owner: "user"
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
var figmaConfig = {
|
|
572
|
+
providerId: "figma",
|
|
573
|
+
serviceId: "figma",
|
|
574
|
+
displayName: "Figma",
|
|
575
|
+
authorizationUrl: "https://www.figma.com/oauth",
|
|
576
|
+
tokenUrl: "https://www.figma.com/api/oauth/token",
|
|
577
|
+
clientIdEnvVar: "FIGMA_CLIENT_ID",
|
|
578
|
+
clientSecretEnvVar: "FIGMA_CLIENT_SECRET",
|
|
579
|
+
apiBaseUrl: "https://api.figma.com/v1",
|
|
580
|
+
defaultScopes: ["file_read"],
|
|
581
|
+
additionalAuthParams: {}
|
|
582
|
+
};
|
|
583
|
+
var discordConfig = {
|
|
584
|
+
providerId: "discord",
|
|
585
|
+
serviceId: "discord",
|
|
586
|
+
displayName: "Discord",
|
|
587
|
+
authorizationUrl: "https://discord.com/api/oauth2/authorize",
|
|
588
|
+
tokenUrl: "https://discord.com/api/oauth2/token",
|
|
589
|
+
clientIdEnvVar: "DISCORD_CLIENT_ID",
|
|
590
|
+
clientSecretEnvVar: "DISCORD_CLIENT_SECRET",
|
|
591
|
+
apiBaseUrl: "https://discord.com/api/v10",
|
|
592
|
+
defaultScopes: ["identify", "guilds"],
|
|
593
|
+
additionalAuthParams: {}
|
|
594
|
+
};
|
|
595
|
+
var linearConfig = {
|
|
596
|
+
providerId: "linear",
|
|
597
|
+
serviceId: "linear",
|
|
598
|
+
displayName: "Linear",
|
|
599
|
+
authorizationUrl: "https://linear.app/oauth/authorize",
|
|
600
|
+
tokenUrl: "https://api.linear.app/oauth/token",
|
|
601
|
+
clientIdEnvVar: "LINEAR_CLIENT_ID",
|
|
602
|
+
clientSecretEnvVar: "LINEAR_CLIENT_SECRET",
|
|
603
|
+
apiBaseUrl: "https://api.linear.app",
|
|
604
|
+
defaultScopes: ["read", "write"],
|
|
605
|
+
additionalAuthParams: {}
|
|
606
|
+
};
|
|
607
|
+
var gitlabConfig = {
|
|
608
|
+
providerId: "gitlab",
|
|
609
|
+
serviceId: "gitlab",
|
|
610
|
+
displayName: "GitLab",
|
|
611
|
+
authorizationUrl: "https://gitlab.com/oauth/authorize",
|
|
612
|
+
tokenUrl: "https://gitlab.com/oauth/token",
|
|
613
|
+
clientIdEnvVar: "GITLAB_CLIENT_ID",
|
|
614
|
+
clientSecretEnvVar: "GITLAB_CLIENT_SECRET",
|
|
615
|
+
apiBaseUrl: "https://gitlab.com/api/v4",
|
|
616
|
+
defaultScopes: ["read_user", "api"],
|
|
617
|
+
additionalAuthParams: {}
|
|
618
|
+
};
|
|
619
|
+
var airtableConfig = {
|
|
620
|
+
providerId: "airtable",
|
|
621
|
+
serviceId: "airtable",
|
|
622
|
+
displayName: "Airtable",
|
|
623
|
+
authorizationUrl: "https://airtable.com/oauth2/v1/authorize",
|
|
624
|
+
tokenUrl: "https://airtable.com/oauth2/v1/token",
|
|
625
|
+
clientIdEnvVar: "AIRTABLE_CLIENT_ID",
|
|
626
|
+
clientSecretEnvVar: "AIRTABLE_CLIENT_SECRET",
|
|
627
|
+
apiBaseUrl: "https://api.airtable.com/v0",
|
|
628
|
+
defaultScopes: ["data.records:read", "data.records:write", "schema.bases:read"],
|
|
629
|
+
useBasicAuth: true,
|
|
630
|
+
additionalAuthParams: {}
|
|
631
|
+
};
|
|
632
|
+
var dropboxConfig = {
|
|
633
|
+
providerId: "dropbox",
|
|
634
|
+
serviceId: "dropbox",
|
|
635
|
+
displayName: "Dropbox",
|
|
636
|
+
authorizationUrl: "https://www.dropbox.com/oauth2/authorize",
|
|
637
|
+
tokenUrl: "https://api.dropbox.com/oauth2/token",
|
|
638
|
+
clientIdEnvVar: "DROPBOX_CLIENT_ID",
|
|
639
|
+
clientSecretEnvVar: "DROPBOX_CLIENT_SECRET",
|
|
640
|
+
apiBaseUrl: "https://api.dropboxapi.com/2",
|
|
641
|
+
defaultScopes: [],
|
|
642
|
+
additionalAuthParams: {
|
|
643
|
+
token_access_type: "offline"
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
var hubspotConfig = {
|
|
647
|
+
providerId: "hubspot",
|
|
648
|
+
serviceId: "hubspot",
|
|
649
|
+
displayName: "HubSpot",
|
|
650
|
+
authorizationUrl: "https://app.hubspot.com/oauth/authorize",
|
|
651
|
+
tokenUrl: "https://api.hubapi.com/oauth/v1/token",
|
|
652
|
+
clientIdEnvVar: "HUBSPOT_CLIENT_ID",
|
|
653
|
+
clientSecretEnvVar: "HUBSPOT_CLIENT_SECRET",
|
|
654
|
+
apiBaseUrl: "https://api.hubapi.com",
|
|
655
|
+
defaultScopes: ["crm.objects.contacts.read", "crm.objects.contacts.write"],
|
|
656
|
+
additionalAuthParams: {}
|
|
657
|
+
};
|
|
658
|
+
var salesforceConfig = {
|
|
659
|
+
providerId: "salesforce",
|
|
660
|
+
serviceId: "salesforce",
|
|
661
|
+
displayName: "Salesforce",
|
|
662
|
+
authorizationUrl: "https://login.salesforce.com/services/oauth2/authorize",
|
|
663
|
+
tokenUrl: "https://login.salesforce.com/services/oauth2/token",
|
|
664
|
+
clientIdEnvVar: "SALESFORCE_CLIENT_ID",
|
|
665
|
+
clientSecretEnvVar: "SALESFORCE_CLIENT_SECRET",
|
|
666
|
+
apiBaseUrl: "https://login.salesforce.com/services/data/v59.0",
|
|
667
|
+
defaultScopes: ["api", "refresh_token"],
|
|
668
|
+
additionalAuthParams: {}
|
|
669
|
+
};
|
|
670
|
+
var twitterConfig = {
|
|
671
|
+
providerId: "twitter",
|
|
672
|
+
serviceId: "twitter",
|
|
673
|
+
displayName: "Twitter/X",
|
|
674
|
+
authorizationUrl: "https://twitter.com/i/oauth2/authorize",
|
|
675
|
+
tokenUrl: "https://api.twitter.com/2/oauth2/token",
|
|
676
|
+
clientIdEnvVar: "TWITTER_CLIENT_ID",
|
|
677
|
+
clientSecretEnvVar: "TWITTER_CLIENT_SECRET",
|
|
678
|
+
apiBaseUrl: "https://api.twitter.com/2",
|
|
679
|
+
defaultScopes: ["tweet.read", "users.read", "offline.access"],
|
|
680
|
+
useBasicAuth: true,
|
|
681
|
+
additionalAuthParams: {}
|
|
682
|
+
};
|
|
683
|
+
var asanaConfig = {
|
|
684
|
+
providerId: "asana",
|
|
685
|
+
serviceId: "asana",
|
|
686
|
+
displayName: "Asana",
|
|
687
|
+
authorizationUrl: "https://app.asana.com/-/oauth_authorize",
|
|
688
|
+
tokenUrl: "https://app.asana.com/-/oauth_token",
|
|
689
|
+
clientIdEnvVar: "ASANA_CLIENT_ID",
|
|
690
|
+
clientSecretEnvVar: "ASANA_CLIENT_SECRET",
|
|
691
|
+
apiBaseUrl: "https://app.asana.com/api/1.0",
|
|
692
|
+
defaultScopes: ["default"],
|
|
693
|
+
additionalAuthParams: {}
|
|
694
|
+
};
|
|
695
|
+
var mondayConfig = {
|
|
696
|
+
providerId: "monday",
|
|
697
|
+
serviceId: "monday",
|
|
698
|
+
displayName: "Monday.com",
|
|
699
|
+
authorizationUrl: "https://auth.monday.com/oauth2/authorize",
|
|
700
|
+
tokenUrl: "https://auth.monday.com/oauth2/token",
|
|
701
|
+
clientIdEnvVar: "MONDAY_CLIENT_ID",
|
|
702
|
+
clientSecretEnvVar: "MONDAY_CLIENT_SECRET",
|
|
703
|
+
apiBaseUrl: "https://api.monday.com/v2",
|
|
704
|
+
defaultScopes: ["me:read", "boards:read", "boards:write"],
|
|
705
|
+
additionalAuthParams: {}
|
|
706
|
+
};
|
|
707
|
+
var zoomConfig = {
|
|
708
|
+
providerId: "zoom",
|
|
709
|
+
serviceId: "zoom",
|
|
710
|
+
displayName: "Zoom",
|
|
711
|
+
authorizationUrl: "https://zoom.us/oauth/authorize",
|
|
712
|
+
tokenUrl: "https://zoom.us/oauth/token",
|
|
713
|
+
clientIdEnvVar: "ZOOM_CLIENT_ID",
|
|
714
|
+
clientSecretEnvVar: "ZOOM_CLIENT_SECRET",
|
|
715
|
+
apiBaseUrl: "https://api.zoom.us/v2",
|
|
716
|
+
defaultScopes: ["meeting:read", "meeting:write", "user:read"],
|
|
717
|
+
useBasicAuth: true,
|
|
718
|
+
additionalAuthParams: {}
|
|
719
|
+
};
|
|
720
|
+
var intercomConfig = {
|
|
721
|
+
providerId: "intercom",
|
|
722
|
+
serviceId: "intercom",
|
|
723
|
+
displayName: "Intercom",
|
|
724
|
+
authorizationUrl: "https://app.intercom.com/oauth",
|
|
725
|
+
tokenUrl: "https://api.intercom.io/auth/eagle/token",
|
|
726
|
+
clientIdEnvVar: "INTERCOM_CLIENT_ID",
|
|
727
|
+
clientSecretEnvVar: "INTERCOM_CLIENT_SECRET",
|
|
728
|
+
apiBaseUrl: "https://api.intercom.io",
|
|
729
|
+
defaultScopes: [],
|
|
730
|
+
additionalAuthParams: {}
|
|
731
|
+
};
|
|
732
|
+
var freshdeskConfig = {
|
|
733
|
+
providerId: "freshdesk",
|
|
734
|
+
serviceId: "freshdesk",
|
|
735
|
+
displayName: "Freshdesk",
|
|
736
|
+
authorizationUrl: "https://accounts.freshworks.com/authorize",
|
|
737
|
+
tokenUrl: "https://accounts.freshworks.com/oauth/token",
|
|
738
|
+
clientIdEnvVar: "FRESHDESK_CLIENT_ID",
|
|
739
|
+
clientSecretEnvVar: "FRESHDESK_CLIENT_SECRET",
|
|
740
|
+
apiBaseUrl: "https://domain.freshdesk.com/api/v2",
|
|
741
|
+
defaultScopes: ["freshdesk"],
|
|
742
|
+
additionalAuthParams: {}
|
|
743
|
+
};
|
|
744
|
+
var mailchimpConfig = {
|
|
745
|
+
providerId: "mailchimp",
|
|
746
|
+
serviceId: "mailchimp",
|
|
747
|
+
displayName: "Mailchimp",
|
|
748
|
+
authorizationUrl: "https://login.mailchimp.com/oauth2/authorize",
|
|
749
|
+
tokenUrl: "https://login.mailchimp.com/oauth2/token",
|
|
750
|
+
clientIdEnvVar: "MAILCHIMP_CLIENT_ID",
|
|
751
|
+
clientSecretEnvVar: "MAILCHIMP_CLIENT_SECRET",
|
|
752
|
+
apiBaseUrl: "https://server.api.mailchimp.com/3.0",
|
|
753
|
+
defaultScopes: [],
|
|
754
|
+
additionalAuthParams: {}
|
|
755
|
+
};
|
|
756
|
+
var shopifyConfig = {
|
|
757
|
+
providerId: "shopify",
|
|
758
|
+
serviceId: "shopify",
|
|
759
|
+
displayName: "Shopify",
|
|
760
|
+
authorizationUrl: "https://shop.myshopify.com/admin/oauth/authorize",
|
|
761
|
+
tokenUrl: "https://shop.myshopify.com/admin/oauth/access_token",
|
|
762
|
+
clientIdEnvVar: "SHOPIFY_CLIENT_ID",
|
|
763
|
+
clientSecretEnvVar: "SHOPIFY_CLIENT_SECRET",
|
|
764
|
+
apiBaseUrl: "https://shop.myshopify.com/admin/api/2024-01",
|
|
765
|
+
defaultScopes: ["read_products", "write_products", "read_orders"],
|
|
766
|
+
additionalAuthParams: {}
|
|
767
|
+
};
|
|
768
|
+
var quickbooksConfig = {
|
|
769
|
+
providerId: "quickbooks",
|
|
770
|
+
serviceId: "quickbooks",
|
|
771
|
+
displayName: "QuickBooks",
|
|
772
|
+
authorizationUrl: "https://appcenter.intuit.com/connect/oauth2",
|
|
773
|
+
tokenUrl: "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",
|
|
774
|
+
clientIdEnvVar: "QUICKBOOKS_CLIENT_ID",
|
|
775
|
+
clientSecretEnvVar: "QUICKBOOKS_CLIENT_SECRET",
|
|
776
|
+
apiBaseUrl: "https://quickbooks.api.intuit.com/v3",
|
|
777
|
+
defaultScopes: ["com.intuit.quickbooks.accounting"],
|
|
778
|
+
additionalAuthParams: {}
|
|
779
|
+
};
|
|
780
|
+
var xeroConfig = {
|
|
781
|
+
providerId: "xero",
|
|
782
|
+
serviceId: "xero",
|
|
783
|
+
displayName: "Xero",
|
|
784
|
+
authorizationUrl: "https://login.xero.com/identity/connect/authorize",
|
|
785
|
+
tokenUrl: "https://identity.xero.com/connect/token",
|
|
786
|
+
clientIdEnvVar: "XERO_CLIENT_ID",
|
|
787
|
+
clientSecretEnvVar: "XERO_CLIENT_SECRET",
|
|
788
|
+
apiBaseUrl: "https://api.xero.com/api.xro/2.0",
|
|
789
|
+
defaultScopes: ["openid", "profile", "email", "accounting.transactions", "offline_access"],
|
|
790
|
+
additionalAuthParams: {}
|
|
791
|
+
};
|
|
792
|
+
var boxConfig = {
|
|
793
|
+
providerId: "box",
|
|
794
|
+
serviceId: "box",
|
|
795
|
+
displayName: "Box",
|
|
796
|
+
authorizationUrl: "https://account.box.com/api/oauth2/authorize",
|
|
797
|
+
tokenUrl: "https://api.box.com/oauth2/token",
|
|
798
|
+
clientIdEnvVar: "BOX_CLIENT_ID",
|
|
799
|
+
clientSecretEnvVar: "BOX_CLIENT_SECRET",
|
|
800
|
+
apiBaseUrl: "https://api.box.com/2.0",
|
|
801
|
+
defaultScopes: [],
|
|
802
|
+
additionalAuthParams: {}
|
|
803
|
+
};
|
|
804
|
+
var webexConfig = {
|
|
805
|
+
providerId: "webex",
|
|
806
|
+
serviceId: "webex",
|
|
807
|
+
displayName: "Webex",
|
|
808
|
+
authorizationUrl: "https://webexapis.com/v1/authorize",
|
|
809
|
+
tokenUrl: "https://webexapis.com/v1/access_token",
|
|
810
|
+
clientIdEnvVar: "WEBEX_CLIENT_ID",
|
|
811
|
+
clientSecretEnvVar: "WEBEX_CLIENT_SECRET",
|
|
812
|
+
apiBaseUrl: "https://webexapis.com/v1",
|
|
813
|
+
defaultScopes: ["spark:all", "spark:kms"],
|
|
814
|
+
additionalAuthParams: {}
|
|
815
|
+
};
|
|
816
|
+
var trelloConfig = {
|
|
817
|
+
providerId: "trello",
|
|
818
|
+
serviceId: "trello",
|
|
819
|
+
displayName: "Trello",
|
|
820
|
+
authorizationUrl: "https://trello.com/1/authorize",
|
|
821
|
+
tokenUrl: "https://trello.com/1/OAuthGetAccessToken",
|
|
822
|
+
clientIdEnvVar: "TRELLO_CLIENT_ID",
|
|
823
|
+
clientSecretEnvVar: "TRELLO_CLIENT_SECRET",
|
|
824
|
+
apiBaseUrl: "https://api.trello.com/1",
|
|
825
|
+
defaultScopes: ["read", "write"],
|
|
826
|
+
additionalAuthParams: {
|
|
827
|
+
expiration: "never"
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
var clickupConfig = {
|
|
831
|
+
providerId: "clickup",
|
|
832
|
+
serviceId: "clickup",
|
|
833
|
+
displayName: "ClickUp",
|
|
834
|
+
authorizationUrl: "https://app.clickup.com/api",
|
|
835
|
+
tokenUrl: "https://api.clickup.com/api/v2/oauth/token",
|
|
836
|
+
clientIdEnvVar: "CLICKUP_CLIENT_ID",
|
|
837
|
+
clientSecretEnvVar: "CLICKUP_CLIENT_SECRET",
|
|
838
|
+
apiBaseUrl: "https://api.clickup.com/api/v2",
|
|
839
|
+
defaultScopes: [],
|
|
840
|
+
additionalAuthParams: {}
|
|
841
|
+
};
|
|
842
|
+
var pipedriveConfig = {
|
|
843
|
+
providerId: "pipedrive",
|
|
844
|
+
serviceId: "pipedrive",
|
|
845
|
+
displayName: "Pipedrive",
|
|
846
|
+
authorizationUrl: "https://oauth.pipedrive.com/oauth/authorize",
|
|
847
|
+
tokenUrl: "https://oauth.pipedrive.com/oauth/token",
|
|
848
|
+
clientIdEnvVar: "PIPEDRIVE_CLIENT_ID",
|
|
849
|
+
clientSecretEnvVar: "PIPEDRIVE_CLIENT_SECRET",
|
|
850
|
+
apiBaseUrl: "https://api.pipedrive.com/v1",
|
|
851
|
+
defaultScopes: [],
|
|
852
|
+
additionalAuthParams: {}
|
|
853
|
+
};
|
|
854
|
+
var commonServices = {
|
|
855
|
+
github: githubConfig,
|
|
856
|
+
slack: slackConfig,
|
|
857
|
+
notion: notionConfig,
|
|
858
|
+
figma: figmaConfig,
|
|
859
|
+
discord: discordConfig,
|
|
860
|
+
linear: linearConfig,
|
|
861
|
+
gitlab: gitlabConfig,
|
|
862
|
+
airtable: airtableConfig,
|
|
863
|
+
dropbox: dropboxConfig,
|
|
864
|
+
hubspot: hubspotConfig,
|
|
865
|
+
salesforce: salesforceConfig,
|
|
866
|
+
twitter: twitterConfig,
|
|
867
|
+
asana: asanaConfig,
|
|
868
|
+
monday: mondayConfig,
|
|
869
|
+
zoom: zoomConfig,
|
|
870
|
+
intercom: intercomConfig,
|
|
871
|
+
freshdesk: freshdeskConfig,
|
|
872
|
+
mailchimp: mailchimpConfig,
|
|
873
|
+
shopify: shopifyConfig,
|
|
874
|
+
quickbooks: quickbooksConfig,
|
|
875
|
+
xero: xeroConfig,
|
|
876
|
+
box: boxConfig,
|
|
877
|
+
webex: webexConfig,
|
|
878
|
+
trello: trelloConfig,
|
|
879
|
+
clickup: clickupConfig,
|
|
880
|
+
pipedrive: pipedriveConfig
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
// src/core/oauth/token-store/memory.ts
|
|
884
|
+
var MemoryTokenStore = class {
|
|
885
|
+
constructor() {
|
|
886
|
+
this.tokens = /* @__PURE__ */ new Map();
|
|
887
|
+
this.states = /* @__PURE__ */ new Map();
|
|
888
|
+
/** State expiration time in ms (10 minutes) */
|
|
889
|
+
this.stateExpirationMs = 10 * 60 * 1e3;
|
|
890
|
+
}
|
|
891
|
+
getTokens(serviceId) {
|
|
892
|
+
return Promise.resolve(this.tokens.get(serviceId) || null);
|
|
893
|
+
}
|
|
894
|
+
setTokens(serviceId, tokens) {
|
|
895
|
+
this.tokens.set(serviceId, tokens);
|
|
896
|
+
return Promise.resolve();
|
|
897
|
+
}
|
|
898
|
+
clearTokens(serviceId) {
|
|
899
|
+
this.tokens.delete(serviceId);
|
|
900
|
+
return Promise.resolve();
|
|
901
|
+
}
|
|
902
|
+
getState(state) {
|
|
903
|
+
const oauthState = this.states.get(state);
|
|
904
|
+
if (!oauthState) {
|
|
905
|
+
return Promise.resolve(null);
|
|
906
|
+
}
|
|
907
|
+
if (Date.now() - oauthState.createdAt > this.stateExpirationMs) {
|
|
908
|
+
this.states.delete(state);
|
|
909
|
+
return Promise.resolve(null);
|
|
910
|
+
}
|
|
911
|
+
return Promise.resolve(oauthState);
|
|
912
|
+
}
|
|
913
|
+
setState(oauthState) {
|
|
914
|
+
this.states.set(oauthState.state, oauthState);
|
|
915
|
+
this.cleanupExpiredStates();
|
|
916
|
+
return Promise.resolve();
|
|
917
|
+
}
|
|
918
|
+
clearState(state) {
|
|
919
|
+
this.states.delete(state);
|
|
920
|
+
return Promise.resolve();
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Clean up expired states
|
|
924
|
+
*/
|
|
925
|
+
cleanupExpiredStates() {
|
|
926
|
+
const now = Date.now();
|
|
927
|
+
for (const [state, oauthState] of this.states) {
|
|
928
|
+
if (now - oauthState.createdAt > this.stateExpirationMs) {
|
|
929
|
+
this.states.delete(state);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Get all stored service IDs
|
|
935
|
+
*/
|
|
936
|
+
getConnectedServices() {
|
|
937
|
+
return Array.from(this.tokens.keys());
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Check if a service is connected
|
|
941
|
+
*/
|
|
942
|
+
isConnected(serviceId) {
|
|
943
|
+
const tokens = this.tokens.get(serviceId);
|
|
944
|
+
if (!tokens)
|
|
945
|
+
return false;
|
|
946
|
+
if (tokens.expiresAt && Date.now() > tokens.expiresAt) {
|
|
947
|
+
return !!tokens.refreshToken;
|
|
948
|
+
}
|
|
949
|
+
return true;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Clear all tokens
|
|
953
|
+
*/
|
|
954
|
+
clearAll() {
|
|
955
|
+
this.tokens.clear();
|
|
956
|
+
this.states.clear();
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
var memoryTokenStore = new MemoryTokenStore();
|
|
960
|
+
|
|
961
|
+
// src/core/oauth/handlers/callback-handler.ts
|
|
962
|
+
function createOAuthCallbackHandler(config, options = {}) {
|
|
963
|
+
const {
|
|
964
|
+
tokenStore = memoryTokenStore,
|
|
965
|
+
baseUrl,
|
|
966
|
+
successRedirect = "/",
|
|
967
|
+
errorRedirect = "/",
|
|
968
|
+
onSuccess,
|
|
969
|
+
onError
|
|
970
|
+
} = options;
|
|
971
|
+
return async (request) => {
|
|
972
|
+
const url = new URL(request.url);
|
|
973
|
+
const code = url.searchParams.get("code");
|
|
974
|
+
const state = url.searchParams.get("state");
|
|
975
|
+
const error = url.searchParams.get("error");
|
|
976
|
+
const errorDescription = url.searchParams.get("error_description");
|
|
977
|
+
const appUrl = baseUrl || getEnv("APP_URL") || getEnv("NEXT_PUBLIC_APP_URL") || "http://localhost:3000";
|
|
978
|
+
if (error) {
|
|
979
|
+
console.error(`OAuth error for ${config.serviceId}:`, error, errorDescription);
|
|
980
|
+
if (onError) {
|
|
981
|
+
await onError(config.serviceId, error);
|
|
982
|
+
}
|
|
983
|
+
const errorUrl = new URL(errorRedirect, appUrl);
|
|
984
|
+
errorUrl.searchParams.set("error", error);
|
|
985
|
+
if (errorDescription) {
|
|
986
|
+
errorUrl.searchParams.set("error_description", errorDescription);
|
|
987
|
+
}
|
|
988
|
+
return Response.redirect(errorUrl.toString());
|
|
989
|
+
}
|
|
990
|
+
if (!code) {
|
|
991
|
+
if (onError) {
|
|
992
|
+
await onError(config.serviceId, "no_code");
|
|
993
|
+
}
|
|
994
|
+
const errorUrl = new URL(errorRedirect, appUrl);
|
|
995
|
+
errorUrl.searchParams.set("error", "no_code");
|
|
996
|
+
return Response.redirect(errorUrl.toString());
|
|
997
|
+
}
|
|
998
|
+
let oauthState = null;
|
|
999
|
+
if (state) {
|
|
1000
|
+
oauthState = await tokenStore.getState(state);
|
|
1001
|
+
if (!oauthState) {
|
|
1002
|
+
console.warn(`Invalid or expired state for ${config.serviceId}`);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
const service = new OAuthService(config, tokenStore);
|
|
1006
|
+
const redirectUri = `${appUrl}/api/auth/${config.serviceId}/callback`;
|
|
1007
|
+
try {
|
|
1008
|
+
const result = await service.exchangeCode({
|
|
1009
|
+
code,
|
|
1010
|
+
redirectUri,
|
|
1011
|
+
codeVerifier: oauthState?.codeVerifier
|
|
1012
|
+
});
|
|
1013
|
+
if (!result.success || !result.tokens) {
|
|
1014
|
+
console.error(`Token exchange failed for ${config.serviceId}:`, result.error);
|
|
1015
|
+
if (onError) {
|
|
1016
|
+
await onError(config.serviceId, result.error || "exchange_failed");
|
|
1017
|
+
}
|
|
1018
|
+
const errorUrl = new URL(errorRedirect, appUrl);
|
|
1019
|
+
errorUrl.searchParams.set("error", result.error || "token_exchange_failed");
|
|
1020
|
+
return Response.redirect(errorUrl.toString());
|
|
1021
|
+
}
|
|
1022
|
+
await tokenStore.setTokens(config.serviceId, result.tokens);
|
|
1023
|
+
if (state) {
|
|
1024
|
+
await tokenStore.clearState(state);
|
|
1025
|
+
}
|
|
1026
|
+
if (onSuccess) {
|
|
1027
|
+
await onSuccess(config.serviceId, result.tokens);
|
|
1028
|
+
}
|
|
1029
|
+
const successUrl = new URL(successRedirect, appUrl);
|
|
1030
|
+
successUrl.searchParams.set("connected", config.serviceId);
|
|
1031
|
+
return Response.redirect(successUrl.toString());
|
|
1032
|
+
} catch (err) {
|
|
1033
|
+
console.error(`OAuth callback error for ${config.serviceId}:`, err);
|
|
1034
|
+
if (onError) {
|
|
1035
|
+
await onError(config.serviceId, "callback_error");
|
|
1036
|
+
}
|
|
1037
|
+
const errorUrl = new URL(errorRedirect, appUrl);
|
|
1038
|
+
errorUrl.searchParams.set("error", "callback_error");
|
|
1039
|
+
return Response.redirect(errorUrl.toString());
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
// src/core/oauth/handlers/init-handler.ts
|
|
1045
|
+
function createOAuthInitHandler(config, options = {}) {
|
|
1046
|
+
const { tokenStore = memoryTokenStore, baseUrl, authOptions = {} } = options;
|
|
1047
|
+
return async () => {
|
|
1048
|
+
const service = new OAuthService(config, tokenStore);
|
|
1049
|
+
if (!service.isConfigured()) {
|
|
1050
|
+
return Response.json(
|
|
1051
|
+
{
|
|
1052
|
+
error: `${config.displayName} OAuth not configured`,
|
|
1053
|
+
details: `Missing ${config.clientIdEnvVar} or ${config.clientSecretEnvVar}`
|
|
1054
|
+
},
|
|
1055
|
+
{ status: 500 }
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
const appUrl = baseUrl || getEnv("APP_URL") || getEnv("NEXT_PUBLIC_APP_URL") || "http://localhost:3000";
|
|
1059
|
+
const redirectUri = `${appUrl}/api/auth/${config.serviceId}/callback`;
|
|
1060
|
+
try {
|
|
1061
|
+
const { url, state } = await service.createAuthorizationUrl({
|
|
1062
|
+
...authOptions,
|
|
1063
|
+
redirectUri
|
|
1064
|
+
});
|
|
1065
|
+
await tokenStore.setState(state);
|
|
1066
|
+
return Response.redirect(url);
|
|
1067
|
+
} catch (error) {
|
|
1068
|
+
console.error(`OAuth init error for ${config.serviceId}:`, error);
|
|
1069
|
+
return Response.json(
|
|
1070
|
+
{
|
|
1071
|
+
error: "Failed to initiate OAuth flow",
|
|
1072
|
+
details: error instanceof Error ? error.message : "Unknown error"
|
|
1073
|
+
},
|
|
1074
|
+
{ status: 500 }
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
function createOAuthStatusHandler(config, options = {}) {
|
|
1080
|
+
const { tokenStore = memoryTokenStore } = options;
|
|
1081
|
+
return async () => {
|
|
1082
|
+
const tokens = await tokenStore.getTokens(config.serviceId);
|
|
1083
|
+
const isConnected = !!tokens?.accessToken;
|
|
1084
|
+
const isExpired = tokens?.expiresAt ? Date.now() > tokens.expiresAt : false;
|
|
1085
|
+
const hasRefreshToken = !!tokens?.refreshToken;
|
|
1086
|
+
return Response.json({
|
|
1087
|
+
service: config.serviceId,
|
|
1088
|
+
displayName: config.displayName,
|
|
1089
|
+
connected: isConnected && (!isExpired || hasRefreshToken),
|
|
1090
|
+
configured: !!(getEnv(config.clientIdEnvVar) && getEnv(config.clientSecretEnvVar)),
|
|
1091
|
+
expiresAt: tokens?.expiresAt,
|
|
1092
|
+
hasRefreshToken
|
|
1093
|
+
});
|
|
1094
|
+
};
|
|
1095
|
+
}
|
|
1096
|
+
function createOAuthDisconnectHandler(config, options = {}) {
|
|
1097
|
+
const { tokenStore = memoryTokenStore } = options;
|
|
1098
|
+
return async () => {
|
|
1099
|
+
await tokenStore.clearTokens(config.serviceId);
|
|
1100
|
+
return Response.json({
|
|
1101
|
+
success: true,
|
|
1102
|
+
message: `Disconnected from ${config.displayName}`
|
|
1103
|
+
});
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
export {
|
|
1107
|
+
MemoryTokenStore,
|
|
1108
|
+
OAuthProvider,
|
|
1109
|
+
OAuthService,
|
|
1110
|
+
airtableConfig,
|
|
1111
|
+
asanaConfig,
|
|
1112
|
+
atlassianServices,
|
|
1113
|
+
bitbucketConfig,
|
|
1114
|
+
boxConfig,
|
|
1115
|
+
calendarConfig,
|
|
1116
|
+
clickupConfig,
|
|
1117
|
+
commonServices,
|
|
1118
|
+
confluenceConfig,
|
|
1119
|
+
createOAuthCallbackHandler,
|
|
1120
|
+
createOAuthDisconnectHandler,
|
|
1121
|
+
createOAuthInitHandler,
|
|
1122
|
+
createOAuthStatusHandler,
|
|
1123
|
+
discordConfig,
|
|
1124
|
+
driveConfig,
|
|
1125
|
+
dropboxConfig,
|
|
1126
|
+
figmaConfig,
|
|
1127
|
+
freshdeskConfig,
|
|
1128
|
+
githubConfig,
|
|
1129
|
+
gitlabConfig,
|
|
1130
|
+
gmailConfig,
|
|
1131
|
+
googleServices,
|
|
1132
|
+
hubspotConfig,
|
|
1133
|
+
intercomConfig,
|
|
1134
|
+
jiraConfig,
|
|
1135
|
+
linearConfig,
|
|
1136
|
+
mailchimpConfig,
|
|
1137
|
+
memoryTokenStore,
|
|
1138
|
+
microsoftServices,
|
|
1139
|
+
mondayConfig,
|
|
1140
|
+
notionConfig,
|
|
1141
|
+
oneDriveConfig,
|
|
1142
|
+
outlookConfig,
|
|
1143
|
+
pipedriveConfig,
|
|
1144
|
+
quickbooksConfig,
|
|
1145
|
+
salesforceConfig,
|
|
1146
|
+
sharePointConfig,
|
|
1147
|
+
sheetsConfig,
|
|
1148
|
+
shopifyConfig,
|
|
1149
|
+
slackConfig,
|
|
1150
|
+
teamsConfig,
|
|
1151
|
+
trelloConfig,
|
|
1152
|
+
twitterConfig,
|
|
1153
|
+
webexConfig,
|
|
1154
|
+
xeroConfig,
|
|
1155
|
+
zoomConfig
|
|
1156
|
+
};
|
|
1157
|
+
//# sourceMappingURL=index.js.map
|