Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/middleware-flexible-checksums/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../api-extractor.packages.json",
"mainEntryPointFilePath": "./dist-types/index.d.ts"
}
1 change: 1 addition & 0 deletions packages/middleware-flexible-checksums/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build:types": "tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"extract:docs": "api-extractor run --local",
"test": "yarn g:vitest run",
"test:watch": "yarn g:vitest watch",
"test:integration": "yarn g:vitest run -c vitest.config.integ.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ import { LoadedConfigSelectors } from "@smithy/node-config-provider";
import { DEFAULT_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation } from "./constants";
import { SelectorType, stringUnionSelector } from "./stringUnionSelector";

/**
* @internal
*/
export const ENV_REQUEST_CHECKSUM_CALCULATION = "AWS_REQUEST_CHECKSUM_CALCULATION";

/**
* @internal
*/
export const CONFIG_REQUEST_CHECKSUM_CALCULATION = "request_checksum_calculation";

/**
* @internal
*/
export const NODE_REQUEST_CHECKSUM_CALCULATION_CONFIG_OPTIONS: LoadedConfigSelectors<RequestChecksumCalculation> = {
environmentVariableSelector: (env) =>
stringUnionSelector(env, ENV_REQUEST_CHECKSUM_CALCULATION, RequestChecksumCalculation, SelectorType.ENV),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ import { LoadedConfigSelectors } from "@smithy/node-config-provider";
import { DEFAULT_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation } from "./constants";
import { SelectorType, stringUnionSelector } from "./stringUnionSelector";

/**
* @internal
*/
export const ENV_RESPONSE_CHECKSUM_VALIDATION = "AWS_RESPONSE_CHECKSUM_VALIDATION";

/**
* @internal
*/
export const CONFIG_RESPONSE_CHECKSUM_VALIDATION = "response_checksum_validation";

/**
* @internal
*/
export const NODE_RESPONSE_CHECKSUM_VALIDATION_CONFIG_OPTIONS: LoadedConfigSelectors<ResponseChecksumValidation> = {
environmentVariableSelector: (env) =>
stringUnionSelector(env, ENV_RESPONSE_CHECKSUM_VALIDATION, ResponseChecksumValidation, SelectorType.ENV),
Expand Down
3 changes: 3 additions & 0 deletions packages/middleware-flexible-checksums/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {

import { RequestChecksumCalculation, ResponseChecksumValidation } from "./constants";

/**
* @internal
*/
export interface PreviouslyResolved {
/**
* The function that will be used to convert binary data to a base64-encoded string.
Expand Down
16 changes: 16 additions & 0 deletions packages/middleware-flexible-checksums/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Determines when a checksum will be calculated for request payloads.
* @public
*/
export const RequestChecksumCalculation = {
/**
Expand All @@ -19,12 +20,19 @@ export const RequestChecksumCalculation = {
WHEN_REQUIRED: "WHEN_REQUIRED",
} as const;

/**
* @public
*/
export type RequestChecksumCalculation = (typeof RequestChecksumCalculation)[keyof typeof RequestChecksumCalculation];

/**
* @internal
*/
export const DEFAULT_REQUEST_CHECKSUM_CALCULATION = RequestChecksumCalculation.WHEN_SUPPORTED;

/**
* Determines when checksum validation will be performed on response payloads.
* @public
*/
export const ResponseChecksumValidation = {
/**
Expand All @@ -44,12 +52,19 @@ export const ResponseChecksumValidation = {
WHEN_REQUIRED: "WHEN_REQUIRED",
} as const;

/**
* @public
*/
export type ResponseChecksumValidation = (typeof ResponseChecksumValidation)[keyof typeof ResponseChecksumValidation];

/**
* @internal
*/
export const DEFAULT_RESPONSE_CHECKSUM_VALIDATION = RequestChecksumCalculation.WHEN_SUPPORTED;

/**
* Checksum Algorithms supported by the SDK.
* @public
*/
export enum ChecksumAlgorithm {
/**
Expand All @@ -65,6 +80,7 @@ export enum ChecksumAlgorithm {

/**
* Location when the checksum is stored in the request body.
* @internal
*/
export enum ChecksumLocation {
HEADER = "header",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChecksumConstructor } from "@smithy/types";

/**
* @public
* @internal
*
* \@aws-sdk/crc64-nvme-crt will install the constructor in this
* container if it is installed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
import { PreviouslyResolved } from "./configuration";
import { RequestChecksumCalculation, ResponseChecksumValidation } from "./constants";

/**
* @internal
*/
export interface FlexibleChecksumsInputMiddlewareConfig {
/**
* Defines a top-level operation input member used to opt-in to best-effort validation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import { isStreaming } from "./isStreaming";
import { selectChecksumAlgorithmFunction } from "./selectChecksumAlgorithmFunction";
import { stringHasher } from "./stringHasher";

/**
* @internal
*/
export interface FlexibleChecksumsRequestMiddlewareConfig {
/**
/**
* Indicates an operation requires a checksum in its HTTP request.
*/
Expand All @@ -45,6 +47,9 @@ export interface FlexibleChecksumsRequestMiddlewareConfig {
};
}

/**
* @internal
*/
export const flexibleChecksumsMiddlewareOptions: BuildHandlerOptions = {
name: "flexibleChecksumsMiddleware",
step: "build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { getChecksumLocationName } from "./getChecksumLocationName";
import { isChecksumWithPartNumber } from "./isChecksumWithPartNumber";
import { validateChecksumFromResponse } from "./validateChecksumFromResponse";

/**
* @internal
*/
export interface FlexibleChecksumsResponseMiddlewareConfig {
/**
* Defines a top-level operation input member used to opt-in to best-effort validation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ import {
flexibleChecksumsResponseMiddlewareOptions,
} from "./flexibleChecksumsResponseMiddleware";

/**
* @internal
*/
export interface FlexibleChecksumsMiddlewareConfig
extends FlexibleChecksumsRequestMiddlewareConfig,
FlexibleChecksumsInputMiddlewareConfig,
FlexibleChecksumsResponseMiddlewareConfig {}

/**
* @internal
*/
export const getFlexibleChecksumsPlugin = (
config: PreviouslyResolved,
middlewareConfig: FlexibleChecksumsMiddlewareConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {
ResponseChecksumValidation,
} from "./constants";

/**
* @public
*/
export interface FlexibleChecksumsInputConfig {
/**
* Determines when a checksum will be calculated for request payloads.
Expand Down Expand Up @@ -37,12 +40,18 @@ export interface FlexibleChecksumsInputConfig {
requestStreamBufferSize?: number | false;
}

/**
* @internal
*/
export interface FlexibleChecksumsResolvedConfig {
requestChecksumCalculation: Provider<RequestChecksumCalculation>;
responseChecksumValidation: Provider<ResponseChecksumValidation>;
requestStreamBufferSize: number;
}

/**
* @internal
*/
export const resolveFlexibleChecksumsConfig = <T>(
input: T & FlexibleChecksumsInputConfig
): T & FlexibleChecksumsResolvedConfig => ({
Expand Down
Loading