[译] Dweb: 基于 Secure Scuttlebutt 的社交消息流 (中英)

栏目: Node.js · 发布时间: 5年前

原文hacks.mozilla.org/2018/08/dwe…

作者André Staltz 发表时间 :August 8, 2018

译者 :西楼听雨 发表时间: 2018/8/19

原文是 Mozilla 开发者网站发布的关于 Dweb 的概念、应用及使用案例介绍的系列文章中的第二篇。( 转载请注明出处 )

In theseries introduction, we highlighted the importance of putting people in control their social interactions online, instead of allowing for-profit companies be the arbiters of hate speech or harassment. Our first installment in the Dweb series introduces Secure Scuttlebutt, which envisions a world where users are in full control of their communities online.

(译注:以下斜体文本是原文的编者按)

在本系列的开篇中,我们着重说明了让人们拥有在线社交互动自主权的重要性,而不是放纵那些追求利益的公司成为诋毁性言论和信息骚扰问题的仲裁方。在这个 Dweb 系列中,我们首先准备发表的是对 Secure Scuttlebutt 的介绍,它让我们可以设想一个用户拥有对自己的在线交流的彻底控制权的世界。

In the weeks ahead we will cover a variety of projects that represent explorations of the decentralized/distributed space. 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.

在未来的几周内我们还将讲到各种类型的项目,他们是我们在去中心化和分布式领域进行探索的见证。这些项目并不附属于 Mozilla,其中一些项目还重新定义了我们对 web 浏览器的认识。他们都有一个共同点:这些项目都是开源的,开放公众参与的,并且和 Mozilla 的“keep web open and accessible for all (让 Web 对所有人保持开放和可访问)”的宗旨一致。

This post is written by André Staltz, who haswritten extensively on the fate of the web in the face of mass digital migration to corporate social networks, and is a core contributor to the Scuttlebutt project. –Dietrich Ayala

这篇贴文的作者是 André Staltz,他已经写过 大量关于在大规模数字迁移至企业社交网络危机下 web 未来的命运的文章,另外他还是 Scuttlebutt 项目的核心成员。——Dietrich Ayala

Scuttlebutt 入门

Scuttlebutt is a free and open source social network with unique offline-first and peer-to-peer properties. As a JavaScript open source programmer, I discovered Scuttlebutt two years ago as a promising foundation for a new “social web” that provides an alternative to proprietary platforms. The social metaphor of mainstream platforms is now a more popular way of creating and consuming content than the Web is. Instead of attempting to adapt existing Web technologies for the mobile social era, Scuttlebutt allows us to start from scratch the construction of a new ecosystem.

Scuttlebutt 是一款免费、开源的社交网络。我是一名 JavaScript 开源程序开发者,我是在两年前发现 Scuttlebutt 的,当时我觉得它有望成为一种可以对抗私有化平台的“新型社交 web”形态。现在主流的平台对社交的涵义认识普遍是一种比 Web 的形式更流行的方式——内容的创建和消费。在这样一个移动社交时代,相对于尝试在现有的 Web 技术中进行适应,Scuttlebutt 的方式是重新从零开始构建一个新的生态系统。

一个与好友共享的本地数据库

The central idea of the Secure Scuttlebutt (SSB) protocol is simple: your social account is just a cryptographic keypair (your identity) plus a log of messages (your feed) stored in a local database. So far, this has no relation to the Internet, it is just a local database where your posts are stored in an append-only sequence, and allows you to write status updates like you would with a personal diary. SSB becomes a social network  when those local feeds are shared among computers through the internet or through local networks. The protocol supports peer-to-peer replication of feeds, so that you can have local (and full) copies of your friends’ feeds, and update them whenever you are online. One implementation of SSB, Scuttlebot , uses Node.js and allows UI applications to interact with the local database and the network stack.

Secure Scuttlebutt 的中心思想非常简单:你的社交账户就是存放于本地数据库中的一个(密码学上的)密钥对(即你的身份标志)及消息记录本(即消息流)。如果只是这样的话,它只是一个本地数据库,和互联网没有任何关系。不过当这些本地数据库通过互联网或本地网络在多台电脑之间相互共享时,SSB 就变成了一个了社交网络。这种(共享)协议支持点对点的信息流复制(交换),因此在你的本地你会拥有你朋友们的消息流的副本——只要你一上线(联网),这些副本就会更新。SSB 的其中一个实现就是 Scuttlebot ,它使用的是 Node.js 开发的,提供了用户界面来(方便地)与本地数据库及网络栈进行交互。

[译] Dweb: 基于 Secure Scuttlebutt 的社交消息流 (中英)

Scuttlebot 的使用

While SSB is being implemented in multiple languages ( Go , Rust ,C), its main implementation at the moment is the npm package scuttlebot and Electron desktop apps that use Scuttlebot. To build your own UI application from scratch, you can setup Scuttlebot plus a localhost HTTP server to render the UI in your browser.

现在 SSB 正在被多种语言 (Go、Rust、C) 所实现,不过目前它最主要的实现还是 scuttlebot 这个 npm 包以及基于它的用 Electron 开发的桌面应用。 如果想要从空白开始构建一款你自己的用户界面应用,你可以采用 Scuttlebot 搭配一个 HTTP 服务的方式通过浏览器来展示界面。

Run the following npm command to add Scuttlebot to your Node.js project:

运行以下 npm 命令,将 Scuttlebot 添加到你的 Node.js 项目中:

npm install --save scuttlebot复制代码

然后,你可以在本地用命令行界面来发布消息、查看消息,和朋友建立连接。首先,启动服务:

$(npm bin)/sbot server复制代码

In another terminal you can use the server to publish a message in your local feed:

然后在另外一个终端窗口中你可以通过这个服务在本地消息流中发布一条消息:

$(npm bin)/sbot publish --type post --text "Hello world"复制代码
You can also consume invite codes to connect with friends and replicate their feeds. Invite codes are generated by 

pub servers  owned by friends in the community, which act as mirrors of feeds in the community. Using an invite code means the server will allow you to connect to it and will mirror your data too.


你也可以使用你获得的邀请码与朋友建立连接,进而获得他们的消息流。邀请码需要你的朋友使用他自己的 pub servers 来生成,邀请码就像是消息流的一个镜像。使用邀请码就意味着你可以连上其服务,同时你的数据也会成为一个镜像。

$(npm bin)/sbot invite.accept $你的邀请码复制代码

To create a simple web app to render your local feed, you can start the scuttlebot server in a Node.js script (with dependencies ssb-config and pull-stream ), and serve the feed through an HTTP server:

要创建一个简单的 web 应用来展示你的本地消息流,你可以通过 Node.js 脚本(将 ssb-config 和 pull-stream 作为依赖项)启动 Scuttlebot 服务,然后通过 HTTP 服务来提供消息流(的查询)来实现:

// server.js
const fs = require('fs');
const http = require('http');
const pull = require('pull-stream');
const sbot = require('scuttlebot/index').call(null, require('ssb-config'));
​
http
  .createServer((request, response) => {
    if (request.url.endsWith('/feed')) {
      pull(
        sbot.createFeedStream({live: false, limit: 100}),
        pull.collect((err, messages) => {
          response.end(JSON.stringify(messages));
        }),
      );
    } else {
      response.end(fs.readFileSync('./index.html'));
    }
  })
  .listen(9000);复制代码

运行 node server.js 命令启动服务,然后在浏览器访问 localhost:9000 时,返回内容如下的 index.html :

<html>
​
<body>
  <script>
    fetch('/feed')
      .then(res => res.json())
      .then(messages => {
        document.body.innerHTML = `
          <h1>Feed</h1>
          <ul>${messages
            .filter(msg => msg.value.content.type === 'post')
            .map(msg =>
              `<li>${msg.value.author} said: ${msg.value.content.text}</li>`
            )
          }</ul>
        `;
      });
  </script>
</body>
​
</html>复制代码

更多信息

SSB applications can accomplish more than social messaging. Secure Scuttlebutt is being used for Git collaboration , chess games , and managing online gatherings .

SSB 应用可以实现的不只是社交消息功能。Secure Scuttlebutt 还被应用在如 Git 协作象棋游戏管理在线发布聚会 上。

You build your own applications on top of SSB by creating or using plug-ins for specialized APIs or different ways of querying the database. See secret-stack for details on how to build custom plugins. See flumedb for details on how to create custom indexes in the database. Also there are many useful repositories in our GitHub org .

你可以通过创建或者使用(现有的)针对特定 API 或数据库查询方式的插件来构建你自己的基于 SBB 的应用。关于如何构建自定义插件,可查看 secret-stack 来获取详细的说明。关于如何在数据库中创建自定义索引,可查看 flumedb 来获取详细的说明。另外 在我们的 Github 组织上还有许多有用的仓库

To learn about the protocol that all of the implementations use, see theprotocol guide, which explains the cryptographic primitives used, and data formats agreed on.

要了解关于这些实现所共同使用的这种协议,可查看协议教程,它给出了关于其所使用的加密学基本原理及相关的数据格式的说明。

Finally, don’t miss the frontpageScuttlebutt.nz, which explains the design decisions and principles we value. We highlight the important role that humans have in internet communities, which should not be delegated to computers.

最后,请不要错过Scuttlebutt.nz,在其网页中详细说明了我们崇尚的设计决策和原则。我们认为人们在互联网的通讯中的所扮演的角色非常重要,这种角色不应该由电脑来代理。

关于 André Staltz

André Staltz is an open source hacker who maintains open source libraries and teaches JavaScript at conferences and workshops. He is a core contributor to the Scuttlebutt community, focusing on developing the first Android app as well as representing the community externally.

André Staltz 是一名开源软件黑客(译注:这里所谓的黑客并无贬义,相反是一种高尚的称号),他维护了许多开源软件库,同时在各种会议上和交流会中教授 JavaScript。他还是 Scuttlebutt 社区的核心成员,主要专注于(社区的)第一款安卓应用的开发,并在社区之外作为代表出现。


以上所述就是小编给大家介绍的《[译] Dweb: 基于 Secure Scuttlebutt 的社交消息流 (中英)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

解码宇宙

解码宇宙

(美) 塞费 / 隋竹梅 / 上海科技教育出版社 / 2010-4 / 26.00元

《解码宇宙:新信息科学看天地万物》:宇宙,或许就是一台庞大的计算机。这是查尔斯·塞费在《解码宇宙:新信息科学看天地万物》中对宇宙做出的结论。作者从信息的特点开始谈起,详细论述了信息论和量子计算,向我们展示了一种不可思议的拜占庭式宇宙的情景,涉及生命的本质、热力学、相对论、量子力学、黑洞、多重宇宙,直至宇宙的命运。《解码宇宙:新信息科学看天地万物》资料翔实,内容丰富多彩,思路清晰,观点明确,读后使人......一起来看看 《解码宇宙》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

MD5 加密
MD5 加密

MD5 加密工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具