@adobe/spacecat-shared-gpt-client 1.5.13 → 1.5.15

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,17 @@
1
+ # [@adobe/spacecat-shared-gpt-client-v1.5.15](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-gpt-client-v1.5.14...@adobe/spacecat-shared-gpt-client-v1.5.15) (2025-06-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * sanitize headers before logging ([#810](https://github.com/adobe/spacecat-shared/issues/810)) ([775168f](https://github.com/adobe/spacecat-shared/commit/775168fa013c615c53ae936805e81c42a6c349c2))
7
+
8
+ # [@adobe/spacecat-shared-gpt-client-v1.5.14](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-gpt-client-v1.5.13...@adobe/spacecat-shared-gpt-client-v1.5.14) (2025-05-31)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#779](https://github.com/adobe/spacecat-shared/issues/779)) ([07f8cce](https://github.com/adobe/spacecat-shared/commit/07f8cce73e33bfb9c61fe14f2ef28012b872437d))
14
+
1
15
  # [@adobe/spacecat-shared-gpt-client-v1.5.13](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-gpt-client-v1.5.12...@adobe/spacecat-shared-gpt-client-v1.5.13) (2025-05-26)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-gpt-client",
3
- "version": "1.5.13",
3
+ "version": "1.5.15",
4
4
  "description": "Shared modules of the Spacecat Services - GPT Client",
5
5
  "type": "module",
6
6
  "engines": {
@@ -42,7 +42,7 @@
42
42
  "devDependencies": {
43
43
  "chai": "5.2.0",
44
44
  "chai-as-promised": "8.0.1",
45
- "nock": "14.0.4",
45
+ "nock": "14.0.5",
46
46
  "sinon": "20.0.0",
47
47
  "sinon-chai": "4.0.0",
48
48
  "typescript": "5.8.3"
@@ -14,7 +14,7 @@ import { createUrl } from '@adobe/fetch';
14
14
  import { ImsClient } from '@adobe/spacecat-shared-ims-client';
15
15
  import { hasText, isObject, isValidUrl } from '@adobe/spacecat-shared-utils';
16
16
 
17
- import { fetch as httpFetch } from '../utils.js';
17
+ import { fetch as httpFetch, sanitizeHeaders } from '../utils.js';
18
18
 
19
19
  const USER_ROLE_IMAGE_URL_TYPE = 'image_url';
20
20
  const USER_ROLE_TEXT_TYPE = 'text';
@@ -125,7 +125,7 @@ export default class FirefallClient {
125
125
  'x-gw-ims-org-id': this.config.imsOrg,
126
126
  };
127
127
 
128
- this.log.info(`URL: ${url}, Headers: ${JSON.stringify(headers)}`);
128
+ this.log.info(`[Firefall API Call]]: ${url}, Headers: ${JSON.stringify(sanitizeHeaders(headers))}`);
129
129
 
130
130
  const response = await httpFetch(url, {
131
131
  method: 'POST',
@@ -158,7 +158,7 @@ export default class FirefallClient {
158
158
  'x-gw-ims-org-id': this.config.imsOrg,
159
159
  };
160
160
 
161
- this.log.info(`URL: ${url}, Headers: ${JSON.stringify(headers)}`);
161
+ this.log.info(`URL: ${url}, Headers: ${JSON.stringify(sanitizeHeaders(headers))}`);
162
162
 
163
163
  const response = await httpFetch(
164
164
  createUrl(url),
@@ -314,7 +314,6 @@ export default class FirefallClient {
314
314
  const result = output.capability_response.generations[0][0];
315
315
 
316
316
  this.log.info(`Generation Info: ${JSON.stringify(result.generation_info)}`);
317
- this.log.info(`LLM Info: ${JSON.stringify(output.capability_response.llm_output)}`);
318
317
 
319
318
  return result.text;
320
319
  } catch (error) {
@@ -18,6 +18,8 @@ import {
18
18
  tracingFetch,
19
19
  } from '@adobe/spacecat-shared-utils';
20
20
 
21
+ import { sanitizeHeaders } from '../utils.js';
22
+
21
23
  export default class GenvarClient {
22
24
  static createFrom(context) {
23
25
  const { log = console } = context;
@@ -84,7 +86,7 @@ export default class GenvarClient {
84
86
  'x-gw-ims-org-id': this.config.imsOrg,
85
87
  };
86
88
 
87
- this.log.info(`[Genvar API Call] URL: ${url}, Headers: ${JSON.stringify({ ...headers, Authorization: '***' })}`);
89
+ this.log.info(`[Genvar API Call] URL: ${url}, Headers: ${JSON.stringify(sanitizeHeaders(headers))}`);
88
90
 
89
91
  let response;
90
92
  let responseJsonObj;
@@ -121,7 +123,7 @@ export default class GenvarClient {
121
123
  'x-gw-ims-org-id': this.config.imsOrg,
122
124
  };
123
125
 
124
- this.log.info(`[Genvar API Call] URL: ${url}, Headers: ${JSON.stringify({ ...headers, Authorization: '***' })}`);
126
+ this.log.info(`[Genvar API Call] URL: ${url}, Headers: ${JSON.stringify(sanitizeHeaders(headers))}`);
125
127
 
126
128
  let response;
127
129
  try {
package/src/utils.js CHANGED
@@ -16,3 +16,11 @@ import { context as h2, h1 } from '@adobe/fetch';
16
16
  export const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1
17
17
  ? h1()
18
18
  : h2();
19
+
20
+ export function sanitizeHeaders(headers) {
21
+ return {
22
+ ...headers,
23
+ ...(headers.Authorization && { Authorization: '***' }),
24
+ ...(headers['x-api-key'] && { 'x-api-key': '****' }),
25
+ };
26
+ }