Skip to main content
Skip table of contents

Android/Apple Applications

The source code of your Android or Apple (iOS/tvOS) App must include elements from the DAS React Native Plugin, plus the relevant React/React Native components needed by your App, for example:

JS
import React, {useState} from 'react';

import ReactNative, {
  StyleSheet,
  Text,
  View
 } from 'react-native';

import DASC from "@nagra/das-react-native-plugin";
import DASGateway from "./components/DASGateway";
...

This is within your App's main file (normally named App.js when generated by following the React Native getting started guide). 

Opening a session

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

JS
let status =  await DASC.open(opData, drmScheme);

if (status === 0) {
  // insert handling of successful response
} else {
  // insert handling of failure 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
  let challenge = await DASC.getAuthenticationData();

  if (challenge.status === 0) {
    // insert handling of successful response
  } else {
    // insert handling of failure response
  }

Importing licenses

The encrSessionRight from within the license response (during Secure Key Exchange from Gateway server) can then be passed into the importLicense() API.

JS
  let importLicenseStatus = await DASC.importLicense(result.encrSessionRight);
  
  if (importLicenseStatus.status === 0) {
    // insert handling of successful response
  } else {
    // insert handling of failure 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
  let encryptedDataObj = await DASC.encrypt(inputBuffer, keyId, iv);
  
  if (encryptedDataObj .status === 0) {
    // insert handling of successful response
  } else {
    // insert handling of failure response
  }

Decrypting a message

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

JS
  let decryptedDataObj = await DASC.decrypt(inputBuffer, keyId, iv);
  
  if (decryptedDataObj .status === 0) {
    // insert handling of successful response
  } else {
    // insert handling of failure response
  }

Signing a message

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

JS
  let signedDataObj = await DASC.sign(inputBuffer, keyId);

  if (signedDataObj.status === 0) {
    // insert handling of successful response
  } else {
    // insert handling of failure response
  }

Verifying a signature

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

JS
    let verifyStatus = await DASC.verify(inputBuffer, output, keyId)

    if (verifyStatus === 0) {
      // insert handling of successful response
    } else {
      // insert handling of failure 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.