@vonage/js-sframe
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

@vonage/js-sframe

Provide encryption/decryption features compatible with Vonage sframe-core native package.

Installation

npm i @vonage/js-sframe

Example

Encryption

import { 
    AudioCodec,
    Client, 
    KidType, 
    KeyContentType,
    VideoCodec
} from "@vonage/js-sframe";


async function encryptConnection(
    kid:KidType, 
    key:KeyContentType,
    connection: RTCPeerConnection
) {
    const [sender] = connection.getSenders();
    const client = await Client.create(); 
    await client.setCodecs(AudioCodec.OPUS, VideoCodec.VP8); // Setting codecs is mandatory for Safari.
    await client.setReceiverEncryptionKey(kid, key);
    await client.encrypt(kid, sender);
}

Decryption

import { 
    AudioCodec,
    Client, 
    KidType, 
    KeyContentType,
    VideoCodec
} from "@vonage/js-sframe";


async function decrypt(
    kid:KidType, 
    key:KeyContentType,
    connection: RTCPeerConnection
) {
    const [receiver] = connection.getReceivers();
    const client = await Client.create(); 
    await client.setCodecs(AudioCodec.OPUS, VideoCodec.VP8); // Setting codecs is mandatory for Safari.
    await client.setReceiverEncryptionKey(kid, key);
    await client.decrypt(kid, receiver);
}

Note about safari

Media codecs used can not be automatically known on Safari (WebKit). Therefore, if you want to support Safari (WebKit), you need to explicitly set them. This could be achieve via "client.setCodecs" method.

Documentation

https://vonage.github.io/client-media-processing-docs/js-sframe/1.1.0/

Readme

Keywords

none

Package Sidebar

Install

npm i @vonage/js-sframe

Weekly Downloads

14

Version

1.3.0

License

ISC

Unpacked Size

2.52 MB

Total Files

28

Last publish

Collaborators

  • web-il
  • iceberg-team
  • unified_portal
  • vreporter-npm
  • vbcbe
  • yuri.guller
  • idanvon
  • nexmo-devrel
  • vvd
  • vonagemeetings
  • vonage-jenkins
  • maikthomas
  • jeffswartz
  • v-kpheng
  • jmoramunoz2
  • vgai-dev
  • vonage_client_media_processing
  • or.cpc
  • tabdullah
  • deliajolt
  • javiermolsanz
  • llihovodov
  • daniel-sapir
  • aviadhouri.va
  • vonage-frontier
  • jtiet
  • hilakl
  • saurabh.vonage
  • leppelin
  • yonatan.kra
  • thealmoggvonage
  • gpojula
  • mprabhu1
  • elimenko.vonage
  • omrizilber
  • molszewski_v
  • sailusha
  • lallen2
  • abolles
  • twilliams253
  • ilan.aradbilavsky.at.vonage.com