Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@libp2p/utils

Package Overview
Dependencies
Maintainers
6
Versions
583
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/utils - npm Package Compare versions

Comparing version 6.2.1-bc90b4fd5 to 6.2.1-d19974d93

dist/src/global-unicast-ip.d.ts

2

dist/src/multiaddr/is-private.d.ts
import type { Multiaddr } from '@multiformats/multiaddr';
/**
* Check if a given multiaddr has a private address.
* Check if a given multiaddr starts with a private address
*/
export declare function isPrivate(ma: Multiaddr): boolean;
//# sourceMappingURL=is-private.d.ts.map
import { isPrivateIp } from '../private-ip.js';
const CODEC_IP4 = 0x04;
const CODEC_IP6 = 0x29;
const CODEC_DNS = 0x35;
const CODEC_DNS4 = 0x36;
const CODEC_DNS6 = 0x37;
const CODEC_DNSADDR = 0x38;
/**
* Check if a given multiaddr has a private address.
* Check if a given multiaddr starts with a private address
*/
export function isPrivate(ma) {
try {
const { address } = ma.nodeAddress();
return Boolean(isPrivateIp(address));
const [[codec, value]] = ma.stringTuples();
if (value == null) {
return true;
}
if (codec === CODEC_DNS || codec === CODEC_DNS4 || codec === CODEC_DNS6 || codec === CODEC_DNSADDR) {
return false;
}
if (codec === CODEC_IP4 || codec === CODEC_IP6) {
return isPrivateIp(value) ?? false;
}
}
catch {
return true;
}
return true;
}
//# sourceMappingURL=is-private.js.map
{
"name": "@libp2p/utils",
"version": "6.2.1-bc90b4fd5",
"version": "6.2.1-d19974d93",
"description": "Package to aggregate shared logic and dependencies for the libp2p ecosystem",

@@ -79,2 +79,6 @@ "license": "Apache-2.0 OR MIT",

},
"./global-unicast-ip": {
"types": "./dist/src/global-unicast-ip.d.ts",
"import": "./dist/src/global-unicast-ip.js"
},
"./ip-port-to-multiaddr": {

@@ -88,2 +92,6 @@ "types": "./dist/src/ip-port-to-multiaddr.d.ts",

},
"./link-local-ip": {
"types": "./dist/src/link-local-ip.d.ts",
"import": "./dist/src/link-local-ip.js"
},
"./moving-average": {

@@ -93,2 +101,10 @@ "types": "./dist/src/moving-average.d.ts",

},
"./multiaddr/is-global-unicast": {
"types": "./dist/src/multiaddr/is-global-unicast.d.ts",
"import": "./dist/src/multiaddr/is-global-unicast.js"
},
"./multiaddr/is-link-local": {
"types": "./dist/src/multiaddr/is-link-local.d.ts",
"import": "./dist/src/multiaddr/is-link-local.js"
},
"./multiaddr/is-loopback": {

@@ -162,6 +178,7 @@ "types": "./dist/src/multiaddr/is-loopback.d.ts",

"@chainsafe/is-ip": "^2.0.2",
"@libp2p/crypto": "5.0.7-bc90b4fd5",
"@libp2p/interface": "2.2.1-bc90b4fd5",
"@libp2p/logger": "5.1.4-bc90b4fd5",
"@multiformats/multiaddr": "^12.2.3",
"@chainsafe/netmask": "^2.0.0",
"@libp2p/crypto": "5.0.7-d19974d93",
"@libp2p/interface": "2.2.1-d19974d93",
"@libp2p/logger": "5.1.4-d19974d93",
"@multiformats/multiaddr": "^12.3.3",
"@sindresorhus/fnv1a": "^3.1.0",

@@ -176,3 +193,3 @@ "@types/murmurhash3js-revisited": "^3.0.3",

"it-pushable": "^3.2.3",
"it-stream-types": "^2.0.1",
"it-stream-types": "^2.0.2",
"murmurhash3js-revisited": "^3.0.0",

@@ -182,3 +199,3 @@ "netmask": "^2.0.2",

"race-event": "^1.3.0",
"race-signal": "^1.0.2",
"race-signal": "^1.1.0",
"uint8arraylist": "^2.4.8",

@@ -188,5 +205,5 @@ "uint8arrays": "^5.1.0"

"devDependencies": {
"@libp2p/peer-id": "5.0.8-bc90b4fd5",
"@libp2p/peer-id": "5.0.8-d19974d93",
"@types/netmask": "^2.0.5",
"aegir": "^44.0.1",
"aegir": "^45.0.5",
"benchmark": "^2.1.4",

@@ -197,3 +214,3 @@ "delay": "^6.0.0",

"it-pair": "^2.0.6",
"sinon": "^18.0.0",
"sinon": "^19.0.2",
"sinon-ts": "^2.0.0"

@@ -200,0 +217,0 @@ },

@@ -52,3 +52,3 @@ # @libp2p/utils

Loading this module through a script tag will make it's exports available as `Libp2pUtils` in the global namespace.
Loading this module through a script tag will make its exports available as `Libp2pUtils` in the global namespace.

@@ -55,0 +55,0 @@ ```html

import { isPrivateIp } from '../private-ip.js'
import type { Multiaddr } from '@multiformats/multiaddr'
const CODEC_IP4 = 0x04
const CODEC_IP6 = 0x29
const CODEC_DNS = 0x35
const CODEC_DNS4 = 0x36
const CODEC_DNS6 = 0x37
const CODEC_DNSADDR = 0x38
/**
* Check if a given multiaddr has a private address.
* Check if a given multiaddr starts with a private address
*/
export function isPrivate (ma: Multiaddr): boolean {
try {
const { address } = ma.nodeAddress()
const [[codec, value]] = ma.stringTuples()
return Boolean(isPrivateIp(address))
if (value == null) {
return true
}
if (codec === CODEC_DNS || codec === CODEC_DNS4 || codec === CODEC_DNS6 || codec === CODEC_DNSADDR) {
return false
}
if (codec === CODEC_IP4 || codec === CODEC_IP6) {
return isPrivateIp(value) ?? false
}
} catch {
return true
}
return true
}

Sorry, the diff of this file is not supported yet

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