Socket
Socket
Sign inDemoInstall

is-ipfs

Package Overview
Dependencies
Maintainers
5
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-ipfs - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0

dist/index.min.js

16

CHANGELOG.md

@@ -0,1 +1,17 @@

# [6.0.0](https://github.com/ipfs/is-ipfs/compare/v5.0.0...v6.0.0) (2021-07-07)
### chore
* update to new multiformats ([#42](https://github.com/ipfs/is-ipfs/issues/42)) ([22bf9b7](https://github.com/ipfs/is-ipfs/commit/22bf9b7c88b6a9d6d9141f8565552557d9109ee8))
### BREAKING CHANGES
* uses the CID class from the new multiformats module
Co-authored-by: Marcin Rataj <lidel@lidel.org>
# [5.0.0](https://github.com/ipfs/is-ipfs/compare/v4.0.0...v5.0.0) (2021-04-19)

@@ -2,0 +18,0 @@

2

dist/src/index.d.ts

@@ -17,3 +17,3 @@ /**

declare function isCID(hash: any): boolean;
import CID = require("cids");
import { CID } from "multiformats/cid";
/**

@@ -20,0 +20,0 @@ * @param {string | Uint8Array} url

{
"name": "is-ipfs",
"version": "5.0.0",
"version": "6.0.0",
"description": "A set of utilities to help identify IPFS resources on the web",

@@ -44,8 +44,6 @@ "keywords": [

"dependencies": {
"cids": "^1.1.6",
"iso-url": "^1.1.3",
"mafmt": "^9.0.0",
"multiaddr": "^9.0.1",
"multibase": "^4.0.2",
"multihashes": "^4.0.2",
"multiaddr": "^10.0.0",
"multiformats": "^9.0.0",
"uint8arrays": "^2.1.3"

@@ -70,7 +68,7 @@ },

"Alan Shaw <alan.shaw@protocol.ai>",
"Alex Potsides <alex@achingbrain.net>",
"nginnever <ginneversource@gmail.com>",
"Alex Potsides <alex@achingbrain.net>",
"Hugo Dias <mail@hugodias.me>",
"Henrique Dias <hacdias@gmail.com>"
"Henrique Dias <hacdias@gmail.com>",
"Hugo Dias <mail@hugodias.me>"
]
}
'use strict'
const multihash = require('multihashes')
const multibase = require('multibase')
const { base58btc } = require('multiformats/bases/base58')
const { base32 } = require('multiformats/bases/base32')
const Digest = require('multiformats/hashes/digest')
const { Multiaddr } = require('multiaddr')
const mafmt = require('mafmt')
const CID = require('cids')
const { CID } = require('multiformats/cid')
const { URL } = require('iso-url')

@@ -30,7 +31,8 @@ const uint8ArrayToString = require('uint8arrays/to-string')

try {
multihash.decode(multibase.decode('z' + formatted))
return true
} catch (e) {
Digest.decode(base58btc.decode('z' + formatted))
} catch {
return false
}
return true
}

@@ -41,8 +43,10 @@

*/
function isMultibase (hash) {
function isBase32EncodedMultibase (hash) {
try {
return multibase.isEncoded(hash)
} catch (e) {
base32.decode(hash)
} catch {
return false
}
return true
}

@@ -55,4 +59,11 @@

try {
new CID(hash) // eslint-disable-line no-new
return true
if (typeof hash === 'string') {
return Boolean(CID.parse(hash))
}
if (hash instanceof Uint8Array) {
return Boolean(CID.decode(hash))
}
return Boolean(CID.asCID(hash)) // eslint-disable-line no-new
} catch (e) {

@@ -228,3 +239,3 @@ return false

*/
base32cid: (cid) => (isMultibase(cid) === 'base32' && isCID(cid)),
base32cid: (cid) => (isBase32EncodedMultibase(cid) && isCID(cid)),
ipfsSubdomain,

@@ -231,0 +242,0 @@ ipnsSubdomain,

Sorry, the diff of this file is not supported yet

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