import edgeServices from '../edges'; import vertexServices from '../vertex'; import Response from '../../common/Response'; import Status from '../../common/Status'; import { RequestVerificationCodeArgs, ChangePasswordWithOldPasswordArgs, ChangePasswordWithVerificationCode, CreateUserArgs, LoginNewDeviceArgs, LoginArgs, VerifyUserPasswordArgs, CreateInvitedUserArgs, GeneratorSigForOldAccountArgs } from './types'; export default class Account { edgeServices?: typeof edgeServices; vertexServices?: typeof vertexServices; constructor(options?: { edgeServices?: Account['edgeServices']; vertexServices?: Account['vertexServices']; }); /** * * @param {RequestVerificationCodeArgs} args * * requests a verification code needed for the user to * complete loging in from new device or registering for the first time */ requestVerificationCode({ phone_number, }: RequestVerificationCodeArgs): Promise; /** * * @param {CreateUserArgs} args * * used to register user and store the user credentials such jwt, publicKey, secretKey in * localStorage */ createUser({ password, phone_number, verification_code, userInfo: name, type, }: CreateUserArgs): Promise; createUserNoModifyKey({ password, phone_number, verification_code, userInfo: name, type, }: CreateUserArgs): Promise; /** * * @param {CreateInvitedUserArgs} args * * used to register invited user and store the user credentials such jwt, publicKey, secretKey in * localStorage */ createInvitedUser({ id, phone_number, password, userInfo: name, }: CreateInvitedUserArgs): Promise; generatorSigForOldAccount({ id, userInfo: name, phoneNumber, sk, }: GeneratorSigForOldAccountArgs): Promise; /** * * @param {LoginArgs} args * * the user's credentials found in the locaStorage are used to authenticate the user * this sends back a JWT token * * Logic here is also used for automatic login to replace the jwt when its expired * */ login({ password, autoLogin }?: LoginArgs): Promise; simpleLogin(): Promise; /** * * @param {LoginNewDeviceArgs} args * * the user's credentials were not found in localStorage so a phone_number and verification_code are required */ loginNewDevice({ phone_number, verification_code, }: LoginNewDeviceArgs): Promise; /** * logs user out by removing the sk from localStorage and leaving the esk */ logout(): Response; /** * clears the user's credentials from local storage. User must sign in * using the loginNewDevice method */ logoutClean(): Response; /** * Retrieves the users login status * * @returns Status * Status.code: * 0 - LOGGED_IN * 1 - LOGGED_OUT * 2 - NEW_DEVICE * 3 - TEMP_ACCOUNT */ getStatus(): Promise; /** * * @param {ChangePasswordWithOldPasswordArgs} args * * change the users password by providing the old and new password. * User must be in loggedIn(status 0) or loggedOut(status 1) to be able to * use this method. */ changePasswordWithOldPassword({ oldPassword, newPassword, }: ChangePasswordWithOldPasswordArgs): Promise; /** * * @param {ChangePasswordWithVerificationCode} args * * change the users password by providing the old and new password. * User must be in loggedIn(status 0) or loggedOut(status 1) to be able to * use this method. */ changePasswordWithVerificationCode({ password, }: ChangePasswordWithVerificationCode): Promise; /** * * @param {VerifyUserPasswordArgs} args.password * @returns Array<[boolean, null | Uint8Array]> * * used to verify the user's password * * returns [true, sk:Uint8Array] if password is valid * */ verifyUserPassword({ password, }: VerifyUserPasswordArgs): [boolean, null | Uint8Array]; updatePassword({ password, userId, pk, sk, }: { password: string; userId: string | Uint8Array; pk: string | Uint8Array; sk: string | Uint8Array; }): Promise; } declare const automaticLogin: () => Promise; export { automaticLogin };