Skip to content

Commit 3126a8d

Browse files
committed
post reviews fixups
1 parent c54d97a commit 3126a8d

File tree

8 files changed

+328
-290
lines changed

8 files changed

+328
-290
lines changed

lib/auth/v2/getCanonicalizedAmzHeaders.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { ArsenalRequestHeaders } from '../../types/ArsenalRequest';
2+
import { normalizeHeaderValue } from '../../utils/normalizeHeaders';
23

34
export default function getCanonicalizedAmzHeaders(headers: ArsenalRequestHeaders, clientType: string) {
45
/*
@@ -16,9 +17,7 @@ export default function getCanonicalizedAmzHeaders(headers: ArsenalRequestHeader
1617
// AWS SDK v3 can pass header values as arrays (for multiple values),
1718
// strings, or other types. We need to normalize them before calling .trim()
1819
// Per HTTP spec and AWS Signature v2, multiple values are joined with commas
19-
const stringValue = Array.isArray(headerValue)
20-
? headerValue.join(',')
21-
: String(headerValue);
20+
const stringValue = normalizeHeaderValue(headerValue);
2221
return [val.trim(), stringValue.trim()];
2322
});
2423
/*

lib/auth/v4/createCanonicalRequest.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as crypto from 'crypto';
22
import * as queryString from 'querystring';
33
import awsURIencode from './awsURIencode';
4+
import { normalizeHeaderValue } from '../../utils/normalizeHeaders';
45

56
/**
67
* createCanonicalRequest - creates V4 canonical request
@@ -77,9 +78,7 @@ export default function createCanonicalRequest(
7778
// AWS SDK v3 can pass header values as arrays (for multiple values),
7879
// strings, or other types. We need to normalize them before calling .trim()
7980
// Per HTTP spec and AWS Signature v4, multiple values are joined with commas
80-
const stringValue = Array.isArray(headerValue)
81-
? headerValue.join(',')
82-
: String(headerValue);
81+
const stringValue = normalizeHeaderValue(headerValue);
8382
const trimmedHeader = stringValue
8483
.trim().replace(/\s+/g, ' ');
8584
return `${signedHeader}:${trimmedHeader}\n`;

lib/network/kmsAWS/Client.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,22 @@ export default class Client implements KMSInterface {
294294
* additional permissions). Callers should rely on higher-level health
295295
* checks provided by their services instead of this method.
296296
*/
297+
/*
297298
healthcheck(logger: werelogs.Logger, cb: (err: Error | null) => void): void {
298-
logger.debug("AWS KMS: healthcheck is a no-op (disabled)");
299-
cb(null);
299+
logger.debug("AWS KMS: performing healthcheck");
300+
301+
const command = new ListKeysCommand({
302+
Limit: 1,
303+
});
304+
305+
this.client.send(command).then(() => {
306+
logger.debug("AWS KMS healthcheck: list keys succeeded");
307+
cb(null);
308+
}).catch(err => {
309+
const error = arsenalErrorAWSKMS(err);
310+
logger.error("AWS KMS healthcheck: failed to list keys", { err });
311+
cb(error);
312+
});
300313
}
314+
*/
301315
}

lib/storage/data/external/AwsClient.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const { S3Client,
1616
GetBucketVersioningCommand,
1717
NoSuchKey,
1818
NotFound } = require('@aws-sdk/client-s3');
19-
const { HttpRequest } = require('@smithy/protocol-http');
2019
const { Upload } = require('@aws-sdk/lib-storage');
2120
const werelogs = require('werelogs');
2221
const { Readable } = require('stream');
@@ -52,14 +51,7 @@ class AwsClient {
5251

5352
setup(cb) {
5453
const callback = typeof cb === 'function' ? cb : () => {};
55-
let settled = false;
56-
const done = err => {
57-
if (settled) {
58-
return;
59-
}
60-
settled = true;
61-
callback(err);
62-
};
54+
const done = jsutil.once(callback);
6355
let usEast1Client;
6456
try {
6557
usEast1Client = new S3Client({

lib/storage/data/external/GCP/GcpApis/mpuHelper.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ class MpuHelper {
198198
return next();
199199
});
200200
}, err => callback(err));
201-
};
202-
201+
};
203202
return async.waterfall([
204203
_getObjectVersions,
205204
_deleteObjects,

0 commit comments

Comments
 (0)