1
1
import { Identity , IdentityProvider } from "@smithy/types" ;
2
2
3
- import { HttpAuthScheme , HttpAuthSchemeId } from "./HttpAuthScheme" ;
3
+ import { HttpAuthSchemeId } from "./HttpAuthScheme" ;
4
4
5
5
/**
6
6
* Interface to get an IdentityProvider for a specified HttpAuthScheme
7
7
* @internal
8
8
*/
9
- export interface IdentityProviderConfiguration {
9
+ export interface IdentityProviderConfig {
10
10
/**
11
11
* Get the IdentityProvider for a specified HttpAuthScheme.
12
12
* @param schemeId schemeId of the HttpAuthScheme
13
13
* @returns IdentityProvider or undefined if HttpAuthScheme is not found
14
14
*/
15
15
getIdentityProvider ( schemeId : HttpAuthSchemeId ) : IdentityProvider < Identity > | undefined ;
16
-
17
- /**
18
- * Gets the configured HttpAuthSchemes.
19
- * @returns all configured HttpAuthSchemes
20
- */
21
- getAuthSchemes ( ) : Map < HttpAuthSchemeId , HttpAuthScheme > ;
22
16
}
23
17
24
18
/**
25
19
* Default implementation of IdentityProviderConfiguration
26
20
* @internal
27
21
*/
28
- export class DefaultIdentityProviderConfiguration implements IdentityProviderConfiguration {
29
- private authSchemes : Map < HttpAuthSchemeId , HttpAuthScheme > = new Map ( ) ;
22
+ export class DefaultIdentityProviderConfig implements IdentityProviderConfig {
23
+ private authSchemes : Map < HttpAuthSchemeId , IdentityProvider < Identity > > = new Map ( ) ;
30
24
31
25
/**
32
26
* Creates an IdentityProviderConfiguration with a list of HttpAuthSchemes.
@@ -35,17 +29,13 @@ export class DefaultIdentityProviderConfiguration implements IdentityProviderCon
35
29
* HttpAuthScheme later in the list will have priority.
36
30
* @param authSchemes auth schemes to configure
37
31
*/
38
- constructor ( authSchemes : HttpAuthScheme [ ] ) {
39
- for ( const authScheme of authSchemes ) {
40
- this . authSchemes . set ( authScheme . schemeId , authScheme ) ;
32
+ constructor ( config : Record < HttpAuthSchemeId , IdentityProvider < Identity > > ) {
33
+ for ( const [ key , value ] of Object . entries ( config ) ) {
34
+ this . authSchemes . set ( key , value ) ;
41
35
}
42
36
}
43
37
44
38
public getIdentityProvider ( schemeId : HttpAuthSchemeId ) : IdentityProvider < Identity > | undefined {
45
- return this . authSchemes . get ( schemeId ) ?. identityProvider ;
46
- }
47
-
48
- public getAuthSchemes ( ) : Map < HttpAuthSchemeId , HttpAuthScheme > {
49
- return this . authSchemes ;
39
+ return this . authSchemes . get ( schemeId ) ;
50
40
}
51
41
}
0 commit comments