mirror of
https://github.com/supabase/supabase.git
synced 2026-06-14 23:25:16 +08:00
* chore(studio): add oauth apps update panel * chore(studio): add client_type value to oauth app form * chore(studio): add logo_uri upload field to oauth apps * chore(studio): don't show oauth app credentials when successfully editing * chore(studio): apply correct filters to oauth apps * chore(studio): show client_secret only on confidential apps * chore(studio): hide regenerate client secret on public oauth apps * chore(studio): add docs link on auth server page
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import type { OAuthClient } from '@supabase/supabase-js'
|
|
|
|
export const OAUTH_APP_REGISTRATION_TYPE_OPTIONS = [
|
|
{ name: 'Manual', value: 'manual' },
|
|
{ name: 'Dynamic', value: 'dynamic' },
|
|
]
|
|
|
|
export const OAUTH_APP_CLIENT_TYPE_OPTIONS = [
|
|
{ name: 'Public', value: 'public' },
|
|
{ name: 'Confidential', value: 'confidential' },
|
|
]
|
|
|
|
interface FilterOAuthAppsParams {
|
|
apps: OAuthClient[]
|
|
searchString?: string
|
|
registrationTypes?: string[]
|
|
clientTypes?: string[]
|
|
}
|
|
|
|
export function filterOAuthApps({
|
|
apps,
|
|
searchString,
|
|
registrationTypes = [],
|
|
clientTypes = [],
|
|
}: FilterOAuthAppsParams): OAuthClient[] {
|
|
return apps.filter((app) => {
|
|
// Filter by search string
|
|
if (searchString) {
|
|
const searchLower = searchString.toLowerCase()
|
|
const matchesName = app.client_name.toLowerCase().includes(searchLower)
|
|
const matchesClientId = app.client_id.toLowerCase().includes(searchLower)
|
|
if (!matchesName && !matchesClientId) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
// Filter by registration type
|
|
if (registrationTypes.length > 0) {
|
|
if (!registrationTypes.includes(app.registration_type)) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
// Filter by client type
|
|
if (clientTypes.length > 0) {
|
|
if (!clientTypes.includes(app.client_type)) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
})
|
|
}
|