Skip to content

Commit

Permalink
Merge pull request #207 from internxt/feature/PB-2251-obtain-token-wh…
Browse files Browse the repository at this point in the history
…en-expire

[PB-2251] feature/Obtain token when is expired
  • Loading branch information
CandelR authored Jun 14, 2024
2 parents 2788f60 + cc817cd commit dc520ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@internxt/sdk",
"version": "1.4.83",
"version": "1.4.84",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
26 changes: 22 additions & 4 deletions src/drive/users/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { headersWithToken } from '../../shared/headers';
import { HttpClient } from '../../shared/http/client';
import { UserSettings } from '../../shared/types/userSettings';
import {
ChangePasswordPayload,
CheckChangeEmailExpirationResponse,
Expand All @@ -10,8 +12,6 @@ import {
UserPublicKeyResponse,
VerifyEmailChangeResponse,
} from './types';
import { UserSettings } from '../../shared/types/userSettings';
import { HttpClient } from '../../shared/http/client';

export * as UserTypes from './types';

Expand Down Expand Up @@ -76,13 +76,31 @@ export class Users {
return this.client.get('/user/refresh', this.headers());
}

/**
* Retrieves the user data for a specific user identified by the uuid.
*
* @param {string} params.userUuid - The UUID of the user.
* @return {Promise<Object>} A promise that resolves to an object containing the user data.
* The object has the following properties:
* - `newToken` (string): The new token of the user.
* - `oldToken` (string): The old drive token of the user.
* - `user` (UserSettings): The user data.
*/
public getUserData({ userUuid }: { userUuid: string }): Promise<{
newToken: string;
oldToken: string;
user: UserSettings;
}> {
return this.client.get(`/users/c/${userUuid}`, this.headers());
}

/**
* Updates the authentication credentials and invalidates previous tokens
* @param payload
*
*
* @returns {Promise<{token: string, newToken: string}>} A promise that returns new tokens for this user.
*/
public changePassword(payload: ChangePasswordPayload): Promise<{token: string, newToken: string}> {
public changePassword(payload: ChangePasswordPayload): Promise<{ token: string; newToken: string }> {
return this.client.patch(
'/user/password',
{
Expand Down

0 comments on commit dc520ba

Please sign in to comment.