feat(connectors): support arbitrary OAuth providers#212
feat(connectors): support arbitrary OAuth providers#212Paveltarno merged 4 commits intopavelta-connectors-1from
Conversation
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Change provider field from closed enum to flexible union that accepts both known providers (googlecalendar, notion, slack, etc.) and any arbitrary provider string. This enables users to configure custom OAuth providers without waiting for first-class Base44 support. Schema changes: - Add GenericConnectorSchema for arbitrary provider types - Update ConnectorResourceSchema to union of specific + generic schemas - Update IntegrationTypeSchema to accept known enum OR any non-empty string - Only reject empty strings Test coverage: - Verify known providers continue to work - Verify arbitrary providers are accepted - Verify empty strings are rejected - All 137 tests passing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.0.28-pr.212.81917a6Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.0.28-pr.212.81917a6"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.0.28-pr.212.81917a6"
}
}
Preview published to npm registry — try new features instantly! |
Code Review - Issues FoundI've reviewed PR #212 and found several issues that need attention: 1. 🔴 Security: Path Traversal VulnerabilityLocation: Issue: The Vulnerable code: // In setConnector()
response = await appClient.put(
`external-auth/integrations/${integrationType}`,
...
);
// In removeConnector()
response = await appClient.delete(
`external-auth/integrations/${integrationType}/remove`
);Impact: URL resolution would normalize Fix: Add character validation to export const IntegrationTypeSchema = z.union([
z.enum(KnownIntegrationTypes),
z.string().min(1).regex(/^[a-z0-9_-]+$/i),
]);Reference: cli/src/core/resources/connector/api.ts Lines 51 to 55 in c89ba59 2. 🟡 Bug: Error Message Shows Literal 'null' or 'undefined'Location: Issue: When Vulnerable code: error:
response.error_message ||
`Already connected by ${response.other_user_email}`,Both fields are typed as Fix: Add a fallback for error:
response.error_message ||
`Already connected by ${response.other_user_email ?? 'another user'}`,Reference: cli/src/core/resources/connector/push.ts Lines 68 to 72 in c89ba59 3. 📋 CLAUDE.md Violation: Generic Error Instead of Structured ErrorLocation: Issue: Code throws CLAUDE.md rule #15:
Current code: throw new Error(`Duplicate connector type "${connector.type}"`);Fix: throw new InvalidInputError(
`Duplicate connector type "${connector.type}"`,
{
hints: [
{ message: `Remove duplicate connectors with type "${connector.type}" - only one connector per type is allowed` }
]
}
);Reference: cli/src/core/resources/connector/config.ts Lines 47 to 49 in c89ba59 4. 📋 CLAUDE.md Violation: Direct
|
Note
Description
This PR adds comprehensive OAuth connector support to the Base44 CLI, enabling users to configure and manage integrations with various OAuth providers. The key enhancement is flexible provider support - the CLI now accepts both known providers (Google Calendar, Slack, Notion, etc.) and arbitrary custom OAuth providers, allowing users to integrate services without waiting for first-class Base44 support.
Related Issue
Part of: #184
Type of Change
Changes Made
Core Connector Resource Module (
src/core/resources/connector/)schema.ts): Added Zod schemas for 12 OAuth providers (Google Calendar, Google Drive, Gmail, Google Sheets, Google Docs, Google Slides, Slack, Notion, Salesforce, HubSpot, LinkedIn, TikTok) with JSDoc links to official scope documentationGenericConnectorSchemato accept arbitrary provider strings, enabling custom OAuth integrationsIntegrationTypeSchemaaccepts both known enum values and any non-empty stringconfig.ts): Reads connector JSONC files fromconnectors/directory with validationapi.ts): Methods for listing, syncing, polling OAuth status, and removing connectorspush.ts): Syncs local connectors with remote state, handles OAuth flow redirects, removes upstream-only connectorsoauth.ts): Browser redirect handling with status polling (5-minute timeout)resource.ts): ImplementsResource<ConnectorResource>patternCLI Command (
src/cli/commands/connectors/)base44 connectors push: Deploy connectors with OAuth flow handling, browser redirect prompts, and sync result reportingProject Integration
ProjectDatatype to includeconnectors?: ConnectorResource[]readProjectConfig()Test Coverage (137 tests passing)
tests/core/connectors.spec.ts): Schema validation (known providers, arbitrary providers, empty string rejection), file reading, push logic, OAuth flow handlingtests/cli/connectors_push.spec.ts): CLI command execution, API mocking, error handlingwith-connectors/,invalid-connector/directories with sample connector filestestkit/Base44APIMock.ts): Mock methods for connector operationsTesting
npm test)Checklist
Additional Notes
Key architectural decisions:
IntegrationTypeSchemausesz.union([z.enum(...), z.string().min(1)])to accept both known and arbitrary providers - only rejects empty stringsentities/andfunctions/modules for consistencyBuild & test verification:
bun run buildbun run test🤖 Generated by Claude | 2026-02-09 12:30 UTC