dhilip89
2019-10-23
Problem
It is currently no way to make a P2P web application to work without first downloading JavaScript from a web server.
Use Case
Any kind of decentralized web applications.
Requirements
- Must be able to work without a HTTP(S) web server.
- Overlay network should be implementation agnostic (eg. DHT implemented in JavaScript).
Implementation Idea
Workflow:
- User open
p2p://app.example.com/
with web browser. - Web browser lookup DNS records for
app.example.com
. - Web browser then process DNS TXT records.
- If
web-p2p: true
is found then load JavaScript code (bootstrapping code, should be as short as possible):web-p2p-1: console.log('this is JS part 1');'
web-p2p-2: console.log('this is JS part 2');'
web-p2p-3: console.log('this is JS part 3');'
...
web-p2p-14: console.log('this is JS part 14');'
- JavaScript is then concatenated and executed to perform logic to join P2P overlay network.
- Additional assets may be loaded from joined P2P overlay network.
- P2P web application is loaded and ready to use.
Caveats:
- Domain name and DNS dependent.
- JavaScript code have to split into many parts to workaround TXT record length limitation (255).
- Due to absense of SSL/TLS, security have to be managed by the application.