1 | |
2 | type Supabase = { |
3 | key: string |
4 | } |
5 | |
6 | * Creates a new SSO provider |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Supabase, |
11 | ref: string, |
12 | body: { |
13 | type: 'saml' |
14 | metadata_xml?: string |
15 | metadata_url?: string |
16 | domains?: string[] |
17 | attribute_mapping?: { keys: {} } |
18 | } |
19 | ) { |
20 | const url = new URL(`https://api.supabase.com/v1/projects/${ref}/config/auth/sso/providers`) |
21 |
|
22 | const response = await fetch(url, { |
23 | method: 'POST', |
24 | headers: { |
25 | 'Content-Type': 'application/json', |
26 | Authorization: 'Bearer ' + auth.key |
27 | }, |
28 | body: JSON.stringify(body) |
29 | }) |
30 | if (!response.ok) { |
31 | const text = await response.text() |
32 | throw new Error(`${response.status} ${text}`) |
33 | } |
34 | return await response.json() |
35 | } |
36 |
|