New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

napi-bindings

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

napi-bindings

Nymi API bindings to work with Nymi SDK 4.x

1.0.1
Source
npm
Version published
Maintainers
1
Created
Source

node-napi-bindings

Simple Node bindings for the Nymi API (NAPI) 4.0.

Please refer to the official Nymi Github or SDK Documentation for details.

Support

All Platforms supported by the Nymi SDK 4.0 should be supported by this module.

Tested on Windows 7 64bit and macOS Sierra 10.12.2.

Apple Mac OS
  • OS X Yosemite (10.10)
  • OS X El Capitan (10.11)
  • macOS Sierra (10.12.2 or later)
Microsoft Windows
  • Windows 10, 8.1, 7
  • 64bit only

Install

npm i napi-bindings

Prerequisite

Create a file in the root directory of your project named config.json with the following content.

{
    "neaName" : "sample",
    "sigAlgorithm" : "NIST256P",
    "automaticFirmwareVersion" : false
}

Example

This example will initialize the NAPI, request info about all provisioned Nymi Bands and print the result. The example makes the assumption you are using the Nymulator on your local machine on default port 9088.

const napi = require('napi-bindings')(true); // true for using Nymulator or false for using physical Nymi Band (default: false) 

try {
    let init, put, get;

    init = napi.jsonNapiConfigureD('.', napi.LogLevel.NORMAL, 9088, '127.0.0.1');

    console.assert(init === napi.ConfigOutcome.OKAY, 'INIT: %s', Object.keys(napi.ConfigOutcome)[init]);

    put = napi.jsonNapiPutD(JSON.stringify({path: 'info/get', exchange: 'provisions'}));

    console.assert(put === napi.JsonPutOutcome.OKAY, 'PUT: %s', Object.keys(napi.JsonPutOutcome)[put]);

    get = napi.jsonNapiGetD();

    console.assert(get.outcome === napi.JsonGetOutcome.OKAY, 'GET: %s', Object.keys(napi.JsonGetOutcome)[get]);

    console.log(JSON.parse(get.message));
} catch(err) {
    console.error(err.message);
} finally {
    napi.jsonNapiTerminateD();
}

License

See LICENSE file.

Keywords

napi

FAQs

Package last updated on 14 Feb 2017

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