@squiz/dx-common-lib 1.71.0 → 1.72.0
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 +12 -0
- package/lib/cache/applyDefaultRulesToCacheControlObject.d.ts +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/secret-api-key-service/SecretApiKeyService.d.ts +52 -0
- package/lib/secret-api-key-service/SecretApiKeyService.js +92 -0
- package/lib/secret-api-key-service/SecretApiKeyService.js.map +1 -0
- package/lib/secret-api-key-service/SecretApiKeyService.spec.d.ts +1 -0
- package/lib/secret-api-key-service/SecretApiKeyService.spec.js +317 -0
- package/lib/secret-api-key-service/SecretApiKeyService.spec.js.map +1 -0
- package/package.json +6 -6
- package/src/index.ts +1 -0
- package/src/secret-api-key-service/SecretApiKeyService.spec.ts +413 -0
- package/src/secret-api-key-service/SecretApiKeyService.ts +121 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CacheControl } from './parseCacheControl';
|
|
2
2
|
export declare function applyDefaultRulesToCacheControlObject(cacheControlInput: CacheControl): {
|
|
3
|
-
[
|
|
3
|
+
[key: string]: string | number | boolean | undefined;
|
|
4
4
|
'max-age'?: number;
|
|
5
5
|
's-maxage'?: number;
|
|
6
6
|
'min-fresh'?: number;
|
package/lib/index.d.ts
CHANGED
|
@@ -15,3 +15,4 @@ export * from './edge-components-secret-key-service/ProductionEdgeComponentsSecr
|
|
|
15
15
|
export * from './edge-components-secret-key-service/EdgeComponentsSecretKeyService';
|
|
16
16
|
export * from './edge-components-secret-key-service/getEdgeComponentsSecretService';
|
|
17
17
|
export * from './esi-mac-token-generator/EsiMacTokenGenerator';
|
|
18
|
+
export * from './secret-api-key-service/SecretApiKeyService';
|
package/lib/index.js
CHANGED
|
@@ -31,4 +31,5 @@ __exportStar(require("./edge-components-secret-key-service/ProductionEdgeCompone
|
|
|
31
31
|
__exportStar(require("./edge-components-secret-key-service/EdgeComponentsSecretKeyService"), exports);
|
|
32
32
|
__exportStar(require("./edge-components-secret-key-service/getEdgeComponentsSecretService"), exports);
|
|
33
33
|
__exportStar(require("./esi-mac-token-generator/EsiMacTokenGenerator"), exports);
|
|
34
|
+
__exportStar(require("./secret-api-key-service/SecretApiKeyService"), exports);
|
|
34
35
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,0CAAwB;AACxB,yCAAuB;AACvB,qDAAmC;AACnC,iEAA+C;AAC/C,+DAA6C;AAC7C,+EAA6D;AAC7D,+EAA6D;AAC7D,gFAA8D;AAC9D,wEAAsD;AACtD,0CAAwB;AACxB,+CAA6B;AAC7B,iHAA+F;AAC/F,gHAA8F;AAC9F,sGAAoF;AACpF,sGAAoF;AACpF,iFAA+D"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,0CAAwB;AACxB,yCAAuB;AACvB,qDAAmC;AACnC,iEAA+C;AAC/C,+DAA6C;AAC7C,+EAA6D;AAC7D,+EAA6D;AAC7D,gFAA8D;AAC9D,wEAAsD;AACtD,0CAAwB;AACxB,+CAA6B;AAC7B,iHAA+F;AAC/F,gHAA8F;AAC9F,sGAAoF;AACpF,sGAAoF;AACpF,iFAA+D;AAC/D,+EAA6D"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @file SecretApiKeyService.ts
|
|
3
|
+
* @description Retrieves API keys from AWS Secrets Manager.
|
|
4
|
+
* @author Squiz
|
|
5
|
+
* @copyright 2025 Squiz
|
|
6
|
+
* @license MIT
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Interface for the SecretApiKeyService
|
|
10
|
+
*/
|
|
11
|
+
export interface SecretApiKeyServiceInterface {
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the API key from AWS Secrets Manager.
|
|
14
|
+
* Expects the secret to be stored as JSON with an 'apikey' field.
|
|
15
|
+
*
|
|
16
|
+
* @returns The API key string
|
|
17
|
+
*/
|
|
18
|
+
getApiKey(): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Clears the cached API key (useful for testing)
|
|
21
|
+
*/
|
|
22
|
+
clearCache(): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Service for retrieving API keys from AWS Secrets Manager.
|
|
26
|
+
* Expects the secret to be stored as JSON with an 'apikey' field.
|
|
27
|
+
*
|
|
28
|
+
* @see https://squizgroup.atlassian.net/wiki/spaces/PRODUCT/pages/3029827767/Service+Keys
|
|
29
|
+
*/
|
|
30
|
+
export declare class SecretApiKeyService implements SecretApiKeyServiceInterface {
|
|
31
|
+
private readonly secretName;
|
|
32
|
+
private readonly region;
|
|
33
|
+
private cachedApiKey;
|
|
34
|
+
/**
|
|
35
|
+
* Constructor for SecretApiKeyService
|
|
36
|
+
* @param secretName The name/ARN of the secret in AWS Secrets Manager
|
|
37
|
+
* @param region AWS region
|
|
38
|
+
*/
|
|
39
|
+
constructor(secretName: string, region: string);
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves the API key from AWS Secrets Manager.
|
|
42
|
+
* Expects the secret to be stored as JSON with an 'apikey' field.
|
|
43
|
+
*
|
|
44
|
+
* @returns The API key string
|
|
45
|
+
*/
|
|
46
|
+
getApiKey(): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Clears the cached API key and client (useful for testing)
|
|
49
|
+
* @returns void
|
|
50
|
+
*/
|
|
51
|
+
clearCache(): void;
|
|
52
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* @file SecretApiKeyService.ts
|
|
4
|
+
* @description Retrieves API keys from AWS Secrets Manager.
|
|
5
|
+
* @author Squiz
|
|
6
|
+
* @copyright 2025 Squiz
|
|
7
|
+
* @license MIT
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SecretApiKeyService = void 0;
|
|
11
|
+
// External
|
|
12
|
+
const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
|
|
13
|
+
/**
|
|
14
|
+
* Service for retrieving API keys from AWS Secrets Manager.
|
|
15
|
+
* Expects the secret to be stored as JSON with an 'apikey' field.
|
|
16
|
+
*
|
|
17
|
+
* @see https://squizgroup.atlassian.net/wiki/spaces/PRODUCT/pages/3029827767/Service+Keys
|
|
18
|
+
*/
|
|
19
|
+
class SecretApiKeyService {
|
|
20
|
+
/**
|
|
21
|
+
* Constructor for SecretApiKeyService
|
|
22
|
+
* @param secretName The name/ARN of the secret in AWS Secrets Manager
|
|
23
|
+
* @param region AWS region
|
|
24
|
+
*/
|
|
25
|
+
constructor(secretName, region) {
|
|
26
|
+
this.secretName = secretName;
|
|
27
|
+
this.region = region;
|
|
28
|
+
this.cachedApiKey = undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves the API key from AWS Secrets Manager.
|
|
32
|
+
* Expects the secret to be stored as JSON with an 'apikey' field.
|
|
33
|
+
*
|
|
34
|
+
* @returns The API key string
|
|
35
|
+
*/
|
|
36
|
+
async getApiKey() {
|
|
37
|
+
// Return cached value if available
|
|
38
|
+
if (this.cachedApiKey) {
|
|
39
|
+
return this.cachedApiKey;
|
|
40
|
+
}
|
|
41
|
+
const secretClient = new client_secrets_manager_1.SecretsManagerClient({ region: this.region });
|
|
42
|
+
try {
|
|
43
|
+
// Retrieve the secret from AWS Secrets Manager
|
|
44
|
+
const command = new client_secrets_manager_1.GetSecretValueCommand({ SecretId: this.secretName });
|
|
45
|
+
const response = await secretClient.send(command);
|
|
46
|
+
// Check if the secret has a SecretString value
|
|
47
|
+
if (!response.SecretString) {
|
|
48
|
+
throw new Error(`Secret ${this.secretName} has no SecretString value`);
|
|
49
|
+
}
|
|
50
|
+
// Parse the secret JSON to extract the apikey field
|
|
51
|
+
let parsedSecret;
|
|
52
|
+
try {
|
|
53
|
+
parsedSecret = JSON.parse(response.SecretString);
|
|
54
|
+
}
|
|
55
|
+
catch (parseError) {
|
|
56
|
+
throw new Error(`Failed to parse secret as JSON. Secret value may not be valid JSON.`);
|
|
57
|
+
}
|
|
58
|
+
// Extract the apikey field from the parsed secret
|
|
59
|
+
const { apikey } = parsedSecret;
|
|
60
|
+
// Check if the apikey field is present
|
|
61
|
+
if (!apikey) {
|
|
62
|
+
const availableKeys = Object.keys(parsedSecret).join(', ');
|
|
63
|
+
throw new Error(`API key not found in secret JSON structure (expected "apikey" field). Available keys: ${availableKeys}`);
|
|
64
|
+
}
|
|
65
|
+
// Check if the apikey field is a non-empty string
|
|
66
|
+
if (typeof apikey !== 'string' || apikey.trim().length === 0) {
|
|
67
|
+
throw new Error('API key value is invalid (must be a non-empty string)');
|
|
68
|
+
}
|
|
69
|
+
// Cache the apikey
|
|
70
|
+
this.cachedApiKey = apikey;
|
|
71
|
+
// Return the apikey
|
|
72
|
+
return apikey;
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// Log the error
|
|
76
|
+
const errorMessage = `Failed to retrieve API key: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
|
77
|
+
const wrappedError = new Error(errorMessage);
|
|
78
|
+
// @ts-expect-error - cause property is not standard in all TypeScript versions
|
|
79
|
+
wrappedError.cause = error;
|
|
80
|
+
throw wrappedError;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Clears the cached API key and client (useful for testing)
|
|
85
|
+
* @returns void
|
|
86
|
+
*/
|
|
87
|
+
clearCache() {
|
|
88
|
+
this.cachedApiKey = undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.SecretApiKeyService = SecretApiKeyService;
|
|
92
|
+
//# sourceMappingURL=SecretApiKeyService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SecretApiKeyService.js","sourceRoot":"","sources":["../../src/secret-api-key-service/SecretApiKeyService.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,WAAW;AACX,4EAA8F;AAoB9F;;;;;GAKG;AACH,MAAa,mBAAmB;IAK9B;;;;OAIG;IACH,YAAY,UAAkB,EAAE,MAAc;QAC5C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,SAAS;QACpB,mCAAmC;QACnC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,6CAAoB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAEvE,IAAI,CAAC;YACH,+CAA+C;YAC/C,MAAM,OAAO,GAAG,IAAI,8CAAqB,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;YACzE,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAElD,+CAA+C;YAC/C,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;gBAC3B,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,UAAU,4BAA4B,CAAC,CAAC;YACzE,CAAC;YAED,oDAAoD;YACpD,IAAI,YAAY,CAAC;YACjB,IAAI,CAAC;gBACH,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YACn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{ value: true });
|
|
3
|
+
const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
|
|
4
|
+
const SecretApiKeyService_1 = require("./SecretApiKeyService");
|
|
5
|
+
// Mock the AWS SDK
|
|
6
|
+
jest.mock('@aws-sdk/client-secrets-manager');
|
|
7
|
+
describe('SecretApiKeyService', () => {
|
|
8
|
+
let service;
|
|
9
|
+
let mockSend;
|
|
10
|
+
const mockSecretsManagerClient = client_secrets_manager_1.SecretsManagerClient;
|
|
11
|
+
let consoleLogSpy;
|
|
12
|
+
let consoleErrorSpy;
|
|
13
|
+
const mockSecretName = 'test-secret';
|
|
14
|
+
const mockRegion = 'us-east-1';
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
// Create a fresh service instance for each test
|
|
17
|
+
service = new SecretApiKeyService_1.SecretApiKeyService(mockSecretName, mockRegion);
|
|
18
|
+
// Create a fresh mock for each test
|
|
19
|
+
mockSend = jest.fn();
|
|
20
|
+
// Setup console spies
|
|
21
|
+
consoleLogSpy = jest.spyOn(console, 'log').mockImplementation();
|
|
22
|
+
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
23
|
+
// Clear and setup the mock client - make sure it always returns our mockSend
|
|
24
|
+
mockSecretsManagerClient.mockReset();
|
|
25
|
+
mockSecretsManagerClient.mockImplementation(() => ({
|
|
26
|
+
send: mockSend,
|
|
27
|
+
destroy: jest.fn(),
|
|
28
|
+
config: {},
|
|
29
|
+
}));
|
|
30
|
+
});
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
// Restore console spies
|
|
33
|
+
consoleLogSpy.mockRestore();
|
|
34
|
+
consoleErrorSpy.mockRestore();
|
|
35
|
+
jest.clearAllMocks();
|
|
36
|
+
});
|
|
37
|
+
describe('AWS Secrets Manager Retrieval', () => {
|
|
38
|
+
it('should successfully retrieve API key from Secrets Manager', async () => {
|
|
39
|
+
const mockApiKey = 'test-api-key-from-secrets';
|
|
40
|
+
const testSecretName = '/servicekeys-dev-au/feaas-metrics';
|
|
41
|
+
const testRegion = 'ap-southeast-2';
|
|
42
|
+
// Create service with specific secret name and region for this test
|
|
43
|
+
const testService = new SecretApiKeyService_1.SecretApiKeyService(testSecretName, testRegion);
|
|
44
|
+
mockSend.mockResolvedValueOnce({
|
|
45
|
+
SecretString: JSON.stringify({ apikey: mockApiKey }),
|
|
46
|
+
});
|
|
47
|
+
const result = await testService.getApiKey();
|
|
48
|
+
expect(result).toBe(mockApiKey);
|
|
49
|
+
expect(mockSecretsManagerClient).toHaveBeenCalledWith({ region: testRegion });
|
|
50
|
+
expect(mockSend).toHaveBeenCalledWith(expect.any(client_secrets_manager_1.GetSecretValueCommand));
|
|
51
|
+
});
|
|
52
|
+
it('should handle complex JSON structure with apikey field', async () => {
|
|
53
|
+
const mockApiKey = 'complex-api-key';
|
|
54
|
+
mockSend.mockResolvedValueOnce({
|
|
55
|
+
SecretString: JSON.stringify({
|
|
56
|
+
apikey: mockApiKey,
|
|
57
|
+
otherField: 'other-value',
|
|
58
|
+
metadata: { created: '2024-01-01' },
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
const result = await service.getApiKey();
|
|
62
|
+
expect(result).toBe(mockApiKey);
|
|
63
|
+
});
|
|
64
|
+
it('should handle SecretString with nested apikey value', async () => {
|
|
65
|
+
const mockApiKey = 'nested-api-key';
|
|
66
|
+
mockSend.mockResolvedValueOnce({
|
|
67
|
+
SecretString: JSON.stringify({
|
|
68
|
+
apikey: mockApiKey,
|
|
69
|
+
// Test that we extract the right field even with similar names
|
|
70
|
+
apikeys: ['wrong-key'],
|
|
71
|
+
api_key: 'also-wrong',
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
const result = await service.getApiKey();
|
|
75
|
+
expect(result).toBe(mockApiKey);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
describe('Caching Behavior', () => {
|
|
79
|
+
it('should cache API key after first successful retrieval', async () => {
|
|
80
|
+
const mockApiKey = 'cached-api-key';
|
|
81
|
+
mockSend.mockResolvedValueOnce({
|
|
82
|
+
SecretString: JSON.stringify({ apikey: mockApiKey }),
|
|
83
|
+
});
|
|
84
|
+
// First call - should hit Secrets Manager
|
|
85
|
+
const result1 = await service.getApiKey();
|
|
86
|
+
expect(result1).toBe(mockApiKey);
|
|
87
|
+
expect(mockSend).toHaveBeenCalledTimes(1);
|
|
88
|
+
// Second call - should use cache
|
|
89
|
+
const result2 = await service.getApiKey();
|
|
90
|
+
expect(result2).toBe(mockApiKey);
|
|
91
|
+
expect(mockSend).toHaveBeenCalledTimes(1); // Still only 1 call
|
|
92
|
+
});
|
|
93
|
+
it('should clear cache when clearMetricsApiKeyCache is called', async () => {
|
|
94
|
+
const mockApiKey1 = 'first-api-key';
|
|
95
|
+
const mockApiKey2 = 'second-api-key';
|
|
96
|
+
mockSend
|
|
97
|
+
.mockResolvedValueOnce({
|
|
98
|
+
SecretString: JSON.stringify({ apikey: mockApiKey1 }),
|
|
99
|
+
})
|
|
100
|
+
.mockResolvedValueOnce({
|
|
101
|
+
SecretString: JSON.stringify({ apikey: mockApiKey2 }),
|
|
102
|
+
});
|
|
103
|
+
// First retrieval
|
|
104
|
+
const result1 = await service.getApiKey();
|
|
105
|
+
expect(result1).toBe(mockApiKey1);
|
|
106
|
+
// Clear cache
|
|
107
|
+
service.clearCache();
|
|
108
|
+
// Second retrieval after cache clear - should fetch again
|
|
109
|
+
const result2 = await service.getApiKey();
|
|
110
|
+
expect(result2).toBe(mockApiKey2);
|
|
111
|
+
expect(mockSend).toHaveBeenCalledTimes(2);
|
|
112
|
+
});
|
|
113
|
+
it('should create new SecretsManagerClient for each non-cached call', async () => {
|
|
114
|
+
// This test verifies that a new client is created when cache is cleared
|
|
115
|
+
mockSend
|
|
116
|
+
.mockResolvedValueOnce({
|
|
117
|
+
SecretString: JSON.stringify({ apikey: 'key1' }),
|
|
118
|
+
})
|
|
119
|
+
.mockResolvedValueOnce({
|
|
120
|
+
SecretString: JSON.stringify({ apikey: 'key2' }),
|
|
121
|
+
});
|
|
122
|
+
await service.getApiKey();
|
|
123
|
+
service.clearCache(); // Clears API key cache
|
|
124
|
+
await service.getApiKey();
|
|
125
|
+
// The mock send should be called twice (once for each call after clearing cache)
|
|
126
|
+
expect(mockSend).toHaveBeenCalledTimes(2);
|
|
127
|
+
// SecretsManagerClient should be created twice (once per non-cached call)
|
|
128
|
+
expect(mockSecretsManagerClient).toHaveBeenCalledTimes(2);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
describe('Error Handling', () => {
|
|
132
|
+
it('should throw error when SecretString is missing', async () => {
|
|
133
|
+
const mockSecretName = 'test-secret';
|
|
134
|
+
mockSend.mockResolvedValueOnce({
|
|
135
|
+
// No SecretString property
|
|
136
|
+
SecretBinary: 'binary-data',
|
|
137
|
+
});
|
|
138
|
+
await expect(service.getApiKey()).rejects.toThrow(`Secret ${mockSecretName} has no SecretString value`);
|
|
139
|
+
});
|
|
140
|
+
it('should throw error when SecretString is not valid JSON', async () => {
|
|
141
|
+
mockSend.mockResolvedValueOnce({
|
|
142
|
+
SecretString: 'not-valid-json{',
|
|
143
|
+
});
|
|
144
|
+
await expect(service.getApiKey()).rejects.toThrow('Failed to parse secret as JSON. Secret value may not be valid JSON.');
|
|
145
|
+
});
|
|
146
|
+
it('should throw error when apikey field is missing', async () => {
|
|
147
|
+
mockSend.mockResolvedValueOnce({
|
|
148
|
+
SecretString: JSON.stringify({
|
|
149
|
+
wrongField: 'value',
|
|
150
|
+
anotherField: 'another-value',
|
|
151
|
+
}),
|
|
152
|
+
});
|
|
153
|
+
await expect(service.getApiKey()).rejects.toThrow('API key not found in secret JSON structure (expected "apikey" field). Available keys: wrongField, anotherField');
|
|
154
|
+
});
|
|
155
|
+
it('should throw error when apikey is null', async () => {
|
|
156
|
+
mockSend.mockResolvedValueOnce({
|
|
157
|
+
SecretString: JSON.stringify({ apikey: null }),
|
|
158
|
+
});
|
|
159
|
+
await expect(service.getApiKey()).rejects.toThrow('API key not found in secret JSON structure (expected "apikey" field). Available keys: apikey');
|
|
160
|
+
});
|
|
161
|
+
it('should throw error when apikey is empty string', async () => {
|
|
162
|
+
mockSend.mockResolvedValueOnce({
|
|
163
|
+
SecretString: JSON.stringify({ apikey: '' }),
|
|
164
|
+
});
|
|
165
|
+
await expect(service.getApiKey()).rejects.toThrow('API key not found in secret JSON structure (expected "apikey" field). Available keys: apikey');
|
|
166
|
+
});
|
|
167
|
+
it('should throw error when apikey is whitespace only', async () => {
|
|
168
|
+
mockSend.mockResolvedValueOnce({
|
|
169
|
+
SecretString: JSON.stringify({ apikey: ' ' }),
|
|
170
|
+
});
|
|
171
|
+
await expect(service.getApiKey()).rejects.toThrow('API key value is invalid (must be a non-empty string)');
|
|
172
|
+
});
|
|
173
|
+
it('should throw error when apikey is not a string', async () => {
|
|
174
|
+
mockSend.mockResolvedValueOnce({
|
|
175
|
+
SecretString: JSON.stringify({ apikey: 12345 }),
|
|
176
|
+
});
|
|
177
|
+
await expect(service.getApiKey()).rejects.toThrow('API key value is invalid (must be a non-empty string)');
|
|
178
|
+
});
|
|
179
|
+
it('should handle AWS SDK errors gracefully', async () => {
|
|
180
|
+
const awsError = new Error('AccessDeniedException: User is not authorized');
|
|
181
|
+
mockSend.mockRejectedValueOnce(awsError);
|
|
182
|
+
await expect(service.getApiKey()).rejects.toThrow('Failed to retrieve API key: AccessDeniedException: User is not authorized');
|
|
183
|
+
});
|
|
184
|
+
it('should throw wrapped error with details', async () => {
|
|
185
|
+
const awsError = new Error('Network error');
|
|
186
|
+
mockSend.mockRejectedValueOnce(awsError);
|
|
187
|
+
await expect(service.getApiKey()).rejects.toThrow('Failed to retrieve API key: Network error');
|
|
188
|
+
});
|
|
189
|
+
it('should include cause in thrown error', async () => {
|
|
190
|
+
const originalError = new Error('Original AWS error');
|
|
191
|
+
mockSend.mockRejectedValueOnce(originalError);
|
|
192
|
+
try {
|
|
193
|
+
await service.getApiKey();
|
|
194
|
+
fail('Should have thrown an error');
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
expect(error.message).toContain('Failed to retrieve API key');
|
|
198
|
+
expect(error.cause).toBe(originalError);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
it('should handle non-Error objects in catch block', async () => {
|
|
202
|
+
mockSend.mockRejectedValueOnce('String error');
|
|
203
|
+
await expect(service.getApiKey()).rejects.toThrow('Failed to retrieve API key: Unknown error');
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
describe('Edge Cases', () => {
|
|
207
|
+
it('should handle very long API keys', async () => {
|
|
208
|
+
const mockApiKey = 'x'.repeat(1000); // 1000 character API key
|
|
209
|
+
mockSend.mockResolvedValueOnce({
|
|
210
|
+
SecretString: JSON.stringify({ apikey: mockApiKey }),
|
|
211
|
+
});
|
|
212
|
+
const result = await service.getApiKey();
|
|
213
|
+
expect(result).toBe(mockApiKey);
|
|
214
|
+
});
|
|
215
|
+
it('should handle special characters in API key', async () => {
|
|
216
|
+
const mockApiKey = 'test-key-!@#$%^&*()_+-=[]{}|;:"<>,.?/~`';
|
|
217
|
+
mockSend.mockResolvedValueOnce({
|
|
218
|
+
SecretString: JSON.stringify({ apikey: mockApiKey }),
|
|
219
|
+
});
|
|
220
|
+
const result = await service.getApiKey();
|
|
221
|
+
expect(result).toBe(mockApiKey);
|
|
222
|
+
});
|
|
223
|
+
it('should handle unicode characters in API key', async () => {
|
|
224
|
+
const mockApiKey = 'test-key-你好-مرحبا-🔑';
|
|
225
|
+
mockSend.mockResolvedValueOnce({
|
|
226
|
+
SecretString: JSON.stringify({ apikey: mockApiKey }),
|
|
227
|
+
});
|
|
228
|
+
const result = await service.getApiKey();
|
|
229
|
+
expect(result).toBe(mockApiKey);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
describe('Integration Scenarios', () => {
|
|
233
|
+
it('should handle rapid concurrent calls efficiently using cache', async () => {
|
|
234
|
+
const mockApiKey = 'concurrent-key';
|
|
235
|
+
// Set up response for concurrent calls
|
|
236
|
+
mockSend.mockResolvedValue({
|
|
237
|
+
SecretString: JSON.stringify({ apikey: mockApiKey }),
|
|
238
|
+
});
|
|
239
|
+
// Make multiple concurrent calls
|
|
240
|
+
const promises = Array(10)
|
|
241
|
+
.fill(null)
|
|
242
|
+
.map(() => service.getApiKey());
|
|
243
|
+
const results = await Promise.all(promises);
|
|
244
|
+
// All should return the same key
|
|
245
|
+
expect(results).toEqual(Array(10).fill(mockApiKey));
|
|
246
|
+
// When calls are truly concurrent, they all execute before any caching happens
|
|
247
|
+
// This is expected behavior - in real use, subsequent calls would benefit from caching
|
|
248
|
+
expect(mockSend).toHaveBeenCalled();
|
|
249
|
+
// Test that subsequent calls use the cache
|
|
250
|
+
const cachedResult = await service.getApiKey();
|
|
251
|
+
expect(cachedResult).toBe(mockApiKey);
|
|
252
|
+
// The total calls should be from the concurrent batch plus no more for the cached call
|
|
253
|
+
const initialCallCount = mockSend.mock.calls.length;
|
|
254
|
+
expect(initialCallCount).toBeGreaterThanOrEqual(1);
|
|
255
|
+
expect(initialCallCount).toBeLessThanOrEqual(10);
|
|
256
|
+
});
|
|
257
|
+
it('should work with different secret name formats', async () => {
|
|
258
|
+
const testCases = [
|
|
259
|
+
'/servicekeys-dev-au/feaas-metrics',
|
|
260
|
+
'servicekeys-prod-us/metrics-api',
|
|
261
|
+
'arn:aws:secretsmanager:us-east-1:123456789:secret:metrics-key-abcdef',
|
|
262
|
+
];
|
|
263
|
+
for (const secretName of testCases) {
|
|
264
|
+
const testService = new SecretApiKeyService_1.SecretApiKeyService(secretName, 'us-east-1');
|
|
265
|
+
mockSend.mockResolvedValueOnce({
|
|
266
|
+
SecretString: JSON.stringify({ apikey: `key-for-${secretName}` }),
|
|
267
|
+
});
|
|
268
|
+
const result = await testService.getApiKey();
|
|
269
|
+
expect(result).toBe(`key-for-${secretName}`);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
it('should work with different AWS regions', async () => {
|
|
273
|
+
// Set up the mock response
|
|
274
|
+
mockSend.mockResolvedValue({
|
|
275
|
+
SecretString: JSON.stringify({ apikey: 'key-for-region' }),
|
|
276
|
+
});
|
|
277
|
+
// Test with a specific region
|
|
278
|
+
const regionService = new SecretApiKeyService_1.SecretApiKeyService('test-secret', 'ap-southeast-2');
|
|
279
|
+
const result = await regionService.getApiKey();
|
|
280
|
+
expect(result).toBe('key-for-region');
|
|
281
|
+
// Verify the client was created (even if it was cached from another test)
|
|
282
|
+
expect(mockSecretsManagerClient).toHaveBeenCalled();
|
|
283
|
+
// Verify the send method was called with a command
|
|
284
|
+
expect(mockSend).toHaveBeenCalled();
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
describe('Console Logging', () => {
|
|
288
|
+
it('should log both retrieval and success messages', async () => {
|
|
289
|
+
const mockApiKey = 'test-key';
|
|
290
|
+
const testSecretName = 'my-secret';
|
|
291
|
+
const testRegion = 'us-west-2';
|
|
292
|
+
const logService = new SecretApiKeyService_1.SecretApiKeyService(testSecretName, testRegion);
|
|
293
|
+
mockSend.mockResolvedValueOnce({
|
|
294
|
+
SecretString: JSON.stringify({ apikey: mockApiKey }),
|
|
295
|
+
});
|
|
296
|
+
await logService.getApiKey();
|
|
297
|
+
// Just verify the service was called and returned the key
|
|
298
|
+
expect(mockSend).toHaveBeenCalledWith(expect.any(client_secrets_manager_1.GetSecretValueCommand));
|
|
299
|
+
});
|
|
300
|
+
it('should not call AWS when using cached value', async () => {
|
|
301
|
+
const mockApiKey = 'cached-key';
|
|
302
|
+
mockSend.mockResolvedValueOnce({
|
|
303
|
+
SecretString: JSON.stringify({ apikey: mockApiKey }),
|
|
304
|
+
});
|
|
305
|
+
// First call - should call AWS
|
|
306
|
+
await service.getApiKey();
|
|
307
|
+
// Clear the mock call counts
|
|
308
|
+
mockSend.mockClear();
|
|
309
|
+
mockSecretsManagerClient.mockClear();
|
|
310
|
+
// Second call - should use cache and not call AWS
|
|
311
|
+
await service.getApiKey();
|
|
312
|
+
expect(mockSend).not.toHaveBeenCalled();
|
|
313
|
+
expect(mockSecretsManagerClient).not.toHaveBeenCalled();
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
//# sourceMappingURL=SecretApiKeyService.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SecretApiKeyService.spec.js","sourceRoot":"","sources":["../../src/secret-api-key-service/SecretApiKeyService.spec.ts"],"names":[],"mappings":";;AAAA,4EAA8F;AAC9F,+DAA4D;AAE5D,mBAAmB;AACnB,IAAI,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAE7C,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,IAAI,OAA4B,CAAC;IACjC,IAAI,QAAmB,CAAC;IACxB,MAAM,wBAAwB,GAAG,6CAAqE,CAAC;IACvG,IAAI,aAA+B,CAAC;IACpC,IAAI,eAAiC,CAAC;IACtC,MAAM,cAAc,GAAG,aAAa,CAAC;IACrC,MAAM,UAAU,GAAG,WAAW,CAAC;IAE/B,UAAU,CAAC,GAAG,EAAE;QACd,gDAAgD;QAChD,OAAO,GAAG,IAAI,yCAAmB,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAE9D,oCAAoC;QACpC,QAAQ,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAErB,sBAAsB;QACtB,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,kBAAkB,EAAE,CAAC;QAChE,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,EAAE,CAAC;QAEpE,6EAA6E;QAC7E,wBAAwB,CAAC,SAAS,EAAE,CAAC;QACrC,wBAAwB,CAAC,kBAAkB,CACzC,GAAG,EAAE,CACH,CAAC;YACC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;YAClB,MAAM,EAAE,EAAE;SACH,CAAA,CACZ,CAAC;IACJ,CAAC,CAAC,CA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C,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;YACxC,MAAM,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squiz/dx-common-lib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.72.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -18,20 +18,20 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@aws-sdk/client-secrets-manager": "3.651.1",
|
|
20
20
|
"@squiz/dx-logger-lib": "^1.65.1",
|
|
21
|
-
"archiver": "
|
|
21
|
+
"archiver": "7.0.1",
|
|
22
22
|
"escape-string-regexp": "4.0.0",
|
|
23
23
|
"fs-extra": "11.1.0",
|
|
24
24
|
"html-entities": "^2.4.0",
|
|
25
25
|
"lodash.clonedeep": "4.5.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/archiver": "
|
|
29
|
-
"@types/express": "4.17.
|
|
28
|
+
"@types/archiver": "6.0.3",
|
|
29
|
+
"@types/express": "4.17.23",
|
|
30
30
|
"@types/fs-extra": "11.0.1",
|
|
31
31
|
"@types/jest": "28.1.8",
|
|
32
|
-
"@types/lodash.clonedeep": "4.5.
|
|
32
|
+
"@types/lodash.clonedeep": "4.5.9",
|
|
33
33
|
"@types/node": "22.10.5",
|
|
34
|
-
"dotenv": "16.
|
|
34
|
+
"dotenv": "16.6.1",
|
|
35
35
|
"jest": "29.4.1",
|
|
36
36
|
"ts-jest": "29.0.5",
|
|
37
37
|
"typescript": "^5.7.2"
|
package/src/index.ts
CHANGED
|
@@ -15,3 +15,4 @@ export * from './edge-components-secret-key-service/ProductionEdgeComponentsSecr
|
|
|
15
15
|
export * from './edge-components-secret-key-service/EdgeComponentsSecretKeyService';
|
|
16
16
|
export * from './edge-components-secret-key-service/getEdgeComponentsSecretService';
|
|
17
17
|
export * from './esi-mac-token-generator/EsiMacTokenGenerator';
|
|
18
|
+
export * from './secret-api-key-service/SecretApiKeyService';
|