@ndn/nfdmgmt
Advanced tools
Comparing version 0.0.20200909 to 0.0.20210203
@@ -18,7 +18,7 @@ import { Endpoint } from "@ndn/endpoint"; | ||
async function call(command, params, opts = {}) { | ||
const { endpoint = new Endpoint(), commandPrefix: prefix = ControlCommand.localhostPrefix, } = opts; | ||
const { endpoint = new Endpoint({ describe: `ControlCommand(${command})` }), commandPrefix: prefix = ControlCommand.localhostPrefix, } = opts; | ||
const name = new Name([ | ||
...prefix.comps, | ||
...command.split("/"), | ||
new Component(TT.GenericNameComponent, Encoder.encode(new ControlParameters(params))), | ||
new Component(TT.GenericNameComponent, Encoder.encode(new ControlParameters(params), 512)), | ||
]); | ||
@@ -25,0 +25,0 @@ const interest = await signInterest02(new Interest(name), opts); |
@@ -18,7 +18,7 @@ import { Endpoint } from "@ndn/endpoint"; | ||
async function call(command, params, opts = {}) { | ||
const { endpoint = new Endpoint(), commandPrefix: prefix = ControlCommand.localhostPrefix, } = opts; | ||
const { endpoint = new Endpoint({ describe: `ControlCommand(${command})` }), commandPrefix: prefix = ControlCommand.localhostPrefix, } = opts; | ||
const name = new Name([ | ||
...prefix.comps, | ||
...command.split("/"), | ||
new Component(TT.GenericNameComponent, Encoder.encode(new ControlParameters(params))), | ||
new Component(TT.GenericNameComponent, Encoder.encode(new ControlParameters(params), 512)), | ||
]); | ||
@@ -25,0 +25,0 @@ const interest = await signInterest02(new Interest(name), opts); |
import { Endpoint } from "@ndn/endpoint"; | ||
import { ReadvertiseDestination, TapFace } from "@ndn/fw"; | ||
import { Certificate } from "@ndn/keychain"; | ||
import { Interest, Name } from "@ndn/packet"; | ||
import { toHex } from "@ndn/tlv"; | ||
import { ControlCommand } from "./control-command_browser.js"; | ||
const PRELOAD_INTEREST_LIFETIME = Interest.Lifetime(500); | ||
class NfdPrefixReg extends ReadvertiseDestination { | ||
@@ -9,11 +13,10 @@ constructor(face, opts) { | ||
this.face = face; | ||
this.preloadCerts = new Map(); | ||
this.commandOptions = { | ||
commandPrefix: ControlCommand.getPrefix(face.attributes.local), | ||
...opts, | ||
}; | ||
if (!this.commandOptions.commandPrefix) { | ||
this.commandOptions.commandPrefix = ControlCommand.getPrefix(face.attributes.local); | ||
} | ||
this.routeOptions = { | ||
origin: 65, | ||
cost: 0x7473, | ||
cost: 87, | ||
flags: 0x02, | ||
@@ -23,12 +26,45 @@ ...opts, | ||
this.refreshInterval = (_a = opts.refreshInterval) !== null && _a !== void 0 ? _a : 300000; | ||
this.preloadCertName = opts.preloadCertName; | ||
face.once("close", () => this.disable()); | ||
} | ||
tap() { | ||
async tap() { | ||
const tapFace = TapFace.create(this.face); | ||
tapFace.addRoute(this.commandOptions.commandPrefix); | ||
const endpoint = new Endpoint({ fw: tapFace.fw }); | ||
return [{ ...this.commandOptions, endpoint }, () => tapFace.close()]; | ||
tapFace.addRoute(new Name("/")); | ||
const endpoint = new Endpoint({ | ||
announcement: false, | ||
describe: "NfdPrefixReg", | ||
fw: tapFace.fw, | ||
}); | ||
const preloadProducers = await this.preload(endpoint); | ||
return [ | ||
{ ...this.commandOptions, endpoint }, | ||
() => { | ||
preloadProducers.forEach((p) => p.close()); | ||
tapFace.close(); | ||
}, | ||
]; | ||
} | ||
async preload(endpoint) { | ||
var _a; | ||
const producers = new Map(); | ||
let name = this.preloadCertName; | ||
while (name) { | ||
const key = toHex(name.value); | ||
if (producers.has(key)) { | ||
break; | ||
} | ||
try { | ||
const cert = (_a = this.preloadCerts.get(key)) !== null && _a !== void 0 ? _a : Certificate.fromData(await endpoint.consume(new Interest(name, Interest.CanBePrefix, PRELOAD_INTEREST_LIFETIME))); | ||
this.preloadCerts.set(key, cert); | ||
producers.set(key, endpoint.produce(name, () => Promise.resolve(cert.data))); | ||
name = cert.issuer; | ||
} | ||
catch { | ||
name = undefined; | ||
} | ||
} | ||
return producers; | ||
} | ||
async doAdvertise(name, state, nameHex) { | ||
const [opts, untap] = this.tap(); | ||
const [opts, untap] = await this.tap(); | ||
try { | ||
@@ -62,3 +98,3 @@ const cr = await ControlCommand.call("rib/register", { | ||
} | ||
const [opts, untap] = this.tap(); | ||
const [opts, untap] = await this.tap(); | ||
try { | ||
@@ -65,0 +101,0 @@ const cr = await ControlCommand.call("rib/unregister", { |
import { Endpoint } from "@ndn/endpoint"; | ||
import { ReadvertiseDestination, TapFace } from "@ndn/fw"; | ||
import { Certificate } from "@ndn/keychain"; | ||
import { Interest, Name } from "@ndn/packet"; | ||
import { toHex } from "@ndn/tlv"; | ||
import { ControlCommand } from "./control-command_node.js"; | ||
const PRELOAD_INTEREST_LIFETIME = Interest.Lifetime(500); | ||
class NfdPrefixReg extends ReadvertiseDestination { | ||
@@ -9,11 +13,10 @@ constructor(face, opts) { | ||
this.face = face; | ||
this.preloadCerts = new Map(); | ||
this.commandOptions = { | ||
commandPrefix: ControlCommand.getPrefix(face.attributes.local), | ||
...opts, | ||
}; | ||
if (!this.commandOptions.commandPrefix) { | ||
this.commandOptions.commandPrefix = ControlCommand.getPrefix(face.attributes.local); | ||
} | ||
this.routeOptions = { | ||
origin: 65, | ||
cost: 0x7473, | ||
cost: 87, | ||
flags: 0x02, | ||
@@ -23,12 +26,45 @@ ...opts, | ||
this.refreshInterval = (_a = opts.refreshInterval) !== null && _a !== void 0 ? _a : 300000; | ||
this.preloadCertName = opts.preloadCertName; | ||
face.once("close", () => this.disable()); | ||
} | ||
tap() { | ||
async tap() { | ||
const tapFace = TapFace.create(this.face); | ||
tapFace.addRoute(this.commandOptions.commandPrefix); | ||
const endpoint = new Endpoint({ fw: tapFace.fw }); | ||
return [{ ...this.commandOptions, endpoint }, () => tapFace.close()]; | ||
tapFace.addRoute(new Name("/")); | ||
const endpoint = new Endpoint({ | ||
announcement: false, | ||
describe: "NfdPrefixReg", | ||
fw: tapFace.fw, | ||
}); | ||
const preloadProducers = await this.preload(endpoint); | ||
return [ | ||
{ ...this.commandOptions, endpoint }, | ||
() => { | ||
preloadProducers.forEach((p) => p.close()); | ||
tapFace.close(); | ||
}, | ||
]; | ||
} | ||
async preload(endpoint) { | ||
var _a; | ||
const producers = new Map(); | ||
let name = this.preloadCertName; | ||
while (name) { | ||
const key = toHex(name.value); | ||
if (producers.has(key)) { | ||
break; | ||
} | ||
try { | ||
const cert = (_a = this.preloadCerts.get(key)) !== null && _a !== void 0 ? _a : Certificate.fromData(await endpoint.consume(new Interest(name, Interest.CanBePrefix, PRELOAD_INTEREST_LIFETIME))); | ||
this.preloadCerts.set(key, cert); | ||
producers.set(key, endpoint.produce(name, () => Promise.resolve(cert.data))); | ||
name = cert.issuer; | ||
} | ||
catch { | ||
name = undefined; | ||
} | ||
} | ||
return producers; | ||
} | ||
async doAdvertise(name, state, nameHex) { | ||
const [opts, untap] = this.tap(); | ||
const [opts, untap] = await this.tap(); | ||
try { | ||
@@ -62,3 +98,3 @@ const cr = await ControlCommand.call("rib/register", { | ||
} | ||
const [opts, untap] = this.tap(); | ||
const [opts, untap] = await this.tap(); | ||
try { | ||
@@ -65,0 +101,0 @@ const cr = await ControlCommand.call("rib/unregister", { |
import { FwFace, ReadvertiseDestination } from "@ndn/fw"; | ||
import { Name } from "@ndn/packet"; | ||
import { ControlCommand } from "./control-command"; | ||
import { ControlParameters } from "./control-parameters"; | ||
import type { ControlParameters } from "./control-parameters"; | ||
declare type CommandOptions = Omit<ControlCommand.Options, "endpoint">; | ||
@@ -10,2 +11,4 @@ declare type RouteOptions = Pick<ControlParameters.Fields, "origin" | "cost" | "flags">; | ||
refreshInterval?: number | false; | ||
/** Set to signer name to retrieve and serve certificate chain. */ | ||
preloadCertName?: Name; | ||
}; | ||
@@ -12,0 +15,0 @@ /** |
{ | ||
"name": "@ndn/nfdmgmt", | ||
"version": "0.0.20200909", | ||
"version": "0.0.20210203", | ||
"description": "NDNts: NFD Management", | ||
@@ -25,9 +25,10 @@ "keywords": [ | ||
"dependencies": { | ||
"@ndn/endpoint": "0.0.20200909", | ||
"@ndn/fw": "0.0.20200909", | ||
"@ndn/packet": "0.0.20200909", | ||
"@ndn/tlv": "0.0.20200909", | ||
"tslib": "^2.0.1" | ||
"@ndn/endpoint": "0.0.20210203", | ||
"@ndn/fw": "0.0.20210203", | ||
"@ndn/keychain": "0.0.20210203", | ||
"@ndn/packet": "0.0.20210203", | ||
"@ndn/tlv": "0.0.20210203", | ||
"tslib": "^2.1.0" | ||
}, | ||
"types": "lib/mod.d.ts" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
26112
602
0
6
+ Added@ndn/keychain@0.0.20210203
+ Added@ndn/endpoint@0.0.20210203(transitive)
+ Added@ndn/fw@0.0.20210203(transitive)
+ Added@ndn/keychain@0.0.20210203(transitive)
+ Added@ndn/naming-convention2@0.0.20210203(transitive)
+ Added@ndn/packet@0.0.20210203(transitive)
+ Added@ndn/tlv@0.0.20210203(transitive)
+ Added@peculiar/asn1-schema@2.3.13(transitive)
+ Added@peculiar/json-schema@1.1.12(transitive)
+ Added@peculiar/webcrypto@1.5.0(transitive)
+ Added@root/encoding@1.0.1(transitive)
+ Added@types/minimalistic-assert@1.0.3(transitive)
+ Added@types/root__asn1@1.0.5(transitive)
+ Added@yoursunny/asn1@0.0.20200718(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedasn1js@3.0.5(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedidb-keyval@5.1.5(transitive)
+ Addedit-pushable@1.4.0(transitive)
+ Addedpvtsutils@1.3.6(transitive)
+ Addedpvutils@1.1.3(transitive)
+ Addedsafari-14-idb-fix@1.0.6(transitive)
+ Addedthroat@6.0.2(transitive)
+ Addedwebcrypto-core@1.8.1(transitive)
- Removed@ndn/endpoint@0.0.20200909(transitive)
- Removed@ndn/fw@0.0.20200909(transitive)
- Removed@ndn/packet@0.0.20200909(transitive)
- Removed@ndn/tlv@0.0.20200909(transitive)
- Removedit-pushable@1.4.2(transitive)
- Removedloglevel@1.9.2(transitive)
- Removedp-cancelable@2.1.1(transitive)
Updated@ndn/endpoint@0.0.20210203
Updated@ndn/fw@0.0.20210203
Updated@ndn/packet@0.0.20210203
Updated@ndn/tlv@0.0.20210203
Updatedtslib@^2.1.0