Browse Source

NACL integrated

pull/78/head
Matthew Raymer 1 year ago
parent
commit
1ce9e788e9
  1. 2
      sw_scripts/additional-scripts.js
  2. 4
      sw_scripts/safari-notifications.js

2
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);
});

4
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;
}

Loading…
Cancel
Save