Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@internxt/sdk",
"author": "Internxt <[email protected]>",
"version": "1.10.13",
"version": "1.11.0",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand All @@ -26,22 +26,22 @@
"format": "prettier src/**/*.ts"
},
"devDependencies": {
"@internxt/eslint-config-internxt": "2.0.0",
"@internxt/eslint-config-internxt": "2.0.1",
"@internxt/prettier-config": "1.0.2",
"@types/jest": "30.0.0",
"@types/sinon": "17.0.4",
"@types/uuid": "10.0.0",
"eslint": "9.29.0",
"eslint": "9.34.0",
"husky": "9.1.7",
"jest": "30.0.3",
"lint-staged": "16.1.2",
"prettier": "3.6.1",
"jest": "30.0.5",
"lint-staged": "16.1.5",
"prettier": "3.6.2",
"sinon": "21.0.0",
"ts-jest": "29.4.0",
"typescript": "5.8.3"
"ts-jest": "29.4.1",
"typescript": "5.9.2"
},
"dependencies": {
"axios": "1.10.0",
"axios": "1.11.0",
"uuid": "11.1.0"
},
"lint-staged": {
Expand Down
16 changes: 14 additions & 2 deletions src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,22 @@ export class Auth {
}

private basicHeaders() {
return basicHeaders(this.appDetails.clientName, this.appDetails.clientVersion, this.appDetails.customHeaders);
return basicHeaders({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}

private headersWithToken(token: Token) {
return headersWithToken(this.appDetails.clientName, this.appDetails.clientVersion, token);
return headersWithToken({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
token: token,
workspaceToken: this.apiSecurity?.workspaceToken,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}
}
64 changes: 17 additions & 47 deletions src/drive/backups/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ export class Backups {
}

/**
* @deprecated Use `getBackupDevices` instead.
* @deprecated Use `getBackupDevices` instead.
* This method uses the old drive backend, while `getBackupDevices` uses the new drive backend.
*/
public getAllDevices(): Promise<Device[]> {
return this.client
.get(
'/backup/device',
this.headers()
);
return this.client.get('/backup/device', this.headers());
}

/**
Expand All @@ -37,11 +33,7 @@ export class Backups {
* @returns {Promise<Device[]>} A promise that resolves to an array of Devices.
*/
public getBackupDevices(): Promise<Device[]> {
return this.client
.get(
'/backup/devices',
this.headers()
);
return this.client.get('/backup/devices', this.headers());
}

/**
Expand All @@ -54,11 +46,7 @@ export class Backups {
* @returns {Promise<DriveFolderData[]>} A promise that resolves to an array of DriveFolderData.
*/
public getAllDevicesAsFolder(): Promise<DriveFolderData[]> {
return this.client
.get(
'/backup/deviceAsFolder',
this.headers()
);
return this.client.get('/backup/deviceAsFolder', this.headers());
}

/**
Expand All @@ -68,11 +56,7 @@ export class Backups {
* @returns A promise that resolves to an array of DeviceBackups.
*/
public getAllBackups(mac: string): Promise<DeviceBackup[]> {
return this.client
.get(
`/backup/${mac}`,
this.headers()
);
return this.client.get(`/backup/${mac}`, this.headers());
}

/**
Expand All @@ -82,23 +66,15 @@ export class Backups {
* @returns A promise that resolves when the backup is successfully deleted.
*/
public deleteBackup(backupId: number): Promise<void> {
return this.client
.delete(
`/backup/${backupId}`,
this.headers()
);
return this.client.delete(`/backup/${backupId}`, this.headers());
}

/**
* @deprecated Use `deleteBackupDevice` instead.
* This method uses the old drive backend, while `deleteBackupDevice` uses the new drive backend.
*/
public deleteDevice(deviceId: number): Promise<void> {
return this.client
.delete(
`/backup/device/${deviceId}`,
this.headers()
);
return this.client.delete(`/backup/device/${deviceId}`, this.headers());
}

/**
Expand All @@ -108,11 +84,7 @@ export class Backups {
* @returns A promise that resolves when the device is successfully deleted.
*/
public deleteBackupDevice(deviceId: number): Promise<void> {
return this.client
.delete(
`/backup/devices/${deviceId}`,
this.headers()
);
return this.client.delete(`/backup/devices/${deviceId}`, this.headers());
}

/**
Expand All @@ -122,23 +94,21 @@ export class Backups {
* @returns A promise that resolves when the device is successfully deleted.
*/
public deleteBackupDeviceAsFolder(folderId: string): Promise<void> {
return this.client
.delete(
`/backup/deviceAsFolder/${folderId}`,
this.headers()
);
return this.client.delete(`/backup/deviceAsFolder/${folderId}`, this.headers());
}

/**
* Returns the needed headers for the module requests
* @private
*/
private headers() {
return headersWithToken(
this.appDetails.clientName,
this.appDetails.clientVersion,
this.apiSecurity.token
);
return headersWithToken({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
token: this.apiSecurity.token,
workspaceToken: this.apiSecurity.workspaceToken,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}
}

21 changes: 8 additions & 13 deletions src/drive/payments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,13 @@ export class Payments {
* @private
*/
private headers() {
const additionalHeaders: Record<string, string> = {};

if (this.appDetails.desktopHeader) {
additionalHeaders['x-internxt-desktop-header'] = this.appDetails.desktopHeader;
}

return headersWithToken(
this.appDetails.clientName,
this.appDetails.clientVersion,
this.apiSecurity.token,
undefined,
additionalHeaders,
);
return headersWithToken({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
token: this.apiSecurity.token,
workspaceToken: this.apiSecurity.workspaceToken,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}
}
7 changes: 6 additions & 1 deletion src/drive/payments/object-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ export class ObjectStorage {
}

private headers() {
return basicHeaders(this.appDetails.clientName, this.appDetails.clientVersion);
return basicHeaders({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}
}
9 changes: 8 additions & 1 deletion src/drive/referrals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export class Referrals {
* @private
*/
private headers() {
return headersWithToken(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token);
return headersWithToken({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
token: this.apiSecurity.token,
workspaceToken: this.apiSecurity.workspaceToken,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}
}
38 changes: 28 additions & 10 deletions src/drive/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
* Fetches paginated folders or files of a specific share link
* @param payload
*/
public getShareLinkDirectory(payload: GetSharedDirectoryPayload): Promise<any> {

Check warning on line 138 in src/drive/share/index.ts

View workflow job for this annotation

GitHub Actions / test (22.x)

Unexpected any. Specify a different type
const types = ['file', 'folder'];
if (!types.includes(payload.type)) {
throw new Error('Invalid type');
Expand All @@ -160,7 +160,7 @@
* Get size of folder in share links
* @param payload
*/
public getShareLinkFolderSize(payload: GetShareLinkFolderSizePayload): Promise<any> {

Check warning on line 163 in src/drive/share/index.ts

View workflow job for this annotation

GitHub Actions / test (22.x)

Unexpected any. Specify a different type
return this.client.get(`/storage/share/${payload.itemId}/folder/${payload.folderId}/size`, this.basicHeaders());
}

Expand Down Expand Up @@ -365,7 +365,7 @@
* @returns {Promise<{ data: SharingInvite[] }>} A promise containing the private folder data.
*/

public getSharedFolderInvitations({ itemId, itemType }: { itemId: string; itemType: ItemType }): Promise<any[]> {

Check warning on line 368 in src/drive/share/index.ts

View workflow job for this annotation

GitHub Actions / test (22.x)

Unexpected any. Specify a different type
return this.client.get(`sharings/${itemType}/${itemId}/invites`, this.headers());
}

Expand Down Expand Up @@ -602,7 +602,7 @@
}: {
itemType: string;
folderId: string;
}): Promise<Record<'users', any[]> | Record<'error', string>> {

Check warning on line 605 in src/drive/share/index.ts

View workflow job for this annotation

GitHub Actions / test (22.x)

Unexpected any. Specify a different type
return this.client.get(`sharings/shared-with/${itemType}/${folderId}`, this.headers());
}

Expand All @@ -621,32 +621,50 @@
* @private
*/
private headers(password?: string) {
const args: [string, string, string, string | undefined] = [
this.appDetails.clientName,
this.appDetails.clientVersion,
this.apiSecurity.token,
this.apiSecurity.workspaceToken,
];
if (password) {
return headersWithTokenAndPassword(...args, password);
return headersWithTokenAndPassword({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
token: this.apiSecurity.token,
workspaceToken: this.apiSecurity.workspaceToken,
desktopToken: this.appDetails.desktopHeader,
password,
});
}
return headersWithToken(...args);
return headersWithToken({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
token: this.apiSecurity.token,
workspaceToken: this.apiSecurity.workspaceToken,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}

/**
* Returns the needed headers for the module requests
* @private
*/
private basicHeaders() {
return basicHeaders(this.appDetails.clientName, this.appDetails.clientVersion);
return basicHeaders({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}

/**
* Used to send the password in shares
* @private
*/
private basicHeadersWithPassword(password: string) {
return basicHeadersWithPassword(this.appDetails.clientName, this.appDetails.clientVersion, password);
return basicHeadersWithPassword({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
desktopToken: this.appDetails.desktopHeader,
password,
});
}

/**
Expand Down
25 changes: 18 additions & 7 deletions src/drive/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,13 +699,24 @@ export class Storage {
* @private
*/
private headers(customHeaders?: CustomHeaders) {
return headersWithToken(
this.appDetails.clientName,
this.appDetails.clientVersion,
this.apiSecurity.token,
this.apiSecurity?.workspaceToken,
customHeaders,
);
let customExtraHeaders: CustomHeaders = {};
if (customHeaders) {
customExtraHeaders = customHeaders;
}
if (this.appDetails.customHeaders) {
customExtraHeaders = {
...customExtraHeaders,
...this.appDetails.customHeaders,
};
}
return headersWithToken({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
token: this.apiSecurity.token,
workspaceToken: this.apiSecurity.workspaceToken,
desktopToken: this.appDetails.desktopHeader,
customHeaders: customExtraHeaders,
});
}

/**
Expand Down
14 changes: 8 additions & 6 deletions src/drive/trash/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ export class Trash {
* @private
*/
private headers() {
return headersWithToken(
this.appDetails.clientName,
this.appDetails.clientVersion,
this.apiSecurity.token,
this.apiSecurity.workspaceToken,
);
return headersWithToken({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
token: this.apiSecurity.token,
workspaceToken: this.apiSecurity.workspaceToken,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}
}
25 changes: 22 additions & 3 deletions src/drive/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,33 @@ export class Users {
}

private basicHeaders() {
return basicHeaders(this.appDetails.clientName, this.appDetails.clientVersion);
return basicHeaders({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}

private headers() {
return headersWithToken(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token);
return headersWithToken({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
token: this.apiSecurity.token,
workspaceToken: this.apiSecurity.workspaceToken,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}

private headersWithToken(token: Token) {
return headersWithToken(this.appDetails.clientName, this.appDetails.clientVersion, token);
return headersWithToken({
clientName: this.appDetails.clientName,
clientVersion: this.appDetails.clientVersion,
token: token,
workspaceToken: this.apiSecurity.workspaceToken,
desktopToken: this.appDetails.desktopHeader,
customHeaders: this.appDetails.customHeaders,
});
}
}
Loading
Loading