2026-03-01 10:29:20 +00:00
export const id = 566 ;
export const ids = [ 566 ] ;
export const modules = {
2026-01-30 14:42:57 +00:00
2026-03-03 17:05:14 +00:00
/***/ 566 :
2026-01-30 14:42:57 +00:00
/***/ ( ( _ _unused _webpack _module , exports , _ _webpack _require _ _ ) => {
var _ _webpack _unused _export _ _ ;
2026-03-03 17:05:14 +00:00
var propertyProvider = _ _webpack _require _ _ ( 8857 ) ;
var url = _ _webpack _require _ _ ( 7016 ) ;
var buffer = _ _webpack _require _ _ ( 181 ) ;
var http = _ _webpack _require _ _ ( 8611 ) ;
var nodeConfigProvider = _ _webpack _require _ _ ( 5704 ) ;
var urlParser = _ _webpack _require _ _ ( 4494 ) ;
2026-01-30 14:42:57 +00:00
function httpRequest ( options ) {
return new Promise ( ( resolve , reject ) => {
const req = http . request ( {
method : "GET" ,
... options ,
hostname : options . hostname ? . replace ( /^\[(.+)\]$/ , "$1" ) ,
} ) ;
req . on ( "error" , ( err ) => {
reject ( Object . assign ( new propertyProvider . ProviderError ( "Unable to connect to instance metadata service" ) , err ) ) ;
req . destroy ( ) ;
} ) ;
req . on ( "timeout" , ( ) => {
reject ( new propertyProvider . ProviderError ( "TimeoutError from instance metadata service" ) ) ;
req . destroy ( ) ;
} ) ;
req . on ( "response" , ( res ) => {
const { statusCode = 400 } = res ;
if ( statusCode < 200 || 300 <= statusCode ) {
reject ( Object . assign ( new propertyProvider . ProviderError ( "Error response received from instance metadata service" ) , { statusCode } ) ) ;
req . destroy ( ) ;
}
const chunks = [ ] ;
res . on ( "data" , ( chunk ) => {
chunks . push ( chunk ) ;
} ) ;
res . on ( "end" , ( ) => {
resolve ( buffer . Buffer . concat ( chunks ) ) ;
req . destroy ( ) ;
} ) ;
} ) ;
req . end ( ) ;
} ) ;
}
const isImdsCredentials = ( arg ) => Boolean ( arg ) &&
typeof arg === "object" &&
typeof arg . AccessKeyId === "string" &&
typeof arg . SecretAccessKey === "string" &&
typeof arg . Token === "string" &&
typeof arg . Expiration === "string" ;
const fromImdsCredentials = ( creds ) => ( {
accessKeyId : creds . AccessKeyId ,
secretAccessKey : creds . SecretAccessKey ,
sessionToken : creds . Token ,
expiration : new Date ( creds . Expiration ) ,
... ( creds . AccountId && { accountId : creds . AccountId } ) ,
} ) ;
const DEFAULT _TIMEOUT = 1000 ;
const DEFAULT _MAX _RETRIES = 0 ;
const providerConfigFromInit = ( { maxRetries = DEFAULT _MAX _RETRIES , timeout = DEFAULT _TIMEOUT , } ) => ( { maxRetries , timeout } ) ;
const retry = ( toRetry , maxRetries ) => {
let promise = toRetry ( ) ;
for ( let i = 0 ; i < maxRetries ; i ++ ) {
promise = promise . catch ( toRetry ) ;
}
return promise ;
} ;
const ENV _CMDS _FULL _URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI" ;
const ENV _CMDS _RELATIVE _URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI" ;
const ENV _CMDS _AUTH _TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN" ;
const fromContainerMetadata = ( init = { } ) => {
const { timeout , maxRetries } = providerConfigFromInit ( init ) ;
return ( ) => retry ( async ( ) => {
const requestOptions = await getCmdsUri ( { logger : init . logger } ) ;
const credsResponse = JSON . parse ( await requestFromEcsImds ( timeout , requestOptions ) ) ;
if ( ! isImdsCredentials ( credsResponse ) ) {
throw new propertyProvider . CredentialsProviderError ( "Invalid response received from instance metadata service." , {
logger : init . logger ,
} ) ;
}
return fromImdsCredentials ( credsResponse ) ;
} , maxRetries ) ;
} ;
const requestFromEcsImds = async ( timeout , options ) => {
if ( process . env [ ENV _CMDS _AUTH _TOKEN ] ) {
options . headers = {
... options . headers ,
Authorization : process . env [ ENV _CMDS _AUTH _TOKEN ] ,
} ;
}
const buffer = await httpRequest ( {
... options ,
timeout ,
} ) ;
return buffer . toString ( ) ;
} ;
const CMDS _IP = "169.254.170.2" ;
const GREENGRASS _HOSTS = {
localhost : true ,
"127.0.0.1" : true ,
} ;
const GREENGRASS _PROTOCOLS = {
"http:" : true ,
"https:" : true ,
} ;
const getCmdsUri = async ( { logger } ) => {
if ( process . env [ ENV _CMDS _RELATIVE _URI ] ) {
return {
hostname : CMDS _IP ,
path : process . env [ ENV _CMDS _RELATIVE _URI ] ,
} ;
}
if ( process . env [ ENV _CMDS _FULL _URI ] ) {
const parsed = url . parse ( process . env [ ENV _CMDS _FULL _URI ] ) ;
if ( ! parsed . hostname || ! ( parsed . hostname in GREENGRASS _HOSTS ) ) {
throw new propertyProvider . CredentialsProviderError ( ` ${ parsed . hostname } is not a valid container metadata service hostname ` , {
tryNextLink : false ,
logger ,
} ) ;
}
if ( ! parsed . protocol || ! ( parsed . protocol in GREENGRASS _PROTOCOLS ) ) {
throw new propertyProvider . CredentialsProviderError ( ` ${ parsed . protocol } is not a valid container metadata service protocol ` , {
tryNextLink : false ,
logger ,
} ) ;
}
return {
... parsed ,
port : parsed . port ? parseInt ( parsed . port , 10 ) : undefined ,
} ;
}
throw new propertyProvider . CredentialsProviderError ( "The container metadata credential provider cannot be used unless" +
` the ${ ENV _CMDS _RELATIVE _URI } or ${ ENV _CMDS _FULL _URI } environment ` +
" variable is set" , {
tryNextLink : false ,
logger ,
} ) ;
} ;
class InstanceMetadataV1FallbackError extends propertyProvider . CredentialsProviderError {
tryNextLink ;
name = "InstanceMetadataV1FallbackError" ;
constructor ( message , tryNextLink = true ) {
super ( message , tryNextLink ) ;
this . tryNextLink = tryNextLink ;
Object . setPrototypeOf ( this , InstanceMetadataV1FallbackError . prototype ) ;
}
}
exports . yI = void 0 ;
( function ( Endpoint ) {
Endpoint [ "IPv4" ] = "http://169.254.169.254" ;
Endpoint [ "IPv6" ] = "http://[fd00:ec2::254]" ;
} ) ( exports . yI || ( exports . yI = { } ) ) ;
const ENV _ENDPOINT _NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT" ;
const CONFIG _ENDPOINT _NAME = "ec2_metadata_service_endpoint" ;
const ENDPOINT _CONFIG _OPTIONS = {
environmentVariableSelector : ( env ) => env [ ENV _ENDPOINT _NAME ] ,
configFileSelector : ( profile ) => profile [ CONFIG _ENDPOINT _NAME ] ,
default : undefined ,
} ;
var EndpointMode ;
( function ( EndpointMode ) {
EndpointMode [ "IPv4" ] = "IPv4" ;
EndpointMode [ "IPv6" ] = "IPv6" ;
} ) ( EndpointMode || ( EndpointMode = { } ) ) ;
const ENV _ENDPOINT _MODE _NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE" ;
const CONFIG _ENDPOINT _MODE _NAME = "ec2_metadata_service_endpoint_mode" ;
const ENDPOINT _MODE _CONFIG _OPTIONS = {
environmentVariableSelector : ( env ) => env [ ENV _ENDPOINT _MODE _NAME ] ,
configFileSelector : ( profile ) => profile [ CONFIG _ENDPOINT _MODE _NAME ] ,
default : EndpointMode . IPv4 ,
} ;
const getInstanceMetadataEndpoint = async ( ) => urlParser . parseUrl ( ( await getFromEndpointConfig ( ) ) || ( await getFromEndpointModeConfig ( ) ) ) ;
const getFromEndpointConfig = async ( ) => nodeConfigProvider . loadConfig ( ENDPOINT _CONFIG _OPTIONS ) ( ) ;
const getFromEndpointModeConfig = async ( ) => {
const endpointMode = await nodeConfigProvider . loadConfig ( ENDPOINT _MODE _CONFIG _OPTIONS ) ( ) ;
switch ( endpointMode ) {
case EndpointMode . IPv4 :
return exports . yI . IPv4 ;
case EndpointMode . IPv6 :
return exports . yI . IPv6 ;
default :
throw new Error ( ` Unsupported endpoint mode: ${ endpointMode } . ` + ` Select from ${ Object . values ( EndpointMode ) } ` ) ;
}
} ;
const STATIC _STABILITY _REFRESH _INTERVAL _SECONDS = 5 * 60 ;
const STATIC _STABILITY _REFRESH _INTERVAL _JITTER _WINDOW _SECONDS = 5 * 60 ;
const STATIC _STABILITY _DOC _URL = "https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html" ;
const getExtendedInstanceMetadataCredentials = ( credentials , logger ) => {
const refreshInterval = STATIC _STABILITY _REFRESH _INTERVAL _SECONDS +
Math . floor ( Math . random ( ) * STATIC _STABILITY _REFRESH _INTERVAL _JITTER _WINDOW _SECONDS ) ;
const newExpiration = new Date ( Date . now ( ) + refreshInterval * 1000 ) ;
logger . warn ( "Attempting credential expiration extension due to a credential service availability issue. A refresh of these " +
` credentials will be attempted after ${ new Date ( newExpiration ) } . \n For more information, please visit: ` +
STATIC _STABILITY _DOC _URL ) ;
const originalExpiration = credentials . originalExpiration ? ? credentials . expiration ;
return {
... credentials ,
... ( originalExpiration ? { originalExpiration } : { } ) ,
expiration : newExpiration ,
} ;
} ;
const staticStabilityProvider = ( provider , options = { } ) => {
const logger = options ? . logger || console ;
let pastCredentials ;
return async ( ) => {
let credentials ;
try {
credentials = await provider ( ) ;
if ( credentials . expiration && credentials . expiration . getTime ( ) < Date . now ( ) ) {
credentials = getExtendedInstanceMetadataCredentials ( credentials , logger ) ;
}
}
catch ( e ) {
if ( pastCredentials ) {
logger . warn ( "Credential renew failed: " , e ) ;
credentials = getExtendedInstanceMetadataCredentials ( pastCredentials , logger ) ;
}
else {
throw e ;
}
}
pastCredentials = credentials ;
return credentials ;
} ;
} ;
const IMDS _PATH = "/latest/meta-data/iam/security-credentials/" ;
const IMDS _TOKEN _PATH = "/latest/api/token" ;
const AWS _EC2 _METADATA _V1 _DISABLED = "AWS_EC2_METADATA_V1_DISABLED" ;
const PROFILE _AWS _EC2 _METADATA _V1 _DISABLED = "ec2_metadata_v1_disabled" ;
const X _AWS _EC2 _METADATA _TOKEN = "x-aws-ec2-metadata-token" ;
const fromInstanceMetadata = ( init = { } ) => staticStabilityProvider ( getInstanceMetadataProvider ( init ) , { logger : init . logger } ) ;
const getInstanceMetadataProvider = ( init = { } ) => {
let disableFetchToken = false ;
const { logger , profile } = init ;
const { timeout , maxRetries } = providerConfigFromInit ( init ) ;
const getCredentials = async ( maxRetries , options ) => {
const isImdsV1Fallback = disableFetchToken || options . headers ? . [ X _AWS _EC2 _METADATA _TOKEN ] == null ;
if ( isImdsV1Fallback ) {
let fallbackBlockedFromProfile = false ;
let fallbackBlockedFromProcessEnv = false ;
const configValue = await nodeConfigProvider . loadConfig ( {
environmentVariableSelector : ( env ) => {
const envValue = env [ AWS _EC2 _METADATA _V1 _DISABLED ] ;
fallbackBlockedFromProcessEnv = ! ! envValue && envValue !== "false" ;
if ( envValue === undefined ) {
throw new propertyProvider . CredentialsProviderError ( ` ${ AWS _EC2 _METADATA _V1 _DISABLED } not set in env, checking config file next. ` , { logger : init . logger } ) ;
}
return fallbackBlockedFromProcessEnv ;
} ,
configFileSelector : ( profile ) => {
const profileValue = profile [ PROFILE _AWS _EC2 _METADATA _V1 _DISABLED ] ;
fallbackBlockedFromProfile = ! ! profileValue && profileValue !== "false" ;
return fallbackBlockedFromProfile ;
} ,
default : false ,
} , {
profile ,
} ) ( ) ;
if ( init . ec2MetadataV1Disabled || configValue ) {
const causes = [ ] ;
if ( init . ec2MetadataV1Disabled )
causes . push ( "credential provider initialization (runtime option ec2MetadataV1Disabled)" ) ;
if ( fallbackBlockedFromProfile )
causes . push ( ` config file profile ( ${ PROFILE _AWS _EC2 _METADATA _V1 _DISABLED } ) ` ) ;
if ( fallbackBlockedFromProcessEnv )
causes . push ( ` process environment variable ( ${ AWS _EC2 _METADATA _V1 _DISABLED } ) ` ) ;
throw new InstanceMetadataV1FallbackError ( ` AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [ ${ causes . join ( ", " ) } ]. ` ) ;
}
}
const imdsProfile = ( await retry ( async ( ) => {
let profile ;
try {
profile = await getProfile ( options ) ;
}
catch ( err ) {
if ( err . statusCode === 401 ) {
disableFetchToken = false ;
}
throw err ;
}
return profile ;
} , maxRetries ) ) . trim ( ) ;
return retry ( async ( ) => {
let creds ;
try {
creds = await getCredentialsFromProfile ( imdsProfile , options , init ) ;
}
catch ( err ) {
if ( err . statusCode === 401 ) {
disableFetchToken = false ;
}
throw err ;
}
return creds ;
} , maxRetries ) ;
} ;
return async ( ) => {
const endpoint = await getInstanceMetadataEndpoint ( ) ;
if ( disableFetchToken ) {
logger ? . debug ( "AWS SDK Instance Metadata" , "using v1 fallback (no token fetch)" ) ;
return getCredentials ( maxRetries , { ... endpoint , timeout } ) ;
}
else {
let token ;
try {
token = ( await getMetadataToken ( { ... endpoint , timeout } ) ) . toString ( ) ;
}
catch ( error ) {
if ( error ? . statusCode === 400 ) {
throw Object . assign ( error , {
message : "EC2 Metadata token request returned error" ,
} ) ;
}
else if ( error . message === "TimeoutError" || [ 403 , 404 , 405 ] . includes ( error . statusCode ) ) {
disableFetchToken = true ;
}
logger ? . debug ( "AWS SDK Instance Metadata" , "using v1 fallback (initial)" ) ;
return getCredentials ( maxRetries , { ... endpoint , timeout } ) ;
}
return getCredentials ( maxRetries , {
... endpoint ,
headers : {
[ X _AWS _EC2 _METADATA _TOKEN ] : token ,
} ,
timeout ,
} ) ;
}
} ;
} ;
const getMetadataToken = async ( options ) => httpRequest ( {
... options ,
path : IMDS _TOKEN _PATH ,
method : "PUT" ,
headers : {
"x-aws-ec2-metadata-token-ttl-seconds" : "21600" ,
} ,
} ) ;
const getProfile = async ( options ) => ( await httpRequest ( { ... options , path : IMDS _PATH } ) ) . toString ( ) ;
const getCredentialsFromProfile = async ( profile , options , init ) => {
const credentialsResponse = JSON . parse ( ( await httpRequest ( {
... options ,
path : IMDS _PATH + profile ,
} ) ) . toString ( ) ) ;
if ( ! isImdsCredentials ( credentialsResponse ) ) {
throw new propertyProvider . CredentialsProviderError ( "Invalid response received from instance metadata service." , {
logger : init . logger ,
} ) ;
}
return fromImdsCredentials ( credentialsResponse ) ;
} ;
_ _webpack _unused _export _ _ = DEFAULT _MAX _RETRIES ;
_ _webpack _unused _export _ _ = DEFAULT _TIMEOUT ;
_ _webpack _unused _export _ _ = ENV _CMDS _AUTH _TOKEN ;
exports . ENV _CMDS _FULL _URI = ENV _CMDS _FULL _URI ;
exports . ENV _CMDS _RELATIVE _URI = ENV _CMDS _RELATIVE _URI ;
exports . fromContainerMetadata = fromContainerMetadata ;
exports . fromInstanceMetadata = fromInstanceMetadata ;
exports . getInstanceMetadataEndpoint = getInstanceMetadataEndpoint ;
exports . httpRequest = httpRequest ;
_ _webpack _unused _export _ _ = providerConfigFromInit ;
/***/ } )
} ;
2026-03-01 10:29:20 +00:00
2026-01-30 14:42:57 +00:00
//# sourceMappingURL=566.index.js.map