Socket
Socket
Sign inDemoInstall

multicodec

Package Overview
Dependencies
1
Maintainers
3
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    multicodec

JavaScript implementation of the multicodec specification


Version published
Weekly downloads
430K
decreased by-22.04%
Maintainers
3
Install size
335 kB
Created
Weekly downloads
 

Changelog

Source

0.4.0 (2019-01-08)

  • Revert "feat: make adding a custom codec possible" (9e251ce)

Chores

  • fully automatic table generation (f3d8c0d)

BREAKING CHANGES

  • multibase is not part of this package anymore

As multibase works differently from multicodec, those codecs were [removed from the multicodec table], hence those are also removed from this implementation as we have automatic conversion from the upstream table.

https://github.com/multiformats/multicodec/commit/1ec0e971d589d2fd5d5418b212846301909525bd

  • the addCodec() function is removed

The addCodec() function is removed as it doesn't work as expected. Things break as soon as the module is loaded several times, which can happen if dependencies require a different version.

Steps to reproduce this problem:

$ mkdir addcodecbug
$ cd addcodecbug
$ npm install cids@0.5.7 multicodec@0.3.0
npm WARN saveError ENOENT: no such file or directory, open '/tmp/addcodecbug/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/tmp/addcodecbug/package.json'
npm WARN addcodecbug No description
npm WARN addcodecbug No repository field.
npm WARN addcodecbug No README data
npm WARN addcodecbug No license field.

+ multicodec@0.3.0
+ cids@0.5.7
added 10 packages from 35 contributors and audited 14 packages in 1.363s
found 0 vulnerabilities
$ cat > index.js <<'EOF'
// Uses multicodec v0.2.7
const CID = require('cids')
// Imports multicodec v0.3.0
const multicodec = require('multicodec')

multicodec.addCodec('my-codec', Buffer.from('5566', 'hex'))
// Works, the codec was added
console.log(multicodec.getCodeVarint('my-codec'))

const multihash = Buffer.from(
  '1220b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9',
  'hex')
const cid = new CID(1, 'my-codec', multihash)
console.log(cid)
// Fails as `my-codec` was only added to the multicodec module loaded by this
// file, and not the one loaded by `cids`.
console.log(cid.toBaseEncodedString())
EOF
$ node index.js
<Buffer e6 aa 01>
CID {
  codec: 'my-codec',
  version: 1,
  multihash:
   <Buffer 12 20 b9 4d 27 b9 93 4d 3e 08 a5 2e 52 d7 da 7d ab fa c4 84 ef e3 7a 53 80 ee 90 88 f7 ac e2 ef cd e9> }
/tmp/addcodecbug/node_modules/cids/node_modules/multicodec/src/index.js:76
    throw new Error('Codec `' + codecName + '` not found')
    ^

Error: Codec `my-codec` not found
    at Object.exports.getCodeVarint (/tmp/addcodecbug/node_modules/cids/node_modules/multicodec/src/index.js:76:11)
    at ClassIsWrapper.get buffer [as buffer] (/tmp/addcodecbug/node_modules/cids/src/index.js:131:22)
    at ClassIsWrapper.toBaseEncodedString (/tmp/addcodecbug/node_modules/cids/src/index.js:202:44)
    at Object.<anonymous> (/tmp/addcodecbug/index.js:17:17)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)

<a name="0.3.0"></a>

Readme

Source

js-multicodec

Travis CI Coverage Status

JavaScript implementation of the multicodec specification

Lead Maintainer

Henrique Dias

Table of Contents

Install

> npm install multicodec
const multicodec = require('multicodec')

Usage

Example


const multicodec = require('multicodec')

const prefixedProtobuf = multicodec.addPrefix('protobuf', protobufBuffer)
// prefixedProtobuf 0x50...

API

https://multiformats.github.io/js-multicodec/

multicodec default table

Updating the lookup table

Updating the lookup table is done with a script. The source of truth is the multicodec default table. Update the table with running:

curl -X GET https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv|./tools/update-table.py

Contribute

Contributions welcome. Please check out the issues.

Check out our contributing document for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS Code of Conduct.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2016 Protocol Labs Inc.

Keywords

FAQs

Last updated on 08 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc