function validateBase64(s) { if (!(/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(s))) { throw new TypeError('invalid encoding'); } } function decodeBase64(s) { validateBase64(s); var i, d = atob(s), b = new Uint8Array(d.length); for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); return b; }; async function getSettingById(id) { return new Promise((resolve, reject) => { let openRequest = indexedDB.open('TimeSafari'); openRequest.onupgradeneeded = (event) => { // Handle database setup if necessary let db = event.target.result; if (!db.objectStoreNames.contains('settings')) { db.createObjectStore('settings', { keyPath: 'id' }); } }; openRequest.onsuccess = (event) => { let db = event.target.result; let transaction = db.transaction('settings', 'readonly'); let objectStore = transaction.objectStore('settings'); let getRequest = objectStore.get(id); getRequest.onsuccess = () => resolve(getRequest.result); getRequest.onerror = () => reject(getRequest.error); }; openRequest.onerror = () => reject(openRequest.error); }); } async function getNotificationCount() { let secret = null; if ('secret' in self) { secret = self.secret; const secretUint8Array = decodeBase64(secret); const settings = await getSettingById(1); const activeDid = settings['activeDid']; } return secret; } self.getNotificationCount = getNotificationCount;