These docs are for v1.0. Click to read the latest docs for v2.3.

Arianee Privacy Gateway

Methods related to content delivery in a private way are covered.

Introduction

NFT content could be a plain JSON file self hosted and requestable as a GET ressource. But in that case, the NFT content is completely public.

Usually, brands want to be able to make their NFT content private but still transferable and sharable. To do so, brands need the Arianee Privacy Gateway - agnostic type of database to check the rights. It has two functions:

  • Store the content
  • Deliver the content

An Arianee Privacy Gateway implementation is based on JSON RPC and should expose few methods.

Our team developed a middleware to manage all these aspects for you. You just have to connect that middleware to your content warehouse. The middleware handles the security for you.

๐Ÿ“Œ


Installation

  1. We recommend you employ the certification module as an NPM package in your application.
$ npm i --save @arianee/arianee-rpc-server
  1. To import the package inside your app.
import { ArianeeRPCCustom } from "@arianee/arianee-rpc-server";
import {NETWORK} from "@arianee/arianeejs";
const arianeeRPC=new ArianeeRPCCustom(NETWORK.mainnet);

Use

This gateway is a server-side application. You need to use a node web server and implement arianee-rpc-server. You need to implement methods and write your own code to connect to your content warehouse.

const certificateContent=(certificateId)=> {

    // Connect to you database / filesystem / document warehouse...
    // Locate certificate content referenced with id : certificateId
    // grab it
    // store it into JsonCertificateContent variable

    Promise.resolve(JsonCertificateContent);

}

arianeeRPC.setCertificateContent(certificateContent);


const rpcServer = arianeeRPC.build();
 
app.post("/rpc", (req, res, next) => rpcServer(req, res, next));
// Or shorter
// app.post("/rpc",rpcServer);

๐Ÿ“Œ

The endpoint needs to be defined into the brand identity JSON as endpoint RPC key.


Basic implementation using express

import { ArianeeRPCCustom } from "../arianeeRPCServer";
import {NETWORK} from "@arianee/arianeejs/dist/src";

const express = require("express");
const app = express();
const port = process.env.PORT || 3000;

var bodyParser = require("body-parser");

// Certificate content array
const certificatesDB={};

// Events content array
const eventsDB={}

const SessionDBRPC = (network=NETWORK.arianeeTestnet)=> new ArianeeRPCCustom(network)
    .setCertificateContentMethods(
        (certificateid:string)=>{
      return Promise.resolve(certificatesDB[certificateid])
    },
        (certificateid:string, data)=>{
      certificatesDB[certificateid] = data;
      return Promise.resolve();
    })
    .setEventContentMethods(
        (certificateid)=>{
      return Promise.resolve(eventsDB[certificateid])
    },
        (certificateid:string, data)=>{
            eventsDB[certificateid] = data;
      return Promise.resolve();
    })
  .build();

const arianeeRpcServer = SessionDBRPC();

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

app.post("/rpc", (req, res, next) => arianeeRpcServer(req, res, next));

app.listen(port, () => console.log(`Example app listening on port ${port}!`));

Methods list

Set NFT content

This method can implement three custom methods:

  • Reading NFT content.
  • Storing NFT content.
  • Storing NFT content which does not exist on the Blockchain.
arianeeRPC.setCertificateContent(promise certificateRead(certificateId), promise certificateCreate(certificateId, content), promise certificateCreateWithoutValidationOnBC(certificateId, content) );

Reading NFT

(certificateId:string)=>{

      // This code is called only is the request is allowed to read certificate content
      // You need to use certificateId reference to read certificate content into your database / other storage system
      // and resolve the content

      return Promise.resolve(certificateContent)
    }

Creating NFT

(certificateId:string, content:string)=>{

      // This code is called only if the request is allowed to store certificate content
      // You need to use certificateId reference to store certificate content into your database / other storage system
      // and resolve the promise

      return Promise.resolve()
    }

Create NFT without blockchain confirmation

(certificateId:string, content:string)=>{

      // This code is called only if the request is allowed to store certificate content
      // You need to use certificateId reference to store certificate content into your database / other storage system
      // and resolve the promise

      return Promise.resolve()
    }

Update content message

This method can implement three custom methods:

  • Reading update content.
  • Storing update content.
  • Storing update content which does not exist on the blockchain.
arianeeRPC.setUpdateContent(promise fetchUpdateContent(certificateId), promise createUpdate(certificateId, content),promise createEventWithoutValidationOnBC(certificateId, content) );

Reading update

(eventId:string)=>{

      // This code is called only is the request is allowed to read certificate update content
      // You need to use eventId reference to read event content into your database / other storage system
      // and resolve the content

      return Promise.resolve(eventContent)
    }

Creating update

(certificate:string, content:string)=>{

      // This code is called only if the request is allowed to store certificate update content
      // You need to use eventId reference to store event content into your database / other storage system
      // and resolve the promise

      return Promise.resolve()
    }

Creating update without blockchain confirmation

(certificateId:string, content:string)=>{

      // This code is called only if the request is allowed to store certificate update content
      // You need to use eventId reference to store event content into your database / other storage system
      // and resolve the promise

      return Promise.resolve()
    }

Set message content

This method can implement three custom methods:

  • Reading message content.
  • Storing message content.
  • Storing message content which does not exist on the blockchain.
arianeeRPC.setMessageContent(promise fetchMessageContent(eventId), promise createMessage(eventId, content), promise createEventcreateMessageWithoutValidationOnBC(eventId, content) );

Read message

(messageId:string)=>{

      // This code is called only is the request is allowed to read message content
      // You need to use messageId reference to read message content into your database / other storage system
      // and resolve the content

      return Promise.resolve(messageContent)
    }

Create message

(messageId:string, content:string)=>{

      // This code is called only if the request is allowed to store message content
      // You need to use messageId reference to store message content into your database / other storage system
      // and resolve the promise

      return Promise.resolve()
    }

Create message without blockchain confirmation

(messageId:string, content:string)=>{

      // This code is called only if the request is allowed to store message content
      // You need to use messageId reference to store message content into your database / other storage system
      // and resolve the promise

      return Promise.resolve()
    }

Set event content

This method can implement three custom methods:

  • Reading event content.
  • Storing event content.
  • Storing event content which does not exist on the blockchain.
arianeeRPC.setEventContent(promise fetchEventContent(eventId), promise createEvent(eventId, content), promise createEventWithoutValidationOnBC(eventId, content) );

Read event

(eventId:string)=>{

      // This code is called only is the request is allowed to read event content
      // You need to use eventId reference to read event content into your database / other storage system
      // and resolve the content

      return Promise.resolve(eventContent)
    }

Create event

(eventId:string, content:string)=>{

      // This code is called only if the request is allowed to store event content
      // You need to use eventId reference to store event content into your database / other storage system
      // and resolve the promise

      return Promise.resolve()
    }

Create event without blockchain confirmation

(eventId:string, content:string)=>{

      // This code is called only if the request is allowed to store event content
      // You need to use eventId reference to store event content into your database / other storage system
      // and resolve the promise

      return Promise.resolve()
    }