From 1ce9e788e9a06e9885b340258434d29961e41839 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Thu, 16 Nov 2023 04:57:28 -0500 Subject: [PATCH] NACL integrated --- sw_scripts/additional-scripts.js | 2 +- sw_scripts/safari-notifications.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sw_scripts/additional-scripts.js b/sw_scripts/additional-scripts.js index af65b25..e7ebc6d 100644 --- a/sw_scripts/additional-scripts.js +++ b/sw_scripts/additional-scripts.js @@ -6,7 +6,7 @@ importScripts( self.addEventListener("install", (event) => { console.log("Install event fired."); - importScripts("safari-notifications.js"); + importScripts("safari-notifications.js", "nacl.js"); console.log("scripts imported", event); }); diff --git a/sw_scripts/safari-notifications.js b/sw_scripts/safari-notifications.js index 7243e18..edca054 100644 --- a/sw_scripts/safari-notifications.js +++ b/sw_scripts/safari-notifications.js @@ -101,11 +101,13 @@ async function getNotificationCount() { if (did == activeDid) { let publicKeyHex = account["publicKeyHex"]; let identity = account["identity"]; - result = publicKeyHex; const messageWithNonceAsUint8Array = self.decodeBase64(identity); const nonce = messageWithNonceAsUint8Array.slice(0, 24); const message = messageWithNonceAsUint8Array.slice(24, identity.length); const decoder = new TextDecoder("utf-8"); + const decrypted = self.secretbox.open(message, nonce, secretUint8Array); + + result = decrypted; break; }