@artik0din/turbogha 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +322 -0
- package/dist/cli/136.index.js +903 -0
- package/dist/cli/136.index.js.map +1 -0
- package/dist/cli/360.index.js +93 -0
- package/dist/cli/360.index.js.map +1 -0
- package/dist/cli/443.index.js +795 -0
- package/dist/cli/443.index.js.map +1 -0
- package/dist/cli/566.index.js +387 -0
- package/dist/cli/566.index.js.map +1 -0
- package/dist/cli/579.index.js +265 -0
- package/dist/cli/579.index.js.map +1 -0
- package/dist/cli/605.index.js +234 -0
- package/dist/cli/605.index.js.map +1 -0
- package/dist/cli/762.index.js +673 -0
- package/dist/cli/762.index.js.map +1 -0
- package/dist/cli/869.index.js +533 -0
- package/dist/cli/869.index.js.map +1 -0
- package/dist/cli/884.index.js +701 -0
- package/dist/cli/884.index.js.map +1 -0
- package/dist/cli/956.index.js +1039 -0
- package/dist/cli/956.index.js.map +1 -0
- package/dist/cli/998.index.js +1455 -0
- package/dist/cli/998.index.js.map +1 -0
- package/dist/cli/file.js +12 -0
- package/dist/cli/index.js +208250 -0
- package/dist/cli/licenses.txt +1645 -0
- package/dist/cli/package.json +3 -0
- package/dist/cli/sourcemap-register.cjs +1 -0
- package/dist/cli/worker.js +174 -0
- package/dist/cli/worker1.js +170 -0
- package/package.json +102 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"443.index.js","mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACvDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACjBA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;AChjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/auth/httpAuthSchemeProvider.js",".././node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/endpoint/endpointResolver.js",".././node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/endpoint/ruleset.js",".././node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js",".././node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/runtimeConfig.js",".././node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/runtimeConfig.shared.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.resolveHttpAuthSchemeConfig = exports.defaultSSOOIDCHttpAuthSchemeProvider = exports.defaultSSOOIDCHttpAuthSchemeParametersProvider = void 0;\nconst core_1 = require(\"@aws-sdk/core\");\nconst util_middleware_1 = require(\"@smithy/util-middleware\");\nconst defaultSSOOIDCHttpAuthSchemeParametersProvider = async (config, context, input) => {\n return {\n operation: (0, util_middleware_1.getSmithyContext)(context).operation,\n region: (await (0, util_middleware_1.normalizeProvider)(config.region)()) ||\n (() => {\n throw new Error(\"expected `region` to be configured for `aws.auth#sigv4`\");\n })(),\n };\n};\nexports.defaultSSOOIDCHttpAuthSchemeParametersProvider = defaultSSOOIDCHttpAuthSchemeParametersProvider;\nfunction createAwsAuthSigv4HttpAuthOption(authParameters) {\n return {\n schemeId: \"aws.auth#sigv4\",\n signingProperties: {\n name: \"sso-oauth\",\n region: authParameters.region,\n },\n propertiesExtractor: (config, context) => ({\n signingProperties: {\n config,\n context,\n },\n }),\n };\n}\nfunction createSmithyApiNoAuthHttpAuthOption(authParameters) {\n return {\n schemeId: \"smithy.api#noAuth\",\n };\n}\nconst defaultSSOOIDCHttpAuthSchemeProvider = (authParameters) => {\n const options = [];\n switch (authParameters.operation) {\n case \"CreateToken\": {\n options.push(createSmithyApiNoAuthHttpAuthOption(authParameters));\n break;\n }\n default: {\n options.push(createAwsAuthSigv4HttpAuthOption(authParameters));\n }\n }\n return options;\n};\nexports.defaultSSOOIDCHttpAuthSchemeProvider = defaultSSOOIDCHttpAuthSchemeProvider;\nconst resolveHttpAuthSchemeConfig = (config) => {\n const config_0 = (0, core_1.resolveAwsSdkSigV4Config)(config);\n return Object.assign(config_0, {\n authSchemePreference: (0, util_middleware_1.normalizeProvider)(config.authSchemePreference ?? []),\n });\n};\nexports.resolveHttpAuthSchemeConfig = resolveHttpAuthSchemeConfig;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.defaultEndpointResolver = void 0;\nconst util_endpoints_1 = require(\"@aws-sdk/util-endpoints\");\nconst util_endpoints_2 = require(\"@smithy/util-endpoints\");\nconst ruleset_1 = require(\"./ruleset\");\nconst cache = new util_endpoints_2.EndpointCache({\n size: 50,\n params: [\"Endpoint\", \"Region\", \"UseDualStack\", \"UseFIPS\"],\n});\nconst defaultEndpointResolver = (endpointParams, context = {}) => {\n return cache.get(endpointParams, () => (0, util_endpoints_2.resolveEndpoint)(ruleset_1.ruleSet, {\n endpointParams: endpointParams,\n logger: context.logger,\n }));\n};\nexports.defaultEndpointResolver = defaultEndpointResolver;\nutil_endpoints_2.customEndpointFunctions.aws = util_endpoints_1.awsEndpointFunctions;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.ruleSet = void 0;\nconst u = \"required\", v = \"fn\", w = \"argv\", x = \"ref\";\nconst a = true, b = \"isSet\", c = \"booleanEquals\", d = \"error\", e = \"endpoint\", f = \"tree\", g = \"PartitionResult\", h = \"getAttr\", i = { [u]: false, \"type\": \"string\" }, j = { [u]: true, \"default\": false, \"type\": \"boolean\" }, k = { [x]: \"Endpoint\" }, l = { [v]: c, [w]: [{ [x]: \"UseFIPS\" }, true] }, m = { [v]: c, [w]: [{ [x]: \"UseDualStack\" }, true] }, n = {}, o = { [v]: h, [w]: [{ [x]: g }, \"supportsFIPS\"] }, p = { [x]: g }, q = { [v]: c, [w]: [true, { [v]: h, [w]: [p, \"supportsDualStack\"] }] }, r = [l], s = [m], t = [{ [x]: \"Region\" }];\nconst _data = { version: \"1.0\", parameters: { Region: i, UseDualStack: j, UseFIPS: j, Endpoint: i }, rules: [{ conditions: [{ [v]: b, [w]: [k] }], rules: [{ conditions: r, error: \"Invalid Configuration: FIPS and custom endpoint are not supported\", type: d }, { conditions: s, error: \"Invalid Configuration: Dualstack and custom endpoint are not supported\", type: d }, { endpoint: { url: k, properties: n, headers: n }, type: e }], type: f }, { conditions: [{ [v]: b, [w]: t }], rules: [{ conditions: [{ [v]: \"aws.partition\", [w]: t, assign: g }], rules: [{ conditions: [l, m], rules: [{ conditions: [{ [v]: c, [w]: [a, o] }, q], rules: [{ endpoint: { url: \"https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}\", properties: n, headers: n }, type: e }], type: f }, { error: \"FIPS and DualStack are enabled, but this partition does not support one or both\", type: d }], type: f }, { conditions: r, rules: [{ conditions: [{ [v]: c, [w]: [o, a] }], rules: [{ conditions: [{ [v]: \"stringEquals\", [w]: [{ [v]: h, [w]: [p, \"name\"] }, \"aws-us-gov\"] }], endpoint: { url: \"https://oidc.{Region}.amazonaws.com\", properties: n, headers: n }, type: e }, { endpoint: { url: \"https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}\", properties: n, headers: n }, type: e }], type: f }, { error: \"FIPS is enabled but this partition does not support FIPS\", type: d }], type: f }, { conditions: s, rules: [{ conditions: [q], rules: [{ endpoint: { url: \"https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}\", properties: n, headers: n }, type: e }], type: f }, { error: \"DualStack is enabled but this partition does not support DualStack\", type: d }], type: f }, { endpoint: { url: \"https://oidc.{Region}.{PartitionResult#dnsSuffix}\", properties: n, headers: n }, type: e }], type: f }], type: f }, { error: \"Invalid Configuration: Missing Region\", type: d }] };\nexports.ruleSet = _data;\n","'use strict';\n\nvar middlewareHostHeader = require('@aws-sdk/middleware-host-header');\nvar middlewareLogger = require('@aws-sdk/middleware-logger');\nvar middlewareRecursionDetection = require('@aws-sdk/middleware-recursion-detection');\nvar middlewareUserAgent = require('@aws-sdk/middleware-user-agent');\nvar configResolver = require('@smithy/config-resolver');\nvar core = require('@smithy/core');\nvar schema = require('@smithy/core/schema');\nvar middlewareContentLength = require('@smithy/middleware-content-length');\nvar middlewareEndpoint = require('@smithy/middleware-endpoint');\nvar middlewareRetry = require('@smithy/middleware-retry');\nvar smithyClient = require('@smithy/smithy-client');\nvar httpAuthSchemeProvider = require('./auth/httpAuthSchemeProvider');\nvar runtimeConfig = require('./runtimeConfig');\nvar regionConfigResolver = require('@aws-sdk/region-config-resolver');\nvar protocolHttp = require('@smithy/protocol-http');\n\nconst resolveClientEndpointParameters = (options) => {\n return Object.assign(options, {\n useDualstackEndpoint: options.useDualstackEndpoint ?? false,\n useFipsEndpoint: options.useFipsEndpoint ?? false,\n defaultSigningName: \"sso-oauth\",\n });\n};\nconst commonParams = {\n UseFIPS: { type: \"builtInParams\", name: \"useFipsEndpoint\" },\n Endpoint: { type: \"builtInParams\", name: \"endpoint\" },\n Region: { type: \"builtInParams\", name: \"region\" },\n UseDualStack: { type: \"builtInParams\", name: \"useDualstackEndpoint\" },\n};\n\nconst getHttpAuthExtensionConfiguration = (runtimeConfig) => {\n const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;\n let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;\n let _credentials = runtimeConfig.credentials;\n return {\n setHttpAuthScheme(httpAuthScheme) {\n const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);\n if (index === -1) {\n _httpAuthSchemes.push(httpAuthScheme);\n }\n else {\n _httpAuthSchemes.splice(index, 1, httpAuthScheme);\n }\n },\n httpAuthSchemes() {\n return _httpAuthSchemes;\n },\n setHttpAuthSchemeProvider(httpAuthSchemeProvider) {\n _httpAuthSchemeProvider = httpAuthSchemeProvider;\n },\n httpAuthSchemeProvider() {\n return _httpAuthSchemeProvider;\n },\n setCredentials(credentials) {\n _credentials = credentials;\n },\n credentials() {\n return _credentials;\n },\n };\n};\nconst resolveHttpAuthRuntimeConfig = (config) => {\n return {\n httpAuthSchemes: config.httpAuthSchemes(),\n httpAuthSchemeProvider: config.httpAuthSchemeProvider(),\n credentials: config.credentials(),\n };\n};\n\nconst resolveRuntimeExtensions = (runtimeConfig, extensions) => {\n const extensionConfiguration = Object.assign(regionConfigResolver.getAwsRegionExtensionConfiguration(runtimeConfig), smithyClient.getDefaultExtensionConfiguration(runtimeConfig), protocolHttp.getHttpHandlerExtensionConfiguration(runtimeConfig), getHttpAuthExtensionConfiguration(runtimeConfig));\n extensions.forEach((extension) => extension.configure(extensionConfiguration));\n return Object.assign(runtimeConfig, regionConfigResolver.resolveAwsRegionExtensionConfiguration(extensionConfiguration), smithyClient.resolveDefaultRuntimeConfig(extensionConfiguration), protocolHttp.resolveHttpHandlerRuntimeConfig(extensionConfiguration), resolveHttpAuthRuntimeConfig(extensionConfiguration));\n};\n\nclass SSOOIDCClient extends smithyClient.Client {\n config;\n constructor(...[configuration]) {\n const _config_0 = runtimeConfig.getRuntimeConfig(configuration || {});\n super(_config_0);\n this.initConfig = _config_0;\n const _config_1 = resolveClientEndpointParameters(_config_0);\n const _config_2 = middlewareUserAgent.resolveUserAgentConfig(_config_1);\n const _config_3 = middlewareRetry.resolveRetryConfig(_config_2);\n const _config_4 = configResolver.resolveRegionConfig(_config_3);\n const _config_5 = middlewareHostHeader.resolveHostHeaderConfig(_config_4);\n const _config_6 = middlewareEndpoint.resolveEndpointConfig(_config_5);\n const _config_7 = httpAuthSchemeProvider.resolveHttpAuthSchemeConfig(_config_6);\n const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);\n this.config = _config_8;\n this.middlewareStack.use(schema.getSchemaSerdePlugin(this.config));\n this.middlewareStack.use(middlewareUserAgent.getUserAgentPlugin(this.config));\n this.middlewareStack.use(middlewareRetry.getRetryPlugin(this.config));\n this.middlewareStack.use(middlewareContentLength.getContentLengthPlugin(this.config));\n this.middlewareStack.use(middlewareHostHeader.getHostHeaderPlugin(this.config));\n this.middlewareStack.use(middlewareLogger.getLoggerPlugin(this.config));\n this.middlewareStack.use(middlewareRecursionDetection.getRecursionDetectionPlugin(this.config));\n this.middlewareStack.use(core.getHttpAuthSchemeEndpointRuleSetPlugin(this.config, {\n httpAuthSchemeParametersProvider: httpAuthSchemeProvider.defaultSSOOIDCHttpAuthSchemeParametersProvider,\n identityProviderConfigProvider: async (config) => new core.DefaultIdentityProviderConfig({\n \"aws.auth#sigv4\": config.credentials,\n }),\n }));\n this.middlewareStack.use(core.getHttpSigningPlugin(this.config));\n }\n destroy() {\n super.destroy();\n }\n}\n\nlet SSOOIDCServiceException$1 = class SSOOIDCServiceException extends smithyClient.ServiceException {\n constructor(options) {\n super(options);\n Object.setPrototypeOf(this, SSOOIDCServiceException.prototype);\n }\n};\n\nlet AccessDeniedException$1 = class AccessDeniedException extends SSOOIDCServiceException$1 {\n name = \"AccessDeniedException\";\n $fault = \"client\";\n error;\n reason;\n error_description;\n constructor(opts) {\n super({\n name: \"AccessDeniedException\",\n $fault: \"client\",\n ...opts,\n });\n Object.setPrototypeOf(this, AccessDeniedException.prototype);\n this.error = opts.error;\n this.reason = opts.reason;\n this.error_description = opts.error_description;\n }\n};\nlet AuthorizationPendingException$1 = class AuthorizationPendingException extends SSOOIDCServiceException$1 {\n name = \"AuthorizationPendingException\";\n $fault = \"client\";\n error;\n error_description;\n constructor(opts) {\n super({\n name: \"AuthorizationPendingException\",\n $fault: \"client\",\n ...opts,\n });\n Object.setPrototypeOf(this, AuthorizationPendingException.prototype);\n this.error = opts.error;\n this.error_description = opts.error_description;\n }\n};\nlet ExpiredTokenException$1 = class ExpiredTokenException extends SSOOIDCServiceException$1 {\n name = \"ExpiredTokenException\";\n $fault = \"client\";\n error;\n error_description;\n constructor(opts) {\n super({\n name: \"ExpiredTokenException\",\n $fault: \"client\",\n ...opts,\n });\n Object.setPrototypeOf(this, ExpiredTokenException.prototype);\n this.error = opts.error;\n this.error_description = opts.error_description;\n }\n};\nlet InternalServerException$1 = class InternalServerException extends SSOOIDCServiceException$1 {\n name = \"InternalServerException\";\n $fault = \"server\";\n error;\n error_description;\n constructor(opts) {\n super({\n name: \"InternalServerException\",\n $fault: \"server\",\n ...opts,\n });\n Object.setPrototypeOf(this, InternalServerException.prototype);\n this.error = opts.error;\n this.error_description = opts.error_description;\n }\n};\nlet InvalidClientException$1 = class InvalidClientException extends SSOOIDCServiceException$1 {\n name = \"InvalidClientException\";\n $fault = \"client\";\n error;\n error_description;\n constructor(opts) {\n super({\n name: \"InvalidClientException\",\n $fault: \"client\",\n ...opts,\n });\n Object.setPrototypeOf(this, InvalidClientException.prototype);\n this.error = opts.error;\n this.error_description = opts.error_description;\n }\n};\nlet InvalidGrantException$1 = class InvalidGrantException extends SSOOIDCServiceException$1 {\n name = \"InvalidGrantException\";\n $fault = \"client\";\n error;\n error_description;\n constructor(opts) {\n super({\n name: \"InvalidGrantException\",\n $fault: \"client\",\n ...opts,\n });\n Object.setPrototypeOf(this, InvalidGrantException.prototype);\n this.error = opts.error;\n this.error_description = opts.error_description;\n }\n};\nlet InvalidRequestException$1 = class InvalidRequestException extends SSOOIDCServiceException$1 {\n name = \"InvalidRequestException\";\n $fault = \"client\";\n error;\n reason;\n error_description;\n constructor(opts) {\n super({\n name: \"InvalidRequestException\",\n $fault: \"client\",\n ...opts,\n });\n Object.setPrototypeOf(this, InvalidRequestException.prototype);\n this.error = opts.error;\n this.reason = opts.reason;\n this.error_description = opts.error_description;\n }\n};\nlet InvalidScopeException$1 = class InvalidScopeException extends SSOOIDCServiceException$1 {\n name = \"InvalidScopeException\";\n $fault = \"client\";\n error;\n error_description;\n constructor(opts) {\n super({\n name: \"InvalidScopeException\",\n $fault: \"client\",\n ...opts,\n });\n Object.setPrototypeOf(this, InvalidScopeException.prototype);\n this.error = opts.error;\n this.error_description = opts.error_description;\n }\n};\nlet SlowDownException$1 = class SlowDownException extends SSOOIDCServiceException$1 {\n name = \"SlowDownException\";\n $fault = \"client\";\n error;\n error_description;\n constructor(opts) {\n super({\n name: \"SlowDownException\",\n $fault: \"client\",\n ...opts,\n });\n Object.setPrototypeOf(this, SlowDownException.prototype);\n this.error = opts.error;\n this.error_description = opts.error_description;\n }\n};\nlet UnauthorizedClientException$1 = class UnauthorizedClientException extends SSOOIDCServiceException$1 {\n name = \"UnauthorizedClientException\";\n $fault = \"client\";\n error;\n error_description;\n constructor(opts) {\n super({\n name: \"UnauthorizedClientException\",\n $fault: \"client\",\n ...opts,\n });\n Object.setPrototypeOf(this, UnauthorizedClientException.prototype);\n this.error = opts.error;\n this.error_description = opts.error_description;\n }\n};\nlet UnsupportedGrantTypeException$1 = class UnsupportedGrantTypeException extends SSOOIDCServiceException$1 {\n name = \"UnsupportedGrantTypeException\";\n $fault = \"client\";\n error;\n error_description;\n constructor(opts) {\n super({\n name: \"UnsupportedGrantTypeException\",\n $fault: \"client\",\n ...opts,\n });\n Object.setPrototypeOf(this, UnsupportedGrantTypeException.prototype);\n this.error = opts.error;\n this.error_description = opts.error_description;\n }\n};\n\nconst _ADE = \"AccessDeniedException\";\nconst _APE = \"AuthorizationPendingException\";\nconst _AT = \"AccessToken\";\nconst _CS = \"ClientSecret\";\nconst _CT = \"CreateToken\";\nconst _CTR = \"CreateTokenRequest\";\nconst _CTRr = \"CreateTokenResponse\";\nconst _CV = \"CodeVerifier\";\nconst _ETE = \"ExpiredTokenException\";\nconst _ICE = \"InvalidClientException\";\nconst _IGE = \"InvalidGrantException\";\nconst _IRE = \"InvalidRequestException\";\nconst _ISE = \"InternalServerException\";\nconst _ISEn = \"InvalidScopeException\";\nconst _IT = \"IdToken\";\nconst _RT = \"RefreshToken\";\nconst _SDE = \"SlowDownException\";\nconst _UCE = \"UnauthorizedClientException\";\nconst _UGTE = \"UnsupportedGrantTypeException\";\nconst _aT = \"accessToken\";\nconst _c = \"client\";\nconst _cI = \"clientId\";\nconst _cS = \"clientSecret\";\nconst _cV = \"codeVerifier\";\nconst _co = \"code\";\nconst _dC = \"deviceCode\";\nconst _e = \"error\";\nconst _eI = \"expiresIn\";\nconst _ed = \"error_description\";\nconst _gT = \"grantType\";\nconst _h = \"http\";\nconst _hE = \"httpError\";\nconst _iT = \"idToken\";\nconst _r = \"reason\";\nconst _rT = \"refreshToken\";\nconst _rU = \"redirectUri\";\nconst _s = \"scope\";\nconst _se = \"server\";\nconst _sm = \"smithy.ts.sdk.synthetic.com.amazonaws.ssooidc\";\nconst _tT = \"tokenType\";\nconst n0 = \"com.amazonaws.ssooidc\";\nvar AccessToken = [0, n0, _AT, 8, 0];\nvar ClientSecret = [0, n0, _CS, 8, 0];\nvar CodeVerifier = [0, n0, _CV, 8, 0];\nvar IdToken = [0, n0, _IT, 8, 0];\nvar RefreshToken = [0, n0, _RT, 8, 0];\nvar AccessDeniedException = [\n -3,\n n0,\n _ADE,\n {\n [_e]: _c,\n [_hE]: 400,\n },\n [_e, _r, _ed],\n [0, 0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(AccessDeniedException, AccessDeniedException$1);\nvar AuthorizationPendingException = [\n -3,\n n0,\n _APE,\n {\n [_e]: _c,\n [_hE]: 400,\n },\n [_e, _ed],\n [0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(AuthorizationPendingException, AuthorizationPendingException$1);\nvar CreateTokenRequest = [\n 3,\n n0,\n _CTR,\n 0,\n [_cI, _cS, _gT, _dC, _co, _rT, _s, _rU, _cV],\n [0, [() => ClientSecret, 0], 0, 0, 0, [() => RefreshToken, 0], 64 | 0, 0, [() => CodeVerifier, 0]],\n];\nvar CreateTokenResponse = [\n 3,\n n0,\n _CTRr,\n 0,\n [_aT, _tT, _eI, _rT, _iT],\n [[() => AccessToken, 0], 0, 1, [() => RefreshToken, 0], [() => IdToken, 0]],\n];\nvar ExpiredTokenException = [\n -3,\n n0,\n _ETE,\n {\n [_e]: _c,\n [_hE]: 400,\n },\n [_e, _ed],\n [0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(ExpiredTokenException, ExpiredTokenException$1);\nvar InternalServerException = [\n -3,\n n0,\n _ISE,\n {\n [_e]: _se,\n [_hE]: 500,\n },\n [_e, _ed],\n [0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(InternalServerException, InternalServerException$1);\nvar InvalidClientException = [\n -3,\n n0,\n _ICE,\n {\n [_e]: _c,\n [_hE]: 401,\n },\n [_e, _ed],\n [0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(InvalidClientException, InvalidClientException$1);\nvar InvalidGrantException = [\n -3,\n n0,\n _IGE,\n {\n [_e]: _c,\n [_hE]: 400,\n },\n [_e, _ed],\n [0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(InvalidGrantException, InvalidGrantException$1);\nvar InvalidRequestException = [\n -3,\n n0,\n _IRE,\n {\n [_e]: _c,\n [_hE]: 400,\n },\n [_e, _r, _ed],\n [0, 0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(InvalidRequestException, InvalidRequestException$1);\nvar InvalidScopeException = [\n -3,\n n0,\n _ISEn,\n {\n [_e]: _c,\n [_hE]: 400,\n },\n [_e, _ed],\n [0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(InvalidScopeException, InvalidScopeException$1);\nvar SlowDownException = [\n -3,\n n0,\n _SDE,\n {\n [_e]: _c,\n [_hE]: 400,\n },\n [_e, _ed],\n [0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(SlowDownException, SlowDownException$1);\nvar UnauthorizedClientException = [\n -3,\n n0,\n _UCE,\n {\n [_e]: _c,\n [_hE]: 400,\n },\n [_e, _ed],\n [0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(UnauthorizedClientException, UnauthorizedClientException$1);\nvar UnsupportedGrantTypeException = [\n -3,\n n0,\n _UGTE,\n {\n [_e]: _c,\n [_hE]: 400,\n },\n [_e, _ed],\n [0, 0],\n];\nschema.TypeRegistry.for(n0).registerError(UnsupportedGrantTypeException, UnsupportedGrantTypeException$1);\nvar SSOOIDCServiceException = [-3, _sm, \"SSOOIDCServiceException\", 0, [], []];\nschema.TypeRegistry.for(_sm).registerError(SSOOIDCServiceException, SSOOIDCServiceException$1);\nvar CreateToken = [\n 9,\n n0,\n _CT,\n {\n [_h]: [\"POST\", \"/token\", 200],\n },\n () => CreateTokenRequest,\n () => CreateTokenResponse,\n];\n\nclass CreateTokenCommand extends smithyClient.Command\n .classBuilder()\n .ep(commonParams)\n .m(function (Command, cs, config, o) {\n return [middlewareEndpoint.getEndpointPlugin(config, Command.getEndpointParameterInstructions())];\n})\n .s(\"AWSSSOOIDCService\", \"CreateToken\", {})\n .n(\"SSOOIDCClient\", \"CreateTokenCommand\")\n .sc(CreateToken)\n .build() {\n}\n\nconst commands = {\n CreateTokenCommand,\n};\nclass SSOOIDC extends SSOOIDCClient {\n}\nsmithyClient.createAggregatedClient(commands, SSOOIDC);\n\nconst AccessDeniedExceptionReason = {\n KMS_ACCESS_DENIED: \"KMS_AccessDeniedException\",\n};\nconst InvalidRequestExceptionReason = {\n KMS_DISABLED_KEY: \"KMS_DisabledException\",\n KMS_INVALID_KEY_USAGE: \"KMS_InvalidKeyUsageException\",\n KMS_INVALID_STATE: \"KMS_InvalidStateException\",\n KMS_KEY_NOT_FOUND: \"KMS_NotFoundException\",\n};\n\nObject.defineProperty(exports, \"$Command\", {\n enumerable: true,\n get: function () { return smithyClient.Command; }\n});\nObject.defineProperty(exports, \"__Client\", {\n enumerable: true,\n get: function () { return smithyClient.Client; }\n});\nexports.AccessDeniedException = AccessDeniedException$1;\nexports.AccessDeniedExceptionReason = AccessDeniedExceptionReason;\nexports.AuthorizationPendingException = AuthorizationPendingException$1;\nexports.CreateTokenCommand = CreateTokenCommand;\nexports.ExpiredTokenException = ExpiredTokenException$1;\nexports.InternalServerException = InternalServerException$1;\nexports.InvalidClientException = InvalidClientException$1;\nexports.InvalidGrantException = InvalidGrantException$1;\nexports.InvalidRequestException = InvalidRequestException$1;\nexports.InvalidRequestExceptionReason = InvalidRequestExceptionReason;\nexports.InvalidScopeException = InvalidScopeException$1;\nexports.SSOOIDC = SSOOIDC;\nexports.SSOOIDCClient = SSOOIDCClient;\nexports.SSOOIDCServiceException = SSOOIDCServiceException$1;\nexports.SlowDownException = SlowDownException$1;\nexports.UnauthorizedClientException = UnauthorizedClientException$1;\nexports.UnsupportedGrantTypeException = UnsupportedGrantTypeException$1;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getRuntimeConfig = void 0;\nconst tslib_1 = require(\"tslib\");\nconst package_json_1 = tslib_1.__importDefault(require(\"../../../package.json\"));\nconst core_1 = require(\"@aws-sdk/core\");\nconst util_user_agent_node_1 = require(\"@aws-sdk/util-user-agent-node\");\nconst config_resolver_1 = require(\"@smithy/config-resolver\");\nconst hash_node_1 = require(\"@smithy/hash-node\");\nconst middleware_retry_1 = require(\"@smithy/middleware-retry\");\nconst node_config_provider_1 = require(\"@smithy/node-config-provider\");\nconst node_http_handler_1 = require(\"@smithy/node-http-handler\");\nconst util_body_length_node_1 = require(\"@smithy/util-body-length-node\");\nconst util_retry_1 = require(\"@smithy/util-retry\");\nconst runtimeConfig_shared_1 = require(\"./runtimeConfig.shared\");\nconst smithy_client_1 = require(\"@smithy/smithy-client\");\nconst util_defaults_mode_node_1 = require(\"@smithy/util-defaults-mode-node\");\nconst smithy_client_2 = require(\"@smithy/smithy-client\");\nconst getRuntimeConfig = (config) => {\n (0, smithy_client_2.emitWarningIfUnsupportedVersion)(process.version);\n const defaultsMode = (0, util_defaults_mode_node_1.resolveDefaultsModeConfig)(config);\n const defaultConfigProvider = () => defaultsMode().then(smithy_client_1.loadConfigsForDefaultMode);\n const clientSharedValues = (0, runtimeConfig_shared_1.getRuntimeConfig)(config);\n (0, core_1.emitWarningIfUnsupportedVersion)(process.version);\n const loaderConfig = {\n profile: config?.profile,\n logger: clientSharedValues.logger,\n };\n return {\n ...clientSharedValues,\n ...config,\n runtime: \"node\",\n defaultsMode,\n authSchemePreference: config?.authSchemePreference ?? (0, node_config_provider_1.loadConfig)(core_1.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS, loaderConfig),\n bodyLengthChecker: config?.bodyLengthChecker ?? util_body_length_node_1.calculateBodyLength,\n defaultUserAgentProvider: config?.defaultUserAgentProvider ??\n (0, util_user_agent_node_1.createDefaultUserAgentProvider)({ serviceId: clientSharedValues.serviceId, clientVersion: package_json_1.default.version }),\n maxAttempts: config?.maxAttempts ?? (0, node_config_provider_1.loadConfig)(middleware_retry_1.NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),\n region: config?.region ??\n (0, node_config_provider_1.loadConfig)(config_resolver_1.NODE_REGION_CONFIG_OPTIONS, { ...config_resolver_1.NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),\n requestHandler: node_http_handler_1.NodeHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),\n retryMode: config?.retryMode ??\n (0, node_config_provider_1.loadConfig)({\n ...middleware_retry_1.NODE_RETRY_MODE_CONFIG_OPTIONS,\n default: async () => (await defaultConfigProvider()).retryMode || util_retry_1.DEFAULT_RETRY_MODE,\n }, config),\n sha256: config?.sha256 ?? hash_node_1.Hash.bind(null, \"sha256\"),\n streamCollector: config?.streamCollector ?? node_http_handler_1.streamCollector,\n useDualstackEndpoint: config?.useDualstackEndpoint ?? (0, node_config_provider_1.loadConfig)(config_resolver_1.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS, loaderConfig),\n useFipsEndpoint: config?.useFipsEndpoint ?? (0, node_config_provider_1.loadConfig)(config_resolver_1.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS, loaderConfig),\n userAgentAppId: config?.userAgentAppId ?? (0, node_config_provider_1.loadConfig)(util_user_agent_node_1.NODE_APP_ID_CONFIG_OPTIONS, loaderConfig),\n };\n};\nexports.getRuntimeConfig = getRuntimeConfig;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getRuntimeConfig = void 0;\nconst core_1 = require(\"@aws-sdk/core\");\nconst protocols_1 = require(\"@aws-sdk/core/protocols\");\nconst core_2 = require(\"@smithy/core\");\nconst smithy_client_1 = require(\"@smithy/smithy-client\");\nconst url_parser_1 = require(\"@smithy/url-parser\");\nconst util_base64_1 = require(\"@smithy/util-base64\");\nconst util_utf8_1 = require(\"@smithy/util-utf8\");\nconst httpAuthSchemeProvider_1 = require(\"./auth/httpAuthSchemeProvider\");\nconst endpointResolver_1 = require(\"./endpoint/endpointResolver\");\nconst getRuntimeConfig = (config) => {\n return {\n apiVersion: \"2019-06-10\",\n base64Decoder: config?.base64Decoder ?? util_base64_1.fromBase64,\n base64Encoder: config?.base64Encoder ?? util_base64_1.toBase64,\n disableHostPrefix: config?.disableHostPrefix ?? false,\n endpointProvider: config?.endpointProvider ?? endpointResolver_1.defaultEndpointResolver,\n extensions: config?.extensions ?? [],\n httpAuthSchemeProvider: config?.httpAuthSchemeProvider ?? httpAuthSchemeProvider_1.defaultSSOOIDCHttpAuthSchemeProvider,\n httpAuthSchemes: config?.httpAuthSchemes ?? [\n {\n schemeId: \"aws.auth#sigv4\",\n identityProvider: (ipc) => ipc.getIdentityProvider(\"aws.auth#sigv4\"),\n signer: new core_1.AwsSdkSigV4Signer(),\n },\n {\n schemeId: \"smithy.api#noAuth\",\n identityProvider: (ipc) => ipc.getIdentityProvider(\"smithy.api#noAuth\") || (async () => ({})),\n signer: new core_2.NoAuthSigner(),\n },\n ],\n logger: config?.logger ?? new smithy_client_1.NoOpLogger(),\n protocol: config?.protocol ?? new protocols_1.AwsRestJsonProtocol({ defaultNamespace: \"com.amazonaws.ssooidc\" }),\n serviceId: config?.serviceId ?? \"SSO OIDC\",\n urlParser: config?.urlParser ?? url_parser_1.parseUrl,\n utf8Decoder: config?.utf8Decoder ?? util_utf8_1.fromUtf8,\n utf8Encoder: config?.utf8Encoder ?? util_utf8_1.toUtf8,\n };\n};\nexports.getRuntimeConfig = getRuntimeConfig;\n"],"names":[],"sourceRoot":""}
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
export const id = 566;
|
|
2
|
+
export const ids = [566];
|
|
3
|
+
export const modules = {
|
|
4
|
+
|
|
5
|
+
/***/ 40566:
|
|
6
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7
|
+
|
|
8
|
+
var __webpack_unused_export__;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var propertyProvider = __webpack_require__(71238);
|
|
12
|
+
var url = __webpack_require__(87016);
|
|
13
|
+
var buffer = __webpack_require__(20181);
|
|
14
|
+
var http = __webpack_require__(58611);
|
|
15
|
+
var nodeConfigProvider = __webpack_require__(55704);
|
|
16
|
+
var urlParser = __webpack_require__(14494);
|
|
17
|
+
|
|
18
|
+
function httpRequest(options) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const req = http.request({
|
|
21
|
+
method: "GET",
|
|
22
|
+
...options,
|
|
23
|
+
hostname: options.hostname?.replace(/^\[(.+)\]$/, "$1"),
|
|
24
|
+
});
|
|
25
|
+
req.on("error", (err) => {
|
|
26
|
+
reject(Object.assign(new propertyProvider.ProviderError("Unable to connect to instance metadata service"), err));
|
|
27
|
+
req.destroy();
|
|
28
|
+
});
|
|
29
|
+
req.on("timeout", () => {
|
|
30
|
+
reject(new propertyProvider.ProviderError("TimeoutError from instance metadata service"));
|
|
31
|
+
req.destroy();
|
|
32
|
+
});
|
|
33
|
+
req.on("response", (res) => {
|
|
34
|
+
const { statusCode = 400 } = res;
|
|
35
|
+
if (statusCode < 200 || 300 <= statusCode) {
|
|
36
|
+
reject(Object.assign(new propertyProvider.ProviderError("Error response received from instance metadata service"), { statusCode }));
|
|
37
|
+
req.destroy();
|
|
38
|
+
}
|
|
39
|
+
const chunks = [];
|
|
40
|
+
res.on("data", (chunk) => {
|
|
41
|
+
chunks.push(chunk);
|
|
42
|
+
});
|
|
43
|
+
res.on("end", () => {
|
|
44
|
+
resolve(buffer.Buffer.concat(chunks));
|
|
45
|
+
req.destroy();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
req.end();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const isImdsCredentials = (arg) => Boolean(arg) &&
|
|
53
|
+
typeof arg === "object" &&
|
|
54
|
+
typeof arg.AccessKeyId === "string" &&
|
|
55
|
+
typeof arg.SecretAccessKey === "string" &&
|
|
56
|
+
typeof arg.Token === "string" &&
|
|
57
|
+
typeof arg.Expiration === "string";
|
|
58
|
+
const fromImdsCredentials = (creds) => ({
|
|
59
|
+
accessKeyId: creds.AccessKeyId,
|
|
60
|
+
secretAccessKey: creds.SecretAccessKey,
|
|
61
|
+
sessionToken: creds.Token,
|
|
62
|
+
expiration: new Date(creds.Expiration),
|
|
63
|
+
...(creds.AccountId && { accountId: creds.AccountId }),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const DEFAULT_TIMEOUT = 1000;
|
|
67
|
+
const DEFAULT_MAX_RETRIES = 0;
|
|
68
|
+
const providerConfigFromInit = ({ maxRetries = DEFAULT_MAX_RETRIES, timeout = DEFAULT_TIMEOUT, }) => ({ maxRetries, timeout });
|
|
69
|
+
|
|
70
|
+
const retry = (toRetry, maxRetries) => {
|
|
71
|
+
let promise = toRetry();
|
|
72
|
+
for (let i = 0; i < maxRetries; i++) {
|
|
73
|
+
promise = promise.catch(toRetry);
|
|
74
|
+
}
|
|
75
|
+
return promise;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const ENV_CMDS_FULL_URI = "AWS_CONTAINER_CREDENTIALS_FULL_URI";
|
|
79
|
+
const ENV_CMDS_RELATIVE_URI = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
|
80
|
+
const ENV_CMDS_AUTH_TOKEN = "AWS_CONTAINER_AUTHORIZATION_TOKEN";
|
|
81
|
+
const fromContainerMetadata = (init = {}) => {
|
|
82
|
+
const { timeout, maxRetries } = providerConfigFromInit(init);
|
|
83
|
+
return () => retry(async () => {
|
|
84
|
+
const requestOptions = await getCmdsUri({ logger: init.logger });
|
|
85
|
+
const credsResponse = JSON.parse(await requestFromEcsImds(timeout, requestOptions));
|
|
86
|
+
if (!isImdsCredentials(credsResponse)) {
|
|
87
|
+
throw new propertyProvider.CredentialsProviderError("Invalid response received from instance metadata service.", {
|
|
88
|
+
logger: init.logger,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return fromImdsCredentials(credsResponse);
|
|
92
|
+
}, maxRetries);
|
|
93
|
+
};
|
|
94
|
+
const requestFromEcsImds = async (timeout, options) => {
|
|
95
|
+
if (process.env[ENV_CMDS_AUTH_TOKEN]) {
|
|
96
|
+
options.headers = {
|
|
97
|
+
...options.headers,
|
|
98
|
+
Authorization: process.env[ENV_CMDS_AUTH_TOKEN],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const buffer = await httpRequest({
|
|
102
|
+
...options,
|
|
103
|
+
timeout,
|
|
104
|
+
});
|
|
105
|
+
return buffer.toString();
|
|
106
|
+
};
|
|
107
|
+
const CMDS_IP = "169.254.170.2";
|
|
108
|
+
const GREENGRASS_HOSTS = {
|
|
109
|
+
localhost: true,
|
|
110
|
+
"127.0.0.1": true,
|
|
111
|
+
};
|
|
112
|
+
const GREENGRASS_PROTOCOLS = {
|
|
113
|
+
"http:": true,
|
|
114
|
+
"https:": true,
|
|
115
|
+
};
|
|
116
|
+
const getCmdsUri = async ({ logger }) => {
|
|
117
|
+
if (process.env[ENV_CMDS_RELATIVE_URI]) {
|
|
118
|
+
return {
|
|
119
|
+
hostname: CMDS_IP,
|
|
120
|
+
path: process.env[ENV_CMDS_RELATIVE_URI],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (process.env[ENV_CMDS_FULL_URI]) {
|
|
124
|
+
const parsed = url.parse(process.env[ENV_CMDS_FULL_URI]);
|
|
125
|
+
if (!parsed.hostname || !(parsed.hostname in GREENGRASS_HOSTS)) {
|
|
126
|
+
throw new propertyProvider.CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
|
|
127
|
+
tryNextLink: false,
|
|
128
|
+
logger,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if (!parsed.protocol || !(parsed.protocol in GREENGRASS_PROTOCOLS)) {
|
|
132
|
+
throw new propertyProvider.CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
|
|
133
|
+
tryNextLink: false,
|
|
134
|
+
logger,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
...parsed,
|
|
139
|
+
port: parsed.port ? parseInt(parsed.port, 10) : undefined,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
throw new propertyProvider.CredentialsProviderError("The container metadata credential provider cannot be used unless" +
|
|
143
|
+
` the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment` +
|
|
144
|
+
" variable is set", {
|
|
145
|
+
tryNextLink: false,
|
|
146
|
+
logger,
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
class InstanceMetadataV1FallbackError extends propertyProvider.CredentialsProviderError {
|
|
151
|
+
tryNextLink;
|
|
152
|
+
name = "InstanceMetadataV1FallbackError";
|
|
153
|
+
constructor(message, tryNextLink = true) {
|
|
154
|
+
super(message, tryNextLink);
|
|
155
|
+
this.tryNextLink = tryNextLink;
|
|
156
|
+
Object.setPrototypeOf(this, InstanceMetadataV1FallbackError.prototype);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
exports.yI = void 0;
|
|
161
|
+
(function (Endpoint) {
|
|
162
|
+
Endpoint["IPv4"] = "http://169.254.169.254";
|
|
163
|
+
Endpoint["IPv6"] = "http://[fd00:ec2::254]";
|
|
164
|
+
})(exports.yI || (exports.yI = {}));
|
|
165
|
+
|
|
166
|
+
const ENV_ENDPOINT_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT";
|
|
167
|
+
const CONFIG_ENDPOINT_NAME = "ec2_metadata_service_endpoint";
|
|
168
|
+
const ENDPOINT_CONFIG_OPTIONS = {
|
|
169
|
+
environmentVariableSelector: (env) => env[ENV_ENDPOINT_NAME],
|
|
170
|
+
configFileSelector: (profile) => profile[CONFIG_ENDPOINT_NAME],
|
|
171
|
+
default: undefined,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
var EndpointMode;
|
|
175
|
+
(function (EndpointMode) {
|
|
176
|
+
EndpointMode["IPv4"] = "IPv4";
|
|
177
|
+
EndpointMode["IPv6"] = "IPv6";
|
|
178
|
+
})(EndpointMode || (EndpointMode = {}));
|
|
179
|
+
|
|
180
|
+
const ENV_ENDPOINT_MODE_NAME = "AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE";
|
|
181
|
+
const CONFIG_ENDPOINT_MODE_NAME = "ec2_metadata_service_endpoint_mode";
|
|
182
|
+
const ENDPOINT_MODE_CONFIG_OPTIONS = {
|
|
183
|
+
environmentVariableSelector: (env) => env[ENV_ENDPOINT_MODE_NAME],
|
|
184
|
+
configFileSelector: (profile) => profile[CONFIG_ENDPOINT_MODE_NAME],
|
|
185
|
+
default: EndpointMode.IPv4,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const getInstanceMetadataEndpoint = async () => urlParser.parseUrl((await getFromEndpointConfig()) || (await getFromEndpointModeConfig()));
|
|
189
|
+
const getFromEndpointConfig = async () => nodeConfigProvider.loadConfig(ENDPOINT_CONFIG_OPTIONS)();
|
|
190
|
+
const getFromEndpointModeConfig = async () => {
|
|
191
|
+
const endpointMode = await nodeConfigProvider.loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS)();
|
|
192
|
+
switch (endpointMode) {
|
|
193
|
+
case EndpointMode.IPv4:
|
|
194
|
+
return exports.yI.IPv4;
|
|
195
|
+
case EndpointMode.IPv6:
|
|
196
|
+
return exports.yI.IPv6;
|
|
197
|
+
default:
|
|
198
|
+
throw new Error(`Unsupported endpoint mode: ${endpointMode}.` + ` Select from ${Object.values(EndpointMode)}`);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 5 * 60;
|
|
203
|
+
const STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 5 * 60;
|
|
204
|
+
const STATIC_STABILITY_DOC_URL = "https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html";
|
|
205
|
+
const getExtendedInstanceMetadataCredentials = (credentials, logger) => {
|
|
206
|
+
const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS +
|
|
207
|
+
Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);
|
|
208
|
+
const newExpiration = new Date(Date.now() + refreshInterval * 1000);
|
|
209
|
+
logger.warn("Attempting credential expiration extension due to a credential service availability issue. A refresh of these " +
|
|
210
|
+
`credentials will be attempted after ${new Date(newExpiration)}.\nFor more information, please visit: ` +
|
|
211
|
+
STATIC_STABILITY_DOC_URL);
|
|
212
|
+
const originalExpiration = credentials.originalExpiration ?? credentials.expiration;
|
|
213
|
+
return {
|
|
214
|
+
...credentials,
|
|
215
|
+
...(originalExpiration ? { originalExpiration } : {}),
|
|
216
|
+
expiration: newExpiration,
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const staticStabilityProvider = (provider, options = {}) => {
|
|
221
|
+
const logger = options?.logger || console;
|
|
222
|
+
let pastCredentials;
|
|
223
|
+
return async () => {
|
|
224
|
+
let credentials;
|
|
225
|
+
try {
|
|
226
|
+
credentials = await provider();
|
|
227
|
+
if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {
|
|
228
|
+
credentials = getExtendedInstanceMetadataCredentials(credentials, logger);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
if (pastCredentials) {
|
|
233
|
+
logger.warn("Credential renew failed: ", e);
|
|
234
|
+
credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
throw e;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
pastCredentials = credentials;
|
|
241
|
+
return credentials;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const IMDS_PATH = "/latest/meta-data/iam/security-credentials/";
|
|
246
|
+
const IMDS_TOKEN_PATH = "/latest/api/token";
|
|
247
|
+
const AWS_EC2_METADATA_V1_DISABLED = "AWS_EC2_METADATA_V1_DISABLED";
|
|
248
|
+
const PROFILE_AWS_EC2_METADATA_V1_DISABLED = "ec2_metadata_v1_disabled";
|
|
249
|
+
const X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
|
|
250
|
+
const fromInstanceMetadata = (init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger });
|
|
251
|
+
const getInstanceMetadataProvider = (init = {}) => {
|
|
252
|
+
let disableFetchToken = false;
|
|
253
|
+
const { logger, profile } = init;
|
|
254
|
+
const { timeout, maxRetries } = providerConfigFromInit(init);
|
|
255
|
+
const getCredentials = async (maxRetries, options) => {
|
|
256
|
+
const isImdsV1Fallback = disableFetchToken || options.headers?.[X_AWS_EC2_METADATA_TOKEN] == null;
|
|
257
|
+
if (isImdsV1Fallback) {
|
|
258
|
+
let fallbackBlockedFromProfile = false;
|
|
259
|
+
let fallbackBlockedFromProcessEnv = false;
|
|
260
|
+
const configValue = await nodeConfigProvider.loadConfig({
|
|
261
|
+
environmentVariableSelector: (env) => {
|
|
262
|
+
const envValue = env[AWS_EC2_METADATA_V1_DISABLED];
|
|
263
|
+
fallbackBlockedFromProcessEnv = !!envValue && envValue !== "false";
|
|
264
|
+
if (envValue === undefined) {
|
|
265
|
+
throw new propertyProvider.CredentialsProviderError(`${AWS_EC2_METADATA_V1_DISABLED} not set in env, checking config file next.`, { logger: init.logger });
|
|
266
|
+
}
|
|
267
|
+
return fallbackBlockedFromProcessEnv;
|
|
268
|
+
},
|
|
269
|
+
configFileSelector: (profile) => {
|
|
270
|
+
const profileValue = profile[PROFILE_AWS_EC2_METADATA_V1_DISABLED];
|
|
271
|
+
fallbackBlockedFromProfile = !!profileValue && profileValue !== "false";
|
|
272
|
+
return fallbackBlockedFromProfile;
|
|
273
|
+
},
|
|
274
|
+
default: false,
|
|
275
|
+
}, {
|
|
276
|
+
profile,
|
|
277
|
+
})();
|
|
278
|
+
if (init.ec2MetadataV1Disabled || configValue) {
|
|
279
|
+
const causes = [];
|
|
280
|
+
if (init.ec2MetadataV1Disabled)
|
|
281
|
+
causes.push("credential provider initialization (runtime option ec2MetadataV1Disabled)");
|
|
282
|
+
if (fallbackBlockedFromProfile)
|
|
283
|
+
causes.push(`config file profile (${PROFILE_AWS_EC2_METADATA_V1_DISABLED})`);
|
|
284
|
+
if (fallbackBlockedFromProcessEnv)
|
|
285
|
+
causes.push(`process environment variable (${AWS_EC2_METADATA_V1_DISABLED})`);
|
|
286
|
+
throw new InstanceMetadataV1FallbackError(`AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [${causes.join(", ")}].`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const imdsProfile = (await retry(async () => {
|
|
290
|
+
let profile;
|
|
291
|
+
try {
|
|
292
|
+
profile = await getProfile(options);
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
295
|
+
if (err.statusCode === 401) {
|
|
296
|
+
disableFetchToken = false;
|
|
297
|
+
}
|
|
298
|
+
throw err;
|
|
299
|
+
}
|
|
300
|
+
return profile;
|
|
301
|
+
}, maxRetries)).trim();
|
|
302
|
+
return retry(async () => {
|
|
303
|
+
let creds;
|
|
304
|
+
try {
|
|
305
|
+
creds = await getCredentialsFromProfile(imdsProfile, options, init);
|
|
306
|
+
}
|
|
307
|
+
catch (err) {
|
|
308
|
+
if (err.statusCode === 401) {
|
|
309
|
+
disableFetchToken = false;
|
|
310
|
+
}
|
|
311
|
+
throw err;
|
|
312
|
+
}
|
|
313
|
+
return creds;
|
|
314
|
+
}, maxRetries);
|
|
315
|
+
};
|
|
316
|
+
return async () => {
|
|
317
|
+
const endpoint = await getInstanceMetadataEndpoint();
|
|
318
|
+
if (disableFetchToken) {
|
|
319
|
+
logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
|
|
320
|
+
return getCredentials(maxRetries, { ...endpoint, timeout });
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
let token;
|
|
324
|
+
try {
|
|
325
|
+
token = (await getMetadataToken({ ...endpoint, timeout })).toString();
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
if (error?.statusCode === 400) {
|
|
329
|
+
throw Object.assign(error, {
|
|
330
|
+
message: "EC2 Metadata token request returned error",
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
else if (error.message === "TimeoutError" || [403, 404, 405].includes(error.statusCode)) {
|
|
334
|
+
disableFetchToken = true;
|
|
335
|
+
}
|
|
336
|
+
logger?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
|
|
337
|
+
return getCredentials(maxRetries, { ...endpoint, timeout });
|
|
338
|
+
}
|
|
339
|
+
return getCredentials(maxRetries, {
|
|
340
|
+
...endpoint,
|
|
341
|
+
headers: {
|
|
342
|
+
[X_AWS_EC2_METADATA_TOKEN]: token,
|
|
343
|
+
},
|
|
344
|
+
timeout,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
const getMetadataToken = async (options) => httpRequest({
|
|
350
|
+
...options,
|
|
351
|
+
path: IMDS_TOKEN_PATH,
|
|
352
|
+
method: "PUT",
|
|
353
|
+
headers: {
|
|
354
|
+
"x-aws-ec2-metadata-token-ttl-seconds": "21600",
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
const getProfile = async (options) => (await httpRequest({ ...options, path: IMDS_PATH })).toString();
|
|
358
|
+
const getCredentialsFromProfile = async (profile, options, init) => {
|
|
359
|
+
const credentialsResponse = JSON.parse((await httpRequest({
|
|
360
|
+
...options,
|
|
361
|
+
path: IMDS_PATH + profile,
|
|
362
|
+
})).toString());
|
|
363
|
+
if (!isImdsCredentials(credentialsResponse)) {
|
|
364
|
+
throw new propertyProvider.CredentialsProviderError("Invalid response received from instance metadata service.", {
|
|
365
|
+
logger: init.logger,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
return fromImdsCredentials(credentialsResponse);
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
__webpack_unused_export__ = DEFAULT_MAX_RETRIES;
|
|
372
|
+
__webpack_unused_export__ = DEFAULT_TIMEOUT;
|
|
373
|
+
__webpack_unused_export__ = ENV_CMDS_AUTH_TOKEN;
|
|
374
|
+
exports.ENV_CMDS_FULL_URI = ENV_CMDS_FULL_URI;
|
|
375
|
+
exports.ENV_CMDS_RELATIVE_URI = ENV_CMDS_RELATIVE_URI;
|
|
376
|
+
exports.fromContainerMetadata = fromContainerMetadata;
|
|
377
|
+
exports.fromInstanceMetadata = fromInstanceMetadata;
|
|
378
|
+
exports.getInstanceMetadataEndpoint = getInstanceMetadataEndpoint;
|
|
379
|
+
exports.httpRequest = httpRequest;
|
|
380
|
+
__webpack_unused_export__ = providerConfigFromInit;
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
/***/ })
|
|
384
|
+
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
//# sourceMappingURL=566.index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"566.index.js","mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sources":[".././node_modules/@smithy/credential-provider-imds/dist-cjs/index.js"],"sourcesContent":["'use strict';\n\nvar propertyProvider = require('@smithy/property-provider');\nvar url = require('url');\nvar buffer = require('buffer');\nvar http = require('http');\nvar nodeConfigProvider = require('@smithy/node-config-provider');\nvar urlParser = require('@smithy/url-parser');\n\nfunction httpRequest(options) {\n return new Promise((resolve, reject) => {\n const req = http.request({\n method: \"GET\",\n ...options,\n hostname: options.hostname?.replace(/^\\[(.+)\\]$/, \"$1\"),\n });\n req.on(\"error\", (err) => {\n reject(Object.assign(new propertyProvider.ProviderError(\"Unable to connect to instance metadata service\"), err));\n req.destroy();\n });\n req.on(\"timeout\", () => {\n reject(new propertyProvider.ProviderError(\"TimeoutError from instance metadata service\"));\n req.destroy();\n });\n req.on(\"response\", (res) => {\n const { statusCode = 400 } = res;\n if (statusCode < 200 || 300 <= statusCode) {\n reject(Object.assign(new propertyProvider.ProviderError(\"Error response received from instance metadata service\"), { statusCode }));\n req.destroy();\n }\n const chunks = [];\n res.on(\"data\", (chunk) => {\n chunks.push(chunk);\n });\n res.on(\"end\", () => {\n resolve(buffer.Buffer.concat(chunks));\n req.destroy();\n });\n });\n req.end();\n });\n}\n\nconst isImdsCredentials = (arg) => Boolean(arg) &&\n typeof arg === \"object\" &&\n typeof arg.AccessKeyId === \"string\" &&\n typeof arg.SecretAccessKey === \"string\" &&\n typeof arg.Token === \"string\" &&\n typeof arg.Expiration === \"string\";\nconst fromImdsCredentials = (creds) => ({\n accessKeyId: creds.AccessKeyId,\n secretAccessKey: creds.SecretAccessKey,\n sessionToken: creds.Token,\n expiration: new Date(creds.Expiration),\n ...(creds.AccountId && { accountId: creds.AccountId }),\n});\n\nconst DEFAULT_TIMEOUT = 1000;\nconst DEFAULT_MAX_RETRIES = 0;\nconst providerConfigFromInit = ({ maxRetries = DEFAULT_MAX_RETRIES, timeout = DEFAULT_TIMEOUT, }) => ({ maxRetries, timeout });\n\nconst retry = (toRetry, maxRetries) => {\n let promise = toRetry();\n for (let i = 0; i < maxRetries; i++) {\n promise = promise.catch(toRetry);\n }\n return promise;\n};\n\nconst ENV_CMDS_FULL_URI = \"AWS_CONTAINER_CREDENTIALS_FULL_URI\";\nconst ENV_CMDS_RELATIVE_URI = \"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI\";\nconst ENV_CMDS_AUTH_TOKEN = \"AWS_CONTAINER_AUTHORIZATION_TOKEN\";\nconst fromContainerMetadata = (init = {}) => {\n const { timeout, maxRetries } = providerConfigFromInit(init);\n return () => retry(async () => {\n const requestOptions = await getCmdsUri({ logger: init.logger });\n const credsResponse = JSON.parse(await requestFromEcsImds(timeout, requestOptions));\n if (!isImdsCredentials(credsResponse)) {\n throw new propertyProvider.CredentialsProviderError(\"Invalid response received from instance metadata service.\", {\n logger: init.logger,\n });\n }\n return fromImdsCredentials(credsResponse);\n }, maxRetries);\n};\nconst requestFromEcsImds = async (timeout, options) => {\n if (process.env[ENV_CMDS_AUTH_TOKEN]) {\n options.headers = {\n ...options.headers,\n Authorization: process.env[ENV_CMDS_AUTH_TOKEN],\n };\n }\n const buffer = await httpRequest({\n ...options,\n timeout,\n });\n return buffer.toString();\n};\nconst CMDS_IP = \"169.254.170.2\";\nconst GREENGRASS_HOSTS = {\n localhost: true,\n \"127.0.0.1\": true,\n};\nconst GREENGRASS_PROTOCOLS = {\n \"http:\": true,\n \"https:\": true,\n};\nconst getCmdsUri = async ({ logger }) => {\n if (process.env[ENV_CMDS_RELATIVE_URI]) {\n return {\n hostname: CMDS_IP,\n path: process.env[ENV_CMDS_RELATIVE_URI],\n };\n }\n if (process.env[ENV_CMDS_FULL_URI]) {\n const parsed = url.parse(process.env[ENV_CMDS_FULL_URI]);\n if (!parsed.hostname || !(parsed.hostname in GREENGRASS_HOSTS)) {\n throw new propertyProvider.CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {\n tryNextLink: false,\n logger,\n });\n }\n if (!parsed.protocol || !(parsed.protocol in GREENGRASS_PROTOCOLS)) {\n throw new propertyProvider.CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {\n tryNextLink: false,\n logger,\n });\n }\n return {\n ...parsed,\n port: parsed.port ? parseInt(parsed.port, 10) : undefined,\n };\n }\n throw new propertyProvider.CredentialsProviderError(\"The container metadata credential provider cannot be used unless\" +\n ` the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment` +\n \" variable is set\", {\n tryNextLink: false,\n logger,\n });\n};\n\nclass InstanceMetadataV1FallbackError extends propertyProvider.CredentialsProviderError {\n tryNextLink;\n name = \"InstanceMetadataV1FallbackError\";\n constructor(message, tryNextLink = true) {\n super(message, tryNextLink);\n this.tryNextLink = tryNextLink;\n Object.setPrototypeOf(this, InstanceMetadataV1FallbackError.prototype);\n }\n}\n\nexports.Endpoint = void 0;\n(function (Endpoint) {\n Endpoint[\"IPv4\"] = \"http://169.254.169.254\";\n Endpoint[\"IPv6\"] = \"http://[fd00:ec2::254]\";\n})(exports.Endpoint || (exports.Endpoint = {}));\n\nconst ENV_ENDPOINT_NAME = \"AWS_EC2_METADATA_SERVICE_ENDPOINT\";\nconst CONFIG_ENDPOINT_NAME = \"ec2_metadata_service_endpoint\";\nconst ENDPOINT_CONFIG_OPTIONS = {\n environmentVariableSelector: (env) => env[ENV_ENDPOINT_NAME],\n configFileSelector: (profile) => profile[CONFIG_ENDPOINT_NAME],\n default: undefined,\n};\n\nvar EndpointMode;\n(function (EndpointMode) {\n EndpointMode[\"IPv4\"] = \"IPv4\";\n EndpointMode[\"IPv6\"] = \"IPv6\";\n})(EndpointMode || (EndpointMode = {}));\n\nconst ENV_ENDPOINT_MODE_NAME = \"AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE\";\nconst CONFIG_ENDPOINT_MODE_NAME = \"ec2_metadata_service_endpoint_mode\";\nconst ENDPOINT_MODE_CONFIG_OPTIONS = {\n environmentVariableSelector: (env) => env[ENV_ENDPOINT_MODE_NAME],\n configFileSelector: (profile) => profile[CONFIG_ENDPOINT_MODE_NAME],\n default: EndpointMode.IPv4,\n};\n\nconst getInstanceMetadataEndpoint = async () => urlParser.parseUrl((await getFromEndpointConfig()) || (await getFromEndpointModeConfig()));\nconst getFromEndpointConfig = async () => nodeConfigProvider.loadConfig(ENDPOINT_CONFIG_OPTIONS)();\nconst getFromEndpointModeConfig = async () => {\n const endpointMode = await nodeConfigProvider.loadConfig(ENDPOINT_MODE_CONFIG_OPTIONS)();\n switch (endpointMode) {\n case EndpointMode.IPv4:\n return exports.Endpoint.IPv4;\n case EndpointMode.IPv6:\n return exports.Endpoint.IPv6;\n default:\n throw new Error(`Unsupported endpoint mode: ${endpointMode}.` + ` Select from ${Object.values(EndpointMode)}`);\n }\n};\n\nconst STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 5 * 60;\nconst STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 5 * 60;\nconst STATIC_STABILITY_DOC_URL = \"https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html\";\nconst getExtendedInstanceMetadataCredentials = (credentials, logger) => {\n const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS +\n Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);\n const newExpiration = new Date(Date.now() + refreshInterval * 1000);\n logger.warn(\"Attempting credential expiration extension due to a credential service availability issue. A refresh of these \" +\n `credentials will be attempted after ${new Date(newExpiration)}.\\nFor more information, please visit: ` +\n STATIC_STABILITY_DOC_URL);\n const originalExpiration = credentials.originalExpiration ?? credentials.expiration;\n return {\n ...credentials,\n ...(originalExpiration ? { originalExpiration } : {}),\n expiration: newExpiration,\n };\n};\n\nconst staticStabilityProvider = (provider, options = {}) => {\n const logger = options?.logger || console;\n let pastCredentials;\n return async () => {\n let credentials;\n try {\n credentials = await provider();\n if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {\n credentials = getExtendedInstanceMetadataCredentials(credentials, logger);\n }\n }\n catch (e) {\n if (pastCredentials) {\n logger.warn(\"Credential renew failed: \", e);\n credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger);\n }\n else {\n throw e;\n }\n }\n pastCredentials = credentials;\n return credentials;\n };\n};\n\nconst IMDS_PATH = \"/latest/meta-data/iam/security-credentials/\";\nconst IMDS_TOKEN_PATH = \"/latest/api/token\";\nconst AWS_EC2_METADATA_V1_DISABLED = \"AWS_EC2_METADATA_V1_DISABLED\";\nconst PROFILE_AWS_EC2_METADATA_V1_DISABLED = \"ec2_metadata_v1_disabled\";\nconst X_AWS_EC2_METADATA_TOKEN = \"x-aws-ec2-metadata-token\";\nconst fromInstanceMetadata = (init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger });\nconst getInstanceMetadataProvider = (init = {}) => {\n let disableFetchToken = false;\n const { logger, profile } = init;\n const { timeout, maxRetries } = providerConfigFromInit(init);\n const getCredentials = async (maxRetries, options) => {\n const isImdsV1Fallback = disableFetchToken || options.headers?.[X_AWS_EC2_METADATA_TOKEN] == null;\n if (isImdsV1Fallback) {\n let fallbackBlockedFromProfile = false;\n let fallbackBlockedFromProcessEnv = false;\n const configValue = await nodeConfigProvider.loadConfig({\n environmentVariableSelector: (env) => {\n const envValue = env[AWS_EC2_METADATA_V1_DISABLED];\n fallbackBlockedFromProcessEnv = !!envValue && envValue !== \"false\";\n if (envValue === undefined) {\n throw new propertyProvider.CredentialsProviderError(`${AWS_EC2_METADATA_V1_DISABLED} not set in env, checking config file next.`, { logger: init.logger });\n }\n return fallbackBlockedFromProcessEnv;\n },\n configFileSelector: (profile) => {\n const profileValue = profile[PROFILE_AWS_EC2_METADATA_V1_DISABLED];\n fallbackBlockedFromProfile = !!profileValue && profileValue !== \"false\";\n return fallbackBlockedFromProfile;\n },\n default: false,\n }, {\n profile,\n })();\n if (init.ec2MetadataV1Disabled || configValue) {\n const causes = [];\n if (init.ec2MetadataV1Disabled)\n causes.push(\"credential provider initialization (runtime option ec2MetadataV1Disabled)\");\n if (fallbackBlockedFromProfile)\n causes.push(`config file profile (${PROFILE_AWS_EC2_METADATA_V1_DISABLED})`);\n if (fallbackBlockedFromProcessEnv)\n causes.push(`process environment variable (${AWS_EC2_METADATA_V1_DISABLED})`);\n throw new InstanceMetadataV1FallbackError(`AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [${causes.join(\", \")}].`);\n }\n }\n const imdsProfile = (await retry(async () => {\n let profile;\n try {\n profile = await getProfile(options);\n }\n catch (err) {\n if (err.statusCode === 401) {\n disableFetchToken = false;\n }\n throw err;\n }\n return profile;\n }, maxRetries)).trim();\n return retry(async () => {\n let creds;\n try {\n creds = await getCredentialsFromProfile(imdsProfile, options, init);\n }\n catch (err) {\n if (err.statusCode === 401) {\n disableFetchToken = false;\n }\n throw err;\n }\n return creds;\n }, maxRetries);\n };\n return async () => {\n const endpoint = await getInstanceMetadataEndpoint();\n if (disableFetchToken) {\n logger?.debug(\"AWS SDK Instance Metadata\", \"using v1 fallback (no token fetch)\");\n return getCredentials(maxRetries, { ...endpoint, timeout });\n }\n else {\n let token;\n try {\n token = (await getMetadataToken({ ...endpoint, timeout })).toString();\n }\n catch (error) {\n if (error?.statusCode === 400) {\n throw Object.assign(error, {\n message: \"EC2 Metadata token request returned error\",\n });\n }\n else if (error.message === \"TimeoutError\" || [403, 404, 405].includes(error.statusCode)) {\n disableFetchToken = true;\n }\n logger?.debug(\"AWS SDK Instance Metadata\", \"using v1 fallback (initial)\");\n return getCredentials(maxRetries, { ...endpoint, timeout });\n }\n return getCredentials(maxRetries, {\n ...endpoint,\n headers: {\n [X_AWS_EC2_METADATA_TOKEN]: token,\n },\n timeout,\n });\n }\n };\n};\nconst getMetadataToken = async (options) => httpRequest({\n ...options,\n path: IMDS_TOKEN_PATH,\n method: \"PUT\",\n headers: {\n \"x-aws-ec2-metadata-token-ttl-seconds\": \"21600\",\n },\n});\nconst getProfile = async (options) => (await httpRequest({ ...options, path: IMDS_PATH })).toString();\nconst getCredentialsFromProfile = async (profile, options, init) => {\n const credentialsResponse = JSON.parse((await httpRequest({\n ...options,\n path: IMDS_PATH + profile,\n })).toString());\n if (!isImdsCredentials(credentialsResponse)) {\n throw new propertyProvider.CredentialsProviderError(\"Invalid response received from instance metadata service.\", {\n logger: init.logger,\n });\n }\n return fromImdsCredentials(credentialsResponse);\n};\n\nexports.DEFAULT_MAX_RETRIES = DEFAULT_MAX_RETRIES;\nexports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;\nexports.ENV_CMDS_AUTH_TOKEN = ENV_CMDS_AUTH_TOKEN;\nexports.ENV_CMDS_FULL_URI = ENV_CMDS_FULL_URI;\nexports.ENV_CMDS_RELATIVE_URI = ENV_CMDS_RELATIVE_URI;\nexports.fromContainerMetadata = fromContainerMetadata;\nexports.fromInstanceMetadata = fromInstanceMetadata;\nexports.getInstanceMetadataEndpoint = getInstanceMetadataEndpoint;\nexports.httpRequest = httpRequest;\nexports.providerConfigFromInit = providerConfigFromInit;\n"],"names":[],"sourceRoot":""}
|