Current Challenges
PostREST and Composite Types
The current implementation faces several challenges when working with Supabase and encrypted data:
-
Complex String Formatting: Users need to manually format encrypted payloads with multiple levels of JSON stringification:
const searchTerm = `(${JSON.stringify(JSON.stringify(searchResult.data))})`
// or even triple stringification in some cases
const searchTerm = `${JSON.stringify(`(${JSON.stringify(JSON.stringify(searchResult.data))})`)}`
-
Type Safety: The current approach lacks proper TypeScript type safety for encrypted fields.
-
Error-Prone: The manual string formatting is error-prone and can lead to subtle bugs.
-
Limited Query Support: Some advanced query patterns are difficult to implement with the current approach.
Proposed Solution: @cipherstash/supabase Package
Overview
Create a dedicated @cipherstash/supabase package that provides a clean, type-safe interface for working with encrypted data in Supabase.
Key Features
-
Type-Safe Query Builder
-
Automatic Payload Formatting
- Handle all JSON stringification internally
- Support for all Supabase query methods (eq, like, ilike, in, etc.)
-
Enhanced TypeScript Support
-
Query Helpers
Implementation Plan
-
Phase 1: Core Integration
- Basic query builder with support for common operations
- Type definitions and basic error handling
-
Phase 2: Advanced Features
- Support for complex queries and joins
- Performance optimizations
- Caching layer for encrypted fields
-
Phase 3: Developer Experience
- Comprehensive documentation
- Example applications
- Migration guide from current approach
Benefits
-
Improved Developer Experience
- No more manual string formatting
- Better IDE support with TypeScript
- Clearer error messages
-
Reduced Errors
- Type checking for encrypted fields
- Consistent handling of encrypted data
-
Better Performance
- Optimized query building
- Potential for caching encrypted fields
Questions to Consider
Next Steps
- Gather community feedback on the proposal
- Create a detailed technical specification
- Begin implementation of Phase 1
- Create example applications and documentation
Current Challenges
PostREST and Composite Types
The current implementation faces several challenges when working with Supabase and encrypted data:
Complex String Formatting: Users need to manually format encrypted payloads with multiple levels of JSON stringification:
Type Safety: The current approach lacks proper TypeScript type safety for encrypted fields.
Error-Prone: The manual string formatting is error-prone and can lead to subtle bugs.
Limited Query Support: Some advanced query patterns are difficult to implement with the current approach.
Proposed Solution: @cipherstash/supabase Package
Overview
Create a dedicated
@cipherstash/supabasepackage that provides a clean, type-safe interface for working with encrypted data in Supabase.Key Features
Type-Safe Query Builder
Automatic Payload Formatting
Enhanced TypeScript Support
Query Helpers
Implementation Plan
Phase 1: Core Integration
Phase 2: Advanced Features
Phase 3: Developer Experience
Benefits
Improved Developer Experience
Reduced Errors
Better Performance
Questions to Consider
Next Steps