Skip to main content
Skip table of contents

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:

JS
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.

JS
  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.

JS
  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.

JS
  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.

JS
  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.

JS
  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.

JS
  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.

JS
  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.

JS
  DASC.close();
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.