-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(middleware-user-agent): add feature detection for account-id, s…
…3-express, lib-dynamodb (#6541)
- Loading branch information
Showing
12 changed files
with
144 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { setFeature } from "@aws-sdk/core"; | ||
import type { AccountIdEndpointMode } from "@aws-sdk/core/account-id-endpoint"; | ||
import type { AwsHandlerExecutionContext } from "@aws-sdk/types"; | ||
import type { IHttpRequest } from "@smithy/protocol-http"; | ||
import type { BuildHandlerArguments, Provider } from "@smithy/types"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
type PreviouslyResolved = Partial<{ | ||
accountIdEndpointMode?: Provider<AccountIdEndpointMode>; | ||
}>; | ||
|
||
/** | ||
* @internal | ||
* Check for features that don't have a middleware activation site but | ||
* may be detected on the context, client config, or request. | ||
*/ | ||
export async function checkFeatures( | ||
context: AwsHandlerExecutionContext, | ||
config: PreviouslyResolved, | ||
args: BuildHandlerArguments<any> | ||
): Promise<void> { | ||
// eslint-disable-next-line | ||
const request = args.request as IHttpRequest; | ||
if (typeof config.accountIdEndpointMode === "function") { | ||
switch (await config.accountIdEndpointMode?.()) { | ||
case "disabled": | ||
setFeature(context, "ACCOUNT_ID_MODE_DISABLED", "Q"); | ||
break; | ||
case "preferred": | ||
setFeature(context, "ACCOUNT_ID_MODE_PREFERRED", "P"); | ||
break; | ||
case "required": | ||
setFeature(context, "ACCOUNT_ID_MODE_REQUIRED", "R"); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters