[譯] Dweb: Beaker–去中心化的瀏覽器 (中英)

西樓聽雨發表於2019-02-26

原文Dweb: Serving the Web from the Browser with Beaker
作者Tara Vancil 發表時間:August 22, 2018
譯者:西樓聽雨 發表時間: 2018/8/25
原文是 Mozilla 開發者網站釋出的關於 Dweb 的概念、應用及使用案例介紹的系列文章中的第四篇。(轉載請註明出處)

本系列各篇章的翻譯連結如下:

  1. [譯] Dweb: 什麼是 Dweb?(中英)
  2. [譯] Dweb: 基於 Secure Scuttlebutt 的社交訊息流 (中英)
  3. [譯] Dweb: 用 WebTorrent 搭建一個可復原的 Web (中英)
  4. [譯] Dweb: Beaker——去中心化瀏覽器 (中英)
  5. [譯] Dweb: 基於 IPFS 的去中心化 Web 檔案系統 (中英)
  6. 待發布······

譯註:下面是斜體文字為原文的編者按。

展開原文

In this series we are covering projects that explore what is possible when the web becomes decentralized or distributed. These projects aren’t affiliated with Mozilla, and some of them rewrite the rules of how we think about a web browser. What they have in common: These projects are open source, and open for participation, and share Mozilla’s mission to keep the web open and accessible for all.

這個系列中,我們會講到一些正在嘗試探索在 Web 變為去中心化或分散式的時候存在哪些可能性的專案,這些專案不附屬於 Mozilla,其中一些專案還重新定義了我們對 web 瀏覽器的認識。他們都有共同點:這些專案都是開源的,開放參與的,並且和 Mozilla ”keep the web open and accessible for all (讓 Web 對所有人保持開放和可訪問)“ 的宗旨一致。

展開原文

So far we’ve covered distributed social feeds and sharing files in a decentralized way. with some new tools for developers. Today we’d like to introduce something a bit different: Imagine what an *entire browser experience* would be like if the web was distributed… Beaker browser does exactly this! Beaker is a big vision from a team who are proving out the distributed web from top to bottom. Please enjoy this post from Beaker co-creator Tara Vancil. – Dietrich Ayala

到這篇文章為止,我們已經講到過分散式的社交訊息流去中心化的檔案共享兩個主題。今天我們想要介紹一些不一樣的東西:想象一下,如果整個 web 都是分散式的······瀏覽器將會變成怎樣一種體驗。 Beaker 瀏覽器就是這樣一款瀏覽器!它代表了其背後開發團隊的一個巨集圖願景,這個團隊旨在提供從頂層設計到基礎設施各層面的去中心化 Web。這是一篇出自 Beaker 的聯合制作人 Tara Vancil 的貼文,請盡情享閱。——Dietrich Ayala

藍鏈實驗室及 Beaker 瀏覽器

展開原文

We’re Blue Link Labs, a team of three working to improve the Web with the Dat protocol and an experimental peer-to-peer browser called Beaker.

我們是藍鏈實驗室團隊,我們是一個3人團隊,我們的任務是用Dat 協議及一個叫做Beaker的點對點瀏覽器來讓 Web 變得更好。

Blue Link Labs team
展開原文

We work on Beaker because publishing and sharing is core to the Web’s ethos, yet to publish your own website or even just share a document, you need to know how to run a server, or be able to pay someone to do it for you.

Web 的基礎就是釋出和分享,現在如果你想釋出屬於自己的網站或者分享一些文件,你仍然需要懂得如何運營一臺伺服器,或者具備因僱人幫你做這些而支付報酬的能力。

So we asked ourselves, “What if you could share a website directly from your browser?”

所以我們開始思考“是否我們可以僅在瀏覽器裡就能搭建一個網站?”

展開原文

Peer-to-peer protocols like `dat://` make it possible for regular user devices to host content, so we use `dat://` in Beaker to enable publishing from the browser, where instead of using a server, a website’s author and its visitors help host its files. It’s kind of like BitTorrent, but for websites!

dat:// 這類點對點 (P2P) 協議使得實現這種想法變為可能,普通的使用者裝置也可以用來提供內容服務,所以我們沒有使用伺服器——那種需要網站作者和他的訪客來支援其檔案供應服務的形式 ,而是採用了 data:// 及 Beaker 來支援在瀏覽器中釋出內容。這有點像 BitTorrent,不過是針對瀏覽器的!

架構

Beaker uses a distributed peer-to-peer network to publish websites and datasets (sometimes we call them “dats”).

Beaker 採用的是一種點對點(P2P)式的網路來釋出網站及資料的(有時候我們也稱之為 “dats”)。

展開原文

`dat://` websites are addressed with a public key as the URL, and each piece of data added to a `dat://` website is appended to a signed log. Visitors to a `dat://` website find each other with a tracker or [DHT](https://en.wikipedia.org/wiki/Distributed_hash_table), then sync the data between each other, acting both as downloaders and uploaders, and checking that the data hasn’t been tampered with in transit.

dat:// 網站的地址是以公鑰作為 URL 來標識的。每份新增到 dat:// 網站的資料都會被追加到一個簽名的日誌本上。訪客們通過 tracker 協議或 DHT 網路來相互找尋各方,然後相互進行資料同步,同時充當下載者(流量下行)和上傳者(流行上行),在此過程中還會對資料是否被篡改做檢查。

a basic illustration of the dat:// network
展開原文

At its core, a `dat://` website isn’t much different than an https:// website — it’s a collection of files and folders that a browser interprets according to Web standards. But `dat://` websites are special in Beaker because we’ve added [peer-to-peer Web APIs](https://beakerbrowser.com/docs/apis) so developers can do things like read, write, and watch `dat://` files and build peer-to-peer Web apps.

從本質上講,一個dat://網站和一個 https:// 網站沒有什麼不同——都是瀏覽器按照 Web 的系列標準來解釋一系列檔案及目錄的形式。但是 dat:// 網站特殊的地方就在於 Beaker,因為我們為其附加了“點對對 Web 介面”, 以便開發者可以進行讀取、寫入及監測 dat:// 檔案從而構建出點對點 Web 應用。

建立一個 P2P 網站

展開原文

Beaker makes it easy for anyone to create a new `dat://` website with one click (see our [tour](https://beakerbrowser.com/docs/tour)). If you’re familiar with HTML, CSS, or JavaScript (even just a little bit!) then you’re ready to publish your first `dat://` website.

Beaker 使得任何人建立一個 dat:// 網站都變得容易——只需一次點選即可完成(檢視我們的教程)。如果你對 HTML、CSS 及 JavaScript 熟悉的話(哪怕只一丁點熟悉),你就可以開始釋出你的第一個 dat:// 網站了。

Developers can get started by checking out our API documentation or reading through our guides.

開發人員可以通過檢視我們的 API 文件或者查閱我們的指導教程來入門。

展開原文

This example shows a website editing *itself* to create and save a new JSON file. While this example is contrived, it demonstrates a common pattern for storing data, user profiles, etc. in a `dat://` website—instead of application data being sent away to a server, it can be stored in the website itself!

下面這個例子展示了一個可以自我編輯以此建立和儲存檔案的網站。雖然這個例子不貼實際,但它完整地展示了一個 dat:// 網站在資料排序,使用者資訊等資料處理方面所共有的操作模式,和那些把應用資料傳輸至一臺伺服器去處理的形式不一樣,這種形式可以把資料儲存在這個網站本身。

// index.html 檔案

傳送訊息

<script src="index.js"></script>

複製程式碼
// index.js 檔案

// first get an instance of the website`s files
// 首先例項化該網站的檔案集合物件
var files = new DatArchive(window.location)

document.getElementById(`create-json-button`).addEventListener(`click`, saveMessage)

async function saveMessage () {
    var timestamp = Date.now()
    var filename = timestamp + `.json`
    var content = {
    timestamp,
    message: document.getElementById(`message`).value
}

// write the message to a JSON file
// this file can be read later using the DatArchive.readFile API
// 將訊息寫入一個 JSON 檔案
// 這個檔案在之後還可以通過 DataArchive.readFile 介面進行讀取
await files.writeFile(filename, JSON.stringify(content))
}
複製程式碼

更多資訊

展開原文

We’re always excited to see what people build with `dat://` and Beaker. We especially love seeing when someone builds a personal site or blog, or when they experiment with Beaker’s APIs to build an app.

每次看到大家用 dat:// 及 Beaker 創造出一些東西來的時候,我們都很激動,特別是當有人用其製作出網站或部落格的時候,或者當他們嘗試用 Beaker 提供的 API 來製作 App 的時候。

展開原文

There’s lots to explore on the peer-to-peer Web!

關於點對點 Web 的資訊還有很多!

關於 Tara Vancil

展開原文

Tara is the co-creator of the [Beaker browser](https://beakerbrowser.com/). Previously she worked at Cloudflare and participated in [the Recurse Center](https://recurse.com/).

Tara 是 Beaker 瀏覽器的聯合制作人。她之前在 Cloudflare 工作過,另外她還參加了 the Recurse Center

相關文章