@quiltt/core 5.1.0 → 5.1.2
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 +14 -0
- package/dist/api/graphql/index.cjs +5 -6
- package/dist/api/graphql/index.js +5 -6
- package/dist/api/rest/index.cjs +49 -33
- package/dist/api/rest/index.d.ts +17 -3
- package/dist/api/rest/index.js +50 -34
- package/dist/config/index.cjs +1 -1
- package/dist/config/index.js +1 -1
- package/dist/utils/index.cjs +4 -4
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.js +4 -4
- package/package.json +1 -1
- package/src/api/graphql/links/VersionLink.ts +4 -5
- package/src/api/rest/auth.ts +25 -4
- package/src/api/rest/connectors.ts +24 -7
- package/src/config/configuration.ts +2 -2
- package/src/utils/telemetry.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @quiltt/core
|
|
2
2
|
|
|
3
|
+
## 5.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#423](https://github.com/quiltt/quiltt-js/pull/423) [`aca4d51`](https://github.com/quiltt/quiltt-js/commit/aca4d51bc699f80e50977d28b120280db9a4414d) Thanks [@sirwolfgang](https://github.com/sirwolfgang)! - Fix VersionLink to allow custom Quiltt-SDK-Agent header override
|
|
8
|
+
|
|
9
|
+
## 5.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
15
|
+
- [#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
|
|
16
|
+
|
|
3
17
|
## 5.1.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -187,22 +187,21 @@ const TerminatingLink = new core.ApolloLink(()=>{
|
|
|
187
187
|
return `${major}.${minor}.${patch}`;
|
|
188
188
|
};
|
|
189
189
|
/**
|
|
190
|
-
* Generates a
|
|
190
|
+
* Generates a custom SDK Agent string following standard format
|
|
191
191
|
* Format: Quiltt/<version> (<platform-info>)
|
|
192
|
-
*/ const
|
|
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
|
|
198
|
+
const sdkAgent = getSDKAgent(versionNumber, platformInfo);
|
|
199
199
|
return new core.ApolloLink((operation, forward)=>{
|
|
200
200
|
operation.setContext(({ headers = {} })=>({
|
|
201
201
|
headers: {
|
|
202
|
-
...headers,
|
|
203
202
|
'Quiltt-Client-Version': index_cjs.version,
|
|
204
|
-
'Quiltt-SDK-Agent':
|
|
205
|
-
|
|
203
|
+
'Quiltt-SDK-Agent': sdkAgent,
|
|
204
|
+
...headers
|
|
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
|
|
185
|
+
* Generates a custom SDK Agent string following standard format
|
|
186
186
|
* Format: Quiltt/<version> (<platform-info>)
|
|
187
|
-
*/ const
|
|
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
|
|
193
|
+
const sdkAgent = getSDKAgent(versionNumber, platformInfo);
|
|
194
194
|
return new ApolloLink((operation, forward)=>{
|
|
195
195
|
operation.setContext(({ headers = {} })=>({
|
|
196
196
|
headers: {
|
|
197
|
-
...headers,
|
|
198
197
|
'Quiltt-Client-Version': version,
|
|
199
|
-
'Quiltt-SDK-Agent':
|
|
200
|
-
|
|
198
|
+
'Quiltt-SDK-Agent': sdkAgent,
|
|
199
|
+
...headers
|
|
201
200
|
}
|
|
202
201
|
}));
|
|
203
202
|
return forward(operation);
|
package/dist/api/rest/index.cjs
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
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('
|
|
211
|
-
headers
|
|
212
|
-
|
|
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.
|
|
236
|
+
this.sdkAgent = sdkAgent;
|
|
237
|
+
this.customHeaders = customHeaders;
|
|
222
238
|
}
|
|
223
239
|
}
|
|
224
240
|
|
package/dist/api/rest/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
100
|
-
|
|
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
|
package/dist/api/rest/index.js
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
import { endpointAuth,
|
|
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
|
-
|
|
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,
|
|
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('
|
|
205
|
-
headers
|
|
206
|
-
|
|
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.
|
|
230
|
+
this.sdkAgent = sdkAgent;
|
|
231
|
+
this.customHeaders = customHeaders;
|
|
216
232
|
}
|
|
217
233
|
}
|
|
218
234
|
|
package/dist/config/index.cjs
CHANGED
package/dist/config/index.js
CHANGED
package/dist/utils/index.cjs
CHANGED
|
@@ -20,13 +20,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
20
20
|
return `${major}.${minor}.${patch}`;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
|
-
* Generates a
|
|
23
|
+
* Generates a custom SDK Agent string following standard format
|
|
24
24
|
* Format: Quiltt/<version> (<platform-info>)
|
|
25
|
-
*/ const
|
|
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.
|
|
61
|
+
exports.getSDKAgent = getSDKAgent;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
declare const extractVersionNumber: (formattedVersion: string) => string;
|
|
7
7
|
/**
|
|
8
|
-
* Generates a
|
|
8
|
+
* Generates a custom SDK Agent string following standard format
|
|
9
9
|
* Format: Quiltt/<version> (<platform-info>)
|
|
10
10
|
*/
|
|
11
|
-
declare const
|
|
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,
|
|
18
|
+
export { extractVersionNumber, getBrowserInfo, getSDKAgent };
|
package/dist/utils/index.js
CHANGED
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
return `${major}.${minor}.${patch}`;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
|
-
* Generates a
|
|
21
|
+
* Generates a custom SDK Agent string following standard format
|
|
22
22
|
* Format: Quiltt/<version> (<platform-info>)
|
|
23
|
-
*/ const
|
|
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,
|
|
57
|
+
export { extractVersionNumber, getBrowserInfo, getSDKAgent };
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { ApolloLink } from '@apollo/client/core'
|
|
2
2
|
|
|
3
3
|
import { version } from '@/config'
|
|
4
|
-
import { extractVersionNumber,
|
|
4
|
+
import { extractVersionNumber, getSDKAgent } from '@/utils/telemetry'
|
|
5
5
|
|
|
6
6
|
export const createVersionLink = (platformInfo: string) => {
|
|
7
7
|
const versionNumber = extractVersionNumber(version)
|
|
8
|
-
const
|
|
8
|
+
const sdkAgent = getSDKAgent(versionNumber, platformInfo)
|
|
9
9
|
|
|
10
10
|
return new ApolloLink((operation, forward) => {
|
|
11
11
|
operation.setContext(({ headers = {} }) => ({
|
|
12
12
|
headers: {
|
|
13
|
-
...headers,
|
|
14
13
|
'Quiltt-Client-Version': version,
|
|
15
|
-
'Quiltt-SDK-Agent':
|
|
16
|
-
|
|
14
|
+
'Quiltt-SDK-Agent': sdkAgent,
|
|
15
|
+
...headers,
|
|
17
16
|
},
|
|
18
17
|
}))
|
|
19
18
|
return forward(operation)
|
package/src/api/rest/auth.ts
CHANGED
|
@@ -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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
31
|
+
sdkAgent: string = getSDKAgent(extractVersionNumber(version), 'Unknown'),
|
|
32
|
+
customHeaders?: Record<string, string>
|
|
26
33
|
) {
|
|
27
34
|
this.clientId = clientId
|
|
28
|
-
this.
|
|
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('
|
|
95
|
-
|
|
96
|
-
|
|
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
|
|
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 = `${
|
|
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`
|
package/src/utils/telemetry.ts
CHANGED
|
@@ -25,15 +25,15 @@ export const extractVersionNumber = (formattedVersion: string): string => {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Generates a
|
|
28
|
+
* Generates a custom SDK Agent string following standard format
|
|
29
29
|
* Format: Quiltt/<version> (<platform-info>)
|
|
30
30
|
*/
|
|
31
|
-
export const
|
|
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 => {
|