<commit_before>import pluginConfig from 'config:@sanity/default-login'
import {versionedClient} from '../versionedClient'

export default function getProviders() {
  const config = pluginConfig || {}
  return versionedClient
    .request({
      uri: '/auth/providers',
      withCredentials: true,
    })
    .then((res) => {
      const {providers, thirdPartyLogin} = res
      const customProviders = (config.providers && config.providers.entries) || []
      if (customProviders.length === 0) {
        return providers
      }

      const custom = customProviders.map((provider) => {
        // A user may want to remove certain login options (eg GitHub) and thus provide "official"
        // login options through the config. These shouldn't be treated as custom login providers
        // which require the third-party login feature, but as the official provider
        const isOfficial = providers.some((official) => official.url === provider.url)
        return {...provider, custom: !isOfficial, supported: isOfficial || thirdPartyLogin}
      })

      if (config.providers.mode === 'replace') {
        return custom
      }

      // Append to the list of official providers, but replace any provider that has
      // the same URL with the custom one (allows customizing the title, name)
      return providers
        .filter((official) => custom.some((provider) => provider.url !== official.url))
        .concat(custom)
    })
}<commit_msg>feat(default-login): add support for sso login providers<commit_after>import pluginConfig from 'config:@sanity/default-login'
import {versionedClient} from '../versionedClient'

export default function getProviders() {
  const config = pluginConfig || {}
  return versionedClient
    .request({
      uri: '/auth/providers',
      withCredentials: true,
    })
    .then((res) => {
      const {providers, thirdPartyLogin, sso} = res
      const customProviders = (config.providers && config.providers.entries) || []
      if (customProviders.length === 0) {
        return providers
      }

      const custom = customProviders.map((provider) => {
        // A user may want to remove certain login options (eg GitHub) and thus provide "official"
        // login options through the config. These shouldn't be treated as custom login providers
        // which require the third-party login feature, but as the official provider
        const isOfficial = providers.some((official) => official.url === provider.url)
        const isSupported =
          isOfficial || thirdPartyLogin || (sso && Object.values(sso).some(Boolean))
        return {...provider, custom: !isOfficial, supported: isSupported}
      })

      if (config.providers.mode === 'replace') {
        return custom
      }

      // Append to the list of official providers, but replace any provider that has
      // the same URL with the custom one (allows customizing the title, name)
      return providers
        .filter((official) => custom.some((provider) => provider.url !== official.url))
        .concat(custom)
    })
}
{'fraction_non_alphanumeric': 0.1110022853411688, 'fraction_numerical': 0.000652954619653934, 'mean_word_length': 2.8932655654383734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7656357', 'n_tokens_mistral': 802, 'n_tokens_neox': 774, 'n_words': 266}