1
1
import { CredentialsProviderError } from "@aws-sdk/property-provider" ;
2
- import { AwsCredentialIdentity , AwsCredentialIdentityProvider } from "@aws-sdk/types" ;
2
+ import { AwsCredentialIdentityProvider } from "@aws-sdk/types" ;
3
3
import { readFileSync } from "fs" ;
4
4
5
5
import { fromWebToken , FromWebTokenInit } from "./fromWebToken" ;
@@ -20,28 +20,24 @@ export interface FromTokenFileInit extends Partial<Omit<FromWebTokenInit, "webId
20
20
21
21
/**
22
22
* @internal
23
- *
23
+ *
24
24
* Represents OIDC credentials from a file on disk.
25
25
*/
26
26
export const fromTokenFile =
27
27
( init : FromTokenFileInit = { } ) : AwsCredentialIdentityProvider =>
28
28
async ( ) => {
29
- return resolveTokenFile ( init ) ;
30
- } ;
31
-
32
- const resolveTokenFile = ( init ?: FromTokenFileInit ) : Promise < AwsCredentialIdentity > => {
33
- const webIdentityTokenFile = init ?. webIdentityTokenFile ?? process . env [ ENV_TOKEN_FILE ] ;
34
- const roleArn = init ?. roleArn ?? process . env [ ENV_ROLE_ARN ] ;
35
- const roleSessionName = init ?. roleSessionName ?? process . env [ ENV_ROLE_SESSION_NAME ] ;
29
+ const webIdentityTokenFile = init ?. webIdentityTokenFile ?? process . env [ ENV_TOKEN_FILE ] ;
30
+ const roleArn = init ?. roleArn ?? process . env [ ENV_ROLE_ARN ] ;
31
+ const roleSessionName = init ?. roleSessionName ?? process . env [ ENV_ROLE_SESSION_NAME ] ;
36
32
37
- if ( ! webIdentityTokenFile || ! roleArn ) {
38
- throw new CredentialsProviderError ( "Web identity configuration not specified" ) ;
39
- }
33
+ if ( ! webIdentityTokenFile || ! roleArn ) {
34
+ throw new CredentialsProviderError ( "Web identity configuration not specified" ) ;
35
+ }
40
36
41
- return fromWebToken ( {
42
- ...init ,
43
- webIdentityToken : readFileSync ( webIdentityTokenFile , { encoding : "ascii" } ) ,
44
- roleArn,
45
- roleSessionName,
46
- } ) ( ) ;
47
- } ;
37
+ return fromWebToken ( {
38
+ ...init ,
39
+ webIdentityToken : readFileSync ( webIdentityTokenFile , { encoding : "ascii" } ) ,
40
+ roleArn,
41
+ roleSessionName,
42
+ } ) ( ) ;
43
+ } ;
0 commit comments