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

@ndn/rdr

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndn/rdr - npm Package Compare versions

Comparing version 0.0.20230121 to 0.0.20240113

5

lib/consumer_browser.js

@@ -17,3 +17,3 @@ import { Endpoint } from "@ndn/endpoint";

export async function retrieveMetadata(prefix, arg2 = {}, opts = {}) {
let ctor;
let ctor = Metadata;
if (typeof arg2 === "function") {

@@ -23,3 +23,2 @@ ctor = arg2;

else {
ctor = Metadata;
opts = arg2;

@@ -35,3 +34,3 @@ }

});
return new Decoder(data.content).decode(ctor);
return Decoder.decode(data.content, ctor);
}

@@ -17,3 +17,3 @@ import { Endpoint } from "@ndn/endpoint";

export async function retrieveMetadata(prefix, arg2 = {}, opts = {}) {
let ctor;
let ctor = Metadata;
if (typeof arg2 === "function") {

@@ -23,3 +23,2 @@ ctor = arg2;

else {
ctor = Metadata;
opts = arg2;

@@ -35,3 +34,3 @@ }

});
return new Decoder(data.content).decode(ctor);
return Decoder.decode(data.content, ctor);
}

4

lib/consumer.d.ts

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

import { type RetxPolicy, Endpoint } from "@ndn/endpoint";
import { type NameLike, type Verifier, Interest } from "@ndn/packet";
import { Endpoint, type RetxPolicy } from "@ndn/endpoint";
import { Interest, type NameLike, type Verifier } from "@ndn/packet";
import { Metadata } from "./metadata.js";

@@ -4,0 +4,0 @@ /**

@@ -9,3 +9,3 @@ import { Keyword } from "@ndn/naming-convention2";

.add(TT.Name, (t, { value }) => t.name = new Name(value), { required: true })
.setIsCritical(() => false);
.setIsCritical(EvDecoder.neverCritical);
}

@@ -24,5 +24,3 @@ const EVD = makeEvd("Metadata");

static decodeFrom(decoder) {
const metadata = new Metadata();
EVD.decodeValue(metadata, decoder);
return metadata;
return EVD.decodeValue(new Metadata(), decoder);
}

@@ -40,5 +38,3 @@ encodeTo(encoder) {

value(decoder) {
const metadata = new ctor();
evd.decodeValue(metadata, decoder);
return metadata;
return evd.decodeValue(new ctor(), decoder);
},

@@ -45,0 +41,0 @@ });

@@ -9,3 +9,3 @@ import { Keyword } from "@ndn/naming-convention2";

.add(TT.Name, (t, { value }) => t.name = new Name(value), { required: true })
.setIsCritical(() => false);
.setIsCritical(EvDecoder.neverCritical);
}

@@ -24,5 +24,3 @@ const EVD = makeEvd("Metadata");

static decodeFrom(decoder) {
const metadata = new Metadata();
EVD.decodeValue(metadata, decoder);
return metadata;
return EVD.decodeValue(new Metadata(), decoder);
}

@@ -40,5 +38,3 @@ encodeTo(encoder) {

value(decoder) {
const metadata = new ctor();
evd.decodeValue(metadata, decoder);
return metadata;
return evd.decodeValue(new ctor(), decoder);
},

@@ -45,0 +41,0 @@ });

import { Endpoint } from "@ndn/endpoint";
import { Segment, Version } from "@ndn/naming-convention2";
import { Data, digestSigning, Name } from "@ndn/packet";
import { Data, Name, noopSigning } from "@ndn/packet";
import { Encoder } from "@ndn/tlv";
import { MetadataKeyword } from "./metadata_browser.js";
function makeName(payload, prefix) {
const name = prefix ? Name.from(prefix) : payload.name.getPrefix(-1);
return name.append(MetadataKeyword, Version.create(Date.now()), Segment.create(0));
function makeName({ name }, prefix) {
prefix = prefix ? Name.from(prefix) : name.getPrefix(-1);
return prefix.append(MetadataKeyword, Version.create(Date.now()), Segment.create(0));
}
/** Make RDR metadata packet. */
export async function makeMetadataPacket(m, { prefix, freshnessPeriod = 1, signer = digestSigning, } = {}) {
export async function makeMetadataPacket(m, { prefix, freshnessPeriod = 1, signer = noopSigning, } = {}) {
const data = new Data();

@@ -21,11 +21,11 @@ data.name = makeName(m, prefix);

export function isDiscoveryInterest({ name, canBePrefix, mustBeFresh }) {
return !!(name.get(-1)?.equals(MetadataKeyword)) && canBePrefix && mustBeFresh;
return !!name.get(-1)?.equals(MetadataKeyword) && canBePrefix && mustBeFresh;
}
/** Serve RDR metadata packet in a producer. */
export function serveMetadata(m, opts = {}) {
const { prefix, endpoint = new Endpoint() } = opts;
const { prefix: prefixInput, endpoint = new Endpoint(), announcement, } = opts;
const makeMetadata = typeof m === "function" ? m : () => m;
const name = makeName(makeMetadata(), prefix).getPrefix(-2);
return endpoint.produce(name, async (interest) => {
if (isDiscoveryInterest(interest) && interest.name.length === name.length) {
const prefix = makeName(makeMetadata(), prefixInput).getPrefix(-2);
return endpoint.produce(prefix, async (interest) => {
if (isDiscoveryInterest(interest) && interest.name.length === prefix.length) {
return makeMetadataPacket(makeMetadata(), opts);

@@ -35,5 +35,5 @@ }

}, {
describe: `RDR-s(${name})`,
announcement: opts.announcement,
describe: `RDR-s(${prefix})`,
announcement,
});
}
import { Endpoint } from "@ndn/endpoint";
import { Segment, Version } from "@ndn/naming-convention2";
import { Data, digestSigning, Name } from "@ndn/packet";
import { Data, Name, noopSigning } from "@ndn/packet";
import { Encoder } from "@ndn/tlv";
import { MetadataKeyword } from "./metadata_node.js";
function makeName(payload, prefix) {
const name = prefix ? Name.from(prefix) : payload.name.getPrefix(-1);
return name.append(MetadataKeyword, Version.create(Date.now()), Segment.create(0));
function makeName({ name }, prefix) {
prefix = prefix ? Name.from(prefix) : name.getPrefix(-1);
return prefix.append(MetadataKeyword, Version.create(Date.now()), Segment.create(0));
}
/** Make RDR metadata packet. */
export async function makeMetadataPacket(m, { prefix, freshnessPeriod = 1, signer = digestSigning, } = {}) {
export async function makeMetadataPacket(m, { prefix, freshnessPeriod = 1, signer = noopSigning, } = {}) {
const data = new Data();

@@ -21,11 +21,11 @@ data.name = makeName(m, prefix);

export function isDiscoveryInterest({ name, canBePrefix, mustBeFresh }) {
return !!(name.get(-1)?.equals(MetadataKeyword)) && canBePrefix && mustBeFresh;
return !!name.get(-1)?.equals(MetadataKeyword) && canBePrefix && mustBeFresh;
}
/** Serve RDR metadata packet in a producer. */
export function serveMetadata(m, opts = {}) {
const { prefix, endpoint = new Endpoint() } = opts;
const { prefix: prefixInput, endpoint = new Endpoint(), announcement, } = opts;
const makeMetadata = typeof m === "function" ? m : () => m;
const name = makeName(makeMetadata(), prefix).getPrefix(-2);
return endpoint.produce(name, async (interest) => {
if (isDiscoveryInterest(interest) && interest.name.length === name.length) {
const prefix = makeName(makeMetadata(), prefixInput).getPrefix(-2);
return endpoint.produce(prefix, async (interest) => {
if (isDiscoveryInterest(interest) && interest.name.length === prefix.length) {
return makeMetadataPacket(makeMetadata(), opts);

@@ -35,5 +35,5 @@ }

}, {
describe: `RDR-s(${name})`,
announcement: opts.announcement,
describe: `RDR-s(${prefix})`,
announcement,
});
}

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

import { type Producer, Endpoint } from "@ndn/endpoint";
import { type Interest, type NameLike, type Signer, Data } from "@ndn/packet";
import { Endpoint, type Producer } from "@ndn/endpoint";
import { Data, type Interest, type NameLike, type Signer } from "@ndn/packet";
import { type Metadata } from "./metadata.js";

@@ -21,3 +21,6 @@ /** Make RDR metadata packet. */

freshnessPeriod?: number;
/** Signing key. */
/**
* Signing key.
* @default noopSigning
*/
signer?: Signer;

@@ -24,0 +27,0 @@ }

{
"name": "@ndn/rdr",
"version": "0.0.20230121",
"version": "0.0.20240113",
"description": "NDNts: RDR Protocol",

@@ -25,9 +25,9 @@ "keywords": [

"dependencies": {
"@ndn/endpoint": "0.0.20230121",
"@ndn/naming-convention2": "0.0.20230121",
"@ndn/packet": "0.0.20230121",
"@ndn/tlv": "0.0.20230121",
"tslib": "^2.4.1"
"@ndn/endpoint": "0.0.20240113",
"@ndn/naming-convention2": "0.0.20240113",
"@ndn/packet": "0.0.20240113",
"@ndn/tlv": "0.0.20240113",
"tslib": "^2.6.2"
},
"types": "lib/mod.d.ts"
}
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