1 import { getAllAddresses } from '@proton/shared/lib/api/addresses';
2 import { getKeySalts } from '@proton/shared/lib/api/keys';
3 import { getUser } from '@proton/shared/lib/api/user';
4 import type { Address as tsAddress, KeySalt as tsKeySalt, User as tsUser } from '@proton/shared/lib/interfaces';
6 import type { AuthCacheResult } from './interface';
8 export const syncUser = async (cache: AuthCacheResult): Promise<tsUser> => {
9 const user = await cache.api<{ User: tsUser }>(getUser()).then(({ User }) => User);
10 cache.data.user = user;
14 export const syncAddresses = async (cache: AuthCacheResult): Promise<tsAddress[]> => {
15 const addresses = await getAllAddresses(cache.api);
16 cache.data.addresses = addresses;
20 export const syncSalts = async (cache: AuthCacheResult): Promise<tsKeySalt[]> => {
21 const salts = await cache.api<{ KeySalts: tsKeySalt[] }>(getKeySalts()).then(({ KeySalts }) => KeySalts);
22 cache.data.salts = salts;