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:
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.
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.
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.
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.
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.
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.
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.
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.
DASC.close();