ssbc/ssb-simple-whois

Name: ssb-simple-whois

Owner: Secure Scuttlebutt Consortium

Description: Example materialized-view program to lookup petname mappings in ssb

Created: 2015-10-02 22:12:56.0

Updated: 2018-03-26 23:41:01.0

Pushed: 2016-03-17 02:25:43.0

Homepage:

Size: 11

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

SSB Simple Whois

Simple program to lookup petname mappings in ssb

t clone https://github.com/ssbc/ssb-simple-whois.git
 ssb-simple-whois
m install

ssb-simple-whois.js
aul *** @hxGxqPrplLjRG2vtjQL87abX4QKqeLgCwQpS730nNwE=.ed25519
nic **  @BIbVppzlrNiRJogxDYz3glUS7G4s4D4NiXiPEAEzxdE=.ed25519
bob *   @HSZ7V+Hrm0mbqNGkINtN1CL8VEsY1CDMBu5yPCHg5zI=.ed25519
bob *   @PgeunKGJm05DZ0WWoRtGvH37gXMbDnVuse9HhaUT6RI=.ed25519

ssb-simple-whois.js paul
 *** @hxGxqPrplLjRG2vtjQL87abX4QKqeLgCwQpS730nNwE=.ed25519

ssb-simple-whois.js bob
*   @HSZ7V+Hrm0mbqNGkINtN1CL8VEsY1CDMBu5yPCHg5zI=.ed25519
*   @PgeunKGJm05DZ0WWoRtGvH37gXMbDnVuse9HhaUT6RI=.ed25519

The stars indicate the amount of trust in the assignment.

There are no universal rules for petnames in SSB. There is no single registry or authority, so you can choose your own policies and algorithms.

How it works

Users publish a type: about message, which has the following schema:


pe: 'about',
out: FeedLink,
me: String

This program uses a very simple set of rules for computing the petname map. Only self-assigned names are used. The trust ranking is described above.

The petname map is a “materialized view,” in the Kappa Architecture semantic. It is created by streaming type: about messages, in the order received, into a view-processing function. The output is then produced from the map.

The streaming code:

etch...
done = multicb({ pluck: 1, spread: true })
.whoami(done()) // ...local users id
.friends.all('follow', done()) // ...computed follow-graph
(function (err, whoami, follows) {
 (err) throw err

 store in globals
elfId = whoami.id
ollows = follows

ll(
// fetch `type: about` messages, in order received
sbot.messagesByType('about'),

// process each message
pull.drain(processAboutMsg, function (err) {
  if (err) throw err

  // ... render ...
})


The processing function:

type: about` message processor
 expected schema: { type: 'about', name: String, about: FeedLink }
tion processAboutMsg (msg) {
r c = msg.value.content

 sanity check
 (!nonEmptyStr(c.name))
return

 only process self-assignments
r target = mlib.link(c.about, 'feed')
 (!target || target.link !== msg.value.author)
return

 remove any past assignments by this user
r (var k in _names)
_names[k] = _names[k].filter(function (entry) { return entry.id !== target.link })

 store the new assignment
r name = makeNameSafe(c.name)
ames[name] = _names[name] || []
ames[name].push({
id:    target.link,
name:  name,
trust: rateTrust(msg)



rust-policy
tion rateTrust (msg) {
 is local user: high trust
 (msg.value.author === _selfId)
return 3
 followed by local user: medium trust
 (_follows[_selfId][msg.value.author])
return 2
 otherwise: low trust
turn 1


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.