From 8684488def7a4e0e6bdda10f780292edad203c14 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Tue, 7 Nov 2023 08:04:26 -0500 Subject: [PATCH] Stip out old approach --- additional-scripts.js | 61 ------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/additional-scripts.js b/additional-scripts.js index 9ce0ea7..5d1d8fe 100644 --- a/additional-scripts.js +++ b/additional-scripts.js @@ -1,7 +1,4 @@ -importScripts("https://cdn.jsdelivr.net/npm/tweetnacl-util@0.15.1/nacl-util.min.js"); -importScripts("https://cdnjs.cloudflare.com/ajax/libs/tweetnacl/1.0.2/nacl.min.js"); -importScripts("https://cdn.jsdelivr.net/npm/@sphereon/did-jwt/build/index.min.js"); self.addEventListener("push", function (event) { let payload; @@ -22,64 +19,6 @@ self.addEventListener("push", function (event) { self.addEventListener('message', function(event) { const data = event.data; - - const secret = await page.evaluate(() => { - const secret = localStorage.getItem('secret'); - return secret; - }); - - const secretUint8Array = util.decodeBase64(secret); - - const dbNames = await page.evaluate(() => { - return new Promise((resolve, reject) => { - let db = indexedDB.open('TimeSafari'); - db.onsuccess = async (event) => { - this.db = event.target.result; - const transaction = this.db.transaction('settings', 'readonly'); - const objectStore = transaction.objectStore('settings'); - const request = objectStore.get(1); - request.onsuccess = () => { - const row = request.result; - resolve(row); - } - }; - }); - }, {timeout: 10000}); - - const dbAccounts = await page.evaluate(() => { - return new Promise((resolve, reject) => { - let db = indexedDB.open('TimeSafariAccounts'); - db.onsuccess = async (event) => { - this.db = event.target.result; - const transaction = this.db.transaction('accounts', 'readonly'); - const objectStore = transaction.objectStore('accounts'); - const request = objectStore.getAll(); - request.onsuccess = () => { - const rows = request.result; - resolve(rows); - } - }; - }); - }, {timeout: 10000}); - - for (var i = 0; i < dbAccounts.length; i++) { - let account = dbAccounts[i]; - let did = account['did']; - let publicKeyHex = account['publicKeyHex']; - let identity = account['identity']; - - const messageWithNonceAsUint8Array = util.decodeBase64(identity); - const nonce = messageWithNonceAsUint8Array.slice(0, 24); - const message = messageWithNonceAsUint8Array.slice(24, identity.length); - - const decrypted = nacl.secretbox.open(message, nonce, secretUint8Array); - - const decoder = new TextDecoder('utf-8'); - const string = decoder.decode(decrypted); - const indentifier = JSON.parse(string); - - - } switch (data.command) { case 'account':