@adobe/spacecat-shared-http-utils 1.6.6 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [@adobe/spacecat-shared-http-utils-v1.6.7](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-http-utils-v1.6.6...@adobe/spacecat-shared-http-utils-v1.6.7) (2024-08-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add try-catch block to authentication manager ([#336](https://github.com/adobe/spacecat-shared/issues/336)) ([a6cf629](https://github.com/adobe/spacecat-shared/commit/a6cf6290e4b8330956fdbb80406523853b0a7b51))
7
+
1
8
  # [@adobe/spacecat-shared-http-utils-v1.6.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-http-utils-v1.6.5...@adobe/spacecat-shared-http-utils-v1.6.6) (2024-08-19)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-http-utils",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "description": "Shared modules of the Spacecat Services - HTTP Utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -45,8 +45,13 @@ export default class AuthenticationManager {
45
45
  for (const handler of this.handlers) {
46
46
  this.log.debug(`Trying to authenticate with ${handler.name}`);
47
47
 
48
- // eslint-disable-next-line no-await-in-loop
49
- const authInfo = await handler.checkAuth(request, context);
48
+ let authInfo;
49
+ try {
50
+ // eslint-disable-next-line no-await-in-loop
51
+ authInfo = await handler.checkAuth(request, context);
52
+ } catch (error) {
53
+ this.log.error(`Failed to authenticate with ${handler.name}:`, error);
54
+ }
50
55
 
51
56
  if (isObject(authInfo)) {
52
57
  this.log.info(`Authenticated with ${handler.name}`);
@@ -29,17 +29,14 @@ export default class ScopedApiKeyHandler extends AbstractHandler {
29
29
  if (!dataAccess) {
30
30
  throw new Error('Data access is required');
31
31
  }
32
- this.log('Checking for API key in the request headers', 'debug');
33
32
 
34
33
  const apiKeyFromHeader = headers['x-api-key'];
35
34
  if (!hasText(apiKeyFromHeader)) {
36
35
  return null;
37
36
  }
38
37
 
39
- this.log(`Checking for API key: ${apiKeyFromHeader}`, 'debug');
40
38
  // Keys are stored by their hash, so we need to hash the key to look it up
41
39
  const hashedApiKey = hashWithSHA256(apiKeyFromHeader);
42
- this.log(`Checking for API key with hash: ${hashedApiKey}`, 'debug');
43
40
  const apiKeyEntity = await dataAccess.getApiKeyByHashedApiKey(hashedApiKey);
44
41
 
45
42
  if (!apiKeyEntity) {
@@ -52,7 +49,6 @@ export default class ScopedApiKeyHandler extends AbstractHandler {
52
49
  const authInfo = new AuthInfo()
53
50
  .withProfile(apiKeyEntity) // Include the API key entity as the profile
54
51
  .withType(this.name);
55
- this.log('Successfully constructed authInfo object', 'debug');
56
52
 
57
53
  // Verify that the api key has not expired or been revoked
58
54
  const now = new Date().toISOString();