mno_lcp 0.1.0 copy "mno_lcp: ^0.1.0" to clipboard
mno_lcp: ^0.1.0 copied to clipboard

This package provides a DART LCP layer (native libraries not provided).

example/lib/main.dart

// Copyright (c) 2021 Mantano. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:typed_data';

import 'package:mno_lcp/lcp.dart';
import 'package:mno_shared/src/publication/content_protection.dart';

Future<void> main() async {
  String passphrase = "passphrase";
  await Lcp.initLcp();
  LcpService? lcpService = await LcpServiceFactory.create(_LcpClientNative());
  if (lcpService != null) {
    ContentProtection contentProtection = lcpService.contentProtection(
        authentication: LcpPassphraseAuthentication(passphrase));
  }
}

class _LcpClientNative extends LcpClient {
  @override
  bool get isAvailable => true;

  @override
  DrmContext createContext(
      String jsonLicense, String hashedPassphrases, String pemCrl) {
    throw DRMException(DRMError.contextInvalid);
  }

  @override
  ByteData decrypt(DrmContext drmContext, ByteData encryptedData) =>
      ByteData(0);

  @override
  String findOneValidPassphrase(
      String jsonLicense, List<String> hashedPassphrases) {
    if (hashedPassphrases.isNotEmpty) {
      return hashedPassphrases.first;
    }
    throw DRMException(DRMError.licenseNoPasshphraseMatched);
  }
}