Skip to content

Commit 15fa113

Browse files
committed
removed request header, added version
1 parent 90055b7 commit 15fa113

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

localtest/shared/uid2SdkTag.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
<script src="https://cdn.integ.uidapi.com/uid2-sdk-3.5.0.js"></script>
1+
<!-- <script src="https://cdn.integ.uidapi.com/uid2-sdk-3.5.0.js"></script> -->
2+
<script src="../../dist/uid2-sdk-3.10.0.js"></script>

src/apiClient.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,11 @@ export class ApiClient {
149149
}
150150

151151
public callRefreshApi(refreshDetails: Identity): Promise<RefreshResult> {
152-
const url = this._baseUrl + '/v2/token/refresh';
152+
const url = this._baseUrl + `/v2/token/refresh?version=${this._clientVersion}`;
153153
const req = new XMLHttpRequest();
154154
this._requestsInFlight.push(req);
155155
req.overrideMimeType('text/plain');
156156
req.open('POST', url, true);
157-
req.setRequestHeader('X-UID2-Client-Version', this._clientVersion); // N.B. EUID and UID2 currently both use the same header
158157
let resolvePromise: (result: RefreshResult) => void;
159158
// eslint-disable-next-line @typescript-eslint/no-explicit-any
160159
let rejectPromise: (reason?: any) => void;
@@ -221,7 +220,7 @@ export class ApiClient {
221220
opts: ClientSideIdentityOptions
222221
): Promise<CstgResult> {
223222
const request =
224-
'emailHash' in data ? { email_hash: data.emailHash } : { phone_hash: data.phoneHash };
223+
'emailHash' in data ? { email_hash: data.emailHash } : { phone_hash: data.phoneHash };
225224

226225
const box = await CstgBox.build(stripPublicKeyPrefix(opts.serverPublicKey));
227226

@@ -243,7 +242,7 @@ export class ApiClient {
243242
subscription_id: opts.subscriptionId,
244243
};
245244

246-
const url = this._baseUrl + '/v2/token/client-generate';
245+
const url = this._baseUrl + `/v2/token/client-generate?version=${this._clientVersion}`;
247246
const req = new XMLHttpRequest();
248247
this._requestsInFlight.push(req);
249248
req.overrideMimeType('text/plain');

src/integrationTests/basic.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const makeIdentityV2 = mocks.makeIdentityV2;
3232

3333
let useCookie: boolean | undefined = undefined;
3434

35+
const UID2Version = 'uid2' + '-sdk-' + UID2.VERSION;
36+
const uid2RefreshUrl = `https://prod.uidapi.com/v2/token/refresh?version=${UID2Version}`;
37+
3538
const testCookieAndLocalStorage = (test: () => void, only = false) => {
3639
const describeFn = only ? describe.only : describe;
3740
describeFn('Using default: ', () => {
@@ -292,8 +295,7 @@ testCookieAndLocalStorage(() => {
292295

293296
test('should initiate token refresh', () => {
294297
expect(xhrMock.send).toHaveBeenCalledTimes(1);
295-
const url = 'https://prod.uidapi.com/v2/token/refresh';
296-
expect(xhrMock.open).toHaveBeenLastCalledWith('POST', url, true);
298+
expect(xhrMock.open).toHaveBeenLastCalledWith('POST', uid2RefreshUrl, true);
297299
expect(xhrMock.send).toHaveBeenLastCalledWith(identity.refresh_token);
298300
xhrMock.onreadystatechange();
299301
expect(cryptoMock.subtle.importKey).toHaveBeenCalled();
@@ -321,8 +323,7 @@ testCookieAndLocalStorage(() => {
321323
test('should initiate token refresh', () => {
322324
const cryptoMock = new mocks.CryptoMock(sdkWindow);
323325
expect(xhrMock.send).toHaveBeenCalledTimes(1);
324-
const url = 'https://prod.uidapi.com/v2/token/refresh';
325-
expect(xhrMock.open).toHaveBeenLastCalledWith('POST', url, true);
326+
expect(xhrMock.open).toHaveBeenLastCalledWith('POST', uid2RefreshUrl, true);
326327
expect(xhrMock.send).toHaveBeenLastCalledWith(identity.refresh_token);
327328
xhrMock.onreadystatechange();
328329
expect(cryptoMock.subtle.importKey).toHaveBeenCalledTimes(0);

0 commit comments

Comments
 (0)