Skip to content

feat(aih): adds posts api and oauth device flow #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 7, 2025

Conversation

joelhooks
Copy link
Collaborator

@joelhooks joelhooks commented Jan 7, 2025

Changes

flowchart TD
    subgraph Auth Flow
        Device[Device/Client] -->|Request Code| OAuthCode[oauth/device/code]
        OAuthCode -->|User Code| Device
        User[User Browser] -->|Activate| Verify[activate]
        Verify -->|Verify| Token[oauth/token]
        Token -->|Access Token| Device
    end

    subgraph Content Management
        Device -->|Auth Token| Posts[api/posts]
        Posts -->|CRUD| DB[(Database)]
        Posts -->|Check| CASL{Abilities}
        Device -->|Upload| S3URL[uploads/signed-url]
        S3URL -->|Direct Upload| S3[(S3 Storage)]
        Posts -->|Associate| S3
    end

    subgraph Video Processing
        S3 -->|Trigger| Lambda[Lambda]
        Lambda -->|Process| AI[AI Pipeline]
        AI -->|Update| Posts
    end
Loading

Core

  • OAuth device flow with activation routes and components
  • Posts API with CASL-based access control
  • Video resource management and S3 uploads

Docs

  • API documentation for OAuth, Posts, and Video endpoints
  • Working OAuth device flow example

Fixes

  • Package dependencies
  • Type issues in video upload components
  • Default visibility set to public

Adds new schema tables for device management:
- deviceVerifications: tracks device verification attempts
- deviceAccessToken: manages device-specific access tokens

This migration enhances security by implementing device-level authentication
and verification mechanisms, enabling granular access control per device.
Adds OAuth endpoints for device-based authentication flow:
- /oauth/device/code: handles device verification code generation
- /oauth/token: enhanced to support device flow grant type
- /oauth/userinfo: updated user info endpoint with device context
- /oauth/register: modified for device registration process

Core package changes:
- Added device verification schemas and types
- Extended drizzle adapter for device token management

Implements OAuth 2.0 device authorization grant (RFC 8628) enabling
secure authentication for input-constrained devices.
Transplants the battle-tested posts management API:
- /api/posts routes for CRUD operations
- posts-query utilities for efficient data fetching
- posts versioning system for content management

Maintains existing authorization patterns and adds
ability-based access control for granular permissions.
Ensures backward compatibility while enabling new AI-specific
features for content management.
Adds secure file upload capabilities:
- /api/uploads/signed-url: generates pre-signed S3 URLs
- /api/uploads/new: handles upload initialization
- video-uploader utilities for client-side handling

Implements direct-to-S3 upload pattern with secure URL signing
and filename uniqueness guarantees. Maintains strict access control
while enabling chunked uploads for large video files.
Implements video resource management:
- CRUD operations for video resources
- Dynamic route handling with [videoResourceId]
- Integrated with existing permission system

Enables programmatic access to video assets while maintaining
the same authorization patterns used across the platform.
Sets foundation for AI-powered video processing pipeline.
Adds detailed documentation for external API integrations:
- OAuth 2.0 device flow authentication
- Posts and Video Resource management
- S3 upload infrastructure

Includes best practices, example TypeScript integration,
and endpoint specifications for partners and collaborators.
Implements user-facing OAuth components:
- /activate pages for device verification flow
- Login page with device activation support
- tRPC router for device verification

Completes the OAuth device flow implementation with
user-facing components and server-side verification logic.
Copy link

vercel bot commented Jan 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai-hero ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:59am
course-builder-egghead ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:59am
course-builder-poc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:59am
course-builder-video-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:59am
epic-react-builder ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:59am
epic-web-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:59am
go-local-first ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:59am
pro-aws ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:59am
pro-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:59am
value-based-design ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 3:59am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
astro-party ⬜️ Ignored (Inspect) Visit Preview Jan 7, 2025 3:59am

- Migrated video upload form components from egghead
- Fixed TypeScript issues in profile and subscription pages
- Improved types in discord and progress utilities
- Enhanced type safety in uploadthing core
- Updated feedback widget action types
Replaces theoretical example with a working Node.js implementation using openid-client.
Adds clear step-by-step flow documentation and improves readability for developers.
Changes default visibility from unlisted to public across all content types:
- Products
- Lessons
- Events
- Posts
- Tutorials
- Pages

This aligns with our open-by-default content strategy.
@kodiakhq kodiakhq bot merged commit d590a6b into main Jan 7, 2025
25 checks passed
@kodiakhq kodiakhq bot deleted the joel/add-posts-api-to-ai-hero branch January 7, 2025 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants