RTCPeerConnection.peerIdentity

The read-only RTCPeerConnection property peerIdentity returns a JavaScript Promise that resolves to an RTCIdentityAssertion which contains a DOMString identifying the remote peer. Once this promise resolves successfully, the resulting identity is the target peer identity and cannot change for the duration of the connection.

Syntax

 var identity = rtcPeerConnection.peerIdentity;

Value

A JavaScript Promise which resolves to an RTCIdentityAssertion that describes the remote peer's identity.

If an error occcurs while attempting to validate an incoming identity assertion (that is, the information describing a peer's identity), the promise is rejected. If there isn't already a target peer identity, peerIdentity is set to a newly created promise and the process begins again, until the process succeeds or no further attempts to authenticate occur.

Note: The promise returned by setRemoteDescription() cannot resolve until any target peer identity that's been set is validated. If the identity hasn't been validated yet, the promise returned by setRemoteDescription() will be rejected. If there's no target peer identity, setRemoteDescription() doesn't need to wait for validation to occur before it resolves.

Example

In this example, a function, getIdentityAssertion(), is created which asynchronously waits for the peer's identity to be verified, then returns the identity to the caller. If an error occurs and the promise is rejected, this logs the error to the console and returns null to the caller.

let pc = new RTCPeerConnection();

/* ... */

async function getIdentityAssertion(pc) {
  try {
    const identity = await pc.peerIdentity;
    return identity;
  } catch(err) {
    console.log("Error identifying remote peer: ", err);
    return null;
  }
}

Specifications

Specification Status Comment
Identity for WebRTC Candidate Recommendation Initial specification.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
peerIdentityChrome No support NoEdge No support ≤18 — 79Firefox Full support 22IE No support NoOpera Full support 43
Notes
Full support 43
Notes
Notes Promise-based version.
No support 37 — 43
Safari ? WebView Android No support NoChrome Android No support NoFirefox Android Full support 44Opera Android Full support 43
Notes
Full support 43
Notes
Notes Promise-based version.
No support 37 — 43
Safari iOS ? Samsung Internet Android Full support 6.0

Legend

Full support
Full support
No support
No support
Compatibility unknown
Compatibility unknown
See implementation notes.
See implementation notes.

See also