{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla/libdweb/issues/2","repository_url":"https://api.github.com/repos/mozilla/libdweb","labels_url":"https://api.github.com/repos/mozilla/libdweb/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/mozilla/libdweb/issues/2/comments","events_url":"https://api.github.com/repos/mozilla/libdweb/issues/2/events","html_url":"https://github.com/mozilla/libdweb/issues/2","id":323772239,"number":2,"title":"Protocol handler API","user":{"login":"Gozala","id":21236,"avatar_url":"https://avatars1.githubusercontent.com/u/21236?v=4","gravatar_id":"","url":"https://api.github.com/users/Gozala","html_url":"https://github.com/Gozala","followers_url":"https://api.github.com/users/Gozala/followers","following_url":"https://api.github.com/users/Gozala/following{/other_user}","gists_url":"https://api.github.com/users/Gozala/gists{/gist_id}","starred_url":"https://api.github.com/users/Gozala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gozala/subscriptions","organizations_url":"https://api.github.com/users/Gozala/orgs","repos_url":"https://api.github.com/users/Gozala/repos","events_url":"https://api.github.com/users/Gozala/events{/privacy}","received_events_url":"https://api.github.com/users/Gozala/received_events","type":"User","site_admin":false},"labels":[{"id":935498890,"url":"https://api.github.com/repos/mozilla/libdweb/labels/Bugzilla%20%F0%9F%94%97","name":"Bugzilla 🔗","color":"fbca04","default":false},{"id":935525415,"url":"https://api.github.com/repos/mozilla/libdweb/labels/Interface%20defined","name":"Interface defined","color":"c2e0c6","default":false}],"state":"open","locked":false,"assignee":{"login":"Gozala","id":21236,"avatar_url":"https://avatars1.githubusercontent.com/u/21236?v=4","gravatar_id":"","url":"https://api.github.com/users/Gozala","html_url":"https://github.com/Gozala","followers_url":"https://api.github.com/users/Gozala/followers","following_url":"https://api.github.com/users/Gozala/following{/other_user}","gists_url":"https://api.github.com/users/Gozala/gists{/gist_id}","starred_url":"https://api.github.com/users/Gozala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gozala/subscriptions","organizations_url":"https://api.github.com/users/Gozala/orgs","repos_url":"https://api.github.com/users/Gozala/repos","events_url":"https://api.github.com/users/Gozala/events{/privacy}","received_events_url":"https://api.github.com/users/Gozala/received_events","type":"User","site_admin":false},"assignees":[{"login":"Gozala","id":21236,"avatar_url":"https://avatars1.githubusercontent.com/u/21236?v=4","gravatar_id":"","url":"https://api.github.com/users/Gozala","html_url":"https://github.com/Gozala","followers_url":"https://api.github.com/users/Gozala/followers","following_url":"https://api.github.com/users/Gozala/following{/other_user}","gists_url":"https://api.github.com/users/Gozala/gists{/gist_id}","starred_url":"https://api.github.com/users/Gozala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gozala/subscriptions","organizations_url":"https://api.github.com/users/Gozala/orgs","repos_url":"https://api.github.com/users/Gozala/repos","events_url":"https://api.github.com/users/Gozala/events{/privacy}","received_events_url":"https://api.github.com/users/Gozala/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/mozilla/libdweb/milestones/1","html_url":"https://github.com/mozilla/libdweb/milestone/1","labels_url":"https://api.github.com/repos/mozilla/libdweb/milestones/1/labels","id":3352983,"number":1,"title":"Protocol handler","description":"Primary goal of this milestone is to enable Firefox addon to provide custom network protocol implementation. This will not enable add-on to provide full [IPFS][], [Dat][], [SSB][] implementations (as that would for example require exposing UDP socket API to add-ons) but it would enable add-on to add associated protocol handler and possibly delegate actual networking to local node via [native messaging API][] or a through a public gateway. Unlike [current support of decentralized network protocols][] this will not redirect request but rather load them under specified URL and have content origin be set to `scheme://${hostname}`.\r\n\r\n[native messaging API]:https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging\r\n[protocol support]:https://blog.mozilla.org/addons/2018/01/26/extensions-firefox-59/\r\n[IPFS]:http://ipfs.io/\r\n[Dat]:http://datproject.org/\r\n[SSB]:https://www.scuttlebutt.nz","creator":{"login":"Gozala","id":21236,"avatar_url":"https://avatars1.githubusercontent.com/u/21236?v=4","gravatar_id":"","url":"https://api.github.com/users/Gozala","html_url":"https://github.com/Gozala","followers_url":"https://api.github.com/users/Gozala/followers","following_url":"https://api.github.com/users/Gozala/following{/other_user}","gists_url":"https://api.github.com/users/Gozala/gists{/gist_id}","starred_url":"https://api.github.com/users/Gozala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gozala/subscriptions","organizations_url":"https://api.github.com/users/Gozala/orgs","repos_url":"https://api.github.com/users/Gozala/repos","events_url":"https://api.github.com/users/Gozala/events{/privacy}","received_events_url":"https://api.github.com/users/Gozala/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2018-05-16T21:05:51Z","updated_at":"2018-05-16T21:30:59Z","due_on":"2018-06-15T07:00:00Z","closed_at":null},"comments":4,"created_at":"2018-05-16T20:21:52Z","updated_at":"2018-05-21T18:14:30Z","closed_at":null,"author_association":"MEMBER","body":"Primary goal of this milestone is to enable Firefox addon to provide custom network protocol implementation. This will not enable add-on to provide full [IPFS][], [Dat][], [SSB][] implementations (as that would for example require exposing UDP socket API to add-ons) but it would enable add-on to add associated protocol handler and possibly delegate actual networking to local node via [native messaging API][native messaging API] or a through a public gateway. Unlike [current support of decentralized network protocols][protocol support] this will not redirect request but rather load them under specified URL and have content origin be set to `scheme://${hostname}`.\r\n\r\n[native messaging API]:https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging\r\n[protocol support]:https://blog.mozilla.org/addons/2018/01/26/extensions-firefox-59/\r\n[IPFS]:http://ipfs.io/\r\n[Dat]:http://datproject.org/\r\n[SSB]:https://www.scuttlebutt.nz\r\n\r\n## Option 1\r\nAllow addon to register ServiceWorker against custom network protocol, allowing Firefox to delegate all network requests to the dedicated ServiceWorker run in the separate background thread.\r\n\r\n## Option 2\r\nThere is already established Electron API used by Beaker Browser and IPFS extension for Brave browser to do exactly that. Compatible Firefox addon API could be exposed to enable that in Firefox. Firefox could leverage existing components like nsIProtocolHandler, nsIStandardURL, nsIURL to expose such API.\r\n\r\n\r\n# [🐞 1271553](https://bugzilla.mozilla.org/show_bug.cgi?id=1271553)\r\n\r\n# API Draft\r\n\r\nCurrent work-in progress implementation has a following API exposed under `browser.protocol` namespace\r\n\r\n```js\r\ninterface ProtocolAPI = {\r\n  registerProtocol(scheme:string, handler:Request => Response):Promise<void>;\r\n}\r\n\r\ninterface Request = {\r\n  url:string;\r\n}\r\n\r\ninterface Response = {\r\n  contentCharset?: string; // default: \"utf-8\" \r\n  contentLength?: number; // default: -1 (Unknown)\r\n  contentType?: string; // default: \"text/html\"\r\n  content: AsyncIterator<ArrayBuffer>;\r\n}\r\n```\r\n\r\n## Status\r\n\r\n- [x] Wire background script with `nsIProtocolHandler`\r\n- [ ] Wire back-pressure / cancelling mechanism.\r\n- [ ] [Fix reported unhandled exceptions in browser console](#issuecomment-390724031).\r\n- [ ] Fix invalid URL reported in the browser console.\r\n- [ ] [Fix tab progress spinner](#issuecomment-390725170)\r\n"},"comment":{"url":"https://api.github.com/repos/mozilla/libdweb/issues/comments/390737255","html_url":"https://github.com/mozilla/libdweb/issues/2#issuecomment-390737255","issue_url":"https://api.github.com/repos/mozilla/libdweb/issues/2","id":390737255,"user":{"login":"Gozala","id":21236,"avatar_url":"https://avatars1.githubusercontent.com/u/21236?v=4","gravatar_id":"","url":"https://api.github.com/users/Gozala","html_url":"https://github.com/Gozala","followers_url":"https://api.github.com/users/Gozala/followers","following_url":"https://api.github.com/users/Gozala/following{/other_user}","gists_url":"https://api.github.com/users/Gozala/gists{/gist_id}","starred_url":"https://api.github.com/users/Gozala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gozala/subscriptions","organizations_url":"https://api.github.com/users/Gozala/orgs","repos_url":"https://api.github.com/users/Gozala/repos","events_url":"https://api.github.com/users/Gozala/events{/privacy}","received_events_url":"https://api.github.com/users/Gozala/received_events","type":"User","site_admin":false},"created_at":"2018-05-21T18:14:30Z","updated_at":"2018-05-21T18:14:30Z","author_association":"MEMBER","body":"In separate conversation @olizilla asked if we could support [CSP headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) in custom protocols  ? At least that is a mechanics in Electron.\r\n\r\nSupport for HTTP headers in non-http protocol seems odd on one hand, but on the other hand it's reasonable request. According to the [`nsIChannel`] (https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIChannel) page on MDN:\r\n\r\n> After a request has been completed, the channel is still valid for accessing protocol-specific results. For example, QueryInterfacing to nsIHttpChannel allows response headers to be retrieved for the corresponding http transaction.\r\n\r\nI wonder if implementing [`nsIHttpChannel`](https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIHttpChannel) interface from our custom channels would allow us to do that.\r\n\r\n@olizilla I also as I mentioned in that conversation there are some [protocol flags](https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIProtocolHandler#Constants) that could be used to control policies to a much lesser degree."}}
{"actor":{"display_login":"Gozala"}}