docs: function getBaseUrl (hostUrl, psaDoc, relType, desc) {
    assert(psaDoc && typeof psaDoc === 'object', 'Invalid PSA service description document')
    assert(psaDoc.links && Array.isArray(psaDoc.links), 'Invalid PSA service description document (no links array)')
    var link = psaDoc.links.find(link => {
      var rel = link.rel
      return rel && typeof rel === 'string' && rel.indexOf(relType) !== -1
    })
    if (!link) {
      throw new Error(`Service does not provide the pinning-service ${desc} API (rel ${relType})`)
    }
    var href = link.href
    assert(href && typeof href === 'string', 'Invalid PSA service description document (no href on API link)')
    if (href.startsWith('/')) {
      href = hostUrl + link.href
    }
    return href
  }