Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/design-system/content/docs/components/combobox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,9 @@ You can create a responsive combobox by using the `<Popover />` on desktop and t
### Form

<ComponentPreview name="combobox-form" />

### Create from list

When users can create an option while choosing one, give the action a clear verb label and place it at the bottom of the list, separated from the existing options. Keep the current selection in place while they create the new option.

<ComponentPreview name="combobox-create-option" peekCode wide />
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
'use client'

import { Check, Plus } from 'lucide-react'
import { useState } from 'react'
import {
ComboboxTrigger,
Command,
CommandGroup,
CommandItem,
CommandList,
CommandSeparator,
Popover,
PopoverContent,
PopoverTrigger,
} from 'ui'

const buckets = ['Images', 'Exports']

export default function ComboboxCreateOption() {
const [selectedBucket, setSelectedBucket] = useState('')
const [isListOpen, setIsListOpen] = useState(false)

return (
<Popover open={isListOpen} onOpenChange={setIsListOpen}>
<PopoverTrigger asChild>
<ComboboxTrigger
aria-expanded={isListOpen}
data-state={isListOpen ? 'open' : 'closed'}
className="w-[240px]"
>
{selectedBucket || 'Select a bucket'}
</ComboboxTrigger>
</PopoverTrigger>
<PopoverContent className="w-[240px] p-0" align="start">
<Command>
<CommandList>
<CommandGroup>
{buckets.map((bucket) => (
<CommandItem
key={bucket}
value={bucket}
className="cursor-pointer justify-between"
onSelect={() => {
setSelectedBucket(bucket)
setIsListOpen(false)
}}
>
{bucket}
{selectedBucket === bucket && <Check size={14} />}
</CommandItem>
))}
</CommandGroup>
<CommandSeparator />
<CommandGroup>
<CommandItem
className="cursor-pointer"
onSelect={() => {
setIsListOpen(false)
// Open the creation flow here without changing the selected bucket.
}}
>
<Plus size={14} className="mr-2" />
New bucket
</CommandItem>
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
)
}
6 changes: 6 additions & 0 deletions apps/design-system/registry/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ export const examples: Registry = [
registryDependencies: ['command'],
files: ['example/combobox-demo.tsx'],
},
{
name: 'combobox-create-option',
type: 'components:example',
registryDependencies: ['command'],
files: ['example/combobox-create-option.tsx'],
},
{
name: 'combobox-dropdown-menu',
type: 'components:example',
Expand Down
5 changes: 3 additions & 2 deletions apps/docs/content/guides/self-hosting/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,11 @@ To change the database password, read [Changing database password](#changing-dat

## Accessing Edge Functions

Edge Functions live in `volumes/functions`. The default setup includes a `hello` function you can invoke with `curl`:
Edge Functions live in `volumes/functions`. The default setup includes a `hello` function you can invoke with `curl`. It requires your publishable or secret key in the `apikey` header:

```sh
curl http://<your-domain>:8000/functions/v1/hello
curl http://<your-domain>:8000/functions/v1/hello \
--header 'apikey: <SUPABASE_PUBLISHABLE_KEY>'
```

Add new functions at `volumes/functions/<FUNCTION_NAME>/index.ts`, then restart the service to pick them up:
Expand Down
21 changes: 19 additions & 2 deletions apps/docs/content/guides/self-hosting/self-hosted-envoy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Routes are matched in the order declared. The first matching prefix wins. Protec
| `/.well-known/oauth-authorization-server` | auth | - | Open | OAuth 2.0 Authorization Server Metadata (RFC 8414) |
| `/auth/v1/sso/saml/acs` | auth | `/sso/saml/acs` | Open | SAML assertion consumer |
| `/auth/v1/sso/saml/metadata` | auth | `/sso/saml/metadata` | Open | SAML metadata |
| `/functions/v1/` | functions | `/` | Bypass | Edge Functions runtime performs its own JWT verification; 150s timeout |
| `/functions/v1/` | functions | `/` | `sb_` keys | Rejects invalid and conflicting `sb_` keys; others pass; timeout: 150s |
| `/storage/v1/` | storage | `/` | Bypass | Storage performs its own authorization |
| `/auth/v1/` | auth | `/` | API key | Protected Auth endpoints |
| `/rest/v1/` | rest | `/` | API key | PostgREST Open API root (requires secret key) |
Expand Down Expand Up @@ -154,7 +154,7 @@ A Lua filter rejects missing or invalid keys with HTTP `401 Unauthorized`. An RB

### Opaque key translation

When the new API keys (`sb_publishable_*`, `sb_secret_*`) are configured, a chain of Lua filters translates opaque keys into the corresponding pre-signed internal JWTs before the request reaches API key enforcement and upstream services. **The entire chain is skipped on `/functions/v1/`**: the Edge Runtime receives the original `apikey` and `Authorization` headers unchanged.
When the new API keys (`sb_publishable_*`, `sb_secret_*`) are configured, a chain of Lua filters translates opaque keys into the corresponding pre-signed internal JWTs before the request reaches API key enforcement and upstream services. **The chain is skipped on `/functions/v1/`**, which has its own filter. See [Edge Functions](#edge-functions).

The chain operates in this order:

Expand All @@ -166,6 +166,23 @@ The chain operates in this order:

For background on opaque vs asymmetric keys, see [New API Keys and Asymmetric Authentication](/docs/guides/self-hosting/self-hosted-auth-keys).

### Edge Functions

On `/functions/v1/`, a dedicated Lua filter handles API keys without changing the `apikey` or `Authorization` headers. When the new API keys are configured, it works as follows:

| Request | Result |
| ------------------------------------------------------------------ | -------------------------------------------------------- |
| No `apikey` or `Authorization` | Passed through |
| `apikey` is `sb_publishable_*` or `sb_secret_*` | Passed through with `sb-api-key` set to the internal JWT |
| `Authorization: Bearer sb_...` and no `apikey` | Same as above, using the key from `Authorization` |
| Non-`sb_` value (legacy API key, user session token, any other) | Passed through |
| Unknown `sb_` key | Rejected with `401 Unauthorized` |
| `apikey` and `Authorization: Bearer sb_...` contain different keys | Rejected with `401 Unauthorized` |

The filter always removes any `sb-api-key` header sent by the client. Without the new API keys configured, all other requests pass through unchanged. The `sb-api-key` value is the raw JWT, without a `Bearer` prefix. The `apikey` query parameter is not read on this route.

When `FUNCTIONS_VERIFY_JWT` is `true`, the functions service verifies the JWT in `Authorization`. If `Authorization` is missing or contains an `sb_` key, it verifies `sb-api-key` instead. It removes `sb-api-key` before the request reaches your function. Functions can also check API keys themselves, for example with `withSupabase` from `@supabase/server`. See [Self-hosted Edge Functions](/docs/guides/self-hosting/self-hosted-functions).

## Forwarded headers and CORS

### X-Forwarded headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Add the following code to `index.ts`:
import { withSupabase } from '@supabase/server'

export default {
fetch: withSupabase({ auth: 'none' }, async (req) => {
fetch: withSupabase({ auth: ['publishable', 'secret'] }, async (req) => {
const { name } = await req.json()
const message = `Hello, ${name}!`

Expand All @@ -51,7 +51,7 @@ export default {
}
```

The `auth` option controls who can call the function: `'none'` accepts every request, `'user'` requires a valid user JWT, and `'publishable'` / `'secret'` require an API key. See the [Edge Functions auth guide](/docs/guides/functions/auth) for details.
The `auth` option controls who can call the function. This example matches the default `hello` function and requires a publishable or secret API key in the `apikey` header. `'none'` accepts every request, and `'user'` requires a valid user JWT. See the [Edge Functions auth guide](/docs/guides/functions/auth) for details.

### Step 2: Restart the functions service to pick up the new function

Expand All @@ -63,6 +63,7 @@ sh run.sh restart functions

```sh
curl -X POST http://<your-domain>/functions/v1/my-function \
-H 'apikey: <SUPABASE_PUBLISHABLE_KEY>' \
-H 'Content-Type: application/json' \
-d '{"name": "World"}'
```
Expand Down Expand Up @@ -226,7 +227,8 @@ Common causes: syntax errors in your function code, invalid imports, or missing
### 401 "invalid JWT"

- Check that `FUNCTIONS_VERIFY_JWT` matches your intent (`true` or `false`) in `.env`
- If verification is enabled, ensure you're passing a valid token: `Authorization: Bearer <anon_key or service_role_key>`
- If verification is enabled, pass either a valid JWT in `Authorization: Bearer <token>` (a user session token or a legacy API key), or an `sb_publishable_*` or `sb_secret_*` key in the `apikey` header. The API gateway translates `sb_` keys to an internal JWT, which the functions service then verifies.
- Verifying asymmetric JWTs, including translated `sb_` keys, requires `SUPABASE_JWKS` to be set for the `functions` service in `docker-compose.yml`. See [New API Keys and Asymmetric Authentication](/docs/guides/self-hosting/self-hosted-auth-keys).

### Changes to function code not reflected after editing

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { describe, expect, it, vi } from 'vitest'

import { IntegrationConnection } from './IntegrationPanels'
import type { IntegrationProjectConnection } from '@/data/integrations/integrations.types'
import { render } from '@/tests/helpers'

vi.mock('@/data/projects/project-detail-query', () => ({
useProjectDetailQuery: () => ({ data: undefined, isPending: false }),
}))

const connectionWithFramework = (framework: string) =>
({
id: 'connection-1',
supabase_project_ref: 'project-ref',
foreign_project_id: 'vercel-project-1',
metadata: { id: 'vercel-project-1', name: 'my-app', framework },
}) as IntegrationProjectConnection

const frameworkIconSelector = 'img[src*="/img/icons/frameworks/"]'

describe('IntegrationConnection', () => {
it('renders the fallback badge for a framework without a shipped icon', () => {
const { container } = render(
<IntegrationConnection type="Vercel" connection={connectionWithFramework('express')} />
)

expect(container.querySelector(frameworkIconSelector)).toBeNull()
})

it('renders the framework icon for a framework with a shipped icon', () => {
const { container } = render(
<IntegrationConnection type="Vercel" connection={connectionWithFramework('nextjs')} />
)

expect(container.querySelector(frameworkIconSelector)?.getAttribute('src')).toMatch(
/\/img\/icons\/frameworks\/nextjs\.svg$/
)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
} from '@/data/integrations/integrations.types'
import { useProjectDetailQuery } from '@/data/projects/project-detail-query'
import { BASE_PATH } from '@/lib/constants'
import { getIntegrationConfigurationUrl } from '@/lib/integration-utils'
import { getFrameworkIconUrl, getIntegrationConfigurationUrl } from '@/lib/integration-utils'

const ICON_STROKE_WIDTH = 2
const ICON_SIZE = 14
Expand Down Expand Up @@ -150,6 +150,7 @@ export const IntegrationConnection = forwardRef<HTMLLIElement, IntegrationConnec
ref
) => {
const { data: project } = useProjectDetailQuery({ ref: connection.supabase_project_ref })
const frameworkIconUrl = getFrameworkIconUrl(connection?.metadata?.framework)

return (
<li
Expand Down Expand Up @@ -186,17 +187,12 @@ export const IntegrationConnection = forwardRef<HTMLLIElement, IntegrationConnec
/>

<div className="flex-1 min-w-0 flex gap-2 items-center">
{!connection?.metadata?.framework ? (
{!frameworkIconUrl ? (
<div className="bg-black text-white w-4 h-4 rounded-sm flex items-center justify-center">
<HandleIcon type={type} className={'w-2.5!'} />
</div>
) : (
<img
src={`${BASE_PATH}/img/icons/frameworks/${connection.metadata.framework}.svg`}
width={21}
height={21}
alt={`icon`}
/>
<img src={frameworkIconUrl} width={21} height={21} alt={`icon`} />
)}
{type === 'GitHub' ? (
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const WrapperRow = ({ wrapper, isShared }: WrapperRowProps) => {
{' '}
Edit this server&apos;s credentials in{' '}
<Link
href={`/project/${ref}/settings/vault/secrets`}
href={`/project/${ref}/integrations/vault/secrets`}
className="underline underline-offset-2"
>
Vault
Expand Down Expand Up @@ -140,7 +140,7 @@ export const WrapperRow = ({ wrapper, isShared }: WrapperRowProps) => {
{encryptedMetadata.map((metadata) => (
<div key={metadata.name} className="flex items-center space-x-2 text-sm">
<Link
href={`/project/${ref}/settings/vault/secrets?search=${encodeURIComponent(
href={`/project/${ref}/integrations/vault/secrets?search=${encodeURIComponent(
`${wrapper.name}_${metadata.name}`
)}`}
className="transition text-foreground-light hover:text-foreground flex items-center space-x-2 max-w-28"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useIntegrationVercelConnectionsCreateMutation } from '@/data/integratio
import { useVercelProjectsQuery } from '@/data/integrations/integrations-vercel-projects-query'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { BASE_PATH } from '@/lib/constants'
import { getFrameworkIconUrl } from '@/lib/integration-utils'
import { EMPTY_ARR } from '@/lib/void'
import { useSidePanelsStateSnapshot } from '@/state/side-panels'
import type { ResponseError } from '@/types'
Expand Down Expand Up @@ -57,16 +57,12 @@ export const SidePanelVercelProjectLinker = () => {
const getForeignProjectIcon = useCallback(
(_project: ForeignProject) => {
const project = vercelProjectsById[_project.id]
const frameworkIconUrl = getFrameworkIconUrl(project?.framework)

return !project?.framework ? (
return !frameworkIconUrl ? (
vercelIcon
) : (
<img
src={`${BASE_PATH}/img/icons/frameworks/${project.framework}.svg`}
width={21}
height={21}
alt={`icon`}
/>
<img src={frameworkIconUrl} width={21} height={21} alt={`icon`} />
)
},
[vercelProjectsById]
Expand Down
Loading
Loading