naM ,sevitcepsreP weN

    @azure/communication-network-traversal
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.0-beta.1 • Public • Published

    Azure Communication Network Traversal client library for JavaScript

    Azure Communication Network Traversal is managing tokens for Azure Communication Services.

    It will provide TURN credentials to a user.

    Getting started

    Prerequisites

    Installing

    npm install @azure/communication-network-traversal
    npm install @azure/communication-identity

    Browser support

    JavaScript Bundle

    To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our bundling documentation.

    Key concepts

    Examples

    Authentication

    You can get a key and/or connection string from your Communication Services resource in Azure Portal. Once you have a key, you can authenticate the CommunicationRelayClient with any of the following methods:

    Create KeyCredential with AzureKeyCredential before initializing the client

    import { AzureKeyCredential } from "@azure/core-auth";
    import { CommunicationRelayClient } from "@azure/communication-network-traversal";
    
    const credential = new AzureKeyCredential(KEY);
    const client = new CommunicationRelayClient(ENDPOINT, credential);

    Using a connection string

    import { CommunicationRelayClient } from "@azure/communication-network-traversal";
    
    const connectionString = `endpoint=ENDPOINT;accessKey=KEY`;
    const client = new CommunicationRelayClient(connectionString);

    Using a TokenCredential

    import { DefaultAzureCredential } from "@azure/identity";
    import { CommunicationRelayClient } from "@azure/communication-network-traversal";
    
    const credential = new DefaultAzureCredential();
    const client = new CommunicationRelayClient(ENDPOINT, credential);

    If you use a key to initialize the client you will also need to provide the appropriate endpoint. You can get this endpoint from your Communication Services resource in Azure Portal.

    Usage

    Creating an instance of CommunicationRelayClient

    import { CommunicationRelayClient } from "@azure/communication-network-traversal";
    
    const client = new CommunicationRelayClient(CONNECTION_STRING);

    Creating an instance of CommunicationIdentityClient to create a user

    import { CommunicationIdentityClient } from "@azure/communication-identity";
    
    const client = new CommunicationIdentityClient(CONNECTION_STRING);

    Use the createUser method to create a new user.

    const user = await client.createUser();

    Getting the configurationRelay

    Use the getConfigurationRelay method to get new TURN credentials providing a user

    const config = await relayClient.getRelayConfiguration(user);

    Also you can call the getConfigurationRelay method without providing a user

    const config = await relayClient.getRelayConfiguration();

    You can specify a RouteType when calling getConfigurationRelay

    const config = await relayClient.getRelayConfiguration(user, "nearest");

    Troubleshooting

    Next steps

    Please take a look at the samples directory for detailed examples on how to use this library.

    Contributing

    If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.

    Related projects

    Impressions

    Install

    npm i @azure/communication-network-traversal

    DownloadsWeekly Downloads

    118

    Version

    1.1.0-beta.1

    License

    MIT

    Unpacked Size

    107 kB

    Total Files

    33

    Last publish

    Collaborators

    • azure-sdk