0.0.1 • Published 6 years ago

tru-widgets v0.0.1

Weekly downloads
5
License
-
Repository
-
Last release
6 years ago

Trunomi Widgets Demo

Set of React components that makes the implementation of the Trunomi platform on a react application easier. Contains a number of fully customizable widgets.

Getting Started

Prerequisites

npm or yarn and React/React-dom to be used. Fully compatible with react 16 and 0.15, more testing pending

Set Up

This module can be installed using npm or yarn. It is currently not hosted in npm yet but can be installed manually.

  • Clone this project: git clone https://github.com/Trunomi/tru-widgets.git
  • Install the module: npm install --save ../tru-widgets (being ../tru-widgets the locatione of the cloned repository)

Usage

Import the wanted widgets from the tru-widgets:

import {ConsentsWidget, ActiveDSRWidget, DSRWidget, CaptureConsent, CaptureDSR, Trucert, UserPreferences} from 'tru-widgets';

Use the component specifyin the appropiate props. For example, the user preferences widget:

<UserPreferences truConfig={...} title='Preferences' dataPane={false}/>

Configuration object (required) More info about a session soon

Prop required by all the widgets (unless a Session has started) that contains the configuration required to interact with the TRUNOMI platform. There are 2 ways of doing this: using static authentication with an API token or using express authenticaion with a JWT token. The config objects has to follow one of the 2 structures:

  • Static Authentication
truConfig = {
    apiToken: '...',
    enterpriseId: '...',
    customerId: '...',
    host_addr: '...',
    locale: '...'
}
NameTypeRequiredDescription
apiTokenStringyesAPI token provided by Trunomi upon enterprise setup
enterpriseIdStringyesUUID v1 assigned to the enterpise upon setup by Trunomi
customerIdStringyesCustomer identifier
host_addrStringyesTrunomi API address
localeStringnoLanguage for the widgets and the data in the Trunomi platform. It follows the 'languagy'_'country' notation. en_US by default
  • Express Authentication
truConfig = {
    jwtToken: '...',
    host_addr: '...',
    locale: '...'
}
NameTypeRequiredDescription
jwtTokenStringyesJWT token signed by Trunomi, for more information check https://api.trunomi.com/docs/#!/default/auth. The user is responsible for refreshing it.
customerIdStringyes*Customer identifier
host_addrStringyesTrunomi API address
localeStringnoLanguage for the widgets and the data in the Trunomi platform. It follows the 'languagy'_'country' notation. en_US by default

* customerId is only required if it's not already specified in the jwt_token. If both are specified, only the one in the JWT token will be considered.

  • Using a Session: with the functions startSession(truConfig) and stopSession() a Session can be managed between the widgets and the Trunomi platform. With this, the user is able to use the widgets without having to pass the truConfig every time and in the case of using a jwt token, to send a new boolean parameter 'refreshToken' to specify whether to refresh the token or not. The validation of the token with Trunomi can be handled by the module.

For example:

setTimeout(stopSession, 20000);

startSession({
    jwtToken: '...', //Unvalidated or validated token
    host_addr: 'http://trunomi.local',
    refreshJWT: true
}).then(()=>{
    ReactDOM.render(<App />, document.getElementById('root'));
});

Widgets

Herethe widgets can be seen in action. Clicking on the developer view will display more information about the props as well as an interactive way of setting them in real time.

Consents widget (ConsentsWidget)

Widget that lists all the consent definitions and the status of those for the the given configuration. It allows the end user to grant and deny/revoke consents and check the Trucert generated for each consent definition.

  • Props
NameTypeRequiredDefaultDescription
truConfigobjectyesConfiguration object
contextIdstringno''Prop to specify to only show consents from an specific context ID
tableobjectno...Customization object for the table

The table object allows for the following keys and have the following default values:

table = {
    striped: false,
    bordered: true,
    condensed: true,
    hover: true,
    responsive: false,
    headerClass: 'greyHeader'
}

The first 5 are parameters that can be passed to a bootstrap table. The last parameter defines a custom class for the header, which allos for further customization. This prop and it's default values are the same for the DSRWidget and the ActiveDSRWidget.

Data Subject Requests widget (DSRWidget)

Widget that lists all the personal informatio the customer has given consent to use and allows them to make access/erasure/obect/rectify if the data type definition in the trunomi platform allows for it. It props the end user to submit a reason for the request.

  • Props
NameTypeRequiredDefaultDescription
truConfigobjectyesConfiguration object
contextIdstringno''Prop to specify to only show DSRs from an specific context ID
tableobjectno...Customization object for the table

Active Data Subject Requests widget (ActiveDSRWidget)

Widget that lists all the data subject requests in process from the customer.

  • Props
NameTypeRequiredDefaultDescription
truConfigobjectyesConfiguration object
typestringno''Prop to specify to show only one type of active DSRs. Must be one of rectify, object, access, erasure or ''
tableobjectno...Customization object for the table

User Preferences widget (UserPreferences)

Component that displays the three previous widgets to form a user preference center where the end user can view it's rights and data subject requests and act on them.

  • Props
NameTypeRequiredDefaultDescription
truConfigobjectyesConfiguration object
titlestringno''If specified, it will displayed on top of the widget
consentPanestringnotrueTo specify whether to display the Consents pane (ConsentsWidget)
consentTitlestringno'My Consents'Title for the consents pane
dataPanestringnotrueTo specify whether to display the Data pane (DSRWidget)
dataTitlestringno'My Data'Title for the data pane
dsrPanestringnotrueTo specify whether to display the active DSR pane (ActiveDSRWidget)
dsrTitlestringno'My Data Requests'Title for the active dsr pane
helpLinkstringno''If specified, a help icon with this link will be created on top of the widget

Capture Consent widget (CaptureConsent)

Widget that prompts a customer to consent or deny consent for a given consent program.

  • Props
NameTypeRequiredDefaultDescription
truConfigobjectyesConfiguration object
contextIdstringyesContext ID
consentIdintegeryesConsent ID
onErrorfunctionnodo nothingFunction to be executed upon an error (on reaching Trunomi or conflict errors)
onSuccessfunctionnodo nothingFunction to be executed upon success in granting/denying/revoking consent
onClosefunctionnodo nothingFunction to be executed upon closing the widget
showbooleannotrueDetermines whether to display the widget

The combination of Context ID and Consent ID must exist in the Trunomi platform or the widget will display an error.

Capture Data Subject Request widget (CaptureDSR)

Widget that prompts a customer to create a data subject request (access, rectification, ereasure, object).

  • Props
NameTypeRequiredDefaultDescription
truConfigobjectyesConfiguration object
dataTypeIdstringyesData type ID
typestringyesType of the data subject request. Must be one of rectify, object, access or erasure
onErrorfunctionnodo nothingFunction to be executed upon an error (on reaching Trunomi or conflict errors)
onSuccessfunctionnodo nothingFunction to be executed upon success in sending the data subject request
onClosefunctionnodo nothingFunction to be executed upon closing the widget
showbooleannotrueDetermines whether to display the widget

The data type with id=dataTypeId must exists in the Trunomi platform and must allow for the type of data subject request specified in type or else an error will be displayed in the widget.

Trucert (Trucert)

Widget that displays the trucert information for a ledger id.

  • Props
NameTypeRequiredDefaultDescription
truConfigobjectyesConfiguration object
ledgerIdstringyesLedger ID from which to display the Trucert

The ledger must exist on the Trunomi platform.