forked from jsnbuchanan/crowd-funder-for-time-pwa
Selected active account and did a little decoding an extraction before building JWT
This commit is contained in:
@@ -5,11 +5,9 @@ importScripts(
|
||||
);
|
||||
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
importScripts("safari-notifications.js");
|
||||
})(),
|
||||
);
|
||||
console.log("Install event fired.");
|
||||
importScripts("safari-notifications.js");
|
||||
console.log("scripts imported", event);
|
||||
});
|
||||
|
||||
self.addEventListener("push", function (event) {
|
||||
|
||||
@@ -87,6 +87,7 @@ async function fetchAllAccounts() {
|
||||
async function getNotificationCount() {
|
||||
let secret = null;
|
||||
let accounts = [];
|
||||
let result = null;
|
||||
if ("secret" in self) {
|
||||
secret = self.secret;
|
||||
const secretUint8Array = self.decodeBase64(secret);
|
||||
@@ -94,22 +95,21 @@ async function getNotificationCount() {
|
||||
const activeDid = settings["activeDid"];
|
||||
accounts = await fetchAllAccounts();
|
||||
let did = null;
|
||||
let result = null;
|
||||
/**
|
||||
for (var i = 0; i < accounts.length; i++) {
|
||||
let account = accounts[i];
|
||||
let did = account['did'];
|
||||
if (did == activeDid) {
|
||||
let publicKeyHex = account['publicKeyHex'];
|
||||
let identity = account['identity'];
|
||||
|
||||
const messageWithNonceAsUint8Array = decodeBase64(identity);
|
||||
const nonce = messageWithNonceAsUint8Array.slice(0, 24);
|
||||
const message = messageWithNonceAsUint8Array.slice(24, identity.length);
|
||||
}
|
||||
**/
|
||||
for (var i = 0; i < accounts.length; i++) {
|
||||
let account = accounts[i];
|
||||
let did = account["did"];
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return accounts.length;
|
||||
}
|
||||
|
||||
self.getNotificationCount = getNotificationCount;
|
||||
|
||||
Reference in New Issue
Block a user