RTCPeerConnection: peerIdentity property
ThepeerIdentity read-only property of theRTCPeerConnection interface returns a JavaScriptPromise that resolves to anRTCIdentityAssertion which contains a string identifying the remote peer.Once this promise resolves successfully, the resulting identity is thetarget peer identity and cannot change for the duration of the connection.
In this article
Value
A JavaScriptPromise which resolves to anRTCIdentityAssertion that describes the remote peer's identity.
If an error occurs 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 bysetRemoteDescription() cannot resolve until any target peer identity that's been set is validated.If the identity hasn't been validated yet, the promise returned bysetRemoteDescription() will be rejected.If there's no target peer identity,setRemoteDescription() doesn't need to wait for validation to occur before it resolves.
Examples
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 returnsnull 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 |
|---|
| Identity for WebRTC 1.0> # dom-rtcpeerconnection-peeridentity> |