using AyCode.Interfaces.StorageHandlers; using Blazored.LocalStorage; using TIAM.Core.Consts; namespace TIAMWebApp.Client.Services { public class SecureStorageHandler : ISecureStorageHandler { private readonly SessionStorageAccessor ssa; private readonly ILocalStorageService localStoragService; public SecureStorageHandler(SessionStorageAccessor ssa, ILocalStorageService localStorageService) { this.ssa = ssa; this.localStoragService = localStorageService; } public async Task SaveToSecureStorageAsync(string key, string value) { await localStoragService.SetItemAsync(key, value); //await ssa.SetValueAsync(key, value); } public async Task GetFromSecureStorageAsync(string key) { var result = await localStoragService.GetItemAsync(key); if (result != null) { return result; } else return string.Empty; //return await ssa.GetValueAsync(key); } public async Task DeleteFromSecureStorageAsync(string key) { await localStoragService.RemoveItemAsync(key); //await ssa.RemoveAsync(key); } public async Task ClearAllSecureStorageAsync() { await localStoragService.ClearAsync(); //await ssa.Clear(); } } }