@@ -10,25 +10,27 @@ import { HttpAuthScheme } from "@smithy/types";
10
10
*/
11
11
export const resolveAuthSchemes = ( candidateAuthSchemes : HttpAuthScheme [ ] , authSchemePreference : string [ ] ) => {
12
12
if ( ! authSchemePreference || authSchemePreference . length === 0 ) {
13
- // reprioritize candidates based on user's preference
14
- const preferredAuthSchemes = [ ] ;
13
+ return candidateAuthSchemes ;
14
+ }
15
15
16
- for ( const preferredSchemeName of authSchemePreference ) {
17
- for ( const candidateAuthScheme of candidateAuthSchemes ) {
18
- const candidateAuthSchemeName = candidateAuthScheme . schemeId . split ( "#" ) [ 1 ] ;
19
- if ( candidateAuthSchemeName === preferredSchemeName ) {
20
- preferredAuthSchemes . push ( candidateAuthScheme ) ;
21
- }
22
- }
23
- }
16
+ // reprioritize candidates based on user's preference
17
+ const preferredAuthSchemes = [ ] ;
24
18
25
- // add any remaining candidates that weren't in the preference list
19
+ for ( const preferredSchemeName of authSchemePreference ) {
26
20
for ( const candidateAuthScheme of candidateAuthSchemes ) {
27
- if ( ! preferredAuthSchemes . find ( ( { schemeId } ) => schemeId === candidateAuthScheme . schemeId ) ) {
21
+ const candidateAuthSchemeName = candidateAuthScheme . schemeId . split ( "#" ) [ 1 ] ;
22
+ if ( candidateAuthSchemeName === preferredSchemeName ) {
28
23
preferredAuthSchemes . push ( candidateAuthScheme ) ;
29
24
}
30
25
}
31
- } else {
32
- return candidateAuthSchemes ;
33
26
}
27
+
28
+ // add any remaining candidates that weren't in the preference list
29
+ for ( const candidateAuthScheme of candidateAuthSchemes ) {
30
+ if ( ! preferredAuthSchemes . find ( ( { schemeId } ) => schemeId === candidateAuthScheme . schemeId ) ) {
31
+ preferredAuthSchemes . push ( candidateAuthScheme ) ;
32
+ }
33
+ }
34
+
35
+ return preferredAuthSchemes ;
34
36
} ;
0 commit comments