Browse Source

Added noble-curves.js

home-view-notification-improvements
Matthew Raymer 12 months ago
parent
commit
fc37f475d5
  1. 3
      sw_scripts/additional-scripts.js
  2. 4772
      sw_scripts/noble-curves.js
  3. 15
      sw_scripts/safari-notifications.js

3
sw_scripts/additional-scripts.js

@ -9,8 +9,7 @@ self.addEventListener("install", (event) => {
importScripts(
"safari-notifications.js",
"nacl.js",
"sw-bn.js",
"secp256k1.js",
"noble-curves.js",
);
console.log("scripts imported", event);
});

4772
sw_scripts/noble-curves.js

File diff suppressed because it is too large

15
sw_scripts/safari-notifications.js

@ -282,18 +282,13 @@ function bufferFromBase64(base64) {
}
return async function(data) {
const privateKey = Secp256k1.uint256(privateKeyBytes, 16);
const hash = await sha256(data);
console.error("sha256", hash);
const digest = Secp256k1.uint256(hash, 16);
const signature = Secp256k1.ecsign(privateKey, digest);
const sigR = Secp256k1.uint256(signature.r,16);
const sigS = Secp256k1.uint256(signature.s,16);
const signature = nobleCurves.secp256k1.sign(hash, privateKeyBytes);
return toJose({
r: leftpad(signature.r.toString(16)),
s: leftpad(signature.s.toString(16)),
recoveryParam: signature.v,
recoveryParam: signature.recovery,
}, recoverable);
}
}
@ -441,7 +436,9 @@ async function getNotificationCount() {
const decrypted = self.secretbox.open(message, nonce, secretUint8Array);
const msg = decoder.decode(decrypted);
const identifier = JSON.parse(JSON.parse(msg));
const identifier = JSON.parse(JSON.parse(msg));
console.log(identifier);
const headers = {
"Content-Type": "application/json",

Loading…
Cancel
Save