UNPKG

@shogun-sdk/accounts

Version:

Shogun with Turnkey: configs, encryption, authentication with Telegram/Turnkey OIDC, etc.

30 lines (23 loc) 726 B
import { lowercase } from '@shogun-sdk/money-legos'; type T = { errorMessage: string }; export function handleDecryptionError(errors: Array<T>) { // Check if errors is an array if (!Array.isArray(errors)) { console.error('Expected array of errors'); return; } // Look for decryption error const hasDecryptionError = errors.some((error) => lowercase(error.errorMessage).includes(lowercase('decryption failed: M')), ); if (hasDecryptionError) { // Clear localStorage localStorage.clear(); // Clear sessionStorage sessionStorage.clear(); // Log the action console.log('Cleared storage due to decryption error'); // Reload the window window.location.reload(); } }