@quiltt/core 5.1.0 → 5.1.1

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,5 +1,13 @@
1
1
  # @quiltt/core
2
2
 
3
+ ## 5.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#419](https://github.com/quiltt/quiltt-js/pull/419) [`5f5846a`](https://github.com/quiltt/quiltt-js/commit/5f5846a1d807f517c156bbebe60d639256a7db1e) Thanks [@rubendinho](https://github.com/rubendinho)! - Update telemetry headers
8
+
9
+ - [#421](https://github.com/quiltt/quiltt-js/pull/421) [`0756cb5`](https://github.com/quiltt/quiltt-js/commit/0756cb59d3fb55208cc2d1bdc10a2a8d5b66b595) Thanks [@sirwolfgang](https://github.com/sirwolfgang)! - Ensure custom Headers are passed to all API calls
10
+
3
11
  ## 5.1.0
4
12
 
5
13
  ### Minor Changes
@@ -187,22 +187,21 @@ const TerminatingLink = new core.ApolloLink(()=>{
187
187
  return `${major}.${minor}.${patch}`;
188
188
  };
189
189
  /**
190
- * Generates a User-Agent string following standard format
190
+ * Generates a custom SDK Agent string following standard format
191
191
  * Format: Quiltt/<version> (<platform-info>)
192
- */ const getUserAgent = (sdkVersion, platformInfo)=>{
192
+ */ const getSDKAgent = (sdkVersion, platformInfo)=>{
193
193
  return `Quiltt/${sdkVersion} (${platformInfo})`;
194
194
  };
195
195
 
196
196
  const createVersionLink = (platformInfo)=>{
197
197
  const versionNumber = extractVersionNumber(index_cjs.version);
198
- const userAgent = getUserAgent(versionNumber, platformInfo);
198
+ const sdkAgent = getSDKAgent(versionNumber, platformInfo);
199
199
  return new core.ApolloLink((operation, forward)=>{
200
200
  operation.setContext(({ headers = {} })=>({
201
201
  headers: {
202
202
  ...headers,
203
203
  'Quiltt-Client-Version': index_cjs.version,
204
- 'Quiltt-SDK-Agent': userAgent,
205
- 'User-Agent': userAgent
204
+ 'Quiltt-SDK-Agent': sdkAgent
206
205
  }
207
206
  }));
208
207
  return forward(operation);
@@ -182,22 +182,21 @@ const TerminatingLink = new ApolloLink(()=>{
182
182
  return `${major}.${minor}.${patch}`;
183
183
  };
184
184
  /**
185
- * Generates a User-Agent string following standard format
185
+ * Generates a custom SDK Agent string following standard format
186
186
  * Format: Quiltt/<version> (<platform-info>)
187
- */ const getUserAgent = (sdkVersion, platformInfo)=>{
187
+ */ const getSDKAgent = (sdkVersion, platformInfo)=>{
188
188
  return `Quiltt/${sdkVersion} (${platformInfo})`;
189
189
  };
190
190
 
191
191
  const createVersionLink = (platformInfo)=>{
192
192
  const versionNumber = extractVersionNumber(version);
193
- const userAgent = getUserAgent(versionNumber, platformInfo);
193
+ const sdkAgent = getSDKAgent(versionNumber, platformInfo);
194
194
  return new ApolloLink((operation, forward)=>{
195
195
  operation.setContext(({ headers = {} })=>({
196
196
  headers: {
197
197
  ...headers,
198
198
  'Quiltt-Client-Version': version,
199
- 'Quiltt-SDK-Agent': userAgent,
200
- 'User-Agent': userAgent
199
+ 'Quiltt-SDK-Agent': sdkAgent
201
200
  }
202
201
  }));
203
202
  return forward(operation);
@@ -7,6 +7,32 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
7
 
8
8
  var crossfetch__default = /*#__PURE__*/_interopDefault(crossfetch);
9
9
 
10
+ /**
11
+ * Extracts version number from formatted version string
12
+ * @param formattedVersion - Formatted version like "@quiltt/core: v4.5.1"
13
+ * @returns Version number like "4.5.1" or "unknown" if not found
14
+ */ const extractVersionNumber = (formattedVersion)=>{
15
+ // Find the 'v' prefix and extract version after it
16
+ const vIndex = formattedVersion.indexOf('v');
17
+ if (vIndex === -1) return 'unknown';
18
+ const versionPart = formattedVersion.substring(vIndex + 1);
19
+ const parts = versionPart.split('.');
20
+ // Validate we have at least major.minor.patch
21
+ if (parts.length < 3) return 'unknown';
22
+ // Extract numeric parts (handles cases like "4.5.1-beta")
23
+ const major = parts[0].match(/^\d+/)?.[0];
24
+ const minor = parts[1].match(/^\d+/)?.[0];
25
+ const patch = parts[2].match(/^\d+/)?.[0];
26
+ if (!major || !minor || !patch) return 'unknown';
27
+ return `${major}.${minor}.${patch}`;
28
+ };
29
+ /**
30
+ * Generates a custom SDK Agent string following standard format
31
+ * Format: Quiltt/<version> (<platform-info>)
32
+ */ const getSDKAgent = (sdkVersion, platformInfo)=>{
33
+ return `Quiltt/${sdkVersion} (${platformInfo})`;
34
+ };
35
+
10
36
  // Use `cross-fetch` only if `fetch` is not available on the `globalThis` object
11
37
  const effectiveFetch = typeof fetch === 'undefined' ? crossfetch__default.default : fetch;
12
38
  const RETRY_DELAY = 150 // ms
@@ -60,8 +86,7 @@ var AuthStrategies = /*#__PURE__*/ function(AuthStrategies) {
60
86
  }({});
61
87
  // https://www.quiltt.dev/api-reference/auth
62
88
  class AuthAPI {
63
- // @todo userAgent: string | undefined - allow SDKs and callers to set a userAgent
64
- constructor(clientId){
89
+ constructor(clientId, customHeaders, sdkAgent = getSDKAgent(extractVersionNumber(index_cjs.version), 'Unknown')){
65
90
  /**
66
91
  * Response Statuses:
67
92
  * - 200: OK -> Session is Valid
@@ -114,6 +139,13 @@ class AuthAPI {
114
139
  const headers = new Headers();
115
140
  headers.set('Content-Type', 'application/json');
116
141
  headers.set('Accept', 'application/json');
142
+ headers.set('Quiltt-SDK-Agent', this.sdkAgent);
143
+ // Apply custom headers
144
+ if (this.customHeaders) {
145
+ Object.entries(this.customHeaders).forEach(([key, value])=>{
146
+ headers.set(key, value);
147
+ });
148
+ }
117
149
  if (token) {
118
150
  headers.set('Authorization', `Bearer ${token}`);
119
151
  }
@@ -136,37 +168,13 @@ class AuthAPI {
136
168
  };
137
169
  };
138
170
  this.clientId = clientId;
171
+ this.customHeaders = customHeaders;
172
+ this.sdkAgent = sdkAgent;
139
173
  }
140
174
  }
141
175
 
142
- /**
143
- * Extracts version number from formatted version string
144
- * @param formattedVersion - Formatted version like "@quiltt/core: v4.5.1"
145
- * @returns Version number like "4.5.1" or "unknown" if not found
146
- */ const extractVersionNumber = (formattedVersion)=>{
147
- // Find the 'v' prefix and extract version after it
148
- const vIndex = formattedVersion.indexOf('v');
149
- if (vIndex === -1) return 'unknown';
150
- const versionPart = formattedVersion.substring(vIndex + 1);
151
- const parts = versionPart.split('.');
152
- // Validate we have at least major.minor.patch
153
- if (parts.length < 3) return 'unknown';
154
- // Extract numeric parts (handles cases like "4.5.1-beta")
155
- const major = parts[0].match(/^\d+/)?.[0];
156
- const minor = parts[1].match(/^\d+/)?.[0];
157
- const patch = parts[2].match(/^\d+/)?.[0];
158
- if (!major || !minor || !patch) return 'unknown';
159
- return `${major}.${minor}.${patch}`;
160
- };
161
- /**
162
- * Generates a User-Agent string following standard format
163
- * Format: Quiltt/<version> (<platform-info>)
164
- */ const getUserAgent = (sdkVersion, platformInfo)=>{
165
- return `Quiltt/${sdkVersion} (${platformInfo})`;
166
- };
167
-
168
176
  class ConnectorsAPI {
169
- constructor(clientId, userAgent = getUserAgent(extractVersionNumber(index_cjs.version), 'Unknown')){
177
+ constructor(clientId, sdkAgent = getSDKAgent(extractVersionNumber(index_cjs.version), 'Unknown'), customHeaders){
170
178
  /**
171
179
  * Response Statuses:
172
180
  * - 200: OK -> Institutions Found
@@ -207,9 +215,16 @@ class ConnectorsAPI {
207
215
  const headers = new Headers();
208
216
  headers.set('Content-Type', 'application/json');
209
217
  headers.set('Accept', 'application/json');
210
- headers.set('User-Agent', this.userAgent);
211
- headers.set('Quiltt-SDK-Agent', this.userAgent);
212
- headers.set('Authorization', `Bearer ${token}`);
218
+ headers.set('Quiltt-SDK-Agent', this.sdkAgent);
219
+ // Apply custom headers
220
+ if (this.customHeaders) {
221
+ Object.entries(this.customHeaders).forEach(([key, value])=>{
222
+ headers.set(key, value);
223
+ });
224
+ }
225
+ if (token) {
226
+ headers.set('Authorization', `Bearer ${token}`);
227
+ }
213
228
  return {
214
229
  headers,
215
230
  validateStatus: this.validateStatus,
@@ -218,7 +233,8 @@ class ConnectorsAPI {
218
233
  };
219
234
  this.validateStatus = (status)=>status < 500 && status !== 429;
220
235
  this.clientId = clientId;
221
- this.userAgent = userAgent;
236
+ this.sdkAgent = sdkAgent;
237
+ this.customHeaders = customHeaders;
222
238
  }
223
239
  }
224
240
 
@@ -50,7 +50,15 @@ type SessionResponse = FetchResponse<SessionData>;
50
50
  declare class AuthAPI {
51
51
  /** The Connector ID, required for identify & authenticate calls */
52
52
  clientId: string | undefined;
53
- constructor(clientId?: string | undefined);
53
+ /** The SDK Agent string for telemetry */
54
+ sdkAgent: string;
55
+ /**
56
+ * Custom headers to include with every request.
57
+ * For Quiltt internal usage. Not intended for public use.
58
+ * @internal
59
+ */
60
+ customHeaders: Record<string, string> | undefined;
61
+ constructor(clientId?: string | undefined, customHeaders?: Record<string, string>, sdkAgent?: string);
54
62
  /**
55
63
  * Response Statuses:
56
64
  * - 200: OK -> Session is Valid
@@ -96,8 +104,14 @@ type SearchResponse = FetchResponse<InstitutionsData>;
96
104
  type ResolvableResponse = FetchResponse<ResolvableData>;
97
105
  declare class ConnectorsAPI {
98
106
  clientId: string;
99
- userAgent: string;
100
- constructor(clientId: string, userAgent?: string);
107
+ sdkAgent: string;
108
+ /**
109
+ * Custom headers to include with every request.
110
+ * For Quiltt internal usage. Not intended for public use.
111
+ * @internal
112
+ */
113
+ customHeaders: Record<string, string> | undefined;
114
+ constructor(clientId: string, sdkAgent?: string, customHeaders?: Record<string, string>);
101
115
  /**
102
116
  * Response Statuses:
103
117
  * - 200: OK -> Institutions Found
@@ -1,6 +1,32 @@
1
- import { endpointAuth, endpointRest, version } from '../../config/index.js';
1
+ import { endpointAuth, version, endpointRest } from '../../config/index.js';
2
2
  import crossfetch from 'cross-fetch';
3
3
 
4
+ /**
5
+ * Extracts version number from formatted version string
6
+ * @param formattedVersion - Formatted version like "@quiltt/core: v4.5.1"
7
+ * @returns Version number like "4.5.1" or "unknown" if not found
8
+ */ const extractVersionNumber = (formattedVersion)=>{
9
+ // Find the 'v' prefix and extract version after it
10
+ const vIndex = formattedVersion.indexOf('v');
11
+ if (vIndex === -1) return 'unknown';
12
+ const versionPart = formattedVersion.substring(vIndex + 1);
13
+ const parts = versionPart.split('.');
14
+ // Validate we have at least major.minor.patch
15
+ if (parts.length < 3) return 'unknown';
16
+ // Extract numeric parts (handles cases like "4.5.1-beta")
17
+ const major = parts[0].match(/^\d+/)?.[0];
18
+ const minor = parts[1].match(/^\d+/)?.[0];
19
+ const patch = parts[2].match(/^\d+/)?.[0];
20
+ if (!major || !minor || !patch) return 'unknown';
21
+ return `${major}.${minor}.${patch}`;
22
+ };
23
+ /**
24
+ * Generates a custom SDK Agent string following standard format
25
+ * Format: Quiltt/<version> (<platform-info>)
26
+ */ const getSDKAgent = (sdkVersion, platformInfo)=>{
27
+ return `Quiltt/${sdkVersion} (${platformInfo})`;
28
+ };
29
+
4
30
  // Use `cross-fetch` only if `fetch` is not available on the `globalThis` object
5
31
  const effectiveFetch = typeof fetch === 'undefined' ? crossfetch : fetch;
6
32
  const RETRY_DELAY = 150 // ms
@@ -54,8 +80,7 @@ var AuthStrategies = /*#__PURE__*/ function(AuthStrategies) {
54
80
  }({});
55
81
  // https://www.quiltt.dev/api-reference/auth
56
82
  class AuthAPI {
57
- // @todo userAgent: string | undefined - allow SDKs and callers to set a userAgent
58
- constructor(clientId){
83
+ constructor(clientId, customHeaders, sdkAgent = getSDKAgent(extractVersionNumber(version), 'Unknown')){
59
84
  /**
60
85
  * Response Statuses:
61
86
  * - 200: OK -> Session is Valid
@@ -108,6 +133,13 @@ class AuthAPI {
108
133
  const headers = new Headers();
109
134
  headers.set('Content-Type', 'application/json');
110
135
  headers.set('Accept', 'application/json');
136
+ headers.set('Quiltt-SDK-Agent', this.sdkAgent);
137
+ // Apply custom headers
138
+ if (this.customHeaders) {
139
+ Object.entries(this.customHeaders).forEach(([key, value])=>{
140
+ headers.set(key, value);
141
+ });
142
+ }
111
143
  if (token) {
112
144
  headers.set('Authorization', `Bearer ${token}`);
113
145
  }
@@ -130,37 +162,13 @@ class AuthAPI {
130
162
  };
131
163
  };
132
164
  this.clientId = clientId;
165
+ this.customHeaders = customHeaders;
166
+ this.sdkAgent = sdkAgent;
133
167
  }
134
168
  }
135
169
 
136
- /**
137
- * Extracts version number from formatted version string
138
- * @param formattedVersion - Formatted version like "@quiltt/core: v4.5.1"
139
- * @returns Version number like "4.5.1" or "unknown" if not found
140
- */ const extractVersionNumber = (formattedVersion)=>{
141
- // Find the 'v' prefix and extract version after it
142
- const vIndex = formattedVersion.indexOf('v');
143
- if (vIndex === -1) return 'unknown';
144
- const versionPart = formattedVersion.substring(vIndex + 1);
145
- const parts = versionPart.split('.');
146
- // Validate we have at least major.minor.patch
147
- if (parts.length < 3) return 'unknown';
148
- // Extract numeric parts (handles cases like "4.5.1-beta")
149
- const major = parts[0].match(/^\d+/)?.[0];
150
- const minor = parts[1].match(/^\d+/)?.[0];
151
- const patch = parts[2].match(/^\d+/)?.[0];
152
- if (!major || !minor || !patch) return 'unknown';
153
- return `${major}.${minor}.${patch}`;
154
- };
155
- /**
156
- * Generates a User-Agent string following standard format
157
- * Format: Quiltt/<version> (<platform-info>)
158
- */ const getUserAgent = (sdkVersion, platformInfo)=>{
159
- return `Quiltt/${sdkVersion} (${platformInfo})`;
160
- };
161
-
162
170
  class ConnectorsAPI {
163
- constructor(clientId, userAgent = getUserAgent(extractVersionNumber(version), 'Unknown')){
171
+ constructor(clientId, sdkAgent = getSDKAgent(extractVersionNumber(version), 'Unknown'), customHeaders){
164
172
  /**
165
173
  * Response Statuses:
166
174
  * - 200: OK -> Institutions Found
@@ -201,9 +209,16 @@ class ConnectorsAPI {
201
209
  const headers = new Headers();
202
210
  headers.set('Content-Type', 'application/json');
203
211
  headers.set('Accept', 'application/json');
204
- headers.set('User-Agent', this.userAgent);
205
- headers.set('Quiltt-SDK-Agent', this.userAgent);
206
- headers.set('Authorization', `Bearer ${token}`);
212
+ headers.set('Quiltt-SDK-Agent', this.sdkAgent);
213
+ // Apply custom headers
214
+ if (this.customHeaders) {
215
+ Object.entries(this.customHeaders).forEach(([key, value])=>{
216
+ headers.set(key, value);
217
+ });
218
+ }
219
+ if (token) {
220
+ headers.set('Authorization', `Bearer ${token}`);
221
+ }
207
222
  return {
208
223
  headers,
209
224
  validateStatus: this.validateStatus,
@@ -212,7 +227,8 @@ class ConnectorsAPI {
212
227
  };
213
228
  this.validateStatus = (status)=>status < 500 && status !== 429;
214
229
  this.clientId = clientId;
215
- this.userAgent = userAgent;
230
+ this.sdkAgent = sdkAgent;
231
+ this.customHeaders = customHeaders;
216
232
  }
217
233
  }
218
234
 
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  var name = "@quiltt/core";
4
- var version$1 = "5.1.0";
4
+ var version$1 = "5.1.1";
5
5
 
6
6
  const QUILTT_API_INSECURE = (()=>{
7
7
  try {
@@ -1,5 +1,5 @@
1
1
  var name = "@quiltt/core";
2
- var version$1 = "5.1.0";
2
+ var version$1 = "5.1.1";
3
3
 
4
4
  const QUILTT_API_INSECURE = (()=>{
5
5
  try {
@@ -20,13 +20,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
20
20
  return `${major}.${minor}.${patch}`;
21
21
  };
22
22
  /**
23
- * Generates a User-Agent string following standard format
23
+ * Generates a custom SDK Agent string following standard format
24
24
  * Format: Quiltt/<version> (<platform-info>)
25
- */ const getUserAgent = (sdkVersion, platformInfo)=>{
25
+ */ const getSDKAgent = (sdkVersion, platformInfo)=>{
26
26
  return `Quiltt/${sdkVersion} (${platformInfo})`;
27
27
  };
28
28
  /**
29
- * Detects browser information from user agent string
29
+ * Detects browser information from Browser's user agent string
30
30
  * Returns browser name and version, or 'Unknown' if not detected
31
31
  */ const getBrowserInfo = ()=>{
32
32
  if (typeof navigator === 'undefined' || !navigator.userAgent) {
@@ -58,4 +58,4 @@ Object.defineProperty(exports, '__esModule', { value: true });
58
58
 
59
59
  exports.extractVersionNumber = extractVersionNumber;
60
60
  exports.getBrowserInfo = getBrowserInfo;
61
- exports.getUserAgent = getUserAgent;
61
+ exports.getSDKAgent = getSDKAgent;
@@ -5,14 +5,14 @@
5
5
  */
6
6
  declare const extractVersionNumber: (formattedVersion: string) => string;
7
7
  /**
8
- * Generates a User-Agent string following standard format
8
+ * Generates a custom SDK Agent string following standard format
9
9
  * Format: Quiltt/<version> (<platform-info>)
10
10
  */
11
- declare const getUserAgent: (sdkVersion: string, platformInfo: string) => string;
11
+ declare const getSDKAgent: (sdkVersion: string, platformInfo: string) => string;
12
12
  /**
13
- * Detects browser information from user agent string
13
+ * Detects browser information from Browser's user agent string
14
14
  * Returns browser name and version, or 'Unknown' if not detected
15
15
  */
16
16
  declare const getBrowserInfo: () => string;
17
17
 
18
- export { extractVersionNumber, getBrowserInfo, getUserAgent };
18
+ export { extractVersionNumber, getBrowserInfo, getSDKAgent };
@@ -18,13 +18,13 @@
18
18
  return `${major}.${minor}.${patch}`;
19
19
  };
20
20
  /**
21
- * Generates a User-Agent string following standard format
21
+ * Generates a custom SDK Agent string following standard format
22
22
  * Format: Quiltt/<version> (<platform-info>)
23
- */ const getUserAgent = (sdkVersion, platformInfo)=>{
23
+ */ const getSDKAgent = (sdkVersion, platformInfo)=>{
24
24
  return `Quiltt/${sdkVersion} (${platformInfo})`;
25
25
  };
26
26
  /**
27
- * Detects browser information from user agent string
27
+ * Detects browser information from Browser's user agent string
28
28
  * Returns browser name and version, or 'Unknown' if not detected
29
29
  */ const getBrowserInfo = ()=>{
30
30
  if (typeof navigator === 'undefined' || !navigator.userAgent) {
@@ -54,4 +54,4 @@
54
54
  return 'Unknown';
55
55
  };
56
56
 
57
- export { extractVersionNumber, getBrowserInfo, getUserAgent };
57
+ export { extractVersionNumber, getBrowserInfo, getSDKAgent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiltt/core",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "Javascript API client and utilities for Quiltt",
5
5
  "keywords": [
6
6
  "quiltt",
@@ -1,19 +1,18 @@
1
1
  import { ApolloLink } from '@apollo/client/core'
2
2
 
3
3
  import { version } from '@/config'
4
- import { extractVersionNumber, getUserAgent } from '@/utils/telemetry'
4
+ import { extractVersionNumber, getSDKAgent } from '@/utils/telemetry'
5
5
 
6
6
  export const createVersionLink = (platformInfo: string) => {
7
7
  const versionNumber = extractVersionNumber(version)
8
- const userAgent = getUserAgent(versionNumber, platformInfo)
8
+ const sdkAgent = getSDKAgent(versionNumber, platformInfo)
9
9
 
10
10
  return new ApolloLink((operation, forward) => {
11
11
  operation.setContext(({ headers = {} }) => ({
12
12
  headers: {
13
13
  ...headers,
14
14
  'Quiltt-Client-Version': version,
15
- 'Quiltt-SDK-Agent': userAgent,
16
- 'User-Agent': userAgent,
15
+ 'Quiltt-SDK-Agent': sdkAgent,
17
16
  },
18
17
  }))
19
18
  return forward(operation)
@@ -1,4 +1,5 @@
1
- import { endpointAuth } from '@/config'
1
+ import { endpointAuth, version } from '@/config'
2
+ import { extractVersionNumber, getSDKAgent } from '@/utils/telemetry'
2
3
 
3
4
  import type { FetchResponse } from './fetchWithRetry'
4
5
  import { fetchWithRetry } from './fetchWithRetry'
@@ -35,11 +36,23 @@ export type SessionResponse = FetchResponse<SessionData>
35
36
  export class AuthAPI {
36
37
  /** The Connector ID, required for identify & authenticate calls */
37
38
  clientId: string | undefined
39
+ /** The SDK Agent string for telemetry */
40
+ sdkAgent: string
41
+ /**
42
+ * Custom headers to include with every request.
43
+ * For Quiltt internal usage. Not intended for public use.
44
+ * @internal
45
+ */
46
+ customHeaders: Record<string, string> | undefined
38
47
 
39
- // @todo userAgent: string | undefined - allow SDKs and callers to set a userAgent
40
-
41
- constructor(clientId?: string | undefined) {
48
+ constructor(
49
+ clientId?: string | undefined,
50
+ customHeaders?: Record<string, string>,
51
+ sdkAgent: string = getSDKAgent(extractVersionNumber(version), 'Unknown')
52
+ ) {
42
53
  this.clientId = clientId
54
+ this.customHeaders = customHeaders
55
+ this.sdkAgent = sdkAgent
43
56
  }
44
57
 
45
58
  /**
@@ -102,6 +115,14 @@ export class AuthAPI {
102
115
  const headers = new Headers()
103
116
  headers.set('Content-Type', 'application/json')
104
117
  headers.set('Accept', 'application/json')
118
+ headers.set('Quiltt-SDK-Agent', this.sdkAgent)
119
+
120
+ // Apply custom headers
121
+ if (this.customHeaders) {
122
+ Object.entries(this.customHeaders).forEach(([key, value]) => {
123
+ headers.set(key, value)
124
+ })
125
+ }
105
126
 
106
127
  if (token) {
107
128
  headers.set('Authorization', `Bearer ${token}`)
@@ -1,5 +1,5 @@
1
1
  import { endpointRest, version } from '@/config'
2
- import { extractVersionNumber, getUserAgent } from '@/utils/telemetry'
2
+ import { extractVersionNumber, getSDKAgent } from '@/utils/telemetry'
3
3
 
4
4
  import type { FetchResponse } from './fetchWithRetry'
5
5
  import { fetchWithRetry } from './fetchWithRetry'
@@ -18,14 +18,22 @@ export type ResolvableResponse = FetchResponse<ResolvableData>
18
18
 
19
19
  export class ConnectorsAPI {
20
20
  clientId: string
21
- userAgent: string
21
+ sdkAgent: string
22
+ /**
23
+ * Custom headers to include with every request.
24
+ * For Quiltt internal usage. Not intended for public use.
25
+ * @internal
26
+ */
27
+ customHeaders: Record<string, string> | undefined
22
28
 
23
29
  constructor(
24
30
  clientId: string,
25
- userAgent: string = getUserAgent(extractVersionNumber(version), 'Unknown')
31
+ sdkAgent: string = getSDKAgent(extractVersionNumber(version), 'Unknown'),
32
+ customHeaders?: Record<string, string>
26
33
  ) {
27
34
  this.clientId = clientId
28
- this.userAgent = userAgent
35
+ this.sdkAgent = sdkAgent
36
+ this.customHeaders = customHeaders
29
37
  }
30
38
 
31
39
  /**
@@ -91,9 +99,18 @@ export class ConnectorsAPI {
91
99
  const headers = new Headers()
92
100
  headers.set('Content-Type', 'application/json')
93
101
  headers.set('Accept', 'application/json')
94
- headers.set('User-Agent', this.userAgent)
95
- headers.set('Quiltt-SDK-Agent', this.userAgent)
96
- headers.set('Authorization', `Bearer ${token}`)
102
+ headers.set('Quiltt-SDK-Agent', this.sdkAgent)
103
+
104
+ // Apply custom headers
105
+ if (this.customHeaders) {
106
+ Object.entries(this.customHeaders).forEach(([key, value]) => {
107
+ headers.set(key, value)
108
+ })
109
+ }
110
+
111
+ if (token) {
112
+ headers.set('Authorization', `Bearer ${token}`)
113
+ }
97
114
 
98
115
  return {
99
116
  headers,
@@ -1,4 +1,4 @@
1
- import { name as packageName, version as packageVersion } from '../../package.json'
1
+ import { name as PACKAGE_NAME, version as PACKAGE_VERSION } from '../../package.json'
2
2
 
3
3
  const QUILTT_API_INSECURE = (() => {
4
4
  try {
@@ -29,7 +29,7 @@ const protocolHttp = `http${QUILTT_API_INSECURE ? '' : 's'}`
29
29
  const protocolWebsockets = `ws${QUILTT_API_INSECURE ? '' : 's'}`
30
30
 
31
31
  export const debugging = QUILTT_DEBUG
32
- export const version = `${packageName}: v${packageVersion}`
32
+ export const version = `${PACKAGE_NAME}: v${PACKAGE_VERSION}`
33
33
 
34
34
  export const cdnBase = `${protocolHttp}://cdn.${domain}`
35
35
  export const endpointAuth = `${protocolHttp}://auth.${domain}/v1/users/session`
@@ -25,15 +25,15 @@ export const extractVersionNumber = (formattedVersion: string): string => {
25
25
  }
26
26
 
27
27
  /**
28
- * Generates a User-Agent string following standard format
28
+ * Generates a custom SDK Agent string following standard format
29
29
  * Format: Quiltt/<version> (<platform-info>)
30
30
  */
31
- export const getUserAgent = (sdkVersion: string, platformInfo: string): string => {
31
+ export const getSDKAgent = (sdkVersion: string, platformInfo: string): string => {
32
32
  return `Quiltt/${sdkVersion} (${platformInfo})`
33
33
  }
34
34
 
35
35
  /**
36
- * Detects browser information from user agent string
36
+ * Detects browser information from Browser's user agent string
37
37
  * Returns browser name and version, or 'Unknown' if not detected
38
38
  */
39
39
  export const getBrowserInfo = (): string => {