MCPcopy
hub / github.com/nextauthjs/next-auth / parseProviders

Function parseProviders

src/core/lib/providers.ts:11–35  ·  view source on GitHub ↗
(params: {
  providers: Provider[]
  url: InternalUrl
  providerId?: string
})

Source from the content-addressed store, hash-verified

9 * and deep merge user-defined options.
10 */
11export default function parseProviders(params: {
12 providers: Provider[]
13 url: InternalUrl
14 providerId?: string
15}): {
16 providers: InternalProvider[]
17 provider?: InternalProvider
18} {
19 const { url, providerId } = params
20
21 const providers = params.providers.map(({ options, ...rest }) => {
22 const defaultOptions = normalizeProvider(rest as Provider)
23 const userOptions = normalizeProvider(options as Provider)
24
25 return merge(defaultOptions, {
26 ...userOptions,
27 signinUrl: `${url}/signin/${userOptions?.id ?? rest.id}`,
28 callbackUrl: `${url}/callback/${userOptions?.id ?? rest.id}`,
29 })
30 })
31
32 const provider = providers.find(({ id }) => id === providerId)
33
34 return { providers, provider }
35}
36
37function normalizeProvider(provider?: Provider) {
38 if (!provider) return

Callers 1

initFunction · 0.85

Calls 2

mergeFunction · 0.90
normalizeProviderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…