New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ndn/autoconfig

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndn/autoconfig - npm Package Compare versions

Comparing version 0.0.20191223-beta.1 to 0.0.20200606

0

lib/connect.d.ts

@@ -0,0 +0,0 @@ import { Forwarder, FwFace } from "@ndn/fw";

13

lib/connect.js

@@ -0,1 +1,6 @@

/// #if false
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const { __importDefault } = require("tslib");
/// #endif
import { Endpoint } from "@ndn/endpoint";

@@ -5,3 +10,11 @@ import { Forwarder, TapFace } from "@ndn/fw";

import { Interest, Name } from "@ndn/packet";
/// #if false
const hirestime = __importDefault(require("hirestime")).default;
/*
/// #else
import hirestime from "hirestime";
/// #endif
/// #if false
*/
/// #endif
import { createTransport } from "./platform/mod.js";

@@ -8,0 +21,0 @@ const getNow = hirestime();

6

lib/fch.d.ts

@@ -10,5 +10,7 @@ export declare function queryFch(opts?: queryFch.Options): Promise<string[]>;

capabilities?: string[];
/** GPS position in GeoJSON [lon,lat] format, or null to use IP geolocation. */
position?: null | [number, number];
/** GPS position in GeoJSON [lon,lat] format, or IpGeolocation. */
position?: [number, number] | typeof IpGeolocation;
}
/** Set IP geolocation in Options.position. */
const IpGeolocation: unique symbol;
}
import { FCH_ALWAYS_CAPABILITIES, fetch } from "./platform/mod.js";
export async function queryFch(opts = {}) {
const { server = "https://ndn-fch.named-data.net", count = 1, capabilities = [], position = null, } = opts;
let u = `${server.replace(/[/]$/, "")}/?k=${count}`;
const { server = "https://ndn-fch.named-data.net", count = 1, capabilities = [], position = queryFch.IpGeolocation, } = opts;
let u = `${server.replace(/\/$/, "")}/?k=${count}`;
for (const cap of new Set([...capabilities, ...FCH_ALWAYS_CAPABILITIES])) {
u += `&cap=${cap}`;
}
if (position) {
if (position !== queryFch.IpGeolocation) {
u += `&lon=${position[0].toFixed(5)}&lat=${position[1].toFixed(5)}`;
}
const resp = await fetch(u);
if (!resp.ok) {
throw new Error(`invalid NDN-FCH HTTP response ${resp.status}`);
}
const text = await resp.text();
return text.split(",");
}
(function (queryFch) {
/** Set IP geolocation in Options.position. */
queryFch.IpGeolocation = Symbol("queryFch.IpGeolocation");
})(queryFch || (queryFch = {}));
export * from "./connect";
export * from "./fch";
export * from "./testbed";
import { Transport } from "@ndn/l3face";
import { connect } from "../mod";
export declare const fetch: ((input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>) & ((input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>);
export declare const fetch: typeof globalThis.fetch;
export declare const FCH_ALWAYS_CAPABILITIES: string[];
export declare function createTransport(host: string, { connectTimeout }: connect.Options): Promise<Transport>;
export declare function getDefaultGateway(): Promise<string>;
import { WsTransport } from "@ndn/ws-transport";
export const fetch = self.fetch;
export const fetch = globalThis.fetch;
export const FCH_ALWAYS_CAPABILITIES = ["wss"];

@@ -4,0 +4,0 @@ export function createTransport(host, { connectTimeout }) {

@@ -0,0 +0,0 @@ import { Transport } from "@ndn/l3face";

@@ -0,4 +1,25 @@

/// #if false
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const { __importDefault } = require("tslib");
/// #endif
import { TcpTransport } from "@ndn/node-transport";
/// #if false
const defaultGateway = __importDefault(require("default-gateway")).default;
/*
/// #else
import defaultGateway from "default-gateway";
/// #endif
/// #if false
*/
/// #endif
/// #if false
const nodeFetch = __importDefault(require("node-fetch")).default;
/*
/// #else
import nodeFetch from "node-fetch";
/// #endif
/// #if false
*/
/// #endif
export const fetch = nodeFetch;

@@ -5,0 +26,0 @@ export const FCH_ALWAYS_CAPABILITIES = [];

@@ -0,0 +0,0 @@ import { FwFace } from "@ndn/fw";

@@ -1,6 +0,19 @@

import { collect, filter, pipeline, take, transform } from "streaming-iterables";
/// #if false
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const { __importDefault } = require("tslib");
/// #endif
/// #if false
const { collect, filter, pipeline, transform } = require("streaming-iterables");
/*
/// #else
import { collect, filter, pipeline, transform } from "streaming-iterables";
/// #endif
/// #if false
*/
/// #endif
import { connect, queryFch } from "./mod.js";
import { getDefaultGateway } from "./platform/mod.js";
export async function connectToTestbed(opts = {}) {
const { fchFallback = [], count = 1, tryDefaultGateway = true, preferFastest = false, } = opts;
const { fchFallback = [], tryDefaultGateway = true, preferFastest = false, } = opts;
const hosts = await queryFch(opts).catch(() => fchFallback);

@@ -11,5 +24,5 @@ if (tryDefaultGateway) {

}
catch (err) { }
catch { }
}
const faces = await pipeline(() => hosts, transform(Infinity, (host) => connect(host, opts).catch(() => undefined)), filter((res) => !!res), take(count), collect);
const faces = await pipeline(() => hosts, transform(Infinity, (host) => connect(host, opts).catch(() => undefined)), filter((res) => !!res), collect);
if (preferFastest && faces.length > 1) {

@@ -16,0 +29,0 @@ faces.sort(({ testConnectionDuration: d1 }, { testConnectionDuration: d2 }) => d1 - d2);

{
"name": "@ndn/autoconfig",
"version": "0.0.20191223-beta.1",
"version": "0.0.20200606",
"description": "NDNts: automatic connection establishment",

@@ -28,14 +28,14 @@ "keywords": [

"dependencies": {
"@ndn/endpoint": "0.0.20191223-beta.1",
"@ndn/fw": "0.0.20191223-beta.1",
"@ndn/l3face": "0.0.20191223-beta.1",
"@ndn/node-transport": "0.0.20191223-beta.1",
"@ndn/packet": "0.0.20191223-beta.1",
"@ndn/ws-transport": "0.0.20191223-beta.1",
"default-gateway": "^5.0.5",
"hirestime": "^4.0.0",
"@ndn/endpoint": "0.0.20200606",
"@ndn/fw": "0.0.20200606",
"@ndn/l3face": "0.0.20200606",
"@ndn/node-transport": "0.0.20200606",
"@ndn/packet": "0.0.20200606",
"@ndn/ws-transport": "0.0.20200606",
"default-gateway": "^6.0.1",
"hirestime": "^6.0.1",
"node-fetch": "^2.6.0",
"streaming-iterables": "^4.1.1",
"streaming-iterables": "^4.1.2",
"tslib": "*"
}
}

@@ -38,3 +38,3 @@ # @ndn/autoconfig

// Ask for router at specific location:
hosts = await queryFch({ position: [121.403351, 31.007990] });
hosts = await queryFch({ position: [121.403351, 31.007990] }); // eslint-disable-line unicorn/no-zero-fractions
console.log("near @yoursunny's birthplace", hosts);

@@ -41,0 +41,0 @@ ```

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