Socket
Socket
Sign inDemoInstall

is-ipfs

Package Overview
Dependencies
Maintainers
2
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 0.5.1 to 0.6.0

dist/index.min.js.map

16

CHANGELOG.md

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

<a name="0.6.0"></a>
# [0.6.0](https://github.com/ipfs/is-ipfs/compare/v0.5.1...v0.6.0) (2019-03-03)
### Bug Fixes
* **ci:** switch to modern .travis.yml ([972ab2e](https://github.com/ipfs/is-ipfs/commit/972ab2e))
### Features
* isIPFS.multiaddr(input) ([820d475](https://github.com/ipfs/is-ipfs/commit/820d475))
* isIPFS.peerMultiaddr(input) ([673dc59](https://github.com/ipfs/is-ipfs/commit/673dc59))
<a name="0.5.1"></a>

@@ -2,0 +18,0 @@ ## [0.5.1](https://github.com/ipfs/is-ipfs/compare/v0.5.0...v0.5.1) (2019-02-11)

12

package.json
{
"name": "is-ipfs",
"version": "0.5.1",
"version": "0.6.0",
"description": "A set of utilities to help identify IPFS resources",

@@ -33,4 +33,6 @@ "leadMaintainer": "Marcin Rataj <lidel@lidel.org>",

"dependencies": {
"bs58": "4.0.1",
"bs58": "^4.0.1",
"cids": "~0.5.6",
"mafmt": "^v6.0.7",
"multiaddr": "^6.0.4",
"multibase": "~0.6.0",

@@ -40,5 +42,5 @@ "multihashes": "~0.4.13"

"devDependencies": {
"aegir": "15.0.1",
"chai": "4.1.2",
"pre-commit": "1.2.2"
"aegir": "^18.2.0",
"chai": "^4.2.0",
"pre-commit": "^1.2.2"
},

@@ -45,0 +47,0 @@ "repository": {

@@ -1,2 +0,2 @@

is-ipfs
is-ipfs 🕵️
====

@@ -26,3 +26,3 @@

```js
var is-ipfs = require('is-ipfs')
var isIPFS = require('is-ipfs')
```

@@ -35,3 +35,3 @@

```
```html
<script src="https://unpkg.com/is-ipfs/dist/index.min.js"></script>

@@ -101,2 +101,13 @@ <!-- OR -->

isIPFS.ipnsSubdomain('http://foo-bar.ipns.dweb.link') // false (not a PeerID)
isIPFS.multiaddr('/ip4/127.0.0.1/udp/1234') // true
isIPFS.multiaddr('/ip4/127.0.0.1/udp/1234/http') // true
isIPFS.multiaddr('/ip6/::1/udp/1234') // true
isIPFS.multiaddr('ip6/::1/udp/1234') // false
isIPFS.multiaddr('/yoloinvalid/::1/udp/1234') // false
isIPFS.peerMultiaddr('/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4') // true
isIPFS.peerMultiaddr('/ip4/127.0.0.1/tcp/1234/ws/ipfs/QmUjNmr8TgJCn1Ao7DvMy4cjoZU15b9bwSCBLE3vwXiwgj') // true
isIPFS.peerMultiaddr('/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4/p2p-circuit/ipfs/QmUjNmr8TgJCn1Ao7DvMy4cjoZU15b9bwSCBLE3vwXiwgj') // true
isIPFS.peerMultiaddr('/ip4/127.0.0.1/udp/1234') // false
```

@@ -113,3 +124,3 @@

## Utils
## Content Identifiers

@@ -122,3 +133,3 @@ ### `isIPFS.multihash(hash)`

Returns `true` if the provided string is a valid `CID` or `false` otherwise.
Returns `true` if the provided string or [`CID`](https://github.com/ipld/js-cid) object represents a valid [CID](https://docs.ipfs.io/guides/concepts/cid/) or `false` otherwise.

@@ -155,3 +166,2 @@ ### `isIPFS.base32cid(hash)`

### `isIPFS.ipfsPath(path)`

@@ -165,2 +175,7 @@

### `isIPFS.cidPath(path)`
Returns `true` if the provided string is a valid "CID path" (IPFS path without `/ipfs/` prefix) or `false` otherwise.
## Subdomains

@@ -182,5 +197,18 @@

## Multiaddrs
Below methods provide basic detection of [multiaddr](https://github.com/multiformats/multiaddr)s: composable and future-proof network addresses.
Complex validation of multiaddr can be built using `isIPFS.multiaddr` and [`mafmt`](https://github.com/multiformats/js-mafmt) library.
### `isIPFS.multiaddr(addr)`
Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr) or `Buffer` represents a valid multiaddr or `false` otherwise.
### `isIPFS.peerMultiaddr(addr)`
Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr) or `Buffer` represents a valid "IPFS Peer" multiaddr (matching [`IPFS` format from `mafmt`](https://github.com/multiformats/js-mafmt#api)) or `false` otherwise.
# License
MIT

@@ -6,2 +6,4 @@ 'use strict'

const multibase = require('multibase')
const Multiaddr = require('multiaddr')
const mafmt = require('mafmt')
const CID = require('cids')

@@ -46,2 +48,17 @@

function isMultiaddr (input) {
if (!input) return false
if (Multiaddr.isMultiaddr(input)) return true
try {
new Multiaddr(input) // eslint-disable-line no-new
return true
} catch (e) {
return false
}
}
function isPeerMultiaddr (input) {
return isMultiaddr(input) && mafmt.IPFS.matches(input)
}
function isIpfs (input, pattern, protocolMatch = defaultProtocolMatch, hashMatch = defaultHashMath) {

@@ -121,2 +138,4 @@ const formatted = convertToString(input)

multihash: isMultihash,
multiaddr: isMultiaddr,
peerMultiaddr: isPeerMultiaddr,
cid: isCID,

@@ -123,0 +142,0 @@ base32cid: (cid) => (isMultibase(cid) === 'base32' && isCID(cid)),

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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