Skip to content
Example materialized-view program to lookup petname mappings in ssb
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

SSB Simple Whois

Simple program to lookup petname mappings in ssb

$ git clone
$ cd ssb-simple-whois
$ npm install

$ ./ssb-simple-whois.js
   paul *** @hxGxqPrplLjRG2vtjQL87abX4QKqeLgCwQpS730nNwE=.ed25519
Dominic **  @BIbVppzlrNiRJogxDYz3glUS7G4s4D4NiXiPEAEzxdE=.ed25519
    bob *   @HSZ7V+Hrm0mbqNGkINtN1CL8VEsY1CDMBu5yPCHg5zI=.ed25519
    bob *   @PgeunKGJm05DZ0WWoRtGvH37gXMbDnVuse9HhaUT6RI=.ed25519

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

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

The stars indicate the amount of trust in the assignment.

  • Three stars is full trust, because it's the name chosen by the local user.
  • Two stars is partial trust, because it's the name chosen by someone the local user follows.
  • One star is little trust, because it's the name chosen by an unfollowed user.

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:

  type: 'about',
  about: FeedLink,
  name: 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:

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

  // store in globals
  _selfId =
  _follows = follows

    // fetch `type: about` messages, in order received

    // 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 }
function processAboutMsg (msg) {
  var c = msg.value.content

  // sanity check
  if (!nonEmptyStr(

  // only process self-assignments
  var target =, 'feed')
  if (!target || !==

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

  // store the new assignment
  var name = makeNameSafe(
  _names[name] = _names[name] || []
    name:  name,
    trust: rateTrust(msg)

// trust-policy
function rateTrust (msg) {
  // is local user: high trust
  if ( === _selfId)
    return 3
  // followed by local user: medium trust
  if (_follows[_selfId][])
    return 2
  // otherwise: low trust
  return 1
You can’t perform that action at this time.