{"_id":"@ansdomain/content-hash","_rev":"1-dd96af7fdbad966d24ccb262081b624a","name":"@ansdomain/content-hash","dist-tags":{"latest":"2.5.7"},"versions":{"2.5.7":{"name":"@ansdomain/content-hash","version":"2.5.7","description":"simple tool to encode/decode content hash for EIP 1577 compliant ENS Resolvers (fork of pldespaigne/content-hash)","main":"./src/index.js","repository":{"type":"git","url":"git+https://github.com/ensdomains/content-hash.git"},"scripts":{"build":"browserify ./src/index.js --s contentHash > ./dist/index.js","demo":"static .","deploy-demo":"echo \"surge demo https://content-hash.surge.sh\"","pub":"npm run build && npm publish --access public","test":"mocha","lint":"npx eslint ."},"author":{"name":"pldespaigne"},"license":"ISC","dependencies":{"cids":"^1.1.5","js-base64":"^3.6.0","multicodec":"^3.2.0","multihashes":"^2.0.0"},"devDependencies":{"browserify":"^16.5.0","chai":"^4.2.0","eslint":"^5.16.0","mocha":"^5.2.0","node-static":"^0.7.11"},"keywords":["ethereum","ens","eip-1577","resolver","ipfs","swarm","content-hash","content","hash","contenthash","contentHash"],"bugs":{"url":"https://github.com/ensdomains/content-hash/issues"},"homepage":"https://github.com/ensdomains/content-hash#readme","_id":"@ansdomain/content-hash@2.5.7","_nodeVersion":"16.13.1","_npmVersion":"8.3.1","dist":{"integrity":"sha512-HjHNvhaSTlkUL/SiqX+MdUiYy1+axuGb6aNLkJ5BSQOJIjrx1jK+HCCUnP/+epm33TdNU/2ojFNKFH8zsb9HQA==","shasum":"4d469b01ec4651124b99cf29b42f8ce3cb39c49f","tarball":"https://registry.npmjs.org/@ansdomain/content-hash/-/content-hash-2.5.7.tgz","fileCount":14,"unpackedSize":350439,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDM4XZY+ZlE+Ks+de67DZbDQGxeg/oyFFxBZogxHYNeqAiBT0vpABThfCOnTAdSLQ9hdmV+6ceDBVkkl3kVBuNM7tw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjMkx1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmotRQ/9GoTSZdHb/ZHULY+coSlnCHyZr0SuytR9VPtEJtdG+rlrA7CD\r\nk5CaSsAyvc/m5V/Ck4zagOknZzyFaHWTZwBdS2FP4igy7A3qv9sRG4gn8h9r\r\nQfMm6efVMOKqVHlPoEidZqtC8H+SPG+XpDuSzaRNdyfRk9GIUIXZ9gJCeXQX\r\nQCMBTviKZWyz5FvemULpOjo6FTocZEP0D/LhmoryCgRvifNjwG02KiPuzWcV\r\nGxJ3RrVzWyJdduO1WHS8m7LmNvX88ZWuTTPDaFZI6gIBfF18EcrxshNP7thC\r\nlzhXiY115YeWSZJG1sX/gmP/RkVClO0FalCM0tIBlQPGbDvya+T4SNnBJ2ML\r\n0PJfhKsQzfTKk5vgJdHW/y/CqGlUSTr6MDgWJmht7fmLzAB/JvNs2kZ9HoPh\r\niNix5dRb+cuy9msEuanndWitL40etEYRjZaBUJPT47eBPx2T3dr+qIWqVJgP\r\nsiDUxK6M9mi7tsiEEB4VjJDSUgNH814o0zrekVIHsive1SBoYmRKNvWCoWoI\r\n9CtU9U+OhCS4GBjfA3SK2QYuRgpTV7XgF3j0MdLo7NnVcvO5+BMD4cVmcA40\r\nD2dN9S1zTZAMCZ8ixBJnWrcwnFgKr2NjAhOqTSXRkdBYEAFTivwG0D2VlBf0\r\nEFxPj1ykImZbHxfbcO04retiURTgHtKE3vs=\r\n=kwF3\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"arbitrumdomains","email":"arbitrumdns@gmail.com"},"directories":{},"maintainers":[{"name":"arbitrumdomains","email":"arbitrumdns@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/content-hash_2.5.7_1664240757434_0.4138600541425459"},"_hasShrinkwrap":false}},"time":{"created":"2022-09-27T01:05:57.378Z","2.5.7":"2022-09-27T01:05:57.635Z","modified":"2022-10-26T13:33:51.848Z"},"maintainers":[{"email":"dev.koold@gmail.com","name":"devilla"},{"email":"arbitrumdns@gmail.com","name":"arbitrumdomains"}],"description":"simple tool to encode/decode content hash for EIP 1577 compliant ENS Resolvers (fork of pldespaigne/content-hash)","homepage":"https://github.com/ensdomains/content-hash#readme","keywords":["ethereum","ens","eip-1577","resolver","ipfs","swarm","content-hash","content","hash","contenthash","contentHash"],"repository":{"type":"git","url":"git+https://github.com/ensdomains/content-hash.git"},"author":{"name":"pldespaigne"},"bugs":{"url":"https://github.com/ensdomains/content-hash/issues"},"license":"ISC","readme":"\n\n# content-hash\n\n[![npm package](https://img.shields.io/npm/v/content-hash.svg)](https://www.npmjs.com/package/content-hash)[![CircleCI](https://circleci.com/gh/pldespaigne/content-hash.svg?style=svg)](https://circleci.com/gh/pldespaigne/content-hash)![licence](https://img.shields.io/npm/l/content-hash.svg)[![Gitter chat](https://badges.gitter.im/content-hash/lobby.png)](https://gitter.im/content-hash/lobby)[![Beerpay](https://beerpay.io/pldespaigne/content-hash/badge.svg)](https://beerpay.io/pldespaigne/content-hash)\n\n>This is a simple package made for encoding and decoding content hashes as specified in the [EIP 1577](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1577.md).\nThis package will be useful for every [Ethereum](https://www.ethereum.org/) developer wanting to interact with [EIP 1577](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1577.md) compliant [ENS resolvers](http://docs.ens.domains/en/latest/introduction.html).\n\nHere you can find a [live demo](https://content-hash.surge.sh/) of this package.\n* link to [npm](https://www.npmjs.com/package/content-hash)\n* link to [Github](https://github.com/pldespaigne/content-hash)\n\n## 🔠 Supported Codec\n- `swarm-ns`\n- `ipfs-ns`\n- `ipns-ns`\n- Every other codec supported by [multicodec](https://github.com/multiformats/multicodec) will be encoded by default in `utf-8`.\n> You can see the full list of codec supported [here](https://github.com/multiformats/multicodec/blob/master/table.csv)\n\n## 📥 Install\n* via **npm** :\n\t```bash\n\t$> npm install content-hash\n\t```\n* via **Github** : Download or clone this repo, then install the dependencies.\n\t```bash\n\t$> git clone https://github.com/pldespaigne/content-hash.git\n\t$> cd content-hash\n\t$> npm install\n\t```\n> For browser only usage, installation is not required.\n\n## 🛠 Usage\nImport the module in order to use it :\n* **NodeJS** :\n\t```javascript\n\tconst contentHash = require('content-hash')\n\t```\n* **Browser** :\n\t```html\n\t<!--From CDN-->\n\t<script type=\"text/javascript\" src=\"https://unpkg.com/content-hash/dist/index.js\"></script>\n\n\t<!--From local module-->\n\t<script type=\"text/javascript\" src=\"path/to/dist/index.js\"></script>\n\t```\n> To rebuild the browser version of the package run `npm run build` into the root folder. Don't forget to also run `npm run lint` and `npm test` before building !\n\n## 📕 API\n\n> All hex string **inputs** can be prefixed with `0x`, but it's **not mandatory**.\n\n> ⚠️ All **outputs** are **NOT** prefixed with `0x`\n\n### contentHash.decode( contentHash ) -> string\nThis function takes a content hash as a hex **string** and returns the decoded content as a **string**.\n```javascript\nconst encoded = 'e3010170122029f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f'\n\nconst content = contentHash.decode(encoded)\n// 'QmRAQB6YaCyidP37UdDnjFY5vQuiBrcqdyoW1CuDgwxkD4'\n```\n\n### contentHash.fromIpfs( ipfsHash ) -> string\nThis function takes an IPFS address as a base58 encoded **string** and returns the encoded content hash as a hex **string**.\n> this function just call `contentHash.encode()` under the hood\n```javascript\nconst ipfsHash = 'QmRAQB6YaCyidP37UdDnjFY5vQuiBrcqdyoW1CuDgwxkD4'\n\nconst contentH = contentHash.fromIpfs(ipfsHash)\n// 'e3010170122029f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f'\n```\n\n### contentHash.fromSwarm( swarmHash ) -> string\nThis function takes a Swarm address as a hex **string** and returns the encoded content hash as a hex **string**.\n> this function just call `contentHash.encode()` under the hood\n```javascript\nconst swarmHash = 'd1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162'\n\nconst contentH = contentHash.fromSwarm(swarmHash)\n// 'e40101701b20d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162'\n```\n\n### contentHash.encode( codec, value) -> string\nThis function takes a [supported codec](#-supported-codec) as a **string** and a value as a **string** and returns coresponding content hash as a hex **string**.\n```javascript\nconst onion = 'zqktlwi4fecvo6ri'\ncontentHash.encode('onion', onion);\n// 'bc037a716b746c776934666563766f367269'\n```\n\n### contentHash.getCodec( contentHash ) -> string\nThis function takes a content hash as a hex **string** and returns the codec as a hex **string**.\n```javascript\nconst encoded = 'e40101701b20d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162'\n\nconst codec = contentHash.getCodec(encoded) // 'swarm-ns'\ncodec === 'ipfs-ns' // false\n```\n\n### contentHash.helpers\nThis object contain the following helpers functions :\n\n- #### cidV0ToV1Base32( ipfsHash ) -> string\n\tThis function takes an ipfsHash and convert it to a CID v1 encoded in base32.\n\t```javascript\n\tconst ipfs = 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG'\n\n\tconst cidV1 = contentHash.helpers.cidV0ToV1Base32(ipfs)\n\t// 'bafybeibj6lixxzqtsb45ysdjnupvqkufgdvzqbnvmhw2kf7cfkesy7r7d4'\n\t```\n\n## 👨‍💻 Maintainer\n*  pldespaigne : [github](https://github.com/pldespaigne), [twitter](https://twitter.com/pldespaigne)\n\n## 🙌 Contributing\nFor any questions, discussions, bug report, or whatever I will be happy to answer through the [issues](https://github.com/pldespaigne/content-hash/issues) or on my [twitter](https://twitter.com/pldespaigne) 😁. PR (with tests) are also welcome !\n\n## 📝 License\nThis project is licensed under the **ISC License**, you can find it [here](https://github.com/pldespaigne/content-hash/blob/master/LICENSE).\n> Note that the dependencies may have a different License\n\n\n","readmeFilename":"README.md"}