StackLatestSupabaseFunctions
encryptedSupabase
API reference for encryptedSupabase
Function: encryptedSupabase()
function encryptedSupabase(config): EncryptedSupabaseInstance;Defined in: .tmp-stack/packages/stack/src/supabase/index.ts:41
Create an encrypted Supabase wrapper that transparently handles encryption and decryption for queries on encrypted columns.
Parameters
config
Configuration containing the encryption client and Supabase client.
Returns
An object with a from() method that mirrors supabase.from() but
auto-encrypts mutations, adds ::jsonb casts, encrypts filter values, and
decrypts results.
Example
import { Encryption } from '@cipherstash/stack'
import { encryptedSupabase } from '@cipherstash/stack/supabase'
import { encryptedTable, encryptedColumn } from '@cipherstash/stack/schema'
const users = encryptedTable('users', {
name: encryptedColumn('name').freeTextSearch().equality(),
email: encryptedColumn('email').freeTextSearch().equality(),
})
const client = await Encryption({ schemas: [users] })
const eSupabase = encryptedSupabase({ encryptionClient: client, supabaseClient: supabase })
// INSERT - auto-encrypts, auto-converts to PG composite
await eSupabase.from('users', users)
.insert({ name: 'John', email: 'john@example.com', age: 30 })
// SELECT with filter - auto-casts ::jsonb, auto-encrypts search term, auto-decrypts
const { data } = await eSupabase.from('users', users)
.select('id, email, name')
.eq('email', 'john@example.com')