MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / getIdentityProviderConfigs

Function getIdentityProviderConfigs

packages/shared/src/env.server.ts:118–147  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116
117
118export const getIdentityProviderConfigs = async (): Promise<Record<string, IdentityProviderConfig>> => {
119 const config = await loadConfig(env.CONFIG_PATH);
120
121 // Collapses the dual-form `identityProviders` field into the canonical object
122 // form keyed by id.
123 const idpConfigs = (() => {
124 if (!config.identityProviders) {
125 return undefined;
126 }
127 if (!Array.isArray(config.identityProviders)) {
128 return config.identityProviders;
129 }
130
131 const result: Record<string, IdentityProviderConfig> = {};
132 for (const entry of config.identityProviders) {
133 const id = entry.provider;
134 if (result[id]) {
135 throw new Error(
136 `Duplicate identity provider id "${id}" in array-form \`identityProviders\`. ` +
137 `The array form is deprecated and only supports one instance per provider type. ` +
138 `Migrate to the object form (keyed by id) to configure multiple instances.`,
139 );
140 }
141 result[id] = entry;
142 }
143 return result;
144 })();
145
146 return idpConfigs ?? {};
147}
148
149export const getIdentityProviderConfig = async (id: string): Promise<IdentityProviderConfig | undefined> => {
150 const idps = await getIdentityProviderConfigs();

Callers 3

getEEIdentityProvidersFunction · 0.90
getLinkedAccountsFunction · 0.90

Calls 1

loadConfigFunction · 0.85

Tested by

no test coverage detected