Skip to content

Commit 538c16c

Browse files
committed
CLDSRV-902: document validateXAmzChecksums and getChecksumDataFromHeaders
1 parent 6600b33 commit 538c16c

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

lib/api/apiUtils/integrity/validateChecksums.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
*/
156164
async 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+
*/
209225
function getChecksumDataFromHeaders(headers) {
210226
const checkSdk = algo => {
211227
if (!('x-amz-sdk-checksum-algorithm' in headers)) {

0 commit comments

Comments
 (0)