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

@ndn/packet

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/packet - npm Package Compare versions

Comparing version 0.0.20200606 to 0.0.20200909

lib/alt-uri_browser.js

12

lib/alt-uri.d.ts
import { Component } from "./component";
import { NamingConvention } from "./convention";
import type { NamingConvention } from "./convention";
import { Name } from "./name";
/**
* Functions to print name or component in alternate/pretty URI syntax.
* Functions to print and parse names in alternate/pretty URI syntax.
*

@@ -16,3 +16,3 @@ * This class is constructed with a sequence of NamingConventions. Each component is matched

*/
export declare class AltUriPrinter {
export declare class AltUriConverter {
readonly conventions: ReadonlyArray<NamingConvention<any> & NamingConvention.WithAltUri>;

@@ -24,4 +24,8 @@ constructor(conventions: ReadonlyArray<NamingConvention<any> & NamingConvention.WithAltUri>);

ofName: (name: Name) => string;
/** Parse component from alternate URI syntax */
parseComponent: (input: string) => Component;
/** Parse name from alternate URI syntax. */
parseName: (input: string) => Name;
}
/** Print Generic, ImplicitDigest, ParamsDigest in alternate URI syntax. */
export declare const AltUri: AltUriPrinter;
export declare const AltUri: AltUriConverter;

@@ -10,2 +10,4 @@ export declare const TT: {

ForwardingHint: number;
Delegation: number;
Preference: number;
Nonce: number;

@@ -21,3 +23,3 @@ InterestLifetime: number;

FreshnessPeriod: number;
FinalBlockId: number;
FinalBlock: number;
Content: number;

@@ -32,4 +34,2 @@ DSigInfo: number;

SigSeqNum: number;
Delegation: number;
Preference: number;
Nack: number;

@@ -43,2 +43,3 @@ NackReason: number;

HmacWithSha256: number;
Null: number;
};

@@ -45,0 +46,0 @@ export declare const NackReason: {

import { Decoder, Encoder } from "@ndn/tlv";
import { NamingConvention } from "./convention";
import type { NamingConvention } from "./convention";
export declare type ComponentLike = Component | string;

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

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

import { Component } from "./component";
/** Naming convention, constructible from A and convertible to R. */
import type { Component } from "./component";
/**
* Naming convention, which interprets a name component in a specific way.
* @template A input type to construct component.
* @template R output type to interpret component.
*/
export interface NamingConvention<A, R = A> {

@@ -12,7 +16,13 @@ /** Determine if a component follows this naming convention. */

export declare namespace NamingConvention {
/** A naming convention that supports alternate/pretty URI. */
interface WithAltUri {
/** Get alternate/pretty URI of a matched component. */
/** Convert to alternate URI. */
toAltUri: (comp: Component) => string;
/**
* Parse from alternate URI.
* @returns component, or undefined if it cannot be parsed.
*/
fromAltUri: (input: string) => Component | undefined;
}
function isConvention(obj: any): obj is NamingConvention<any>;
}
import { Decoder, Encoder } from "@ndn/tlv";
import { Component } from "./component";
import type { Interest } from "./interest";
import { Name, NameLike } from "./name";

@@ -18,4 +19,4 @@ import { SigInfo } from "./sig-info";

content: Uint8Array;
sigInfo?: SigInfo;
sigValue?: Uint8Array;
sigInfo: SigInfo;
sigValue: Uint8Array;
private contentType_;

@@ -49,2 +50,7 @@ private freshnessPeriod_;

computeFullName(): Promise<Name>;
/**
* Determine if a Data can satisfy an Interest.
* @returns a Promise that will be resolved with the result.
*/
canSatisfy(interest: Interest): Promise<boolean>;
[LLSign.OP](sign: LLSign): Promise<void>;

@@ -51,0 +57,0 @@ [LLVerify.OP](verify: LLVerify): Promise<void>;

import { Component } from "./component";
import { NamingConvention } from "./convention";
import { Name } from "./name";
import type { NamingConvention } from "./convention";
import type { Name } from "./name";
declare class DigestComp implements NamingConvention<Uint8Array>, NamingConvention.WithAltUri {
private readonly tt;
private readonly altUriPrefix;
private readonly altUriRegex;
constructor(tt: number, altUriPrefix: string);

@@ -12,2 +13,3 @@ match(comp: Component): boolean;

toAltUri(comp: Component): string;
fromAltUri(input: string): Component | undefined;
}

@@ -14,0 +16,0 @@ declare class ImplicitDigestComp extends DigestComp {

@@ -21,3 +21,3 @@ import { Decoder, Encoder } from "@ndn/tlv";

sigInfo?: SigInfo;
sigValue?: Uint8Array;
sigValue: Uint8Array;
private nonce_;

@@ -48,2 +48,3 @@ private lifetime_;

encodeTo(encoder: Encoder): void;
private encodeParamsPortion;
private appendParamsDigestPlaceholder;

@@ -50,0 +51,0 @@ updateParamsDigest(): Promise<void>;

@@ -7,9 +7,9 @@ export * from "./alt-uri";

export * from "./digest-comp";
export * from "./encryption";
export * from "./fwhint";
export * from "./interest";
export * from "./key-locator";
export * from "./signing";
export * from "./nack";
export * from "./name";
export * from "./satisfy";
export * from "./sig-info";
export * from "./signing";
import { Decoder, Encoder } from "@ndn/tlv";
import { Interest } from "./interest";
import type { Interest } from "./interest";
/** Nack header. */

@@ -4,0 +4,0 @@ export declare class NackHeader {

import { Decoder, Encoder } from "@ndn/tlv";
import { Component, ComponentLike } from "./component";
import { NamingConvention } from "./convention";
import type { NamingConvention } from "./convention";
export declare type NameLike = Name | string;

@@ -17,2 +17,4 @@ /**

constructor(input?: NameLike);
/** Parse from URI, with specific component parser. */
constructor(uri: string, parseComponent?: (input: string) => Component);
/** Construct from TLV-VALUE. */

@@ -52,5 +54,3 @@ constructor(value: Uint8Array);

function isNameLike(obj: any): obj is NameLike;
/**
* Name compare result.
*/
/** Name compare result. */
enum CompareResult {

@@ -57,0 +57,0 @@ /** lhs is less than, but not a prefix of rhs */

@@ -6,3 +6,3 @@ import { Decoder, EncodableObj, Extensible } from "@ndn/tlv";

static decodeFrom(decoder: Decoder): SigInfo;
type?: number;
type: number;
keyLocator?: KeyLocator;

@@ -9,0 +9,0 @@ nonce?: number;

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

import { timingSafeEqual as timingSafeEqual_ } from "./digest_node";
import { KeyLocator } from "./key-locator";
import { Name } from "./name";
import { timingSafeEqual as timingSafeEqual_ } from "./platform/mod";
import type { Name } from "./name";
import { SigInfo } from "./sig-info";

@@ -32,3 +32,3 @@ /**

sigInfo?: SigInfo;
sigValue?: Uint8Array;
sigValue: Uint8Array;
}

@@ -67,4 +67,11 @@ /** High level signer, such as a private key. */

}
/** Signer and Verifier that do nothing. */
export declare const noopSigning: Signer & Verifier;
/** Signer and Verifier for SigType.Sha256 digest. */
export declare const digestSigning: Signer & Verifier;
/**
* Signer for SigType.Null, a packet that is not signed.
* @see https://redmine.named-data.net/projects/ndn-tlv/wiki/NullSignature
*/
export declare const nullSigner: Signer;
export {};
{
"name": "@ndn/packet",
"version": "0.0.20200606",
"version": "0.0.20200909",
"description": "NDNts: Network Layer Packets",

@@ -15,10 +15,5 @@ "keywords": [

"type": "module",
"main": "lib/mod.js",
"browser": {
"./lib/platform/mod.js": "./lib/platform/browser.js",
"./src/platform/mod.ts": "./src/platform/browser.ts"
},
"sideEffects": [
"./test-fixture/expect.ts"
],
"main": "lib/mod_node.js",
"module": "lib/mod_browser.js",
"sideEffects": false,
"homepage": "https://yoursunny.com/p/NDNts/",

@@ -31,7 +26,8 @@ "repository": {

"dependencies": {
"@ndn/tlv": "0.0.20200606",
"@ndn/tlv": "0.0.20200909",
"buffer-compare": "^1.1.1",
"minimalistic-assert": "^1.0.1",
"tslib": "*"
}
"tslib": "^2.0.1"
},
"types": "lib/mod.d.ts"
}

@@ -8,4 +8,3 @@ # @ndn/packet

```ts
import { TT, Name, Component, ImplicitDigest, AltUri, Interest, Data,
canSatisfy, canSatisfySync, digestSigning } from "@ndn/packet";
import { TT, Name, Component, ImplicitDigest, AltUri, Interest, Data, digestSigning } from "@ndn/packet";

@@ -213,4 +212,3 @@ // other imports for examples

assert(typeof fullName2 !== "undefined");
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
assert.equal(fullName2!.toString(), fullName.toString());
assert.equal(fullName2.toString(), fullName.toString());

@@ -224,17 +222,11 @@ // Note that you cannot modify the Data after encoding or decoding,

```ts
// To determine whether a Data satisfy an Interest, use canSatisfy or canSatisfySync.
// data.canSatisfy(interest) determines whether a Data satisfy an Interest.
// This is an async function because it potentially involves computing the implicit digest.
// canSatisfySync returns a boolean:
assert.equal(canSatisfySync(interest, data), true);
assert.equal(await data.canSatisfy(interest), true);
const interest3 = new Interest("/B");
assert.equal(canSatisfySync(interest3, data), false);
// However, it does not support implicit digest, because digest computation is async:
assert.equal(await data.canSatisfy(interest3), false);
const data3 = new Decoder(dataWire).decode(Data);
const interestWithFullName = new Interest(fullName);
assert(typeof canSatisfySync(interestWithFullName, data3) === "undefined");
// Unless the Data contains cached implicit digest:
assert.equal(canSatisfySync(interestWithFullName, data), true);
// canSatisfy returns a Promise that resolves to boolean, which can support implicit digest.
assert.equal(await canSatisfy(interestWithFullName, data3), true);
assert.equal(await data.canSatisfy(interestWithFullName), true);
```

@@ -241,0 +233,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