1+ "use strict" ;
2+ exports . id = 290 ;
3+ exports . ids = [ 290 ] ;
4+ exports . modules = {
5+
6+ /***/ 3757 :
7+ /***/ ( ( __unused_webpack_module , exports , __webpack_require__ ) => {
8+
9+
10+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
11+ exports . checkUrl = void 0 ;
12+ const property_provider_1 = __webpack_require__ ( 9721 ) ;
13+ const LOOPBACK_CIDR_IPv4 = "127.0.0.0/8" ;
14+ const LOOPBACK_CIDR_IPv6 = "::1/128" ;
15+ const ECS_CONTAINER_HOST = "169.254.170.2" ;
16+ const EKS_CONTAINER_HOST_IPv4 = "169.254.170.23" ;
17+ const EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]" ;
18+ const checkUrl = ( url , logger ) => {
19+ if ( url . protocol === "https:" ) {
20+ return ;
21+ }
22+ if ( url . hostname === ECS_CONTAINER_HOST ||
23+ url . hostname === EKS_CONTAINER_HOST_IPv4 ||
24+ url . hostname === EKS_CONTAINER_HOST_IPv6 ) {
25+ return ;
26+ }
27+ if ( url . hostname . includes ( "[" ) ) {
28+ if ( url . hostname === "[::1]" || url . hostname === "[0000:0000:0000:0000:0000:0000:0000:0001]" ) {
29+ return ;
30+ }
31+ }
32+ else {
33+ if ( url . hostname === "localhost" ) {
34+ return ;
35+ }
36+ const ipComponents = url . hostname . split ( "." ) ;
37+ const inRange = ( component ) => {
38+ const num = parseInt ( component , 10 ) ;
39+ return 0 <= num && num <= 255 ;
40+ } ;
41+ if ( ipComponents [ 0 ] === "127" &&
42+ inRange ( ipComponents [ 1 ] ) &&
43+ inRange ( ipComponents [ 2 ] ) &&
44+ inRange ( ipComponents [ 3 ] ) &&
45+ ipComponents . length === 4 ) {
46+ return ;
47+ }
48+ }
49+ throw new property_provider_1 . CredentialsProviderError ( `URL not accepted. It must either be HTTPS or match one of the following:
50+ - loopback CIDR 127.0.0.0/8 or [::1/128]
51+ - ECS container host 169.254.170.2
52+ - EKS container host 169.254.170.23 or [fd00:ec2::23]` , { logger } ) ;
53+ } ;
54+ exports . checkUrl = checkUrl ;
55+
56+
57+ /***/ } ) ,
58+
59+ /***/ 6070 :
60+ /***/ ( ( __unused_webpack_module , exports , __webpack_require__ ) => {
61+
62+
63+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
64+ exports . fromHttp = void 0 ;
65+ const tslib_1 = __webpack_require__ ( 9679 ) ;
66+ const client_1 = __webpack_require__ ( 2825 ) ;
67+ const node_http_handler_1 = __webpack_require__ ( 258 ) ;
68+ const property_provider_1 = __webpack_require__ ( 9721 ) ;
69+ const promises_1 = tslib_1 . __importDefault ( __webpack_require__ ( 3977 ) ) ;
70+ const checkUrl_1 = __webpack_require__ ( 3757 ) ;
71+ const requestHelpers_1 = __webpack_require__ ( 9287 ) ;
72+ const retry_wrapper_1 = __webpack_require__ ( 9921 ) ;
73+ const AWS_CONTAINER_CREDENTIALS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI" ;
74+ const DEFAULT_LINK_LOCAL_HOST = "http://169.254.170.2" ;
75+ const AWS_CONTAINER_CREDENTIALS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI" ;
76+ const AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE = "AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE" ;
77+ const AWS_CONTAINER_AUTHORIZATION_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN" ;
78+ const fromHttp = ( options = { } ) => {
79+ options . logger ?. debug ( "@aws-sdk/credential-provider-http - fromHttp" ) ;
80+ let host ;
81+ const relative = options . awsContainerCredentialsRelativeUri ?? process . env [ AWS_CONTAINER_CREDENTIALS_RELATIVE_URI ] ;
82+ const full = options . awsContainerCredentialsFullUri ?? process . env [ AWS_CONTAINER_CREDENTIALS_FULL_URI ] ;
83+ const token = options . awsContainerAuthorizationToken ?? process . env [ AWS_CONTAINER_AUTHORIZATION_TOKEN ] ;
84+ const tokenFile = options . awsContainerAuthorizationTokenFile ?? process . env [ AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE ] ;
85+ const warn = options . logger ?. constructor ?. name === "NoOpLogger" || ! options . logger ?. warn
86+ ? console . warn
87+ : options . logger . warn . bind ( options . logger ) ;
88+ if ( relative && full ) {
89+ warn ( "@aws-sdk/credential-provider-http: " +
90+ "you have set both awsContainerCredentialsRelativeUri and awsContainerCredentialsFullUri." ) ;
91+ warn ( "awsContainerCredentialsFullUri will take precedence." ) ;
92+ }
93+ if ( token && tokenFile ) {
94+ warn ( "@aws-sdk/credential-provider-http: " +
95+ "you have set both awsContainerAuthorizationToken and awsContainerAuthorizationTokenFile." ) ;
96+ warn ( "awsContainerAuthorizationToken will take precedence." ) ;
97+ }
98+ if ( full ) {
99+ host = full ;
100+ }
101+ else if ( relative ) {
102+ host = `${ DEFAULT_LINK_LOCAL_HOST } ${ relative } ` ;
103+ }
104+ else {
105+ throw new property_provider_1 . CredentialsProviderError ( `No HTTP credential provider host provided.
106+ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.` , { logger : options . logger } ) ;
107+ }
108+ const url = new URL ( host ) ;
109+ ( 0 , checkUrl_1 . checkUrl ) ( url , options . logger ) ;
110+ const requestHandler = node_http_handler_1 . NodeHttpHandler . create ( {
111+ requestTimeout : options . timeout ?? 1000 ,
112+ connectionTimeout : options . timeout ?? 1000 ,
113+ } ) ;
114+ return ( 0 , retry_wrapper_1 . retryWrapper ) ( async ( ) => {
115+ const request = ( 0 , requestHelpers_1 . createGetRequest ) ( url ) ;
116+ if ( token ) {
117+ request . headers . Authorization = token ;
118+ }
119+ else if ( tokenFile ) {
120+ request . headers . Authorization = ( await promises_1 . default . readFile ( tokenFile ) ) . toString ( ) ;
121+ }
122+ try {
123+ const result = await requestHandler . handle ( request ) ;
124+ return ( 0 , requestHelpers_1 . getCredentials ) ( result . response ) . then ( ( creds ) => ( 0 , client_1 . setCredentialFeature ) ( creds , "CREDENTIALS_HTTP" , "z" ) ) ;
125+ }
126+ catch ( e ) {
127+ throw new property_provider_1 . CredentialsProviderError ( String ( e ) , { logger : options . logger } ) ;
128+ }
129+ } , options . maxRetries ?? 3 , options . timeout ?? 1000 ) ;
130+ } ;
131+ exports . fromHttp = fromHttp ;
132+
133+
134+ /***/ } ) ,
135+
136+ /***/ 9287 :
137+ /***/ ( ( __unused_webpack_module , exports , __webpack_require__ ) => {
138+
139+
140+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
141+ exports . createGetRequest = createGetRequest ;
142+ exports . getCredentials = getCredentials ;
143+ const property_provider_1 = __webpack_require__ ( 9721 ) ;
144+ const protocol_http_1 = __webpack_require__ ( 4418 ) ;
145+ const smithy_client_1 = __webpack_require__ ( 3570 ) ;
146+ const util_stream_1 = __webpack_require__ ( 6607 ) ;
147+ function createGetRequest ( url ) {
148+ return new protocol_http_1 . HttpRequest ( {
149+ protocol : url . protocol ,
150+ hostname : url . hostname ,
151+ port : Number ( url . port ) ,
152+ path : url . pathname ,
153+ query : Array . from ( url . searchParams . entries ( ) ) . reduce ( ( acc , [ k , v ] ) => {
154+ acc [ k ] = v ;
155+ return acc ;
156+ } , { } ) ,
157+ fragment : url . hash ,
158+ } ) ;
159+ }
160+ async function getCredentials ( response , logger ) {
161+ const stream = ( 0 , util_stream_1 . sdkStreamMixin ) ( response . body ) ;
162+ const str = await stream . transformToString ( ) ;
163+ if ( response . statusCode === 200 ) {
164+ const parsed = JSON . parse ( str ) ;
165+ if ( typeof parsed . AccessKeyId !== "string" ||
166+ typeof parsed . SecretAccessKey !== "string" ||
167+ typeof parsed . Token !== "string" ||
168+ typeof parsed . Expiration !== "string" ) {
169+ throw new property_provider_1 . CredentialsProviderError ( "HTTP credential provider response not of the required format, an object matching: " +
170+ "{ AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }" , { logger } ) ;
171+ }
172+ return {
173+ accessKeyId : parsed . AccessKeyId ,
174+ secretAccessKey : parsed . SecretAccessKey ,
175+ sessionToken : parsed . Token ,
176+ expiration : ( 0 , smithy_client_1 . parseRfc3339DateTime ) ( parsed . Expiration ) ,
177+ } ;
178+ }
179+ if ( response . statusCode >= 400 && response . statusCode < 500 ) {
180+ let parsedBody = { } ;
181+ try {
182+ parsedBody = JSON . parse ( str ) ;
183+ }
184+ catch ( e ) { }
185+ throw Object . assign ( new property_provider_1 . CredentialsProviderError ( `Server responded with status: ${ response . statusCode } ` , { logger } ) , {
186+ Code : parsedBody . Code ,
187+ Message : parsedBody . Message ,
188+ } ) ;
189+ }
190+ throw new property_provider_1 . CredentialsProviderError ( `Server responded with status: ${ response . statusCode } ` , { logger } ) ;
191+ }
192+
193+
194+ /***/ } ) ,
195+
196+ /***/ 9921 :
197+ /***/ ( ( __unused_webpack_module , exports ) => {
198+
199+
200+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
201+ exports . retryWrapper = void 0 ;
202+ const retryWrapper = ( toRetry , maxRetries , delayMs ) => {
203+ return async ( ) => {
204+ for ( let i = 0 ; i < maxRetries ; ++ i ) {
205+ try {
206+ return await toRetry ( ) ;
207+ }
208+ catch ( e ) {
209+ await new Promise ( ( resolve ) => setTimeout ( resolve , delayMs ) ) ;
210+ }
211+ }
212+ return await toRetry ( ) ;
213+ } ;
214+ } ;
215+ exports . retryWrapper = retryWrapper ;
216+
217+
218+ /***/ } ) ,
219+
220+ /***/ 7290 :
221+ /***/ ( ( __unused_webpack_module , exports , __webpack_require__ ) => {
222+
223+
224+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
225+ exports . fromHttp = void 0 ;
226+ var fromHttp_1 = __webpack_require__ ( 6070 ) ;
227+ Object . defineProperty ( exports , "fromHttp" , ( { enumerable : true , get : function ( ) { return fromHttp_1 . fromHttp ; } } ) ) ;
228+
229+
230+ /***/ } )
231+
232+ } ;
233+ ;
0 commit comments