opentok-network-test-js
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -14,2 +14,4 @@ /** | ||
videoSource?: string; | ||
initSessionOptions?: OT.InitSessionOptions; | ||
proxyServerUrl?: string; | ||
} | ||
@@ -28,2 +30,4 @@ export default class NetworkTest { | ||
private validateCredentials; | ||
private validateProxyUrl; | ||
private setProxyUrl; | ||
private startLoggingEngine; | ||
@@ -30,0 +34,0 @@ /** |
@@ -38,6 +38,7 @@ import * as OTSession from './session'; | ||
initPublisher(targetElement?: HTMLElement | string, properties?: OTPublisher.PublisherProperties, callback?: (error?: Error) => void): Publisher; | ||
initSession(partnerId: string, sessionId: string): Session; | ||
initSession(partnerId: string, sessionId: string, options?: OTSession.initSessionOptions): Session; | ||
registerScreenSharingExtension(kind: string, id: string, version: number): void; | ||
reportIssue(callback: (error?: OTError, reportId?: string) => void): void; | ||
setLogLevel(level: number): void; | ||
setProxyUrl(proxyUrl: string): void; | ||
upgradeSystemRequirements(): void; | ||
@@ -66,2 +67,3 @@ } | ||
type Session = OTSession.Session; | ||
type InitSessionOptions = OTSession.initSessionOptions; | ||
type Event<Type, Target> = OTEvent.Event<Type, Target>; | ||
@@ -68,0 +70,0 @@ type Connection = OTConnection.Connection; |
@@ -81,1 +81,14 @@ import { Connection } from './connection'; | ||
} | ||
export interface initSessionOptions { | ||
ipWhitelist?: boolean; | ||
iceConfig?: { | ||
includeServers: 'all' | 'custom'; | ||
transportPolicy: 'all' | 'relay'; | ||
customServers: { | ||
urls: string | string[]; | ||
username?: string; | ||
credential?: string; | ||
}[]; | ||
}; | ||
proxyUrl?: string; | ||
} |
{ | ||
"name": "opentok-network-test-js", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"description": "Precall network test for applications using the OpenTok platform.", | ||
@@ -36,7 +36,7 @@ "main": "dist/NetworkTest/index.js", | ||
"axios": "^0.19.0", | ||
"opentok-solutions-logging": "^1.0.15", | ||
"opentok-solutions-logging": "^1.1.0", | ||
"promise": "^8.0.1" | ||
}, | ||
"devDependencies": { | ||
"@opentok/client": "^2.16.1", | ||
"@opentok/client": "^2.17.5", | ||
"@types/expect.js": "^0.3.29", | ||
@@ -43,0 +43,0 @@ "@types/jasmine": "^2.8.8", |
@@ -237,3 +237,17 @@ | ||
influence the quality test score. | ||
* `initSessionOptions` (Object) -- An object that includes optional options | ||
for initializing the session | ||
([Session Options](https://tokbox.com/developer/sdks/js/reference/OT.html#initSession)). | ||
This object includes the following properties: | ||
* `ipWhitelist ` (Boolean) -- This is available as an add-on feature | ||
for **enterprise accounts**. Set this to true if IP white listing | ||
is enabled for your project. The default value is false. | ||
* `iceConfig ` (Object) -- This feature is part of the configurable TURN add-on feature. | ||
* `proxyServerUrl` (String) -- (Optional) Set this to the proxy server URL | ||
you use in the OpenTok client SDKs (for example, when calling `OT.setProxyUrl()` | ||
in OpenTok.js). For more information, please check the | ||
[IP Proxy Documentation](https://tokbox.com/developer/guides/ip-proxy/). | ||
The `options` parameter is optional. | ||
@@ -240,0 +254,0 @@ |
@@ -10,36 +10,36 @@ import NetworkTest from 'opentok-network-test-js'; | ||
const precallDiv = document.getElementById('precall'); | ||
precallDiv.querySelector('#precall button').addEventListener('click', function() { | ||
document.getElementById('connectivity_status_container').style.display = 'block'; | ||
precallDiv.style.display = 'none'; | ||
startTest(); | ||
precallDiv.querySelector('#precall button').addEventListener('click', function () { | ||
document.getElementById('connectivity_status_container').style.display = 'block'; | ||
precallDiv.style.display = 'none'; | ||
startTest(); | ||
}) | ||
function startTest() { | ||
audioOnly = precallDiv.querySelector('#precall input').checked; | ||
var timeoutSelect = precallDiv.querySelector('select'); | ||
var timeout = timeoutSelect.options[timeoutSelect.selectedIndex].text * 1000; | ||
var options = { | ||
audioOnly: audioOnly, | ||
timeout: timeout | ||
}; | ||
otNetworkTest = new NetworkTest(OT, sessionInfo, options); | ||
otNetworkTest.testConnectivity() | ||
.then(results => ConnectivityUI.displayTestConnectivityResults(results)) | ||
.then(testQuality); | ||
audioOnly = precallDiv.querySelector('#precall input').checked; | ||
var timeoutSelect = precallDiv.querySelector('select'); | ||
var timeout = timeoutSelect.options[timeoutSelect.selectedIndex].text * 1000; | ||
var options = { | ||
audioOnly: audioOnly, | ||
timeout: timeout | ||
}; | ||
otNetworkTest = new NetworkTest(OT, sessionInfo, options); | ||
otNetworkTest.testConnectivity() | ||
.then(results => ConnectivityUI.displayTestConnectivityResults(results)) | ||
.then(testQuality); | ||
} | ||
function testQuality() { | ||
createChart('audio'); | ||
createChart('video'); | ||
ConnectivityUI.init(audioOnly); | ||
document.getElementById('stop_test').addEventListener('click', function stopTestListener() { | ||
ConnectivityUI.hideStopButton(); | ||
otNetworkTest.stop(); | ||
}); | ||
otNetworkTest.testQuality(function updateCallback(stats) { | ||
ConnectivityUI.checkToDisplayStopButton(); | ||
ConnectivityUI.graphIntermediateStats('audio', stats); | ||
ConnectivityUI.graphIntermediateStats('video', stats); | ||
}).then(results => ConnectivityUI.displayTestQualityResults(null, results)) | ||
.catch(error => ConnectivityUI.displayTestQualityResults(error)); | ||
createChart('audio'); | ||
createChart('video'); | ||
ConnectivityUI.init(audioOnly); | ||
document.getElementById('stop_test').addEventListener('click', function stopTestListener() { | ||
ConnectivityUI.hideStopButton(); | ||
otNetworkTest.stop(); | ||
}); | ||
otNetworkTest.testQuality(function updateCallback(stats) { | ||
ConnectivityUI.checkToDisplayStopButton(); | ||
ConnectivityUI.graphIntermediateStats('audio', stats); | ||
ConnectivityUI.graphIntermediateStats('video', stats); | ||
}).then(results => ConnectivityUI.displayTestQualityResults(null, results)) | ||
.catch(error => ConnectivityUI.displayTestQualityResults(error)); | ||
} |
@@ -36,2 +36,4 @@ /** | ||
videoSource?: string; | ||
initSessionOptions?: OT.InitSessionOptions | ||
proxyServerUrl?: string; | ||
} | ||
@@ -52,6 +54,8 @@ | ||
this.validateCredentials(credentials); | ||
this.otLogging = this.startLoggingEngine(credentials.apiKey, credentials.sessionId); | ||
const proxyServerUrl = this.validateProxyUrl(options) | ||
this.otLogging = this.startLoggingEngine(credentials.apiKey, credentials.sessionId, proxyServerUrl); | ||
this.OT = OT; | ||
this.credentials = credentials; | ||
this.options = options; | ||
this.setProxyUrl(proxyServerUrl) | ||
} | ||
@@ -74,3 +78,16 @@ | ||
private startLoggingEngine(apiKey: string, sessionId: string): OTKAnalytics { | ||
private validateProxyUrl(options?: NetworkTestOptions): string { | ||
if (!options || !options.proxyServerUrl) { | ||
return ''; | ||
} | ||
return options.proxyServerUrl; | ||
} | ||
private setProxyUrl(proxyServerUrl: string) { | ||
if (this.OT.setProxyUrl && typeof this.OT.setProxyUrl === 'function' && proxyServerUrl) { | ||
this.OT.setProxyUrl(proxyServerUrl); | ||
} | ||
} | ||
private startLoggingEngine(apiKey: string, sessionId: string, proxyUrl: string): OTKAnalytics { | ||
return new OTKAnalytics({ | ||
@@ -82,3 +99,5 @@ sessionId, | ||
name: 'opentok-network-test', | ||
componentId: 'opentok-network-test', | ||
componentId: 'opentok-network-test' | ||
}, { | ||
proxyUrl | ||
}); | ||
@@ -85,0 +104,0 @@ } |
@@ -86,5 +86,15 @@ /** | ||
{ apiKey, sessionId, token }: OT.SessionCredentials, | ||
options?: NetworkTestOptions | ||
): Promise<OT.Session> { | ||
return new Promise((resolve, reject) => { | ||
const session = OT.initSession(apiKey, sessionId); | ||
let sessionOptions: OT.InitSessionOptions = {}; | ||
if (options && options.initSessionOptions) { | ||
sessionOptions = options.initSessionOptions | ||
} | ||
if (options && options.proxyServerUrl) { | ||
if (!OT.hasOwnProperty('setProxyUrl')) { // Fallback for OT.version < 2.17.4 | ||
sessionOptions.proxyUrl = options.proxyServerUrl; | ||
} | ||
} | ||
const session = OT.initSession(apiKey, sessionId, sessionOptions); | ||
session.connect(token, (error?: OT.OTError) => { | ||
@@ -256,5 +266,6 @@ if (errorHasName(error, OTErrorType.OT_AUTHENTICATION_ERROR)) { | ||
*/ | ||
function checkLoggingServer(OT: OT.Client, input?: SubscribeToSessionResults): Promise<SubscribeToSessionResults> { | ||
function checkLoggingServer(OT: OT.Client, options?: NetworkTestOptions, input?: SubscribeToSessionResults): Promise<SubscribeToSessionResults> { | ||
return new Promise((resolve, reject) => { | ||
const url = `${getOr('', 'properties.loggingURL', OT)}/logging/ClientEvent`; | ||
const loggingUrl = `${getOr('', 'properties.loggingURL', OT)}/logging/ClientEvent`; //https://hlg.tokbox.com/prod | ||
const url = options && options.proxyServerUrl && `${options.proxyServerUrl}/${loggingUrl.replace('https://', '')}` || loggingUrl; | ||
const handleError = () => reject(new e.LoggingServerConnectionError()); | ||
@@ -321,3 +332,3 @@ | ||
} else { | ||
checkLoggingServer(OT) | ||
checkLoggingServer(OT, options) | ||
.then(() => handleResults(error)) | ||
@@ -328,6 +339,6 @@ .catch((loggingError: e.LoggingServerConnectionError) => handleResults(error, loggingError)); | ||
connectToSession(OT, credentials) | ||
connectToSession(OT, credentials, options) | ||
.then((session: OT.Session) => checkPublishToSession(OT, session, options)) | ||
.then(checkSubscribeToSession) | ||
.then((results: SubscribeToSessionResults) => checkLoggingServer(OT, results)) | ||
.then((results: SubscribeToSessionResults) => checkLoggingServer(OT, options, results)) | ||
.then(onSuccess) | ||
@@ -334,0 +345,0 @@ .catch(onFailure); |
@@ -368,3 +368,12 @@ /** | ||
.then(() => { | ||
const session = OT.initSession(credentials.apiKey, credentials.sessionId); | ||
let sessionOptions: OT.InitSessionOptions = {}; | ||
if (options && options.initSessionOptions) { | ||
sessionOptions = options.initSessionOptions | ||
} | ||
if (options && options.proxyServerUrl) { | ||
if (!OT.hasOwnProperty('setProxyUrl')) { // Fallback for OT.version < 2.17.4 | ||
sessionOptions.proxyUrl = options.proxyServerUrl; | ||
} | ||
} | ||
const session = OT.initSession(credentials.apiKey, credentials.sessionId, sessionOptions); | ||
checkSubscriberQuality(OT, session, credentials, options, onUpdate) | ||
@@ -371,0 +380,0 @@ .then(onSuccess) |
@@ -51,2 +51,3 @@ | ||
sessionId: string, | ||
options?: OTSession.initSessionOptions | ||
): Session; | ||
@@ -64,2 +65,4 @@ | ||
setProxyUrl(proxyUrl: string): void; | ||
upgradeSystemRequirements(): void; | ||
@@ -92,2 +95,3 @@ } | ||
export type Session = OTSession.Session; | ||
export type InitSessionOptions = OTSession.initSessionOptions; | ||
export type Event<Type, Target> = OTEvent.Event<Type, Target>; | ||
@@ -94,0 +98,0 @@ export type Connection = OTConnection.Connection; |
@@ -96,1 +96,15 @@ import { Connection } from './connection'; | ||
} | ||
export interface initSessionOptions { | ||
ipWhitelist?: boolean; | ||
iceConfig?: { | ||
includeServers: 'all' | 'custom'; | ||
transportPolicy: 'all' | 'relay'; | ||
customServers: { | ||
urls: string | string[]; | ||
username?: string; | ||
credential?: string; | ||
}[]; | ||
}; | ||
proxyUrl?: string; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
505897
4674
594
1