# immutifi-node-sdk

> immutifi SDK for communicating to the chain

Latest version **2.1.7** (published 2022-10-11) · 0 weekly downloads

## Install

```sh
npm install immutifi-node-sdk
pnpm add immutifi-node-sdk
yarn add immutifi-node-sdk
bun add immutifi-node-sdk
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.7 |
| Published | 2022-10-11 |
| First published | 2022-10-11 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 34.1 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Author | immutifi immutifi@gmail.com |
| Maintainers | immutifi |

## Links

- npm: https://www.npmjs.com/package/immutifi-node-sdk
- npm.io page: https://npm.io/package/immutifi-node-sdk

## Dependencies (13)

- [utf8](https://npm.io/package/utf8.md) ^3.0.0
- [axios](https://npm.io/package/axios.md) ^0.21.1
- [bip32](https://npm.io/package/bip32.md) ^2.0.6
- [bip39](https://npm.io/package/bip39.md) ^3.0.3
- [aes-js](https://npm.io/package/aes-js.md) ^3.1.2
- [qrcode](https://npm.io/package/qrcode.md) ^1.4.4
- [sha256](https://npm.io/package/sha256.md) ^0.2.0
- [twilio](https://npm.io/package/twilio.md) ^3.60.0
- [secp256k1](https://npm.io/package/secp256k1.md) ^4.0.2
- [es6-promise](https://npm.io/package/es6-promise.md) ^4.2.8
- [bitcoinjs-lib](https://npm.io/package/bitcoinjs-lib.md) ^5.2.0
- [js-crypto-aes](https://npm.io/package/js-crypto-aes.md) ^1.0.2
- [isomorphic-fetch](https://npm.io/package/isomorphic-fetch.md) ^3.0.0

## Recent versions

- 2.1.7 (latest) — 2022-10-11

## README

# Immutifi Node SDK

This is the Immutifi Application Chain SDK. Developers can use this tool to connect there existing node applications to their devices on the Immutifi Chain, or create new applications with this! The readme file will provide a simple overview of some of the requirements of the sdk. It will be divided up into several sections:

1. #### Requirements

2. #### Installation

3. #### Setup (Pre Use)

4. #### Usage & Functionality



## Requirements

- NodeJS 
  - current version
- NPM
  - current version



## Installation

1. Create your project

   ```bash
   npm init 
   ```

2. Install the immutifi-node-sdk

   ```bash
   npm i immutifi-node-sdk --save
   ```

3. Look at our Setup Section!

   

## Setup & Pre Use

In order to begin developing with the Immutifi Chain there are some things you must understand about how the chain works! Basically with the SDK or the Application you are able to create a user account and add devices to the chain. With these devices that you add you are able to add attributes to the devices. We have some predefined attributes such as *Lock*, *Lat, Lng, Flag*  which also have some functionality for connecting back to the chain through the application, but users are also able to create custom attributes and then view them in the application, but with the sdk you are able to take custom attributes to a whole new level by being able to query the chain and view the device state. 

One of the main parts of the Immutifi Chain that ensures privacy on a public blockchain is by having users be able to encrypt there device attributes with an AES Secret Key and AES IV String. The main mode of attribute encryption is Password AES 128bit CBC.



## Usage & Functionality

- getTenant(***deviceAddress***)
  - Parameter
    - deviceAddress, the string value of the address of the device you would like to get the tenant of
  - Return Value
    - String of the tenant address
- setupWallet(***walletName***)
  - Parameter
    - the walletName is the local name of your wallet, or the name of the saved file of your wallet
  - Return Value
    - Wallet object from the Immutifi Sdk
- sendState(***state, deviceAddress, wallet, aesSecret, aesIv***)
  - Parameter
    - state
      - Map of string key / value pairs which contain the variables that your device tracks
    - deviceAddress
      - the string value of the device address you wish to update
    - wallet
      - Wallet object -< should get from setupWallet
    - aesSecret
      - String hexadecimal value of the AES Secret key used for attribute encryption on the given device
    - aesIv
      - String hexadecimal value of the AES IV String used for attribute encryption
  - Return Value
    - A json variable containing the Immutifi API response to the api call
- getChainEvents(***address, aesSec, aesIv***)
  - Parameter
    - deviceAddress
      - the string value of the device address you wish to update
    - aesSecret
      - String hexadecimal value of the AES Secret key used for attribute encryption on the given device
    - aesIv
      - String hexadecimal value of the AES IV String used for attribute encryption
  - Return Value
    - An array of json variables containing the current state updates (decrypted attribute updates of the requested device)
- getDeviceAddress()
  - Return Value
    - A string value containing an address that can be used to register a device  

## Examples  
[Tracker Example](https://pastebin.com/pmM3PpHB)  
[Twilio Chain Watcher Example](https://pastebin.com/FcJpHmVC)

---
_Source: https://npm.io/package/immutifi-node-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
