DAS React Native Client
1.1.x 1.0.x
1.1.x 1.0.x

Web Application

The source code of your web app must include elements from the DAS React Native Plugin as well as the relevant required React/React Native components needed by your App, for example:

JavaScript
import DASC, { DASDRMScheme } from "@nagra/das-react-native-plugin";
import React, { useEffect, useState } from "react";
import { View, Text, StyleSheet } from "react-native";
...

Opening a session

A session is opened providing the JSON of the Opvault and the relevant DRM Scheme to the open() API.

JavaScript
  DASC.open(jsonString, DASDRMScheme.WIDEVINE)
    .then(function opened(openResponse) {
      // insert handling of response
    })
    .catch(function initFailed(openResponse) {
      // insert handling of response
    });

Getting Authentication Data

The Challenge can be determined by a call to getAuthenticationData() and the contents of the response used in subsequent calls.

JavaScript
  DASC.getAuthenticationData()
    .then(function gotAuth(authResponse) {
      // insert handling of response
    })
    .catch(function authFailed(authResponse) {
      // insert handling of response
    });

Importing licenses

The encryptedSessionRight from within the authentication response can then be passed into the importLicense() API.

JavaScript
  DASC.importLicense(props.encryptedSessionRight)
    .then(function gotImport(importResponse) {
      // insert handling of response
    })
    .catch(function importFailed(importResponse) {
      // insert handling of response
    });

Encrypting a message

After generating an encryption IV, the raw data of the message can be encrypted with a call to the encrypt() API.

JavaScript
  DASC.encrypt(props.dataForEncryption, props.iv)
    .then(function encryptionDone(encryptResponse) {
      // insert handling of response
    })
    .catch(function encrFailed(encryptResponse) {
      // insert handling of response
    });

Decrypting a message

With an encryption IV, an encrypted message can be decrypted with a call to the decrypt() API.

JavaScript
  DASC.decrypt(formData.encryptedData, props.iv)
    .then(function decryptionDone(decryptResponse) {
      // insert handling of response
    })
    .catch(function decrFailed(decryptResponse) {
      // insert handling of response
    });

Signing a message

Messages can also be signed by passing the raw data to the sign() API.

JavaScript
  DASC.sign(props.dataForEncryption)
    .then(function signDone(signResponse) {
      // insert handling of response
    })
    .catch(function signFailed(signResponse) {
      // insert handling of response
    });

Verifying a signature

Signatures can be verified by passing the raw data and the signature to the verify() API.

JavaScript
  DASC.verify(props.dataForEncryption, formData.signingData)
    .then(function verifyDone(verifyResponse) {
      // insert handling of response
    })
    .catch(function verifyFailed(verifyResponse) {
      // insert handling of response
    });

Closing a session

When no longer required, the session can be closed.

JavaScript
  DASC.close();