Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ssb-bfe

Package Overview
Dependencies
Maintainers
19
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssb-bfe - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

23

package.json
{
"name": "ssb-bfe",
"description": "Binary Field Encodings (BFE) for Secure Scuttlebutt (SSB)",
"version": "3.2.0",
"homepage": "https://github.com/ssb-ngi-pointer/ssb-bfe",
"version": "3.2.1",
"homepage": "https://github.com/ssbc/ssb-bfe",
"repository": {
"type": "git",
"url": "git://github.com/ssb-ngi-pointer/ssb-bfe.git"
"url": "git://github.com/ssbc/ssb-bfe.git"
},

@@ -16,8 +16,2 @@ "main": "index.js",

],
"scripts": {
"test": "tape test/*.js | tap-bail | tap-spec",
"coverage": "nyc --reporter=lcov npm test",
"format-code": "prettier --write \"*.js\" \"test/*.js\"",
"format-code-staged": "pretty-quick --staged --pattern \"*.js\" --pattern \"test/*.js\""
},
"dependencies": {

@@ -48,3 +42,10 @@ "is-canonical-base64": "^1.1.1",

],
"license": "LGPL-3.0"
}
"license": "LGPL-3.0",
"scripts": {
"test": "tape test/*.js | tap-bail | tap-spec",
"coverage": "nyc --reporter=lcov npm test",
"format-code": "prettier --write \"*.js\" \"test/*.js\"",
"format-code-staged": "pretty-quick --staged --pattern \"*.js\" --pattern \"test/*.js\""
},
"readme": "<!--\nSPDX-FileCopyrightText: 2021 Anders Rune Jensen\n\nSPDX-License-Identifier: CC0-1.0\n-->\n\n# SSB BFE\n\nJavascript implementation of the [SSB binary field encodings] spec.\n\nThe spec only has one type of **nil**, but JavaScript has two: `null` and\n`undefined`. ssb-bfe will treat these two values in a way that mirrors what\nJSON.stringify does:\n\n- BFE Encoding an **object** with a `null` field becomes an object with the\n**nil** marker\n - Similar to `JSON.stringify({a: null}) === '{\"a\": null}'`\n- BFE Encoding an **array** with a `null` element becomes an array with the\n**nil** marker\n - Similar to `JSON.stringify([null]) === '[null]'`\n- BFE Encoding an **object** with a `undefined` field will **omit** that field\n - Similar to `JSON.stringify({a: undefined}) === '{}'`\n- BFE Encoding an **array** with an `undefined` element becomes an array with\nthe **nil** marker\n - Similar to `JSON.stringify([undefined]) === '[null]'`\n\n## API\n\n### encode(input)\n\nTakes any JavaScript primitive and returns its encoded counterpart. Is applied\nrecursively in case the input is an object or an array. All inputs are converted\nto [TFD] Buffers, except for objects, arrays, and numbers, which remain the\nsame.\n\n### decode(input)\n\nTakes an encoded value (such as the output from `encode`) and returns the\ndecoded counterparts as JavaScript primitives.\n\n### bfeTypes\n\nReturns the `bfe.json` object that can be used to look up information\nbased on Type and Field. Example:\n\n```\nconst { bfeTypes } = require('ssb-bfe')\nconst classic_key_size = bfeTypes[0][0].data_length\n```\n\n### bfeNamedTypes\n\nReturns the `bfe.json` object converted to a map where the keys are\nthe type and format names. Example:\n\n```\nconst { bfeNamedTypes } = require('ssb-bfe')\nconst FEED = bfeNamedTypes['feed']\nconst CLASSIC_FEED_TF = Buffer.from([FEED.code, FEED.formats['classic'].code])\n```\n\n### toTF(typeName, formatName)\n\nSometimes when you're wanting to check what sort of buffer you're handling, you want\nto pivot on the type and format bytes.\n\n```js\nconst CLASSIC_MSG_TF = Buffer.from([1, 0]) // << Did I get the right codes?\n\nif (buf.slice(0, 2).equals(CLASSIC_MSG_TF)) {\n // ...\n}\n```\n\nbecause remembering those codes is tricky, it's safer to use this convenience method:\n```js\nconst CLASSIC_MSG_TF = bfe.toTF('msg', 'classic')\n```\n\nIf you remembered the type or format name wrong, you'll instantly get an error!\n\n\n\n[ssb binary field encodings]: https://github.com/ssb-ngi-pointer/ssb-binary-field-encodings-spec\n[TFD]: https://github.com/ssbc/envelope-spec/blob/master/encoding/tfk.md\n"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc