immudb-node-get-started

Contents

Introduction

immudb-node implements a grpc immudb client. A minimalist API is exposed for applications while cryptographic verifications and state update protocol implementation are fully implemented by this client. Latest validated immudb state may be keep in the local filesystem when initialising the client with the rootPath option, please read immudb research paper for details of how immutability is ensured by immudb.

Prerequisites

immudb-node assumes an already running immudb server. Running immudb is quite simple, please refer to the
following link for downloading and running it: https://docs.immudb.io/quickstart.html

Installation

Just include immudb-node as a dependency in your project:

const ImmudbClient = require('immudb-node')

Supported Versions

immudb-node supports the latest immudb release.

Quickstart

Check out some examples

Step by step guide

Creating a Client

The following code snippets shows how to create a client.

Using default configuration:

const config = {
  address: '127.0.0.1:3322',
  rootPath: '.',
}

ImmudbClient(config, (err, cl) => {
  if (err) {
    return console.log(err)
  }

  // Interact with the client.
})

User sessions

Use login and logout methods to initiate and terminate user sessions:

try {
  await cl.login({ username: 'usr1', password: 'pwd1' })

  // Interact with immudb using logged user.

  await cl.logout()
} catch (err) {
  console.log(err)
}

Or with callbacks

cl.login({ username: 'usr1', password: 'pwd1' }, (err, res) => {
  if (err) {
    return console.log(err)
  }

  // Interact with immudb using logged user.

  cl.logout(null, (err, res) => {
    if (err) {
      return console.log(err)
    })
    // Logged out.
})

Creating a database

Creating a new database is quite simple:

cl.createDatabase('db1')

Setting the active database

Specify the active database with:

cl.useDatabase('db1')

Traditional read and write

immudb provides read and write operations that behave as a traditional
key-value store i.e. no cryptographic verification is done. This operations
may be used when validations can be post-poned:

let res = await cl.set({ key: 'key1', value: 'value1' })
console.log(res.index)

res = await cl.get({ key: 'key1' })
console.log(res.key, res.value, res.index)

Verified or Safe read and write

immudb provides built-in cryptographic verification for any entry. The client
implements the mathematical validations while the application uses as a traditional
read or write operation:

try {
  let res = await cl.safeSet({ key: 'key1', value: 'value1' })
  console.log(res.index)

  res = await cl.safeGet({ key: 'key1' })
  console.log(res.key, res.value, res.index)
} catch (err) {
  if (err.clientErr == cl.proofErr) {
    // Proof does not verify.
  }
  console.log(err)
}

Multi-key read and write

Transactional multi-key read and write operations are supported by immudb and immudb-node.

Atomic multi-key write (all entries are persisted or none):

  req = {
    skvList: [{
      key: 'key1',
      payload: 'value1',
      timestamp: Math.floor(Date.now()/100),
    },{
      key: 'key2',
      payload: 'value2',
      timestamp: Math.floor(Date.now()/100),
    }]
  }
  res = await cl.setBatchSV(req)

Atomic multi-key read (all entries are retrieved or none):

    req = {
      keys: [{
        key: 'key1',
      },{
        key: 'key2',
      }],
    }
    res = await cl.getBatchSV(req)

Closing the client

To programatically close the connection with immudb server use the shutdown operation:

 cl.shutdown()

Note: after shutdown, a new client needs to be created to establish a new connection.

Contributing

We welcome contributions. Feel free to join the team!

To report bugs or get help, use GitHub’s issues.

immudb

BUILT ON THE FASTEST
IMMUTABLE LEDGER
TECHNOLOGY

Open Source and easy to use in new applications and easy to integrate into existing application.

Subscribe to Our Newsletter

Get the latest product updates, company news, and special offers delivered right to your inbox.

Subscribe to our newsletter

Use Case - Tamper-resistant Clinical Trials

Goal:

Blockchain PoCs were unsuccessful due to complexity and lack of developers.

Still the goal of data immutability as well as client verification is a crucial. Furthermore, the system needs to be easy to use and operate (allowing backup, maintenance windows aso.).

Implementation:

immudb is running in different datacenters across the globe. All clinical trial information is stored in immudb either as transactions or the pdf documents as a whole.

Having that single source of truth with versioned, timestamped, and cryptographically verifiable records, enables a whole new way of transparency and trust.

Use Case - Finance

Goal:

Store the source data, the decision and the rule base for financial support from governments timestamped, verifiable.

A very important functionality is the ability to compare the historic decision (based on the past rulebase) with the rulebase at a different date. Fully cryptographic verifiable Time Travel queries are required to be able to achieve that comparison.

Implementation:

While the source data, rulebase and the documented decision are stored in verifiable Blobs in immudb, the transaction is stored using the relational layer of immudb.

That allows the use of immudb’s time travel capabilities to retrieve verified historic data and recalculate with the most recent rulebase.

Use Case - eCommerce and NFT marketplace

Goal:

No matter if it’s an eCommerce platform or NFT marketplace, the goals are similar:

  • High amount of transactions (potentially millions a second)
  • Ability to read and write multiple records within one transaction
  • prevent overwrite or updates on transactions
  • comply with regulations (PCI, GDPR, …)


Implementation:

immudb is typically scaled out using Hyperscaler (i. e. AWS, Google Cloud, Microsoft Azure) distributed across the Globe. Auditors are also distributed to track the verification proof over time. Additionally, the shop or marketplace applications store immudb cryptographic state information. That high level of integrity and tamper-evidence while maintaining a very high transaction speed is key for companies to chose immudb.

Use Case - IoT Sensor Data

Goal:

IoT sensor data received by devices collecting environment data needs to be stored locally in a cryptographically verifiable manner until the data is transferred to a central datacenter. The data integrity needs to be verifiable at any given point in time and while in transit.

Implementation:

immudb runs embedded on the IoT device itself and is consistently audited by external probes. The data transfer to audit is minimal and works even with minimum bandwidth and unreliable connections.

Whenever the IoT devices are connected to a high bandwidth, the data transfer happens to a data center (large immudb deployment) and the source and destination date integrity is fully verified.

Use Case - DevOps Evidence

Goal:

CI/CD and application build logs need to be stored auditable and tamper-evident.
A very high Performance is required as the system should not slow down any build process.
Scalability is key as billions of artifacts are expected within the next years.
Next to a possibility of integrity validation, data needs to be retrievable by pipeline job id or digital asset checksum.

Implementation:

As part of the CI/CD audit functionality, data is stored within immudb using the Key/Value functionality. Key is either the CI/CD job id (i. e. Jenkins or GitLab) or the checksum of the resulting build or container image.

White Paper — Registration

We will also send you the research paper
via email.

CodeNotary — Webinar

White Paper — Registration

Please let us know where we can send the whitepaper on CodeNotary Trusted Software Supply Chain. 

Become a partner

Start Your Trial

Please enter contact information to receive an email with the virtual appliance download instructions.

Start Free Trial

Please enter contact information to receive an email with the free trial details.