New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aculab-com/aculab-webrtc

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aculab-com/aculab-webrtc - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

test/media/lotus_dancing_in_the_wind_360.mp4

0

demos/generate_token.js

@@ -0,0 +0,0 @@ function setUpGetToken(showButton, cloudObj, clientObj, tokenObj, settings) {

@@ -31,5 +31,6 @@ _aculab-webrtc javascript interface_

### AculabCloudOutgoingCall callService(serviceName)
### AculabCloudOutgoingCall callService(serviceName, options)
`serviceName` is the name of the Aculab Cloud incoming service that the call will be connected to.
`options`, when specified, is an AculabCloudCallOptions object.

@@ -52,3 +53,3 @@ This initiates a call to the specified Aculab Cloud incoming service. Call progress is reported by callbacks, these should be set on the object returned by this function.

`token` is an authenication token. These can be obtained using an Aculab Cloud webservice.
`options`, when specified, is a AculabCloudCallOptions object.
`options`, when specified, is an AculabCloudCallOptions object.

@@ -75,2 +76,15 @@ This initiates a call to the specified Aculab Cloud WebRTC client. Call progress is reported by callbacks, these should be set on the object returned by this function.

### void setPeerConnectionConfiguration(configuration)
This function allows the user to set various settings in the PeerConnectionConfiguration object. It can be useful if an ISP or router is filtering RTP traffic preventing media from being connected. It can be called at any time. Outgoing calls will use the value set when the call is made. Incoming calls will use the value set when the call is answered.
The parameter object can have the following properties which are all optional:
| property | value |
| --- | --- |
| `iceServers` | an array of RTCIceServer objects. Incoming calls will use the value set when the call is answered. If the value is null, or the property is missing, an Aculab provided set of iceServers is used. Using an empty array will disable the Aculab provided iceServers. |
| `iceTransportPolicy` | a string representing the ICE Transport Policy. Must be one of "all" (all ICE candidates will be considered) or "relay" (only ICE candidates whose IP addresses are being relayed, such as those being passed through a TURN server, will be considered). If this property is missing, then the default of "all" will be used. |
In normal operation, iceTransportPolicy should not be set. It can be useful as a diagnostic option to help identify firewall or connectivity issues, but relying on this could result in higher latency.
AculabCloudClient data properties

@@ -83,2 +97,4 @@ ---------------------------------

This is deprecated in favour of setting the iceServers in setPeerConnectionConfiguration().
### maxConcurrent

@@ -409,3 +425,3 @@

`options`, when specified, is a AculabCloudCallOptions object.
`options`, when specified, is an AculabCloudCallOptions object.

@@ -412,0 +428,0 @@ Answer the incoming call.

@@ -12,2 +12,3 @@ import { MediaEventSessionDescriptionHandler } from './media-event-session-description-handler';

_ice_connected: boolean;
_signaling_stable: boolean;
_allowed_reinvite: boolean;

@@ -142,2 +143,3 @@ _disconnect_called: boolean;

private _set_ice_state;
private _set_signaling_state;
/**

@@ -144,0 +146,0 @@ * Add media handlers to media description session handler.

@@ -33,2 +33,3 @@ /* eslint-disable @typescript-eslint/restrict-plus-operands */

_ice_connected;
_signaling_stable;
_allowed_reinvite;

@@ -66,2 +67,3 @@ _disconnect_called;

this._ice_connected = false;
this._signaling_stable = false;
this._termination_reason = '';

@@ -474,3 +476,3 @@ this._sdh_options = undefined;

_check_notify_remove_media() {
for (let i = this._notified_remote_streams.length - 1; i > 0; i--) {
for (let i = this._notified_remote_streams.length - 1; i >= 0; i--) {
let found = false;

@@ -595,2 +597,5 @@ this._remote_streams?.forEach(stream => {

}
_set_signaling_state(stable) {
this._signaling_stable = stable;
}
/**

@@ -668,5 +673,15 @@ * Add media handlers to media description session handler.

},
onsignalingstatechange: () => {
const signalingstate = sdh.peerConnection?.signalingState;
this._set_signaling_state(signalingstate === 'stable');
this.client.console_log('AculabCloudCall onsignalingstatechange ' + signalingstate);
},
onicegatheringstatechange: () => {
const icestate = sdh.peerConnection?.iceGatheringState;
this.client.console_log('AculabCloudCall onicegatheringstatechange ' + icestate);
},
oniceconnectionstatechange: () => {
this._remote_streams = sdh.remoteMediaStreams;
const icestate = sdh.peerConnection?.iceConnectionState;
this.client.console_log('AculabCloudCall oniceconnectionstatechange ' + icestate);
if (icestate == 'connected' || icestate == 'completed') {

@@ -758,2 +773,5 @@ this._set_ice_state(true);

}
if (!this._signaling_stable) {
throw 'Re-invite in progress';
}
this.client.console_log('AculabCloudOutgoingCall addStream :' + this._session);

@@ -802,2 +820,5 @@ if (this._session && !this._disconnect_called) {

}
if (!this._signaling_stable) {
throw 'Re-invite in progress';
}
this.client.console_log('AculabCloudOutgoingCall removeStream :' + this._session);

@@ -839,2 +860,5 @@ if (this._session && !this._disconnect_called) {

}
if (!this._signaling_stable) {
throw 'Re-invite in progress';
}
if (options?.localStreams === undefined ||

@@ -841,0 +865,0 @@ options?.localStreams.length === 0) {

@@ -26,2 +26,3 @@ import { UserAgent, Web, Session, Core as sipCore } from 'sip.js';

iceServers: RTCIceServer[] | null;
_peerConnectionConfiguration: RTCConfiguration | null;
onIncoming: ((onIncomingObj: OnIncomingObj) => void) | undefined;

@@ -83,3 +84,3 @@ onIncomingState: ((onIncomingStateObj: OnIncomingStateObj) => void) | undefined;

*/
callService(serviceName: string): AculabCloudOutgoingServiceCall;
callService(serviceName: string, options?: CallOptions | undefined): AculabCloudOutgoingServiceCall;
/**

@@ -108,2 +109,6 @@ * Create a client call

/**
* Sets the RTCPeerConnection configuration
*/
setPeerConnectionConfiguration(configuration: object): void;
/**
* Check is WebRTC client supported.

@@ -110,0 +115,0 @@ * @returns true if WebRTC client is supported.

42

lib/aculab-cloud-client.js

@@ -25,2 +25,3 @@ 'use strict';

iceServers;
_peerConnectionConfiguration;
onIncoming;

@@ -201,2 +202,3 @@ onIncomingState;

this.iceServers = null;
this._peerConnectionConfiguration = null;
this._reconnecting = false;

@@ -259,15 +261,21 @@ }

iceGatheringTimeout,
peerConnectionConfiguration: Object.assign(Object.assign({}, Web.defaultPeerConnectionConfiguration()), options === null || options === void 0
peerConnectionConfiguration: Object.assign(Object.assign(Object.assign({}, Web.defaultPeerConnectionConfiguration()), options === null || options === void 0
? void 0
: options.peerConnectionConfiguration),
: options.peerConnectionConfiguration), this._peerConnectionConfiguration === null || this._peerConnectionConfiguration === void 0
? void 0
: this._peerConnectionConfiguration)
};
// set the desired ice servers
if (this.iceServers != null) {
sessionDescriptionHandlerConfiguration.peerConnectionConfiguration.iceServers =
this.iceServers;
if (this._peerConnectionConfiguration?.iceServers === undefined) {
if (this.iceServers != null) {
// This is deprecated functionality. iceServers should be passed into
// setPeerConnectionConfiguration
sessionDescriptionHandlerConfiguration.peerConnectionConfiguration.iceServers =
this.iceServers;
}
else {
sessionDescriptionHandlerConfiguration.peerConnectionConfiguration.iceServers =
this._aculabIceServers;
}
}
else {
sessionDescriptionHandlerConfiguration.peerConnectionConfiguration.iceServers =
this._aculabIceServers;
}
const logger = session.userAgent.getLogger('sip.SessionDescriptionHandler');

@@ -391,3 +399,3 @@ return new MediaEventSessionDescriptionHandler(logger, mediaStreamFactory, sessionDescriptionHandlerConfiguration);

*/
callService(serviceName) {
callService(serviceName, options = undefined) {
// some users are including the sip: in the service name, strip it

@@ -411,3 +419,3 @@ if (serviceName.startsWith('sip%3A') || serviceName.startsWith('sip%3a')) {

}
const outcall = new AculabCloudOutgoingServiceCall(this, serviceName, this._legacy_interface);
const outcall = new AculabCloudOutgoingServiceCall(this, serviceName, options, this._legacy_interface);
this._calls.add(outcall);

@@ -540,2 +548,12 @@ return outcall;

/**
* Sets the RTCPeerConnection configuration
*/
setPeerConnectionConfiguration(configuration) {
const defaults = {
iceServers: undefined
};
let conf = { ...defaults, ...configuration };
this._peerConnectionConfiguration = conf;
}
/**
* Check is WebRTC client supported.

@@ -564,3 +582,3 @@ * @returns true if WebRTC client is supported.

'setCodecPreferences' in window.RTCRtpTransceiver.prototype) {
const codecs = RTCRtpSender.getCapabilities(mediaType)?.codecs;
const codecs = RTCRtpReceiver.getCapabilities(mediaType)?.codecs;
return codecs;

@@ -567,0 +585,0 @@ }

@@ -101,4 +101,11 @@ import { CallInviter } from './call-inviter';

}
else {
if (this._termination_reason == '') {
this._termination_reason = 'CANCELLED';
this.client.console_log(`setting termination reason - disconnect - ${this._termination_reason}`);
}
void this._session.cancel();
}
}
}
}
import type { AculabCloudClient } from './aculab-cloud-client';
import { AculabCloudOutgoingCall } from './aculab-cloud-outgoing-call';
import { CallOptions } from './types';
export declare class AculabCloudOutgoingServiceCall extends AculabCloudOutgoingCall {
constructor(client: AculabCloudClient, serviceName: string, legacy_interface?: boolean);
constructor(client: AculabCloudClient, serviceName: string, callOptions: CallOptions | undefined, legacy_interface?: boolean);
}
//# sourceMappingURL=aculab-cloud-outgoing-service-call.d.ts.map
import { AculabCloudOutgoingCall } from './aculab-cloud-outgoing-call';
import { URI } from 'sip.js';
export class AculabCloudOutgoingServiceCall extends AculabCloudOutgoingCall {
constructor(client, serviceName, legacy_interface = false) {
constructor(client, serviceName, callOptions, legacy_interface = false) {
const uri = new URI('sip', serviceName, `sip-${client._cloud}.aculab.com;transport=tcp`);
super(client, uri, {
earlyMedia: true,
}, undefined, false, legacy_interface);
}, callOptions, false, legacy_interface);
}
}

@@ -90,3 +90,3 @@ import { Web } from 'sip.js';

removeRemoteMediaTrack(track) {
for (let i = this._acuRemoteMediaStreams.length - 1; i > 0; i--) {
for (let i = this._acuRemoteMediaStreams.length - 1; i >= 0; i--) {
if (this._acuRemoteMediaStreams[i].getTrackById(track.id)) {

@@ -235,2 +235,3 @@ this._acuRemoteMediaStreams[i].removeTrack(track);

return this.getLocalMediaStreams(options)
.then(() => this.updateDirection(options))
.then(() => this.createDataChannel(options))

@@ -312,3 +313,3 @@ .then(() => this.createLocalOfferOrAnswer(options))

let newStream = stream;
if (do_clone) {
if (do_clone && stream.clone !== undefined) {
// Clone the stream in case it changes beneath us

@@ -517,2 +518,5 @@ newStream = stream.clone();

}
else if (options.receiveVideo) {
offerDirection = 'recvonly';
}
}

@@ -526,2 +530,5 @@ else if (kind === 'audio') {

}
else if (options.receiveAudio) {
offerDirection = 'recvonly';
}
}

@@ -548,3 +555,4 @@ if (transceiver.direction !== offerDirection) {

this._peerConnection.getTransceivers().forEach(transceiver => {
if (transceiver.direction /* guarding, but should always be true */ &&
if (options.constraints !== undefined &&
transceiver.direction /* guarding, but should always be true */ &&
transceiver.direction !== 'stopped') {

@@ -608,4 +616,4 @@ let answerDirection = 'inactive';

},
receiveAudio: false,
receiveVideo: false,
receiveAudio: undefined,
receiveVideo: undefined,
codecs: {

@@ -612,0 +620,0 @@ audio: [],

{
"name": "@aculab-com/aculab-webrtc",
"version": "4.0.1",
"version": "4.0.2",
"main": "lib/index.js",

@@ -9,3 +9,3 @@ "types": "lib/index.d.ts",

"sip.js": "^0.21.2",
"source-map-loader": "^4.0.1",
"source-map-loader": "^4.0.2",
"uuid": "^9.0.0"

@@ -37,8 +37,8 @@ },

"scripts": {
"build-package": "mkdir dist && cd dist && npm pack ..",
"build-package": "mkdir -p dist; cd dist; npm pack ..",
"build-reg-bundle": "webpack --progress --config build/webpack.config.cjs --env buildType=reg",
"build-min-bundle": "webpack --progress --config build/webpack.config.cjs --env buildType=min",
"build-bundles": "npm run build-reg-bundle && npm run build-min-bundle",
"copy-dist-file": "copy dist/AculabCloudCaller.js dist/AculabCloudCaller-$npm_package_version.js",
"copy-dist-file-min": "copy dist/AculabCloudCaller.min.js dist/AculabCloudCaller-$npm_package_version.min.js",
"copy-dist-file": "cp dist/AculabCloudCaller.js dist/AculabCloudCaller-$npm_package_version.js",
"copy-dist-file-min": "cp dist/AculabCloudCaller.min.js dist/AculabCloudCaller-$npm_package_version.min.js",
"copy-dist-files": "npm run copy-dist-file && npm run copy-dist-file-min",

@@ -45,0 +45,0 @@ "build-interface-html": "marked -i interface.md -o interface.html",

@@ -10,6 +10,6 @@ # How to Write Aculab WebRTC Apps

Include the JavaScript library by adding the [aculab-webrtc](https://www.npmjs.com/package/aculab-webrtc) npm package
Include the JavaScript library by adding the [@aculab-com/aculab-webrtc](https://www.npmjs.com/package/@aculab-com/aculab-webrtc) npm package
```
yarn add aculab-webrtc
yarn add @aculab-com/aculab-webrtc
```

@@ -380,2 +380,3 @@

On Chrome-based browsers, a page can handle a maximum total of 500 incoming/outgoing calls. Once this limit has been reached, the page must be refreshed. This is due to chromium bug https://issues.chromium.org/issues/41378764.

@@ -382,0 +383,0 @@

@@ -0,0 +0,0 @@ type Report = {[key: string]: unknown};

@@ -45,2 +45,3 @@ /* eslint-disable @typescript-eslint/restrict-plus-operands */

_ice_connected: boolean;
_signaling_stable: boolean;
_allowed_reinvite: boolean;

@@ -83,2 +84,3 @@ _disconnect_called: boolean;

this._ice_connected = false;
this._signaling_stable = false;
this._termination_reason = '';

@@ -552,3 +554,3 @@ this._sdh_options = undefined;

private _check_notify_remove_media() {
for (let i = this._notified_remote_streams.length - 1; i > 0; i--) {
for (let i = this._notified_remote_streams.length - 1; i >= 0; i--) {
let found = false;

@@ -688,2 +690,6 @@ this._remote_streams?.forEach(stream => {

private _set_signaling_state(stable: boolean) {
this._signaling_stable = stable;
}
/**

@@ -768,2 +774,11 @@ * Add media handlers to media description session handler.

},
onsignalingstatechange: () => {
const signalingstate = sdh.peerConnection?.signalingState;
this._set_signaling_state(signalingstate === 'stable');
this.client.console_log('AculabCloudCall onsignalingstatechange ' + signalingstate);
},
onicegatheringstatechange: () => {
const icestate = sdh.peerConnection?.iceGatheringState;
this.client.console_log('AculabCloudCall onicegatheringstatechange ' + icestate);
},
oniceconnectionstatechange: () => {

@@ -773,2 +788,3 @@ this._remote_streams = sdh.remoteMediaStreams;

const icestate = sdh.peerConnection?.iceConnectionState;
this.client.console_log('AculabCloudCall oniceconnectionstatechange ' + icestate);
if (icestate == 'connected' || icestate == 'completed') {

@@ -874,2 +890,5 @@ this._set_ice_state(true);

}
if (!this._signaling_stable) {
throw 'Re-invite in progress';
}
this.client.console_log(

@@ -923,2 +942,5 @@ 'AculabCloudOutgoingCall addStream :' + this._session,

}
if (!this._signaling_stable) {
throw 'Re-invite in progress';
}
this.client.console_log(

@@ -964,2 +986,5 @@ 'AculabCloudOutgoingCall removeStream :' + this._session,

}
if (!this._signaling_stable) {
throw 'Re-invite in progress';
}
if (

@@ -966,0 +991,0 @@ options?.localStreams === undefined ||

@@ -0,0 +0,0 @@ 'use strict';

@@ -41,2 +41,3 @@ 'use strict';

iceServers: RTCIceServer[] | null;
_peerConnectionConfiguration: RTCConfiguration | null;
onIncoming: ((onIncomingObj: OnIncomingObj) => void) | undefined;

@@ -250,2 +251,3 @@ onIncomingState:

this.iceServers = null;
this._peerConnectionConfiguration = null;
this._reconnecting = false;

@@ -316,15 +318,23 @@ }

peerConnectionConfiguration: Object.assign(
Object.assign({}, Web.defaultPeerConnectionConfiguration()),
options === null || options === void 0
? void 0
: options.peerConnectionConfiguration,
),
Object.assign(
Object.assign({}, Web.defaultPeerConnectionConfiguration()),
options === null || options === void 0
? void 0
: options.peerConnectionConfiguration),
this._peerConnectionConfiguration === null || this._peerConnectionConfiguration === void 0
? void 0
: this._peerConnectionConfiguration
)
};
// set the desired ice servers
if (this.iceServers != null) {
sessionDescriptionHandlerConfiguration.peerConnectionConfiguration.iceServers =
this.iceServers;
} else {
sessionDescriptionHandlerConfiguration.peerConnectionConfiguration.iceServers =
this._aculabIceServers;
if (this._peerConnectionConfiguration?.iceServers === undefined) {
if (this.iceServers != null) {
// This is deprecated functionality. iceServers should be passed into
// setPeerConnectionConfiguration
sessionDescriptionHandlerConfiguration.peerConnectionConfiguration.iceServers =
this.iceServers;
} else {
sessionDescriptionHandlerConfiguration.peerConnectionConfiguration.iceServers =
this._aculabIceServers;
}
}

@@ -486,3 +496,3 @@ const logger = session.userAgent.getLogger('sip.SessionDescriptionHandler');

*/
callService(serviceName: string) {
callService(serviceName: string, options: CallOptions | undefined = undefined) {
// some users are including the sip: in the service name, strip it

@@ -508,3 +518,4 @@ if (serviceName.startsWith('sip%3A') || serviceName.startsWith('sip%3a')) {

serviceName,
this._legacy_interface,
options,
this._legacy_interface
);

@@ -650,2 +661,12 @@ this._calls.add(outcall);

/**
* Sets the RTCPeerConnection configuration
*/
setPeerConnectionConfiguration(configuration: object) {
const defaults = {
iceServers: undefined
};
let conf = {...defaults, ...configuration};
this._peerConnectionConfiguration = conf;
}
/**
* Check is WebRTC client supported.

@@ -677,3 +698,3 @@ * @returns true if WebRTC client is supported.

) {
const codecs = RTCRtpSender.getCapabilities(mediaType)?.codecs;
const codecs = RTCRtpReceiver.getCapabilities(mediaType)?.codecs;
return codecs;

@@ -680,0 +701,0 @@ }

@@ -0,0 +0,0 @@ import {AculabCloudCall} from './aculab-cloud-call';

@@ -132,2 +132,8 @@ import {CallInviter} from './call-inviter';

void this._session.cancel();
} else {
if (this._termination_reason == '') {
this._termination_reason = 'CANCELLED';
this.client.console_log(`setting termination reason - disconnect - ${this._termination_reason}`);
}
void this._session.cancel();
}

@@ -134,0 +140,0 @@ }

@@ -0,0 +0,0 @@ import type {AculabCloudClient} from './aculab-cloud-client';

import type {AculabCloudClient} from './aculab-cloud-client';
import {AculabCloudOutgoingCall} from './aculab-cloud-outgoing-call';
import {URI} from 'sip.js';
import {CallOptions} from './types';

@@ -9,3 +10,4 @@ export class AculabCloudOutgoingServiceCall extends AculabCloudOutgoingCall {

serviceName: string,
legacy_interface: boolean = false,
callOptions: CallOptions | undefined,
legacy_interface: boolean = false
) {

@@ -23,3 +25,3 @@ const uri = new URI(

},
undefined,
callOptions,
false,

@@ -26,0 +28,0 @@ legacy_interface,

@@ -0,0 +0,0 @@ import {Invitation} from 'sip.js';

@@ -0,0 +0,0 @@ import {Inviter, URI, UserAgent, Core as sipCore} from 'sip.js';

@@ -0,0 +0,0 @@ 'use strict';

@@ -106,3 +106,3 @@ import {SessionDescriptionHandlerModifier, Web, Core as sipCore} from 'sip.js';

removeRemoteMediaTrack(track: MediaStreamTrack) {
for (let i = this._acuRemoteMediaStreams.length - 1; i > 0; i--) {
for (let i = this._acuRemoteMediaStreams.length - 1; i >= 0; i--) {
if (this._acuRemoteMediaStreams[i].getTrackById(track.id)) {

@@ -293,2 +293,3 @@ this._acuRemoteMediaStreams[i].removeTrack(track);

return this.getLocalMediaStreams(options)
.then(() => this.updateDirection(options))
.then(() => this.createDataChannel(options))

@@ -382,3 +383,3 @@ .then(() => this.createLocalOfferOrAnswer(options))

let newStream = stream;
if (do_clone) {
if (do_clone && stream.clone !== undefined) {
// Clone the stream in case it changes beneath us

@@ -617,2 +618,4 @@ newStream = stream.clone();

offerDirection = 'sendonly';
} else if (options.receiveVideo) {
offerDirection = 'recvonly';
}

@@ -624,2 +627,4 @@ } else if (kind === 'audio') {

offerDirection = 'sendonly';
} else if (options.receiveAudio) {
offerDirection = 'recvonly';
}

@@ -655,2 +660,3 @@ }

if (
options.constraints !== undefined &&
transceiver.direction /* guarding, but should always be true */ &&

@@ -728,4 +734,4 @@ transceiver.direction !== 'stopped'

},
receiveAudio: false,
receiveVideo: false,
receiveAudio: undefined,
receiveVideo: undefined,
codecs: {

@@ -732,0 +738,0 @@ audio: [],

@@ -0,0 +0,0 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */

@@ -0,0 +0,0 @@ import {RegistererState, Web} from 'sip.js';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc