Skip to content

Commit

Permalink
Change protocol name to ADX (bluesky-social#96)
Browse files Browse the repository at this point in the history
* Name change to ADX

* readme updates

* use did:example

* quick readme edit

* typo
  • Loading branch information
dholms authored May 2, 2022
1 parent a3c2752 commit f23cf12
Show file tree
Hide file tree
Showing 53 changed files with 132 additions and 154 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,5 @@ analytics.txt
/**/*/.data
/**/*/yarn-error.log

go/bluesky
go/bsky
go/server

server/blockstore
server/dev.sqlite
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Bluesky Experiment 🧪
# Authenticated Data eXperiment (ADX) 🧪

Welcome 👋
This is an early proof of concept for Bluesky's data protocol, which we've affectionately termed ADX - Authenticated Data eXperiment.

This is an early proof of concept for the Bluesky data network. We built this for two primary reasons:
We built this for two primary reasons:
- To explore and demonstrate some of the core concepts that we're working with: content addressing, user held keys, user generated authority, and a federated network topology
- To help identify the sort of interfaces we'll want and the rough edges and pain points that we'll hit along the way

**This is not production-ready, or even alpha software. This is a proof of concept.**

Please do not try to build your next big social network on this. There are many rough edges. Interfaces and data structures are likely to radically change, and we took some shortcuts on concepts that were not in the scope of this demo (key management, schemas, indexing, to name a few). This experiment is primarily confined to the data & authorization layer with hints at some of the other systems.

To learn more about the Bluesky network, and get a fuller picture of what we're building towards check out our docs on [Network architecture]() and the [Blogpost on self-authenticating data structures](https://blueskyweb.xyz/blog/3-6-2022-a-self-authenticating-social-protocol).
To learn more about the ADX network, and get a fuller picture of what we're building towards check out our docs on [Network architecture]() and the [Blogpost on self-authenticating data structures](https://blueskyweb.xyz/blog/3-6-2022-a-self-authenticating-social-protocol).

All that being said, we're very excited to share some of the work that we've done here. Please play around with the server & CLI, poke around the code, even build a small demo app to get the feel for it!

Expand All @@ -22,13 +22,13 @@ And without further ado, let's dive into what you'll find here.

This is a monorepo containing three packages:

- `common`: This is the bluesky SDK that contains implementations of:
- `common`: This is the adx SDK that contains implementations of:
- the repository data structure
- a sample network namespace (microblogging) with both a full client and delegator client implementation
- an authorization library for working with bluesky-capable UCANs
- some helpers for making calls to a bluesky data server
- an authorization library for working with adx-capable UCANs
- some helpers for making calls to a adx data server

- `server`: This is an implementation of a bluesky server. For simplicity's sake, it actually combines the function of three "roles" in the network:
- `server`: This is an implementation of a adx server. For simplicity's sake, it actually combines the function of three "roles" in the network:
- **Identity:**
- maintains a mapping of username -> DID
- **Data:**
Expand All @@ -41,7 +41,7 @@ This is a monorepo containing three packages:
- stores an indexed version of repositories that it is hosting or that its user's are following
- returned global view of data including follower lists, aggregated like counts, and user timelines.

- `cli`: This is a basic command line interface for interactions with the bluesky network :
- `cli`: This is a basic command line interface for interactions with the adx network:
- creating a local repository
- registering a user
- creating/editing/deleting posts
Expand Down Expand Up @@ -81,10 +81,10 @@ From project root:
(2) yarn server:alt # runs on localhost:2584

# set an env var to store alice's repo in a scoped dir
(3) export SKY_REPO_PATH="~/.sky-alice"
(3) export ADX_REPO_PATH="~/.adx-alice"

# set an env var to store bob's repo in a scoped dir
(4) export SKY_REPO_PATH="~/.sky-bob"
(4) export ADX_REPO_PATH="~/.adx-bob"

# register alice
(3) yarn cli init
Expand Down Expand Up @@ -174,13 +174,13 @@ Therefore we try to talk about the general concept as "interactions" and the par

### DIDs and UCANs

In this prototype a user's root DID is a simple `did:key`. In the future, these will be more permanent identifiers such as `did:bsky` (read our proposal in the architecture docs) or `did:ion`.
In this prototype a user's root DID is a simple `did:key`. In the future, these will be more permanent identifiers such as `did:ion` or our currently unnamed consortium-provided DID proposed in the architecture docs.

The DID network is outside of the scope of this prototype. However, a DID is the canoncial, unchanging identifier for a user. and is needed in ordcer to enable data/server interop. Therefore we run a very simple DID network that only allows POSTs and GETs (with signature checks). The DID network is run _on_ the data server (`http://localhost:2583/did-network`), however every server that is running communicates with the _same_ data server when it comes to DID network requests. As DIDs are self-describing for resolution, we emulate this by hard coding how to discover a DID (ie "always go to _this particular address_ not your personal data server").

You'll notice that we delegate a UCAN from the root key to the root key (which is a no-op), this is to mirror the process of receiving a fully delegated UCAN _from your actual root key_ to a _fully permissioned device key_.

You'll also notice that the DID for the microblogging namespace is just `did:bsky:microblog` (which is not an actual valid DID). This is a stand in until we have an addressed network for schemas.
You'll also notice that the DID for the microblogging namespace is just `did:example:microblog` (which is not an actual valid DID). This is a stand in until we have an addressed network for schemas.

UCAN permissions are also simplified at the current moment, allowing for scoped `WRITE` permission or full-repo `MAINTENANCE` permission. These permissions will be expanding in the future to allow presenting CRUD operations, and more detailed maintenance (ie creation vs merging vs cleanup, etc)

Expand Down
4 changes: 2 additions & 2 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# @bluesky/cli
# @adx/cli

The command line interface for the SKY protocol.
The command line interface for ADX.
4 changes: 2 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@bluesky/cli",
"name": "@adx/cli",
"version": "0.0.1",
"type": "module",
"scripts": {
"cli": "node dist/bin.js",
"build": "(cd ../common && yarn build) && tsc --project tsconfig.json"
},
"dependencies": {
"@bluesky/common": "*",
"@adx/common": "*",
"chalk": "^5.0.0",
"minimist": "^1.2.5",
"multiformats": "^9.6.4",
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/dev/spam.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cmd from '../../lib/command.js'
import { loadClient } from '../../lib/client.js'
import { REPO_PATH } from '../../lib/env.js'
import { TID } from '@bluesky/common'
import { TID } from '@adx/common'

function makeRandText(l: number) {
const set = ' abcdefghijklmnopqrstuvwxyz '
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/interactions/like.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cmd from '../../lib/command.js'
import { loadClient } from '../../lib/client.js'
import { REPO_PATH } from '../../lib/env.js'
import { TID } from '@bluesky/common'
import { TID } from '@adx/common'

export default cmd({
name: 'like',
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/interactions/unlike.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cmd from '../../lib/command.js'
import { loadClient } from '../../lib/client.js'
import { REPO_PATH } from '../../lib/env.js'
import { TID } from '@bluesky/common'
import { TID } from '@adx/common'

export default cmd({
name: 'unlike',
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/posts/delete-post.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cmd from '../../lib/command.js'
import { loadClient } from '../../lib/client.js'
import { REPO_PATH } from '../../lib/env.js'
import { TID } from '@bluesky/common'
import { TID } from '@adx/common'

export default cmd({
name: 'delete post',
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/posts/edit-post.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cmd from '../../lib/command.js'
import { loadClient } from '../../lib/client.js'
import { REPO_PATH } from '../../lib/env.js'
import { TID } from '@bluesky/common'
import { TID } from '@adx/common'

export default cmd({
name: 'edit post',
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/posts/feed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cmd from '../../lib/command.js'
import { loadClient } from '../../lib/client.js'
import { REPO_PATH } from '../../lib/env.js'
import { TID } from '@bluesky/common'
import { TID } from '@adx/common'
import chalk from 'chalk'
import { formatDate } from '../../lib/util.js'

Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/posts/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk'
import cmd from '../../lib/command.js'
import { loadClient } from '../../lib/client.js'
import { REPO_PATH } from '../../lib/env.js'
import { TID } from '@bluesky/common'
import { TID } from '@adx/common'
import { formatDate } from '../../lib/util.js'

export default cmd({
Expand Down
4 changes: 2 additions & 2 deletions cli/src/commands/setup/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ prompt.message = ''
export default cmd({
name: 'init',
category: 'setup',
help: 'Create a new scdb repo.',
help: 'Create a new adx repo.',
opts: [
{ name: 'server', type: 'string', default: '' },
{ name: 'username', type: 'string', default: '' },
Expand All @@ -31,7 +31,7 @@ export default cmd({
}

if (!username || !server) {
console.log(`This utility will initialize your sky repo.`)
console.log(`This utility will initialize your adx repo.`)
console.log(`Press ^C at any time to quit.`)
prompt.start()
username = (
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
MicroblogDelegator,
MicroblogFull,
Repo,
} from '@bluesky/common'
} from '@adx/common'
import * as config from '../lib/config.js'

export const loadClient = async (
Expand Down
6 changes: 3 additions & 3 deletions cli/src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path'
import { promises as fsp } from 'fs'
import * as ucan from 'ucans'
import { auth } from '@bluesky/common'
import { auth } from '@adx/common'
import { CID } from 'multiformats/cid'

export type AccountJson = {
Expand Down Expand Up @@ -40,7 +40,7 @@ export const writeCfg = async (
delegator,
}
await fsp.writeFile(
path.join(repoPath, 'sky.key'),
path.join(repoPath, 'adx.key'),
await keypair.export(),
'utf-8',
)
Expand All @@ -67,7 +67,7 @@ export const cfgExists = async (repoPath: string): Promise<boolean> => {

export const loadCfg = async (repoPath: string): Promise<Config> => {
const account = await readAccountFile(repoPath, 'account.json')
const secretKeyStr = (await readFile(repoPath, 'sky.key', 'utf-8')) as string
const secretKeyStr = (await readFile(repoPath, 'adx.key', 'utf-8')) as string
const keypair = ucan.EdKeypair.fromSecretKey(secretKeyStr)
const tokenStr = (await readFile(repoPath, 'full.ucan', 'utf-8')) as string
const ucanStore = await ucan.Store.fromTokens([tokenStr])
Expand Down
2 changes: 1 addition & 1 deletion cli/src/lib/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os from 'os'
import path from 'path'

export const REPO_PATH = expandPath(process.env.SKY_REPO_PATH || `~/.sky`)
export const REPO_PATH = expandPath(process.env.ADX_REPO_PATH || `~/.adx`)

function expandPath(str: string) {
if (str.startsWith('~')) {
Expand Down
4 changes: 2 additions & 2 deletions cli/src/lib/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function usage(err: any) {
console.log('')
}
console.log(
`Usage: ${chalk.bold(`scdb`)} <command> ${chalk.gray(`[opts...]`)}`,
`Usage: ${chalk.bold(`adx`)} <command> ${chalk.gray(`[opts...]`)}`,
)

let lhsLength = 0
Expand Down Expand Up @@ -47,7 +47,7 @@ export function usage(err: any) {
}

export function commandUsage(cmd: RegisteredCmd) {
console.log(`${chalk.bold(`scdb ${cmd.name}`)}${cmdArgs(cmd)}${cmdHelp(cmd)}`)
console.log(`${chalk.bold(`adx ${cmd.name}`)}${cmdArgs(cmd)}${cmdHelp(cmd)}`)
if (cmd.opts?.length) {
console.log('')
for (const opt of cmd.opts) {
Expand Down
2 changes: 1 addition & 1 deletion common/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@bluesky/common",
"name": "@adx/common",
"version": "0.0.1",
"main": "dist/index.js",
"type": "module",
Expand Down
Loading

0 comments on commit f23cf12

Please sign in to comment.