File tree Expand file tree Collapse file tree
lib/api/apiUtils/integrity Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,6 +153,14 @@ const algorithms = Object.freeze({
153153 } ,
154154} ) ;
155155
156+ /**
157+ * Validate the x-amz-checksum-<algo> header against a buffered body.
158+ *
159+ * @param {object } headers - HTTP request headers (lowercased keys)
160+ * @param {Buffer } body - the entire buffered request body
161+ * @returns {Promise<null | { error: string, details: object }> } -
162+ * null on success; otherwise a ChecksumError with details.
163+ */
156164async function validateXAmzChecksums ( headers , body ) {
157165 const checksumHeaders = Object . keys ( headers ) . filter ( header => header . startsWith ( 'x-amz-checksum-' ) ) ;
158166 const xAmzChecksumCnt = checksumHeaders . length ;
@@ -206,6 +214,14 @@ async function validateXAmzChecksums(headers, body) {
206214 return null ;
207215}
208216
217+ /**
218+ * Extract checksum data from request headers.
219+ *
220+ * @param {object } headers - HTTP request headers (lowercased keys)
221+ * @returns {null
222+ * | { algorithm: string, isTrailer: boolean, expected: string|undefined }
223+ * | { error: string, details: object }}
224+ */
209225function getChecksumDataFromHeaders ( headers ) {
210226 const checkSdk = algo => {
211227 if ( ! ( 'x-amz-sdk-checksum-algorithm' in headers ) ) {
You can’t perform that action at this time.
0 commit comments