chained-obj

1.3.2 • Public • Published

chained-obj

Builder and parser for objects stored by Tradle on chain. Currently uses multipart to store arbitrary JSON data + attachments. These objects are later encrypted and put on-chain.

this module is used by Tradle

Usage

var ChainedObj = require('chained-obj')
var Builder = ChainedObj.Builder
var Parser = ChainedObj.Parser
var b = new Builder()
  // required
  .data({
    some: 'json'
  })
  // optional
  .attach([
    { name: 'headshot', path: './path/to/attachment1' },
    { name: 'passport', path: './path/to/attachment2' }
  ])
  // optional
  .signWith(key) // a key from [kiki](https://npmjs.org/package/kiki) or a key conforming to its API
  .build(function (err, result) {
    // result consists of the form and the multipart boundary used
    // {
    //   form: Buffer,
    //   boundary: String
    // }
  })
  
var p = new Parser()
  // optional
  .verifyWith(key) // a key from [kiki](https://npmjs.org/package/kiki) or a key   
  .parse(formBuf, function (err, parsed) {
    // parsed consists of the data and attachments
    // {
    //   data: Buffer,
    //   attachments: [
    //     {
    //       name: String,
    //       path: String,
    //       contentType: String
    //     }
    //   ]
    // }
  })

/chained-obj/

    Package Sidebar

    Install

    npm i chained-obj

    Weekly Downloads

    11

    Version

    1.3.2

    License

    MIT

    Last publish

    Collaborators

    • spwilko
    • genevayngrib
    • pgmemk
    • tenaciousmv