From dfe231bbfa9534bf5a2c1b4137ea0f352020b505 Mon Sep 17 00:00:00 2001 From: Xavier Abad <77491413+xabg2@users.noreply.github.com> Date: Tue, 10 Feb 2026 09:09:50 +0100 Subject: [PATCH 1/2] fix: remove useless headers --- package.json | 2 +- src/misc/location/index.ts | 24 +++-------- test/misc/location/index.test.ts | 73 +++----------------------------- 3 files changed, 12 insertions(+), 87 deletions(-) diff --git a/package.json b/package.json index 49032e3..acb07a0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@internxt/sdk", "author": "Internxt ", - "version": "1.12.5", + "version": "1.12.6", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git", diff --git a/src/misc/location/index.ts b/src/misc/location/index.ts index 36bf9a3..8000605 100644 --- a/src/misc/location/index.ts +++ b/src/misc/location/index.ts @@ -1,5 +1,4 @@ -import { basicHeaders } from '../../shared/headers'; -import { ApiSecurity, ApiUrl, AppDetails } from '../../shared'; +import { ApiUrl } from '../../shared'; import { HttpClient } from '../../shared/http/client'; export interface UserLocation { @@ -9,27 +8,16 @@ export interface UserLocation { export class Location { private readonly client: HttpClient; - private readonly appDetails: AppDetails; - private constructor(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity?: ApiSecurity) { - this.client = HttpClient.create(apiUrl, apiSecurity?.unauthorizedCallback); - this.appDetails = appDetails; + private constructor(apiUrl: ApiUrl) { + this.client = HttpClient.create(apiUrl); } - public static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity?: ApiSecurity) { - return new Location(apiUrl, appDetails, apiSecurity); + public static client(apiUrl: ApiUrl) { + return new Location(apiUrl); } public async getUserLocation(): Promise { - return this.client.get('', this.basicUserHeaders()); - } - - private basicUserHeaders() { - return basicHeaders({ - clientName: this.appDetails.clientName, - clientVersion: this.appDetails.clientVersion, - desktopToken: this.appDetails.desktopHeader, - customHeaders: this.appDetails.customHeaders, - }); + return this.client.get('', {}); } } diff --git a/test/misc/location/index.test.ts b/test/misc/location/index.test.ts index fb233c6..ca7235f 100644 --- a/test/misc/location/index.test.ts +++ b/test/misc/location/index.test.ts @@ -1,12 +1,10 @@ import sinon from 'sinon'; -import { AppDetails } from '../../../src/shared'; -import { basicHeaders } from '../../../src/shared/headers'; import { Location, UserLocation } from '../../../src/misc/location'; import { HttpClient } from '../../../src/shared/http/client'; const httpClient = HttpClient.create(''); -describe('location service', () => { +describe('Location service', () => { beforeEach(() => { sinon.stub(HttpClient, 'create').returns(httpClient); }); @@ -22,53 +20,13 @@ describe('location service', () => { ip: '1.1.1.1', location: 'ES', }; - const callStub = sinon.stub(httpClient, 'get').resolves(mockLocation); - const { client, headers } = clientAndHeaders(); + sinon.stub(httpClient, 'get').resolves(mockLocation); + const { client } = clientAndHeaders(); // Act const result = await client.getUserLocation(); // Assert - expect(callStub.firstCall.args).toEqual(['', headers]); - expect(result).toEqual(mockLocation); - }); - - it('should include desktop header when provided', async () => { - // Arrange - const mockLocation: UserLocation = { - ip: '10.0.0.1', - location: 'US', - }; - const callStub = sinon.stub(httpClient, 'get').resolves(mockLocation); - const { client, headers } = clientAndHeaders({ - desktopHeader: 'desktop-token', - }); - - // Act - const result = await client.getUserLocation(); - - // Assert - expect(callStub.firstCall.args).toEqual(['', headers]); - expect(result).toEqual(mockLocation); - }); - - it('should include custom headers when provided', async () => { - // Arrange - const mockLocation: UserLocation = { - ip: '172.16.0.1', - location: 'FR', - }; - const customHeaders = { 'x-custom-header': 'custom-value' }; - const callStub = sinon.stub(httpClient, 'get').resolves(mockLocation); - const { client, headers } = clientAndHeaders({ - customHeaders, - }); - - // Act - const result = await client.getUserLocation(); - - // Assert - expect(callStub.firstCall.args).toEqual(['', headers]); expect(result).toEqual(mockLocation); }); }); @@ -76,33 +34,12 @@ describe('location service', () => { function clientAndHeaders({ apiUrl = '', - clientName = 'internxt-client', - clientVersion = '0.1', - desktopHeader, - customHeaders, }: { apiUrl?: string; - clientName?: string; - clientVersion?: string; - desktopHeader?: string; - customHeaders?: Record; } = {}): { client: Location; - headers: object; } { - const appDetails: AppDetails = { - clientName, - clientVersion, - desktopHeader, - customHeaders, - }; + const client = Location.client(apiUrl); - const client = Location.client(apiUrl, appDetails); - const headers = basicHeaders({ - clientName, - clientVersion, - desktopToken: desktopHeader, - customHeaders, - }); - return { client, headers }; + return { client }; } From 4075e0420d87c4a3a14b19313a41ea03b3545467 Mon Sep 17 00:00:00 2001 From: Xavier Abad <77491413+xabg2@users.noreply.github.com> Date: Tue, 10 Feb 2026 09:26:44 +0100 Subject: [PATCH 2/2] fix: add slash instead of empty string --- src/misc/location/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/misc/location/index.ts b/src/misc/location/index.ts index 8000605..a4694c9 100644 --- a/src/misc/location/index.ts +++ b/src/misc/location/index.ts @@ -18,6 +18,6 @@ export class Location { } public async getUserLocation(): Promise { - return this.client.get('', {}); + return this.client.get('/', {}); } }