{"id":13555415,"url":"https://github.com/named-data/ndn-js","last_synced_at":"2025-04-03T08:31:15.969Z","repository":{"id":2468562,"uuid":"3440997","full_name":"named-data/ndn-js","owner":"named-data","description":"(OBSOLETE, use NDNts) Lightweight NDN stack in pure JavaScript","archived":true,"fork":false,"pushed_at":"2023-10-13T02:22:26.000Z","size":31059,"stargazers_count":101,"open_issues_count":8,"forks_count":36,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-03-30T13:02:49.687Z","etag":null,"topics":["javascript","library","ndn"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/named-data.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2012-02-14T15:26:33.000Z","updated_at":"2023-10-13T02:25:20.000Z","dependencies_parsed_at":"2024-01-14T18:05:49.871Z","dependency_job_id":null,"html_url":"https://github.com/named-data/ndn-js","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/named-data%2Fndn-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/named-data%2Fndn-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/named-data%2Fndn-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/named-data%2Fndn-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/named-data","download_url":"https://codeload.github.com/named-data/ndn-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246965661,"owners_count":20861906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","library","ndn"],"created_at":"2024-08-01T12:03:11.985Z","updated_at":"2025-04-03T08:31:11.109Z","avatar_url":"https://github.com/named-data.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","library"],"sub_categories":[],"readme":"NDN-JS:  A JavaScript client library for Named Data Networking\n--------------------------------------------------------------\n\nNDN-JS is the first native version of the NDN protocol written in JavaScript.  It\nimplements the NDN packet format.\n\nThe project is managed by the UCLA NDN team - for more information on NDN, see\n\thttps://named-data.net/\n\nSee the file [INSTALL](https://github.com/named-data/ndn-js/blob/master/INSTALL) for build and install instructions.\n\nIf you are new to the NDN community of software generally, read the\n[Contributor's Guide](https://github.com/named-data/NFD/blob/master/CONTRIBUTING.md).\nProposed code contributions should use a\n[GitHub pull request](https://github.com/named-data/ndn-js/pulls).\n\nLicense\n-------\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\nA copy of the GNU Lesser General Public License is in the file COPYING.\n\nOverview\n--------\nThis is a young project, with minimal documentation that we are slowly enhancing.  Please\nsubmit any bugs or issues to the NDN-JS issue tracker:\nhttps://redmine.named-data.net/projects/ndn-js/issues\n\nThe primary goal of NDN-JS is to provide a pure JavaScript implementation of the NDN API\nthat enables developers to create browser-based or Node.js-based applications using Named Data Networking.\nThe approach requires no native code or signed Java applets, and thus can be delivered\nover the current web to modern browsers with no hassle for the end user.\n\nAdditional goals for the project:\n- WebSockets transport for the browser (rather than TCP or UDP, which are not directly supported in\nthe browser).\n- Relatively lightweight and compact, to enable efficient use on the web.\n\nThe library currently requires a remote NDN forwarder, and has been tested with NFD from the package\nhttps://github.com/named-data/NFD .\n\nCurrently, the library has two APIs for developers:\n\n1.  The Javascript API for asynchronous Interest/Data exchange which follows the\n    NDN Common Client Libraries API: https://named-data.net/doc/ndn-ccl-api/ .\n    This API can be used from the browser or Node.js. The browser version uses\n    WebSockets for transport. Node.js can use TCP or Unix sockets.\n\n2.  A Firefox plug-in, which implements an \"ndn:/\" url scheme following\n    [NDNFS](https://github.com/remap/ndnfs-port) conventions for file retrieval.\n\nBy default, both parts of the library connect automatically to a set of hubs\nthat are part of the [NDN research project's testbed](https://named-data.net/ndn-testbed/).\nThere are currently no restrictions on non-commercial, research-oriented data exchange on\nthis testbed. (Contact jburke@remap.ucla.edu for more details.)   The developer can also\nspecify a local or remote NDN forwarder as well, as an argument to the Face constructor.\n\n\n\nJAVASCRIPT API\n--------------\n\nSee files in [js/](js/) and examples in [tests/](tests/), [examples/](examples/).\n\nNDN-JS currently supports expressing Interests (and receiving data) and publishing Data\n(that answers Interests).  This includes encoding and decoding data packets as well as\nsigning and verifying them using RSA/EC keys.\n\n### NDN connectivity\nThe only way (for now) to get connectivity to other NDN nodes is via an NDN forwarder.\nJavaScript API in the browser requires NFD's WebSockets transport.\nNode.js API can use TCP (remote or local) or Unix sockets (to the local NDN forwarder).\n\n### Including the scripts on a web page\nTo use NDN-JS in a web page, one of two scripts must be included using a script tag:\n`ndn.js` is a combined library; `ndn.min.js` is a compressed version of the combined library\nthat loads faster but doesn't show the original source for debugging.\n\nA web page script tag can load a [released version](https://github.com/named-data/ndn-js/releases) from jsDelivr.\nThis URL loads version v0.17.0:\n\n- https://cdn.jsdelivr.net/gh/named-data/ndn-js@v0.17.0/build/ndn.min.js\n\nFor development, see [INSTALL](INSTALL) for instructions on how to build these files.\nOr the latest development snapshot can be downloaded from the `build` directory:\n\n- https://github.com/named-data/ndn-js/raw/master/build/ndn.js\n- https://github.com/named-data/ndn-js/raw/master/build/ndn.min.js\n\n### Examples\n\n**ndnping**\n\nYou can check out [examples/ndnping/ndn-ping.html](examples/ndnping/ndn-ping.html) to see how to implement ndnping in NDN.js\n\n**Example to retrieve content**\n\nA simple example of the current API to express an Interest and receive data:\n\n```\nvar face = new Face();\t// connect to a default hub\n\nfunction onData(interest, data) {\n  console.log(\"Received \" + data.getName().toUri());\n}\n\nface.expressInterest(new Name(\"/ndn/edu/ucla/remap/ndn-js-test/hello.txt\"), onData);\n```\n\n**Example to publish content**\n\nPublishing content requires knowledge of a routable prefix for your upstream\nNDN forwarder.  We are working on a way to either obtain that prefix or use\nthe `/local` convention.\nFor now, see [examples/browser/test-publish-async-nfd.html](examples/browser/test-publish-async-nfd.html).\n\n\n\nFIREFOX ADD-ON FOR THE NDN PROTOCOL\n-----------------------------------\n\nSee files in [ndn-protocol/](ndn-protocol/).\n\nNDN-JS includes a Firefox extension for the ndn protocol built with the JavaScript\nlibrary.   It currently obtains NDN connectivity through the NDN testbed, but you can\nclick \"Set\" on the NDN Toolbar to change the connected hub.\n\nTo install, either download\nhttps://github.com/named-data/ndn-js/raw/master/ndn-protocol.xpi\nor use ndn-protocol.xpi in the distribution.  In Firefox, open\nTools \u003e Add-ons.  In the \"gear\" or \"wrench\" menu, click Install Add-on From File and open\nndn-protocol.xpi.  (In Firefox for Android, type file: in the address bar and click the\ndownloaded ndn-protocol.xpi.)  Restart Firefox.\n\nFirefox uses the protocol extension to load any URI starting with ndn.  See this test page for examples:\n`ndn:/ndn/edu/ucla/remap/demo/ndn-js-test/NDN-Protocol-Examples.html?ndn.ChildSelector=1`\n\nWhen the page is loaded, Firefox updates the address bar with the full matched name from\nthe retrieved content object including the version, but without the implicit digest or\nsegment number (see below).\n\n### Interest selectors in the ndn protocol\n\nYou can add interest selectors. For example, this uses 1 to select the \"rightmost\" child\n(latest version):\n`ndn:/ndn/edu/ucla/remap/ndn-js-test/howdy.txt?my=query\u0026ndn.ChildSelector=1\u0026key=value#ref`\n\nThe browser loads the latest version and changes the address to:\n`ndn:/ndn/edu/ucla/remap/ndn-js-test/howdy.txt/%FD%052%A1%EA_%89?my=query\u0026key=value#ref`\n\nThe child selector was used and removed. Note that the other non-ndn query and\nref \"?key=value#ref\" are still present, in case they are needed by the web application.\n\nThe following selector keys are supported:\n\n* ndn.MinSuffixComponent= non-negative int\n* ndn.MaxSuffixComponents= non-negative int\n* ndn.ChildSelector= non-negative int\n* ndn.Scope= non-negative int\n* ndn.InterestLifetime= non-negative int (milliseconds)\n* ndn.PublisherPublicKeyDigest= % escaped value\n* ndn.Nonce= % escaped value\n* ndn.Exclude= comma-separated list of % escaped values or * for ANY\n\n### Multiple segments in the ndn protocol\n\nA URI for content with multiple segments is handled as follows. If the URI has a segment\nnumber, just retrieve that segment and return the content to the browser.\n\nOtherwise look at the name in the returned ContentObject.  If the returned name has no\nsegment number, just return the content to the browser. If the name has a segment number\nwhich isn't 0, store it and express an interest for segment 0. Also express an interest for\nthe highest segment to try to determine the FinalBlockID early. Fetch multiple segments in order and\nreturn each content to the browser (in order) as the arrive until we get the segment for FinalBlockID.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamed-data%2Fndn-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnamed-data%2Fndn-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamed-data%2Fndn-js/lists"}