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

ndnts-svs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndnts-svs

SVS library based on NDNts

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

NDNts-SVS

State Vector Sync (SVS) library for the browser with NDNts.

Usage

Note: the library uses the nightly package of NDNts

npm install ndnts-svs

To create a new SVS instance

import { SVSync } from 'ndnts-svs';
import { Name } from '@ndn/packet';
import { createSigner, createVerifier, HMAC } from "@ndn/keychain";

const prefix = new Name('/ndn/svs');
const nodeId = 'alice';
const secret = 'confidential';

let sync: SVSync;

// Missing data callback
const updateCallback = (missingData) => {
    // For each node with missing data
    for (const m of missingData) {
        // Fetch all new data
        for (let i = m.low; i <= m.high; i++) {
            sync.fetchData(m.session, i).then((data) => {
                const msg = new TextDecoder().decode(data.content);
                console.log(`${m.session} => ${msg}`);
            }).catch((err) => {
                console.warn(`Could not get data nid=${m.session} => ${i}`);
            });
        }
    }
};

const symKey = await HMAC.cryptoGenerate({
    importRaw: new TextEncoder().encode(secret),
}, true);

// Start SVS instance
sync = new SVSync({
    face: face,
    prefix: prefix,
    id: nodeId,
    update: updateCallback,
    security: {
        syncInterestSigner: createSigner(HMAC, symKey),
        syncInterestVerifier: createVerifier(HMAC, symKey),
    },
});

License

ndnts-svs is an open source project licensed under the LGPL version 2.1. See COPYING.md for more information.

Keywords

FAQs

Package last updated on 07 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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