Skip to content

Commit

Permalink
Merge branch 'master' into feat/password-protected-sharings
Browse files Browse the repository at this point in the history
  • Loading branch information
apsantiso committed Dec 19, 2023
2 parents 852e39d + c52610d commit dceea92
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
48 changes: 47 additions & 1 deletion src/drive/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { headersWithToken } from '../../shared/headers';
import {
ChangePasswordPayload,
CheckChangeEmailExpirationResponse,
FriendInvite,
InitializeUserResponse,
PreCreateUserResponse,
UpdateProfilePayload,
UserPublicKeyResponse,
VerifyEmailChangeResponse,
} from './types';
import { UUID, UserSettings } from '../../shared/types/userSettings';
import { UserSettings } from '../../shared/types/userSettings';
import { HttpClient } from '../../shared/http/client';

export * as UserTypes from './types';
Expand Down Expand Up @@ -153,6 +155,50 @@ export class Users {
return this.client.post<void>('/user/verifyEmail', payload, this.headers());
}

/**
* Change user email by new email
*
* @param {string} newEmail
*
* @returns {Promise<void>}
*/
public changeUserEmail(newEmail: string): Promise<void> {
return this.client.post(
'users/attempt-change-email',
{
newEmail,
},
this.headers(),
);
}

/**
* Verify user email change
*
* @param {string} encryptedAttemptChangeEmailId
*
* @returns {Promise<VerifyEmailChangeResponse>}
*/
public verifyEmailChange(encryptedAttemptChangeEmailId: string): Promise<VerifyEmailChangeResponse> {
return this.client.post(`users/attempt-change-email/${encryptedAttemptChangeEmailId}/accept`, {}, this.headers());
}

/**
* Check if user email change verification link is expired
*
* @param {string} encryptedAttemptChangeEmailId
*
* @returns {Promise<CheckChangeEmailExpirationResponse>}
*/
public checkChangeEmailExpiration(
encryptedAttemptChangeEmailId: string,
): Promise<CheckChangeEmailExpirationResponse> {
return this.client.get(
`users/attempt-change-email/${encryptedAttemptChangeEmailId}/verify-expiration`,
this.headers(),
);
}

/**
* Get public key of given email
*/
Expand Down
8 changes: 8 additions & 0 deletions src/drive/users/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ export type PreCreateUserResponse = {
export type FriendInvite = { guestEmail: string; host: number; accepted: boolean; id: number };

export type UserPublicKeyResponse = { publicKey: string };


export type VerifyEmailChangeResponse = {
oldEmail: string;
newEmail: string;
};

export type CheckChangeEmailExpirationResponse = { isExpired: boolean };

0 comments on commit dceea92

Please sign in to comment.