How to use the ssb-ref.isBlobId 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 blockades / scuttle-dark-crystal / lib / unpackLink.js View on Github external
module.exports = function unpackLink (link) {
  const index = link.indexOf('?')
  const blobId = link.substring(0, index)
  const blobKey = link.substring(index + 1)
  assert(((index > 0) && (blobKey.length)), 'Blob not encrypted')
  // TODO: test for well formed blob key
  assert((isBlobId(blobId)), 'attachment contains invalid blob reference')
  return { blobId, blobKey }
}
github staltz / manyverse / src / backend / plugins / feedUtilsBack.ts View on Github external
publishAbout(content: AboutContent, cb: Callback) {
        if (content.image && !Ref.isBlobId(content.image[0])) {
          ssb.blobsUtils.addFromPath(
            content.image,
            (err: any, hash: string) => {
              if (err) return console.error(err);
              content.image = hash;
              ssb.publish(content, (err2: any, msg: any) => {
                if (err2) console.error(err2);
                if (cb) cb(err2, msg);
              });
            },
          );
        } else {
          ssb.publish(content, (err: any, msg: any) => {
            if (err) console.error(err);
            if (cb) cb(err, msg);
          });
github soapdog / patchfox / src / router / sync / routes.js View on Github external
case "%":
                if (!isMsgId(id)) {
                    console.error(`intercept url should been a msg but it is not: ${id}`);
                    return false;
                }
                window.location.hash = "thread/" + encodeURIComponent(id);
                break;
            case "@":
                if (!isFeedId(id)) {
                    console.error(`intercept url should been a feed but it is not: ${id}`);
                    return false;
                }
                window.location.hash = "feed/" + encodeURIComponent(id);
                break;
            case "&":
                if (!isBlobId(id)) {
                    console.error(`intercept url should been a blob but it is not: ${id}`);
                    return false;
                }
                window.location = "http://localhost:8989/blobs/get/" + id;
                break;
            }

            if (id.indexOf("javascript:") === 0) {
                return h("h1", "stop trying to inject JS here");
            }

            return h("p", `loading ${id}...`);
        };
github staltz / manyverse / src / ssb / opinions / sbot.ts View on Github external
sbotP.then(sbot => {
                if (content.image && !Ref.isBlobId(content.image[0])) {
                  sbot.blobsFromPath.add(
                    content.image,
                    (err: any, hash: string) => {
                      if (err) return console.error(err);
                      content.image = hash;
                      sbot.publish(content, (err2: any, msg: any) => {
                        if (err2) console.error(err2);
                        if (cb) cb(err2, msg);
                      });
                    },
                  );
                } else {
                  sbot.publish(content, (err: any, msg: any) => {
                    if (err) console.error(err);
                    if (cb) cb(err, msg);
                  });
github regular / ssb-revisions / indexes / links.js View on Github external
const links = traverse(content).reduce(function (acc, x) {
      if (this.isLeaf) {
        if (isMsgId(x) || isBlobId(x) || isFeedId(x)) {
          if (!['revisionRoot', 'revisionBranch'].includes(this.path[0])) {
            acc.push([this.path.join('.'), x])
          }
        }
      }
      return acc
    }, [])