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

@ndn/endpoint

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndn/endpoint - npm Package Compare versions

Comparing version 0.0.20210930 to 0.0.20220501

LICENSE

11

lib/consumer_browser.js

@@ -1,5 +0,4 @@

import { __importDefault, __importStar } from "tslib";
import { CancelInterest, FwPacket } from "@ndn/fw";
import { Data, Interest } from "@ndn/packet";
import _cjsDefaultImport0 from "it-pushable"; const pushable = __importDefault(_cjsDefaultImport0).default;
import { pushable } from "it-pushable";
import { makeRetxGenerator } from "./retx_browser.js";

@@ -11,3 +10,3 @@ /** Consumer functionality of Endpoint. */

const interest = interestInput instanceof Interest ? interestInput : new Interest(interestInput);
const { describe = `consume(${interest.name})`, modifyInterest, retx, signal, verifier, } = { ...this.opts, ...opts };
const { describe = `consume(${interest.name})`, signal, modifyInterest, retx, verifier, } = { ...this.opts, ...opts };
Interest.makeModifyFunc(modifyInterest)(interest);

@@ -34,7 +33,7 @@ let nRetx = -1;

};
const onabort = () => {
const onAbort = () => {
cancelRetx();
rx.push(new CancelInterest(interest));
};
signal?.addEventListener("abort", onabort);
signal?.addEventListener("abort", onAbort);
this.fw.addFace({

@@ -61,3 +60,3 @@ rx,

cancelRetx();
signal?.removeEventListener("abort", onabort);
signal?.removeEventListener("abort", onAbort);
rx.end();

@@ -64,0 +63,0 @@ },

@@ -1,5 +0,4 @@

import { __importDefault, __importStar } from "tslib";
import { CancelInterest, FwPacket } from "@ndn/fw";
import { Data, Interest } from "@ndn/packet";
import _cjsDefaultImport0 from "it-pushable"; const pushable = __importDefault(_cjsDefaultImport0).default;
import { pushable } from "it-pushable";
import { makeRetxGenerator } from "./retx_node.js";

@@ -11,3 +10,3 @@ /** Consumer functionality of Endpoint. */

const interest = interestInput instanceof Interest ? interestInput : new Interest(interestInput);
const { describe = `consume(${interest.name})`, modifyInterest, retx, signal, verifier, } = { ...this.opts, ...opts };
const { describe = `consume(${interest.name})`, signal, modifyInterest, retx, verifier, } = { ...this.opts, ...opts };
Interest.makeModifyFunc(modifyInterest)(interest);

@@ -34,7 +33,7 @@ let nRetx = -1;

};
const onabort = () => {
const onAbort = () => {
cancelRetx();
rx.push(new CancelInterest(interest));
};
signal?.addEventListener("abort", onabort);
signal?.addEventListener("abort", onAbort);
this.fw.addFace({

@@ -61,3 +60,3 @@ rx,

cancelRetx();
signal?.removeEventListener("abort", onabort);
signal?.removeEventListener("abort", onAbort);
rx.end();

@@ -64,0 +63,0 @@ },

@@ -1,10 +0,9 @@

/// <reference types="node" />
/// <reference types="web" />
import { Forwarder } from "@ndn/fw";
import { Data, Interest, NameLike, Verifier } from "@ndn/packet";
import type { AbortSignal } from "abort-controller";
import { RetxPolicy } from "./retx";
export interface Options {
import { type Forwarder } from "@ndn/fw";
import { type NameLike, type Verifier, Data, Interest } from "@ndn/packet";
import { type RetxPolicy } from "./retx";
export interface ConsumerOptions {
/** Description for debugging purpose. */
describe?: string;
/** AbortSignal that allows canceling the Interest via AbortController. */
signal?: AbortSignal;
/**

@@ -20,4 +19,2 @@ * Modify Interest according to specified options.

retx?: RetxPolicy;
/** AbortSignal that allows canceling the Interest via AbortController. */
signal?: AbortSignal | globalThis.AbortSignal;
/**

@@ -35,3 +32,3 @@ * Data verifier.

*/
export interface Context extends Promise<Data> {
export interface ConsumerContext extends Promise<Data> {
readonly interest: Interest;

@@ -43,5 +40,5 @@ readonly nRetx: number;

fw: Forwarder;
opts: Options;
opts: ConsumerOptions;
/** Consume a single piece of Data. */
consume(interestInput: Interest | NameLike, opts?: Options): Context;
consume(interestInput: Interest | NameLike, opts?: ConsumerOptions): ConsumerContext;
}

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

import { __importDefault, __importStar } from "tslib";
import _cjsDefaultImport0 from "minimalistic-assert"; const assert = __importDefault(_cjsDefaultImport0).default;
import { assert } from "@ndn/util";
import { signUnsignedData } from "./producer_browser.js";

@@ -4,0 +3,0 @@ // We declare an interface here instead of importing DataStore, in order to reduce bundle size for

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

import { __importDefault, __importStar } from "tslib";
import _cjsDefaultImport0 from "minimalistic-assert"; const assert = __importDefault(_cjsDefaultImport0).default;
import { assert } from "@ndn/util";
import { signUnsignedData } from "./producer_node.js";

@@ -4,0 +3,0 @@ // We declare an interface here instead of importing DataStore, in order to reduce bundle size for

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

import { Data, Interest, Signer } from "@ndn/packet";
import type { Data, Interest, Signer } from "@ndn/packet";
/** Outgoing Data buffer for producer. */

@@ -3,0 +3,0 @@ export interface DataBuffer {

import { Forwarder } from "@ndn/fw";
import { EndpointConsumer, Options as ConsumerOptions } from "./consumer";
import { EndpointProducer, Options as ProducerOptions } from "./producer";
import { type ConsumerOptions, EndpointConsumer } from "./consumer";
import { type ProducerOptions, EndpointProducer } from "./producer";
export interface Options extends ConsumerOptions, ProducerOptions {

@@ -5,0 +5,0 @@ fw?: Forwarder;

export type { RetxOptions, RetxPolicy } from "./retx";
export type { Context as ConsumerContext, Options as ConsumerOptions } from "./consumer";
export type { ConsumerContext, ConsumerOptions } from "./consumer";
export { DataBuffer, DataStoreBuffer } from "./data-buffer";
export type { Handler as ProducerHandler, Options as ProducerOptions, Producer } from "./producer";
export type { ProducerHandler, ProducerOptions, Producer } from "./producer";
export * from "./endpoint";

@@ -13,3 +13,3 @@ import { FwPacket } from "@ndn/fw";

const prefix = prefixInput === undefined ? undefined : new Name(prefixInput);
const { describe = `produce(${prefix})`, routeCapture = true, announcement, concurrency = 1, dataSigner, dataBuffer, autoBuffer = true, } = { ...this.opts, ...opts };
const { describe = `produce(${prefix})`, signal, routeCapture = true, announcement, concurrency = 1, dataSigner, dataBuffer, autoBuffer = true, } = { ...this.opts, ...opts };
let producer; // eslint-disable-line prefer-const

@@ -63,2 +63,7 @@ const processInterestUnbuffered = async (interest) => {

}
const onAbort = () => {
face.close();
signal?.removeEventListener("abort", onAbort);
};
signal?.addEventListener("abort", onAbort);
producer = {

@@ -69,3 +74,3 @@ prefix,

processInterest,
close() { face.close(); },
close: onAbort,
};

@@ -72,0 +77,0 @@ return producer;

@@ -13,3 +13,3 @@ import { FwPacket } from "@ndn/fw";

const prefix = prefixInput === undefined ? undefined : new Name(prefixInput);
const { describe = `produce(${prefix})`, routeCapture = true, announcement, concurrency = 1, dataSigner, dataBuffer, autoBuffer = true, } = { ...this.opts, ...opts };
const { describe = `produce(${prefix})`, signal, routeCapture = true, announcement, concurrency = 1, dataSigner, dataBuffer, autoBuffer = true, } = { ...this.opts, ...opts };
let producer; // eslint-disable-line prefer-const

@@ -63,2 +63,7 @@ const processInterestUnbuffered = async (interest) => {

}
const onAbort = () => {
face.close();
signal?.removeEventListener("abort", onAbort);
};
signal?.addEventListener("abort", onAbort);
producer = {

@@ -69,3 +74,3 @@ prefix,

processInterest,
close() { face.close(); },
close: onAbort,
};

@@ -72,0 +77,0 @@ return producer;

@@ -1,3 +0,3 @@

import { Forwarder, FwFace } from "@ndn/fw";
import { Data, Interest, Name, NameLike, Signer } from "@ndn/packet";
import { type Forwarder, type FwFace } from "@ndn/fw";
import { type NameLike, type Signer, Data, Interest, Name } from "@ndn/packet";
import type { DataBuffer } from "./data-buffer";

@@ -14,6 +14,8 @@ /**

*/
export declare type Handler = (interest: Interest, producer: Producer) => Promise<Data | undefined>;
export interface Options {
export declare type ProducerHandler = (interest: Interest, producer: Producer) => Promise<Data | undefined>;
export interface ProducerOptions {
/** Description for debugging purpose. */
describe?: string;
/** AbortSignal that allows closing the producer via AbortController. */
signal?: AbortSignal;
/**

@@ -72,3 +74,3 @@ * Whether routes registered by producer would cause @ndn/fw internal FIB to stop matching toward

fw: Forwarder;
opts: Options;
opts: ProducerOptions;
/**

@@ -79,3 +81,3 @@ * Start a producer.

*/
produce(prefixInput: NameLike | undefined, handler: Handler, opts?: Options): Producer;
produce(prefixInput: NameLike | undefined, handler: ProducerHandler, opts?: ProducerOptions): Producer;
}

@@ -82,0 +84,0 @@ export declare namespace EndpointProducer {

{
"name": "@ndn/endpoint",
"version": "0.0.20210930",
"version": "0.0.20220501",
"description": "NDNts: Client Endpoint",

@@ -25,13 +25,12 @@ "keywords": [

"dependencies": {
"@ndn/fw": "0.0.20210930",
"@ndn/packet": "0.0.20210930",
"@ndn/tlv": "0.0.20210930",
"abort-controller": "^3.0.0",
"@ndn/fw": "0.0.20220501",
"@ndn/packet": "0.0.20220501",
"@ndn/util": "0.0.20220501",
"applymixins": "^1.1.0",
"it-pushable": "^1.4.2",
"minimalistic-assert": "^1.0.1",
"streaming-iterables": "^6.0.0",
"tslib": "^2.3.1"
"it-pushable": "^2.0.1",
"streaming-iterables": "^7.0.2",
"tslib": "^2.4.0"
},
"types": "lib/mod.d.ts"
"types": "lib/mod.d.ts",
"readme": "# @ndn/endpoint\n\nThis package is part of [NDNts](https://yoursunny.com/p/NDNts/), Named Data Networking libraries for the modern web.\n\nThis package implements **Endpoint** type, which is the basic abstraction through which an application can communicate with the NDN network.\n\nAn endpoint is similar to a \"client face\" in other NDN libraries, with the enhancement that it handles these details automatically:\n\n* [X] Outgoing packets are signed and incoming packets are verified, if trust schema is provided.\n* [X] Outgoing Interests are retransmitted periodically, if retransmission policy is specified.\n* [X] Outgoing Data buffer, if enabled, allows the producer to reply to one Interest with multiple Data (e.g. segments), or push generated Data without receiving an Interest.\n Data will be sent automatically upon Interest arrival.\n* [X] The underlying transport is reconnected upon failure, if transport failure policy is specified (implemented in `@ndn/l3face` package).\n* [ ] Prefix registrations are refreshed periodically or upon transport reconnection.\n"
}
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