|
1 | | -const ssoOidcClientsHash: Record<string, any> = {}; |
| 1 | +import { FromSsoInit } from "./fromSso"; |
2 | 2 |
|
3 | 3 | /** |
4 | | - * Returns a SSOOIDC client for the given region. If the client has already been created, |
5 | | - * it will be returned from the hash. |
| 4 | + * Returns a SSOOIDC client for the given region. |
6 | 5 | * @internal |
7 | 6 | */ |
8 | | -export const getSsoOidcClient = async (ssoRegion: string) => { |
| 7 | +export const getSsoOidcClient = async (ssoRegion: string, init: FromSsoInit = {}) => { |
9 | 8 | // @ts-ignore Cannot find module '@aws-sdk/client-sso-oidc' |
10 | 9 | const { SSOOIDCClient } = await import("@aws-sdk/client-sso-oidc"); |
11 | 10 |
|
12 | | - // return ssoOidsClient if already created. |
13 | | - if (ssoOidcClientsHash[ssoRegion]) { |
14 | | - return ssoOidcClientsHash[ssoRegion]; |
15 | | - } |
16 | | - |
17 | | - // Create new SSOOIDC client, and store is in hash. |
18 | | - // If we need to support configuration of SsoOidc client in future through code, |
19 | | - // the provision to pass region from client configuration needs to be added. |
20 | | - const ssoOidcClient = new SSOOIDCClient({ region: ssoRegion }); |
21 | | - ssoOidcClientsHash[ssoRegion] = ssoOidcClient; |
| 11 | + const ssoOidcClient = new SSOOIDCClient( |
| 12 | + Object.assign({}, init.clientConfig ?? {}, { |
| 13 | + region: ssoRegion ?? init.clientConfig.region, |
| 14 | + logger: init.clientConfig?.logger ?? init.parentClientConfig?.logger, |
| 15 | + }) |
| 16 | + ); |
22 | 17 | return ssoOidcClient; |
23 | 18 | }; |
0 commit comments