How to use the ssb-ref.parseInvite function in ssb-ref

To help you get started, we’ve selected a few ssb-ref examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssbc / ssb-server / plugins / invite.js View on Github external
var modern = false
        if(ref.isInvite(invite)) { //legacy ivite
          if(ref.isLegacyInvite(invite)) {
            var parts = invite.split('~')
            opts = ref.parseAddress(parts[0])//.split(':')
            //convert legacy code to multiserver invite code.
            var protocol = 'net:'
            if (opts.host.endsWith(".onion"))
              protocol = 'onion:'
            invite = protocol+opts.host+':'+opts.port+'~shs:'+opts.key.slice(1, -8)+':'+parts[1]
          }
          else
            modern = true
        }

        opts = ref.parseAddress(ref.parseInvite(invite).remote)
        function connect (cb) {
          ssbClient(null, {
            caps: config.caps,
            remote: invite,
            manifest: {invite: {use: 'async'}, getAddress: 'async'}
          }, cb)
        }

        // retry 3 times, with timeouts.
        // This is an UGLY hack to get the test/invite.js to pass
        // it's a race condition, I think because the server isn't ready
        // when it connects?

        function retry (fn, cb) {
          var n = 0
          ;(function next () {
github Happy0 / ssb-chess / modules_basic / invite.js View on Github external
screen_view: function (invite) {

      var data = ref.parseInvite(invite)
      if(!data) return

      var progress = Progress(4)

      //connect to server
      //request follow
      //post pub announce
      //post follow pub
      var div = h('div.column.scroller__wrapper',
        h('div.column.scroller__content', {style: 'margin-top: 25%;'},
          h('h1', {innerHTML: 'The <a href="https://scuttlebot.io">Secure Scuttlebutt</a> Lite Client'}),
          h('p', "You've been invited to join:"),
          h('p', h('code', data.invite))
        ),
        h('p', h('button', 'Accept', {onclick: attempt})),
        progress,
github Happy0 / ssb-chess / modules_basic / invite.js View on Github external
invite_parse: function (invite) {
      return ref.parseInvite(invite)
    },
github ssbc / ssb-server / plugins / invite.js View on Github external
(function (err, results) {
              if(err) return cb(err)
              rpc.close()
                rpc.close()
                //ignore err if this is new style invite
                if(server.gossip) server.gossip.add(ref.parseInvite(invite).remote, 'seed')
                cb(null, results)
            })
          })