@param uri {string} Provider URI or Web ID URI

@returns {Promise<string|null>} Returns the Provider URI origin if an OIDC
provider exists at the given uri, or `null` if none exists
function providerExists (uri) {
  let providerOrigin = (new URL(uri)).origin
  let providerConfigUri = providerOrigin + '/.well-known/openid-configuration'

  return fetch(providerConfigUri, { method: 'HEAD' })
    .then(result => {
      if (result.ok) {
        return providerOrigin
      }

      return null
    })
}