Created
October 18, 2021 04:59
-
-
Save amark/74e6ca101b9e8ba5669d6e856f344d79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TEMPORARY TEST FILE TO DELETE! | |
/* HOW IT WORKS: | |
........_______________. | |
APP -> | SECURE RENDER | <-> DATA | |
........---------------. | |
The app ONLY feeds *in* view logic. | |
Secure Render NEVER sends back or up. | |
*/ | |
;(function(){ | |
var i = document.createElement('iframe'); | |
i.style = "position: fixed; border: 0; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0;"; | |
function sub(msg){ i.contentWindow.postMessage(msg, '*') } | |
i.onload = function(){ sub({rpc: 'html', put: html}) } | |
i.sandbox = 'allow-scripts'; | |
i.csp = "default-src 'unsafe-inline'; img-src data:;"; | |
i.srcdoc = "<!DOCTYPE html><div id='securerender'></div><script>"+(function(){ | |
window.R = "SecureRender1"; | |
console.log("IN", window.R, location, self.crossOriginIsolated, 'SEA?', window.SEA, '------------', window.parent.frames, 'COOKIES!', document.cookies); document.cookies = "A=1;"; | |
window.onmessage = function(e){ | |
var msg = e.data; | |
if(!msg){ return } | |
console.log("from parent:", msg); | |
securerender.innerHTML = msg.put; | |
}; | |
setInterval(function(){ console.log("ping", window.R); }, 1000); | |
}+'').slice(11,-1)+"</script>"; | |
var html = document.body.innerHTML; document.body.innerHTML = ""; | |
document.body.appendChild(i); | |
window.i = i; | |
;(async function go(){ | |
return; | |
console.log("go"); | |
if(!window.GUN){ return load('http://localhost:8765/gun.js',go) } | |
window.gun = GUN('http://localhost:8765/gun'); | |
gun.get('test').map().once(function(data){ | |
if("data:" !== data.slice(0,5)){ return } | |
//console.log("base64", data); | |
//sub({rpc: 'html', put: "<img src='"+data+"'>"}) | |
}) | |
}()); | |
function load(src, cb){ | |
var script = document.createElement('script'); | |
script.onload = cb; script.src = src; | |
document.head.appendChild(script); | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment