paint-brush
ActivityPub简介:社交网络的未来经过@thebojda
7,886 讀數
7,886 讀數

ActivityPub简介:社交网络的未来

经过 Laszlo Fazekas10m2023/10/07
Read on Terminal Reader

太長; 讀書

ActivityPub 是一种由万维网标准化的开放式分布式社交网络协议。它唯一的弱点是它使用 HTTP 协议,需要一个中央服务器。 ActivityPub 协议应该通过对现有去中心化协议的支持进行扩展,这将使 Fediverse 朝着更加开放和去中心化的方向发展。
featured image - ActivityPub简介:社交网络的未来
Laszlo Fazekas HackerNoon profile picture

ActivityPub是由万维网联盟标准化的开放式分布式社交网络协议。它的第一个版本于 2018 年发布,所以它并不新鲜。它被多个社交网络使用,其中包括Mastodon ,最近,当埃隆·马斯克 (Elon Musk) 收购 Twitter 并做出了一些让很多人不满意的改变后,Mastodon 的受欢迎程度显着增加。


此外,Tumblr 和 Facebook 的 Twitter 替代品 Threads 也已表示未来将支持该协议。尽管不是一个新协议,ActivityPub 现在变得越来越流行。


由于欧盟和美国长期以来一直担心大型社交网络的市场垄断,我可以想象,未来在政府压力下,现有最大的社交网络如Facebook和Twitter也将支持该协议并成为联邦宇宙的一部分。 (Fediverse 是一个由支持 ActivityPub 的提供商组成的社交网络世界。)


我相信,未来我们不会选择Twitter或Facebook,因为它们会被关闭,我们别无选择。


每个平台的优势将来自于谁拥有更好的人工智能来过滤传入的海量数据,为用户筛选、选择和总结最重要的信息。


当然,要做到这一点,必须非常了解用户,这也符合用户的利益。作为回报,人工智能可以提供更多相关的广告。


在一个开放、可访问的系统中,竞争将不再是社交网络之间,而是基于人工智能的算法之间。


让我们看看 ActivityPub 是如何工作的。这个非常简单的图表很好地总结了基本功能。

ActivityPub 解释


来源:https://activitypub.rocks/



该协议有两个主要组成部分:收件箱和发件箱。这是两个可以通过 HTTP 协议访问的 API 端点。当用户想要与外界交流某些内容(例如,发布一些内容)时,他们会将其发送到发件箱。在这里,系统将其添加到适当的列表中,关注者可以通过阅读发件箱来访问该列表。


如果外部世界的某人想要向用户发送某些内容(例如,只能由某些用户看到的非公开帖子),他们会以加密形式将其发送到收件箱。收件箱就像电子邮件收件箱,收集传入的内容并让用户可以访问它。


人们可以使用 WebFinger 协议检索收件箱和发件箱的位置。这也可以在ActivityPub Explorer的帮助下进行测试,这是一个用于实验和理解协议的超级工具。


ActivityPub 中的用户名类似于电子邮件地址。例如,我的 Mastodon 用户名是@[email protected]。这意味着我的用户信息以 thebojda 名称存储在 dm.me 服务器上。


当进入ActivityPub Explorer时,它会根据WebFinger协议查询以下URL来检索数据:


 https://me.dm/.well-known/webfinger?resource=acct:thebojda%40me.dm


响应是一个 JSON 对象,如下所示:


 { "subject":"acct:[email protected]", "aliases":[ "https://me.dm/@thebojda", "https://me.dm/users/thebojda" ], "links":[ { "rel":"http://webfinger.net/rel/profile-page", "type":"text/html", "href":"https://me.dm/@thebojda" }, { "rel":"self", "type":"application/activity+json", "href":"https://me.dm/users/thebojda" }, { "rel":"http://ostatus.org/schema/1.0/subscribe", "template":"https://me.dm/authorize_interaction?uri={uri}" } ] }


从这里可以确定,可以通过https://me.dm/users/thebojda URL 访问 ActivityPub 信息。如果我们将其输入 ActivityPub Explorer,它将返回以下 JSON:


 { "@context": [ "https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1", { "manuallyApprovesFollowers": "as:manuallyApprovesFollowers", "toot": "http://joinmastodon.org/ns#", "featured": { "@id": "toot:featured", "@type": "@id" }, "featuredTags": { "@id": "toot:featuredTags", "@type": "@id" }, "alsoKnownAs": { "@id": "as:alsoKnownAs", "@type": "@id" }, "movedTo": { "@id": "as:movedTo", "@type": "@id" }, "schema": "http://schema.org#", "PropertyValue": "schema:PropertyValue", "value": "schema:value", "discoverable": "toot:discoverable", "Device": "toot:Device", "Ed25519Signature": "toot:Ed25519Signature", "Ed25519Key": "toot:Ed25519Key", "Curve25519Key": "toot:Curve25519Key", "EncryptedMessage": "toot:EncryptedMessage", "publicKeyBase64": "toot:publicKeyBase64", "deviceId": "toot:deviceId", "claim": { "@type": "@id", "@id": "toot:claim" }, "fingerprintKey": { "@type": "@id", "@id": "toot:fingerprintKey" }, "identityKey": { "@type": "@id", "@id": "toot:identityKey" }, "devices": { "@type": "@id", "@id": "toot:devices" }, "messageFranking": "toot:messageFranking", "messageType": "toot:messageType", "cipherText": "toot:cipherText", "suspended": "toot:suspended", "focalPoint": { "@container": "@list", "@id": "toot:focalPoint" } } ], "id": "https://me.dm/users/thebojda", "type": "Person", "following": "https://me.dm/users/thebojda/following", "followers": "https://me.dm/users/thebojda/followers", "inbox": "https://me.dm/users/thebojda/inbox", "outbox": "https://me.dm/users/thebojda/outbox", "featured": "https://me.dm/users/thebojda/collections/featured", "featuredTags": "https://me.dm/users/thebojda/collections/tags", "preferredUsername": "thebojda", "name": "Laszlo Fazekas", "summary": "<p>Software developer, contributing writer</p>", "url": "https://me.dm/@thebojda", "manuallyApprovesFollowers": false, "discoverable": false, "published": "2023-03-02T00:00:00Z", "devices": "https://me.dm/users/thebojda/collections/devices", "publicKey": { "id": "https://me.dm/users/thebojda#main-key", "owner": "https://me.dm/users/thebojda", "publicKeyPem": "-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxlvpgcOxBikiXfm9snZt EB3Y2BSnBW3s8nd1d4Z1wCzaNfa/woB6RDQJoQYEISbMpkEyWhDzI4jRDafpn5/j YiyyGka9U2KZHv1to0Ej9uVwUcQOnsq9iUtJGhOWCP27blKGTLKFEHtPL2Y4hp4Z kYzlh1x0aAyw8YC7/nbS8WDAeZNS7R3ET7Syhp3LKiCMmL1aCLSoOQJ5DdxVikMJ rJ9bzlUjxzCsm1aNBB0i269t4fD1evBO8QDhEAOnAZ6wLEV74j9SCjYMvKRV8z5i PQbhbKntXjn1XhbkIkj1D+yGRYYfnm1XyWTuaM4mDllvuOyqJ8GQVFADLc6KCQYz 7QIDAQAB -----END PUBLIC KEY----- " }, "tag": [], "endpoints": { "sharedInbox": "https://me.dm/inbox" }, "icon": { "type": "Image", "mediaType": "image/jpeg", "url": "https://media.me.dm/accounts/avatars/109/955/144/019/799/820/original/fe8e930e0f1467ac.jpeg" } }


在这里,您可以找到有关我的所有特定于用户的信息,但最重要的是,这里是收件箱和发件箱端点的 URL,以及用于加密发送给我的消息的公钥。查询发件箱内容时,返回如下JSON:


 { "@context": "https://www.w3.org/ns/activitystreams", "id": "https://me.dm/users/thebojda/outbox", "type": "OrderedCollection", "totalItems": 1, "first": "https://me.dm/users/thebojda/outbox?page=true", "last": "https://me.dm/users/thebojda/outbox?min_id=0&page=true" }


由于帖子分为页面,因此我们可以看到第一页和最后一页的 URL。通过访问第一页的URL,我们可以查看我的条目,目前只有一条。


 { "@context": [ "https://www.w3.org/ns/activitystreams", { "ostatus": "http://ostatus.org#", "atomUri": "ostatus:atomUri", "inReplyToAtomUri": "ostatus:inReplyToAtomUri", "conversation": "ostatus:conversation", "sensitive": "as:sensitive", "toot": "http://joinmastodon.org/ns#", "votersCount": "toot:votersCount" } ], "id": "https://me.dm/users/thebojda/outbox?page=true", "type": "OrderedCollectionPage", "prev": "https://me.dm/users/thebojda/outbox?min_id=109955178005562038&page=true", "partOf": "https://me.dm/users/thebojda/outbox", "orderedItems": [ { "id": "https://me.dm/users/thebojda/statuses/109955178005562038/activity", "type": "Create", "actor": "https://me.dm/users/thebojda", "published": "2023-03-02T18:47:47Z", "to": [ "https://www.w3.org/ns/activitystreams#Public" ], "cc": [ "https://me.dm/users/thebojda/followers" ], "object": { "id": "https://me.dm/users/thebojda/statuses/109955178005562038", "type": "Note", "summary": null, "inReplyTo": null, "published": "2023-03-02T18:47:47Z", "url": "https://me.dm/@thebojda/109955178005562038", "attributedTo": "https://me.dm/users/thebojda", "to": [ "https://www.w3.org/ns/activitystreams#Public" ], "cc": [ "https://me.dm/users/thebojda/followers" ], "sensitive": false, "atomUri": "https://me.dm/users/thebojda/statuses/109955178005562038", "inReplyToAtomUri": null, "conversation": "tag:me.dm,2023-03-02:objectId=1406005:objectType=Conversation", "content": "<p>My &quot;ars poetica&quot;: How to Change the World?! Pocket Guide for People With a Messiah Complex <a href=\"https://medium.com/geekculture/how-to-change-the-world-pocket-guide-for-people-with-a-messiah-complex-dd2d16bb92a\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><span class=\"invisible\">https://</span><span class=\"ellipsis\">medium.com/geekculture/how-to-</span><span class=\"invisible\">change-the-world-pocket-guide-for-people-with-a-messiah-complex-dd2d16bb92a</span></a></p>", "contentMap": { "en": "<p>My &quot;ars poetica&quot;: How to Change the World?! Pocket Guide for People With a Messiah Complex <a href=\"https://medium.com/geekculture/how-to-change-the-world-pocket-guide-for-people-with-a-messiah-complex-dd2d16bb92a\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><span class=\"invisible\">https://</span><span class=\"ellipsis\">medium.com/geekculture/how-to-</span><span class=\"invisible\">change-the-world-pocket-guide-for-people-with-a-messiah-complex-dd2d16bb92a</span></a></p>" }, "attachment": [], "tag": [], "replies": { "id": "https://me.dm/users/thebojda/statuses/109955178005562038/replies", "type": "Collection", "first": { "type": "CollectionPage", "next": "https://me.dm/users/thebojda/statuses/109955178005562038/replies?only_other_accounts=true&page=true", "partOf": "https://me.dm/users/thebojda/statuses/109955178005562038/replies", "items": [] } } } } ] }


基于这些例子,很容易实现一个最小的客户端,可以读取别人的公开帖子,或者可以向外界发布公开帖子。我不会在这里详细介绍各个 JSON 文件的确切结构以及收件箱的功能。


这些可以在ActivityPub 文档中找到。


可以看出,ActivityPub是一个相对简单的标准,易于理解和实现。它唯一的弱点是它使用 HTTP 协议,需要一个中央服务器。这催生了 Nostr 等替代协议,这是 Jack Dorsey(Twitter 创始人)最喜欢的项目。


但我认为这是没有必要的,它只会导致社交网络进一步碎片化。相反,ActivityPub 协议应该通过支持现有的去中心化协议进行扩展,这将使 Fediverse 朝着更加开放和去中心化的方向发展。接下来,我将演示如何实现这一目标。


分散描述性数据和源的一个完美解决方案是使用Swarm FeedsIPNS (我有一篇关于这些协议的完整文章)。对于以太坊 Swarm,提要标识符是 Swarm 地址,而对于 IPNS,它是公钥。


使用这些,ActivityPub 用户将如下所示:{swarm 地址}@swarm 或 {IPNS 地址}@IPNS。可以从这里查询用户描述。


为了向后兼容,还可以使用网关服务器,例如 {swarm address}@gateway.ethswarm.org,它将通过 Webfinger 协议返回存储在 Swarm 上的用户描述,允许现有系统(如 Mastodon)无需任何操作即可读取此数据。修改。


发件箱的实施也可以通过 Swarm 或 IPNS feed 来完成。为了保持向后兼容性,需要引入“decentralized_outbox”字段,其中包含 Swarm feed (bzz://...) 或 IPNS (ipns://...) 地址。


为了保持向后兼容性,可以在原始“发件箱”字段中包含额外的网关地址,以便现有客户端无需任何更改即可读取这些提要。


收件箱的实现可以通过多种方式完成。以太坊 Swarm 有一个名为PSS的消息系统,但也有其他替代方案,例如Waku 。在这里,PSS 或 Waku 地址将被放置在“decentralized_inbox”字段中,而原始收件箱字段将包含网关地址。


通过这几个小扩展,ActivityPub 可以完全去中心化并“兼容 web3”,而不需要引入像 Nostr 这样的新协议。


根据 Nostr 的GitHub 存储库,对新协议和中继系统的需求是由于 ActivityPub 服务器对用户的潜在审查以及缺乏激励系统。不过,这个问题通过上面的扩展就完全解决了。


IPNS 和 Swarm 都具有抗审查性,Swarm 还提供完全的匿名性。此外,Swarm 有自己的激励系统,而 FileCoin 可用于 IPNS。


我相信,未来显然属于ActivityPub,开发者应该专注于推进和发展ActivityPub,而不是创建新的协议,以最终建立一个全面且真正统一的Fediverse。