Commit 1ec3cc9f authored by taco@waag.org's avatar taco@waag.org
Browse files

library load order

parent d7ad9cc0
This diff is collapsed.
const zip = (a, b) => a.map((k, i) => [k, b[i]]);
//to test library integration was succesful
console.log(blockhashjs);
//post to verification backend
browser.runtime.onMessage.addListener(function(msg, sender, sendResponse){
......@@ -9,6 +11,8 @@ browser.runtime.onMessage.addListener(function(msg, sender, sendResponse){
let keys = msg.signatures.map(entry=> entry[0]);
let values = msg.signatures.map(entry=>entry[1]);
let envelopes = msg.signatures.map(entry=>entry[2]);
//TODO first calculate all hashes and replace the message of each img fragment
//then verify everything
Promise.all(values.map(signature =>
fetch('http://localhost:3000/verify', { method: 'POST', headers: {
......
......@@ -23,7 +23,7 @@
"run_at": "document_idle"
}],
"background": {
"scripts": ["local_backend.js"]
"scripts": ["zlib.js","blockhash.js","local_backend.js"]
},
"web_accessible_resources": ["icons/clippy.svg"]
}
//this is a content script, fired at document complete (it can not do xhr)
console.log("pop verification extension loaded (v0) ")
console.log("pop verification extension loaded (v0) ");
//console.log(blockhash);
//implementation of unpacking signatures for verification according to v0
//step 1. base64 decode
//step 2. normalize message using textContent
function signatures_v0(fragments){
return Array.from(fragments).map(node =>{
return Array.from(fragments).map(node =>{
//get the v0 attribute, there should only be one per fragment!
let attribute = Array.from(node.attributes).filter(a => a.name.includes("data-pop-v0-"))[0];
......@@ -17,6 +20,7 @@ function signatures_v0(fragments){
var obj = JSON.parse(signature_string);
if(fragment_type == "data-pop-v0-img")
{
//calculate hash of the image in the backend based on this url
obj.message = node.getAttribute('src');
}
else
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment