diff --git a/dist/index.js b/dist/index.js index 0d0a5ba..b09d8ea 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3362,6 +3362,7 @@ exports['path'] = Buffer.from('2f', 'hex') exports['ipld-ns'] = Buffer.from('e2', 'hex') exports['ipfs-ns'] = Buffer.from('e3', 'hex') exports['swarm-ns'] = Buffer.from('e4', 'hex') +exports['ipns-ns'] = Buffer.from('e5', 'hex') // key exports['ed25519-pub'] = Buffer.from('ed', 'hex') @@ -3808,6 +3809,7 @@ module.exports = Object.freeze({ IPLD_NS: 0xe2, IPFS_NS: 0xe3, SWARM_NS: 0xe4, + IPNS_NS: 0xe5, // key ED25519_PUB: 0xed, @@ -4397,6 +4399,7 @@ module.exports = Object.freeze({ 0xe2: 'ipld-ns', 0xe3: 'ipfs-ns', 0xe4: 'swarm-ns', + 0xe5: 'ipns-ns', // key 0xed: 'ed25519-pub', @@ -5878,7 +5881,7 @@ module.exports = function (value) { },{}],30:[function(require,module,exports){ module.exports={ "name": "content-hash", - "version": "2.4.0", + "version": "2.4.1", "next-release": "patch", "description": "simple tool to encode/decode content hash for EIP 1577 compliant ENS Resolvers", "main": "index.js", @@ -5897,7 +5900,7 @@ module.exports={ "license": "ISC", "dependencies": { "cids": "^0.6.0", - "multicodec": "^0.5.3", + "multicodec": "^0.5.4", "multihashes": "^0.4.15" }, "devDependencies": { @@ -6125,6 +6128,10 @@ const profiles = { encode: encodes.ipfs, decode: decodes.b58MultiHash, }, + 'ipns-ns': { + encode: encodes.ipfs, + decode: decodes.b58MultiHash, + }, 'onion': { encode: encodes.utf8, decode: decodes.utf8, diff --git a/package-lock.json b/package-lock.json index 107688e..5b7da89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1524,9 +1524,9 @@ } }, "multicodec": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-0.5.3.tgz", - "integrity": "sha512-TUId9mavSh7q4ui5nUYiC0U10XVrMhsoMLPoG6nAAaFt2GKqZKK3aB2AeFk58aqEnLhmTSdRkmNrlty4jjOxzg==", + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-0.5.4.tgz", + "integrity": "sha512-0lPLiZ58b2jyXylx2qgda9/6N0YCNIpBxRsZ8sxYayVjEKh58XyNN74VTTQOR/ZCQFgbj0CsqfyRpEDPPlOMkw==", "requires": { "varint": "^5.0.0" } diff --git a/package.json b/package.json index d4066a1..deee0f2 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "ISC", "dependencies": { "cids": "^0.6.0", - "multicodec": "^0.5.3", + "multicodec": "^0.5.4", "multihashes": "^0.4.15" }, "devDependencies": { diff --git a/src/profiles.js b/src/profiles.js index 600627d..d67c799 100644 --- a/src/profiles.js +++ b/src/profiles.js @@ -106,6 +106,10 @@ const profiles = { encode: encodes.ipfs, decode: decodes.b58MultiHash, }, + 'ipns-ns': { + encode: encodes.ipfs, + decode: decodes.b58MultiHash, + }, 'onion': { encode: encodes.utf8, decode: decodes.utf8, diff --git a/test/test.js b/test/test.js index 5ab0725..9e8b191 100644 --- a/test/test.js +++ b/test/test.js @@ -5,6 +5,7 @@ const contentHash = require('../src/index.js') const ipfs = 'QmRAQB6YaCyidP37UdDnjFY5vQuiBrcqdyoW1CuDgwxkD4' const ipfs_contentHash = 'e3010170122029f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f' +const ipns_contentHash = 'e5010170122029f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f' const swarm = 'd1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162' const swarm_contentHash = 'e40101fa011b20d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162' const onion = 'zqktlwi4fecvo6ri' @@ -81,6 +82,20 @@ describe('content-hash', () => { actual.should.be.equal(ipfs); }); }); + describe('ipns', () => { + it('should encode', () => { + const actual = contentHash.encode('ipns-ns', ipfs); // ipns & ipfs are the same hash and same encoding, only codec differ + actual.should.be.equal(ipns_contentHash); + }); + it('should getCodec', () => { + const actual = contentHash.getCodec(ipns_contentHash); + actual.should.be.equal('ipns-ns'); + }); + it('should decode', () => { + const actual = contentHash.decode(ipns_contentHash); + actual.should.be.equal(ipfs); // ipns & ipfs are the same hash and same encoding, only codec differ + }); + }); describe('onion', () => { it('should encode', () => { const actual = contentHash.encode('onion', onion);