Edits history of script submission #20920 for ' Updates a project's auth config (supabase)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Supabase = {
    	key: string
    }
    /**
     * Updates a project's auth config
     *
     */
    export async function main(
    	auth: Supabase,
    	ref: string,
    	body: {
    		site_url?: string
    		disable_signup?: false | true
    		jwt_exp?: number
    		smtp_admin_email?: string
    		smtp_host?: string
    		smtp_port?: string
    		smtp_user?: string
    		smtp_pass?: string
    		smtp_max_frequency?: number
    		smtp_sender_name?: string
    		mailer_allow_unverified_email_sign_ins?: false | true
    		mailer_autoconfirm?: false | true
    		mailer_subjects_invite?: string
    		mailer_subjects_confirmation?: string
    		mailer_subjects_recovery?: string
    		mailer_subjects_email_change?: string
    		mailer_subjects_magic_link?: string
    		mailer_subjects_reauthentication?: string
    		mailer_templates_invite_content?: string
    		mailer_templates_confirmation_content?: string
    		mailer_templates_recovery_content?: string
    		mailer_templates_email_change_content?: string
    		mailer_templates_magic_link_content?: string
    		mailer_templates_reauthentication_content?: string
    		mfa_max_enrolled_factors?: number
    		uri_allow_list?: string
    		external_anonymous_users_enabled?: false | true
    		external_email_enabled?: false | true
    		external_phone_enabled?: false | true
    		saml_enabled?: false | true
    		saml_external_url?: string
    		security_captcha_enabled?: false | true
    		security_captcha_provider?: 'turnstile' | 'hcaptcha'
    		security_captcha_secret?: string
    		sessions_timebox?: number
    		sessions_inactivity_timeout?: number
    		sessions_single_per_user?: false | true
    		sessions_tags?: string
    		rate_limit_anonymous_users?: number
    		rate_limit_email_sent?: number
    		rate_limit_sms_sent?: number
    		rate_limit_verify?: number
    		rate_limit_token_refresh?: number
    		rate_limit_otp?: number
    		rate_limit_web3?: number
    		mailer_secure_email_change_enabled?: false | true
    		refresh_token_rotation_enabled?: false | true
    		password_hibp_enabled?: false | true
    		password_min_length?: number
    		password_required_characters?:
    			| ''
    			| 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:0123456789'
    			| 'abcdefghijklmnopqrstuvwxyz:ABCDEFGHIJKLMNOPQRSTUVWXYZ:0123456789'
    			| 'abcdefghijklmnopqrstuvwxyz:ABCDEFGHIJKLMNOPQRSTUVWXYZ:0123456789:!@#$%^&*()_+-=[]{};\'\\\\:"|<>?,./`~'
    		security_manual_linking_enabled?: false | true
    		security_update_password_require_reauthentication?: false | true
    		security_refresh_token_reuse_interval?: number
    		mailer_otp_exp?: number
    		mailer_otp_length?: number
    		sms_autoconfirm?: false | true
    		sms_max_frequency?: number
    		sms_otp_exp?: number
    		sms_otp_length?: number
    		sms_provider?: 'messagebird' | 'textlocal' | 'twilio' | 'twilio_verify' | 'vonage'
    		sms_messagebird_access_key?: string
    		sms_messagebird_originator?: string
    		sms_test_otp?: string
    		sms_test_otp_valid_until?: string
    		sms_textlocal_api_key?: string
    		sms_textlocal_sender?: string
    		sms_twilio_account_sid?: string
    		sms_twilio_auth_token?: string
    		sms_twilio_content_sid?: string
    		sms_twilio_message_service_sid?: string
    		sms_twilio_verify_account_sid?: string
    		sms_twilio_verify_auth_token?: string
    		sms_twilio_verify_message_service_sid?: string
    		sms_vonage_api_key?: string
    		sms_vonage_api_secret?: string
    		sms_vonage_from?: string
    		sms_template?: string
    		hook_mfa_verification_attempt_enabled?: false | true
    		hook_mfa_verification_attempt_uri?: string
    		hook_mfa_verification_attempt_secrets?: string
    		hook_password_verification_attempt_enabled?: false | true
    		hook_password_verification_attempt_uri?: string
    		hook_password_verification_attempt_secrets?: string
    		hook_custom_access_token_enabled?: false | true
    		hook_custom_access_token_uri?: string
    		hook_custom_access_token_secrets?: string
    		hook_send_sms_enabled?: false | true
    		hook_send_sms_uri?: string
    		hook_send_sms_secrets?: string
    		hook_send_email_enabled?: false | true
    		hook_send_email_uri?: string
    		hook_send_email_secrets?: string
    		external_apple_enabled?: false | true
    		external_apple_client_id?: string
    		external_apple_secret?: string
    		external_apple_additional_client_ids?: string
    		external_azure_enabled?: false | true
    		external_azure_client_id?: string
    		external_azure_secret?: string
    		external_azure_url?: string
    		external_bitbucket_enabled?: false | true
    		external_bitbucket_client_id?: string
    		external_bitbucket_secret?: string
    		external_discord_enabled?: false | true
    		external_discord_client_id?: string
    		external_discord_secret?: string
    		external_facebook_enabled?: false | true
    		external_facebook_client_id?: string
    		external_facebook_secret?: string
    		external_figma_enabled?: false | true
    		external_figma_client_id?: string
    		external_figma_secret?: string
    		external_github_enabled?: false | true
    		external_github_client_id?: string
    		external_github_secret?: string
    		external_gitlab_enabled?: false | true
    		external_gitlab_client_id?: string
    		external_gitlab_secret?: string
    		external_gitlab_url?: string
    		external_google_enabled?: false | true
    		external_google_client_id?: string
    		external_google_secret?: string
    		external_google_additional_client_ids?: string
    		external_google_skip_nonce_check?: false | true
    		external_kakao_enabled?: false | true
    		external_kakao_client_id?: string
    		external_kakao_secret?: string
    		external_keycloak_enabled?: false | true
    		external_keycloak_client_id?: string
    		external_keycloak_secret?: string
    		external_keycloak_url?: string
    		external_linkedin_oidc_enabled?: false | true
    		external_linkedin_oidc_client_id?: string
    		external_linkedin_oidc_secret?: string
    		external_slack_oidc_enabled?: false | true
    		external_slack_oidc_client_id?: string
    		external_slack_oidc_secret?: string
    		external_notion_enabled?: false | true
    		external_notion_client_id?: string
    		external_notion_secret?: string
    		external_slack_enabled?: false | true
    		external_slack_client_id?: string
    		external_slack_secret?: string
    		external_spotify_enabled?: false | true
    		external_spotify_client_id?: string
    		external_spotify_secret?: string
    		external_twitch_enabled?: false | true
    		external_twitch_client_id?: string
    		external_twitch_secret?: string
    		external_twitter_enabled?: false | true
    		external_twitter_client_id?: string
    		external_twitter_secret?: string
    		external_workos_enabled?: false | true
    		external_workos_client_id?: string
    		external_workos_secret?: string
    		external_workos_url?: string
    		external_web3_solana_enabled?: false | true
    		external_zoom_enabled?: false | true
    		external_zoom_client_id?: string
    		external_zoom_secret?: string
    		db_max_pool_size?: number
    		api_max_request_duration?: number
    		mfa_totp_enroll_enabled?: false | true
    		mfa_totp_verify_enabled?: false | true
    		mfa_web_authn_enroll_enabled?: false | true
    		mfa_web_authn_verify_enabled?: false | true
    		mfa_phone_enroll_enabled?: false | true
    		mfa_phone_verify_enabled?: false | true
    		mfa_phone_max_frequency?: number
    		mfa_phone_otp_length?: number
    		mfa_phone_template?: string
    	}
    ) {
    	const url = new URL(`https://api.supabase.com/v1/projects/${ref}/config/auth`)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.key
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 207 days ago