Repository navigation
Bring back auth sdk doc - #661
Conversation
WalkthroughRefactors OAuth provider representation (oauths → oAuthProviders/providers), updates AuthService.getMetadata to fetch providers and public auth config concurrently, enables the auth-sdk docs mapping, and expands SDK docs with new sign-up/sign-in/session/profile and email/password reset endpoints and return shapes. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Comment |
|
|
||
| --- | ||
|
|
||
| ## getPublicAuthConfig() |
There was a problem hiding this comment.
i don't think we need this.
This is purely used internally and only use in auth component. right?
There was a problem hiding this comment.
Yeah this is mainly used internally, but what if developer wants to use this to build an app that dynamically changes when the dashboard auth configuration changes? I would say it's a very less common use though
|
i think we can rebase(put this in front of) main for this now? |
4bd6ef7 to
88ead1d
Compare
I updated the instructions.md. Does it look good to you? Or do we want more testing? |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
shared-schemas/src/docs.schema.ts (1)
15-27: Update the schema description to include auth-sdk.The
.describe()text lists all documentation types but is missing the newly added"auth-sdk"type. This could lead to confusion for developers inspecting the schema.🔎 Proposed fix to add auth-sdk to the description
.describe( ` Documentation type: "instructions" (essential backend setup - use FIRST), + "auth-sdk" (authentication SDK for custom auth flows), "db-sdk" (database operations), "storage-sdk" (file storage), "functions-sdk" (edge functions), "auth-components-react" (authentication components for React+Vite applications), "auth-components-nextjs" (authentication components for Next.js applications), "ai-integration-sdk" (AI features), "real-time" (real-time pub/sub through WebSockets) ` );
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (12)
backend/src/api/routes/docs/index.routes.tsbackend/src/services/auth/auth.service.tsdocs/core-concepts/authentication/sdk.mdxdocs/insforge-instructions-sdk.mdfrontend/src/features/dashboard/pages/DashboardPage.tsxfrontend/src/features/database/components/TemplatePreview.tsxfrontend/src/features/visualizer/components/AuthNode.tsxfrontend/src/features/visualizer/components/SchemaVisualizer.tsxfrontend/src/features/visualizer/pages/VisualizerPage.tsxshared-schemas/package.jsonshared-schemas/src/docs.schema.tsshared-schemas/src/metadata.schema.ts
🧰 Additional context used
📓 Path-based instructions (15)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx,js,jsx}: Use TypeScript for all code files
Prefer descriptive, unabbreviated variable and function names
Follow consistent file naming: kebab-case for files, PascalCase for components
Use ES modules (import/export syntax)
Implement proper error handling with try-catch blocks
Add appropriate logging for debugging
Use camelCase for variables, parameters, properties, and functions
Use UPPER_CASE for constants and Enum members
Avoid snake_case except in SQL queries and external APIs
Use single quotes for strings
Include semicolons at the end of statements
Use arrow functions for callbacks and inline functions
Prefer const over let, avoid var
Use template literals for string interpolation
Maintain consistent indentation (2 spaces)
Format code with Prettier configuration
Include JSDoc comments for complex functions
Files:
shared-schemas/src/docs.schema.tsfrontend/src/features/dashboard/pages/DashboardPage.tsxfrontend/src/features/database/components/TemplatePreview.tsxshared-schemas/src/metadata.schema.tsbackend/src/api/routes/docs/index.routes.tsfrontend/src/features/visualizer/components/AuthNode.tsxfrontend/src/features/visualizer/pages/VisualizerPage.tsxfrontend/src/features/visualizer/components/SchemaVisualizer.tsxbackend/src/services/auth/auth.service.ts
{backend/src/**/*.{ts,js},shared-schemas/**/*.{ts,js}}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use Zod schemas for request/response validation in backend
Files:
shared-schemas/src/docs.schema.tsshared-schemas/src/metadata.schema.tsbackend/src/api/routes/docs/index.routes.tsbackend/src/services/auth/auth.service.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use PascalCase for React components and TypeScript types/interfaces
Files:
shared-schemas/src/docs.schema.tsfrontend/src/features/dashboard/pages/DashboardPage.tsxfrontend/src/features/database/components/TemplatePreview.tsxshared-schemas/src/metadata.schema.tsbackend/src/api/routes/docs/index.routes.tsfrontend/src/features/visualizer/components/AuthNode.tsxfrontend/src/features/visualizer/pages/VisualizerPage.tsxfrontend/src/features/visualizer/components/SchemaVisualizer.tsxbackend/src/services/auth/auth.service.ts
frontend/src/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.{tsx,jsx}: Use functional components with hooks exclusively in React
Implement proper TypeScript interfaces for all props in React components
Use React Hook Form for form handling in frontend
Follow component composition patterns in React
Implement proper loading and error states in React components
Keep components focused and single-purpose in React
Use Radix UI primitives for accessibility in frontend
Use appropriate loading skeletons for data fetching in frontend
Display clear error messages with actionable feedback in frontend
Implement proper form validation with inline errors in frontend
Use consistent icon set from lucide-react
Optimize React component re-renders
Files:
frontend/src/features/dashboard/pages/DashboardPage.tsxfrontend/src/features/database/components/TemplatePreview.tsxfrontend/src/features/visualizer/components/AuthNode.tsxfrontend/src/features/visualizer/pages/VisualizerPage.tsxfrontend/src/features/visualizer/components/SchemaVisualizer.tsx
frontend/src/**/*.{tsx,jsx,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
frontend/src/**/*.{tsx,jsx,ts}: Use TanStack Query for server state management in frontend
Use lazy loading for code splitting
Optimize bundle size with proper imports
Files:
frontend/src/features/dashboard/pages/DashboardPage.tsxfrontend/src/features/database/components/TemplatePreview.tsxfrontend/src/features/visualizer/components/AuthNode.tsxfrontend/src/features/visualizer/pages/VisualizerPage.tsxfrontend/src/features/visualizer/components/SchemaVisualizer.tsx
frontend/src/**/*.{tsx,jsx,css}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Maintain consistent color scheme using CSS variables
Files:
frontend/src/features/dashboard/pages/DashboardPage.tsxfrontend/src/features/database/components/TemplatePreview.tsxfrontend/src/features/visualizer/components/AuthNode.tsxfrontend/src/features/visualizer/pages/VisualizerPage.tsxfrontend/src/features/visualizer/components/SchemaVisualizer.tsx
{backend,frontend}/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use environment variables for configuration
Files:
frontend/src/features/dashboard/pages/DashboardPage.tsxfrontend/src/features/database/components/TemplatePreview.tsxbackend/src/api/routes/docs/index.routes.tsfrontend/src/features/visualizer/components/AuthNode.tsxfrontend/src/features/visualizer/pages/VisualizerPage.tsxfrontend/src/features/visualizer/components/SchemaVisualizer.tsxbackend/src/services/auth/auth.service.ts
{backend/src/{api,controllers},frontend/src/**}/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
{backend/src/{api,controllers},frontend/src/**}/*.{ts,tsx,js,jsx}: Validate all user inputs
Use pagination for large data sets
Files:
frontend/src/features/dashboard/pages/DashboardPage.tsxfrontend/src/features/database/components/TemplatePreview.tsxfrontend/src/features/visualizer/components/AuthNode.tsxfrontend/src/features/visualizer/pages/VisualizerPage.tsxfrontend/src/features/visualizer/components/SchemaVisualizer.tsx
{backend/src,frontend/src}/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
{backend/src,frontend/src}/**/*.{ts,tsx,js,jsx}: Implement proper caching strategies
Monitor and log performance metrics
Files:
frontend/src/features/dashboard/pages/DashboardPage.tsxfrontend/src/features/database/components/TemplatePreview.tsxbackend/src/api/routes/docs/index.routes.tsfrontend/src/features/visualizer/components/AuthNode.tsxfrontend/src/features/visualizer/pages/VisualizerPage.tsxfrontend/src/features/visualizer/components/SchemaVisualizer.tsxbackend/src/services/auth/auth.service.ts
backend/src/**/*.{ts,js}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
backend/src/**/*.{ts,js}: Use async/await for asynchronous operations in backend code
Implement proper database transaction handling
Sanitize data before database operations
Use prepared statements for SQL queries
Implement proper database indexing
Files:
backend/src/api/routes/docs/index.routes.tsbackend/src/services/auth/auth.service.ts
backend/src/api/**/*.{ts,js}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
backend/src/api/**/*.{ts,js}: Implement proper middleware for authentication and error handling
Follow RESTful conventions for API endpoints
Implement rate limiting for API endpoints
Files:
backend/src/api/routes/docs/index.routes.ts
backend/src/{controllers,api}/**/*.{ts,js}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Return consistent API responses using utility functions
Files:
backend/src/api/routes/docs/index.routes.ts
backend/src/{api,core,controllers}/**/*.{ts,js}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Implement proper authentication and authorization
Files:
backend/src/api/routes/docs/index.routes.ts
{backend/src/api,openapi}/**/*.{ts,yaml,yml,json}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Document all API endpoints with clear descriptions
Files:
backend/src/api/routes/docs/index.routes.ts
backend/src/**/*.service.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Name service files in camelCase with .service.ts suffix (e.g., auth.service.ts)
Files:
backend/src/services/auth/auth.service.ts
🧠 Learnings (6)
📚 Learning: 2025-12-01T06:28:41.515Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-01T06:28:41.515Z
Learning: Applies to {backend/src/**/*.{ts,js},shared-schemas/**/*.{ts,js}} : Use Zod schemas for request/response validation in backend
Applied to files:
shared-schemas/src/docs.schema.tsshared-schemas/src/metadata.schema.tsfrontend/src/features/visualizer/components/SchemaVisualizer.tsx
📚 Learning: 2025-12-01T06:28:41.515Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-01T06:28:41.515Z
Learning: Applies to {backend/src/api,openapi}/**/*.{ts,yaml,yml,json} : Document all API endpoints with clear descriptions
Applied to files:
backend/src/api/routes/docs/index.routes.ts
📚 Learning: 2025-12-01T06:28:41.515Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-01T06:28:41.515Z
Learning: Applies to backend/src/{api,core,controllers}/**/*.{ts,js} : Implement proper authentication and authorization
Applied to files:
backend/src/api/routes/docs/index.routes.tsdocs/insforge-instructions-sdk.md
📚 Learning: 2025-12-01T06:28:41.515Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-01T06:28:41.515Z
Learning: Applies to backend/src/api/**/*.{ts,js} : Implement proper middleware for authentication and error handling
Applied to files:
backend/src/api/routes/docs/index.routes.tsdocs/insforge-instructions-sdk.md
📚 Learning: 2025-12-01T06:28:41.515Z
Learnt from: CR
Repo: InsForge/InsForge PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-01T06:28:41.515Z
Learning: Applies to backend/src/{controllers,api}/**/*.{ts,js} : Return consistent API responses using utility functions
Applied to files:
docs/insforge-instructions-sdk.md
📚 Learning: 2025-12-12T22:31:18.410Z
Learnt from: tonychang04
Repo: InsForge/InsForge PR: 639
File: backend/src/api/routes/email/index.routes.ts:28-28
Timestamp: 2025-12-12T22:31:18.410Z
Learning: In the InsForge codebase, new API endpoints intentionally return empty objects `{}` for forward compatibility, allowing fields to be added later without breaking existing clients. The shared-schemas package defines corresponding empty object schemas (e.g., SendEmailResponse) for this purpose.
Applied to files:
docs/core-concepts/authentication/sdk.mdx
🧬 Code graph analysis (3)
shared-schemas/src/metadata.schema.ts (1)
shared-schemas/src/auth-api.schema.ts (1)
getPublicAuthConfigResponseSchema(301-309)
frontend/src/features/visualizer/pages/VisualizerPage.tsx (1)
frontend/src/features/visualizer/components/SchemaVisualizer.tsx (1)
SchemaVisualizer(199-394)
frontend/src/features/visualizer/components/SchemaVisualizer.tsx (2)
shared-schemas/src/auth.schema.ts (1)
OAuthProvidersSchema(136-136)shared-schemas/src/metadata.schema.ts (2)
DatabaseMetadataSchema(62-62)StorageMetadataSchema(64-64)
🪛 Gitleaks (8.30.0)
docs/core-concepts/authentication/sdk.mdx
[high] 522-522: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
[high] 627-627: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🔇 Additional comments (21)
shared-schemas/package.json (1)
3-3: Verify semantic versioning alignment with schema changes.The version bump to 1.1.36 (patch) aligns with typical documentation and non-breaking releases. However, per the PR summary, the auth SDK involves refactoring OAuth provider representation from
oauthstooAuthProviders/providers. Please confirm whether this schema refactoring maintains backward compatibility, or if it warrants a minor (1.2.0) or major (2.0.0) version bump instead.backend/src/services/auth/auth.service.ts (1)
847-858: LGTM! Good use of Promise.all for concurrent data fetching.The refactoring from a single OAuth config fetch to two separate concurrent calls improves performance by reducing sequential wait time. The use of
Promise.allensures both service methods execute in parallel, and the spread operator cleanly merges the auth config fields with the OAuth providers array in the response.The service methods handle their own error scenarios with appropriate fallbacks (e.g.,
getPublicAuthConfigreturns default values if no config exists), so error propagation here is intentional and correct.frontend/src/features/database/components/TemplatePreview.tsx (1)
73-73: LGTM!The property name change from
oauthstoprovidersis consistent with the broader refactoring in this PR and correctly reflects the updated metadata shape forSchemaVisualizer.docs/insforge-instructions-sdk.md (2)
56-59: LGTM! Clear distinction between custom and pre-built auth flows.The addition of the
auth-sdkdocumentation type and the clarification that other auth options are "Pre-built auth UI" significantly improves the documentation's clarity. This helps developers choose the right implementation path based on their needs.
85-85: LGTM! Updated guidance aligns with new auth-sdk offering.The updated important note correctly guides developers to use
auth-sdkfor custom UI implementations and framework-specific components for pre-built UI, which aligns perfectly with the newly enabled documentation.shared-schemas/src/docs.schema.ts (1)
6-6: LGTM! Schema updated to include auth-sdk.The addition of
'auth-sdk'to the enum is consistent with the documentation changes and backend route updates in this PR.backend/src/api/routes/docs/index.routes.ts (1)
19-19: Documentation file exists and is properly mapped.The file
docs/core-concepts/authentication/sdk.mdxis present in the repository and correctly mapped in the DOCS_MAP object. No 404 errors will occur.frontend/src/features/dashboard/pages/DashboardPage.tsx (1)
22-22: No issues found—property name refactoring is complete and consistent across the codebase.The change from
oauthstooAuthProvidershas been applied consistently throughout all files including type definitions, API schemas, backend services, and frontend components. No stale references to the old property name remain.shared-schemas/src/metadata.schema.ts (1)
5-7: LGTM! Schema consolidation improves maintainability.Replacing the local auth metadata schema with
getPublicAuthConfigResponseSchemaensures consistency across the codebase and reduces duplication. The public schema includesoAuthProvidersand relevant auth config fields.frontend/src/features/visualizer/pages/VisualizerPage.tsx (1)
91-100: LGTM! Metadata mapping aligns with the providers refactor.The restructured metadata prop correctly maps
metadata.auth.oAuthProviderstoauth.providersfor SchemaVisualizer, consistent with the broader schema changes across the codebase.frontend/src/features/visualizer/components/AuthNode.tsx (2)
3-3: LGTM! Import aligns with the new providers-based schema.Importing
OAuthProvidersSchemafrom shared-schemas ensures type safety with the updated data structure.
8-20: LGTM! Data shape simplification improves clarity.The component now expects
providers: OAuthProvidersSchema[]directly instead of nestedauthMetadata.oauths, making the data flow clearer. The enabled count calculation correctly usesproviders.length + 1to account for email/password authentication.frontend/src/features/visualizer/components/SchemaVisualizer.tsx (3)
23-42: LGTM! Prop interface updated consistently with schema changes.The
SchemaVisualizerPropsnow uses explicit type composition withDatabaseMetadataSchema,StorageMetadataSchema, andOAuthProvidersSchema[], replacing the previousAppMetadataSchema. This provides better type safety and aligns with the providers-based refactor.
54-58: LGTM! AuthNodeData type aligns with AuthNode component.The
providers: OAuthProvidersSchema[]type matches the updated AuthNode component expectations, ensuring type consistency across the visualizer components.
267-276: LGTM! Authentication node initialization uses correct data shape.The auth node data correctly passes
metadata.auth.providersinstead of the previous nested structure, consistent with the broader refactor.docs/core-concepts/authentication/sdk.mdx (6)
10-83: LGTM! Email verification flow clearly documented.The updated
signUp()documentation accurately reflects the new email verification workflow, including the conditionalaccessTokenandrequireEmailVerificationfields. The note clearly distinguishes between code and link verification methods.
85-151: LGTM! Sign-in documentation updated with redirect support.The
signInWithPassword()documentation correctly shows the optionalredirectToandcsrfTokenfields, with a clear example of handling post-authentication redirects.
244-308: LGTM! Session documentation reflects updated user structure.The
getCurrentSession()documentation correctly includes theprovidersfield in the user object and documents the automatic refresh behavior via httpOnly cookies. The example showing expiration checking is helpful.
312-420: LGTM! Flattened profile structure simplifies API usage.The updated
getProfile()andsetProfile()documentation clearly shows the flattened structure with all fields at the top level, making the API more intuitive. Examples correctly demonstrate accessing fields directly from the data object.
422-532: LGTM! Email verification endpoints thoroughly documented.The new
sendVerificationEmail()andverifyEmail()documentation is comprehensive, with clear explanations of both code and link verification methods. The security note about user enumeration prevention is appropriate.
534-686: LGTM! Password reset workflows clearly documented.The password reset documentation comprehensively covers both single-step (magic link) and two-step (code exchange) flows. The
exchangeResetPasswordToken()endpoint is correctly noted as only applicable for code-based resets.Note: Static analysis flagged example JWT tokens on lines 522 and 627, but these are documentation examples, not real secrets.
|
it's good to go! |
Summary
Update auth sdk doc and bring it back to the doc list
Summary by CodeRabbit
New Features
Documentation
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.