Skip to content

Commit

Permalink
Merge branch 'next' into feat/byods-next-1
Browse files Browse the repository at this point in the history
  • Loading branch information
bhabalan committed Sep 18, 2024
2 parents 8f30732 + e42b390 commit ce687dc
Show file tree
Hide file tree
Showing 62 changed files with 2,259 additions and 844 deletions.
21 changes: 20 additions & 1 deletion docs/samples/browser-plugin-meetings/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ const passwordCaptchaStatusElm = document.querySelector('#password-captcha-statu
const refreshCaptchaElm = document.querySelector('#meetings-join-captcha-refresh');
const verifyPasswordElm = document.querySelector('#btn-verify-password');
const displayMeetingStatusElm = document.querySelector('#display-meeting-status');
const notes=document.querySelector('#notes');
const spaceIDError = `Using the space ID as a destination is no longer supported. Please refer to the <a href="https://github.com/webex/webex-js-sdk/wiki/Migration-to-Unified-Space-Meetings" target="_blank">migration guide</a> to migrate to use the meeting ID or SIP address.`;
const BNR = 'BNR';
const VBG = 'VBG';
Expand Down Expand Up @@ -381,6 +382,17 @@ createMeetingSelectElm.addEventListener('change', (event) => {
}
});

createMeetingSelectElm.addEventListener('change', (event) => {
if (event.target.value === 'Others') {
notes.classList.remove('hidden');
}
else {
notes.classList.add('hidden');

}
});


function createMeeting(e) {
e.preventDefault();

Expand Down Expand Up @@ -427,19 +439,26 @@ function refreshCaptcha() {
meetingsListElm.onclick = (e) => {
selectedMeetingId = e.target.value;
const meeting = webex.meetings.getAllMeetings()[selectedMeetingId];
const selectedMeetingType = createMeetingSelectElm.options[createMeetingSelectElm.selectedIndex].innerText;

if (meeting && meeting.passwordStatus === 'REQUIRED') {
meetingsJoinPinElm.disabled = false;
verifyPasswordElm.disabled = false;
document.getElementById('btn-join').disabled = true;
document.getElementById('btn-join-media').disabled = true;
}
else if (meeting && meeting.passwordStatus === 'UNKNOWN') {
else if (meeting && (meeting.passwordStatus === 'UNKNOWN' && selectedMeetingType === 'SIP URI')) {
meetingsJoinPinElm.disabled = true;
verifyPasswordElm.disabled = true;
document.getElementById('btn-join').disabled = true;
document.getElementById('btn-join-media').disabled = true;
}
else if(meeting && (meeting.passwordStatus === 'UNKNOWN' && selectedMeetingType != 'SIP URI')) {
meetingsJoinPinElm.disabled = true;
verifyPasswordElm.disabled = true;
document.getElementById('btn-join').disabled = false;
document.getElementById('btn-join-media').disabled = false;
}
else {
meetingsJoinPinElm.disabled = true;
verifyPasswordElm.disabled = true;
Expand Down
4 changes: 2 additions & 2 deletions docs/samples/browser-plugin-meetings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,14 @@ <h2 class="collapsible">
<input id="create-meeting-destination" name="createMeetingDestination" placeholder="Destination"
value="" type="text" required>
<select name="createMeetingDest" id="createMeetingDest">
<option value="">Email</option>
<option value="">Person ID</option>
<option value="">SIP URI</option>
<option value="CONVERSATION_URL">Conversation URL</option>
<option value="Others">Others</option>
</select>
<button id="create-meeting-action" type="submit" class="btn-code">Create Meeting</button>
</div>
</div>
<p class="note hidden" id="notes">NOTE: The destination shall be "Person ID" or "Email".</p>
</form>
</div>

Expand Down
4 changes: 4 additions & 0 deletions docs/samples/calling/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,10 @@ async function createCustomContact() {
type: 'work',
value: formData.get('phone')
}],
emails: [{
type: 'work',
value: formData.get('email')
}],
contactType: 'CUSTOM',
};
const res = await contacts.createContact(contact);
Expand Down
6 changes: 6 additions & 0 deletions packages/@webex/internal-plugin-device/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ export default {
* @type {boolean}
*/
ephemeralDeviceTTL: 30 * 60,

/**
* energyForcast
* @type {boolean}
*/
energyForecast: false,
},

/**
Expand Down
27 changes: 27 additions & 0 deletions packages/@webex/internal-plugin-device/src/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ const Device = WebexPlugin.extend({
*/
isReachabilityChecked: ['boolean', false, false],

/**
* This property stores whether or not the next refresh or register request should request energy forecast data
* in order to prevent over fetching energy forecasts
*
* @type {boolean}
*/
energyForecastConfig: 'boolean',

/**
* This property stores whether or not the current device is in a meeting
* to prevent an unneeded timeout of a meeting due to inactivity.
Expand Down Expand Up @@ -344,6 +352,15 @@ const Device = WebexPlugin.extend({
this.webex.trigger('meeting ended');
},

/**
* Set the value of energy forecast config for the current registered device.
* @param {boolean} [energyForecastConfig=false] - fetch an energy forecast on the next refresh/register
* @returns {void}
*/
setEnergyForecastConfig(energyForecastConfig = false) {
this.energyForecastConfig = energyForecastConfig;
},

// Registration method members

/* eslint-disable require-jsdoc */
Expand Down Expand Up @@ -395,6 +412,11 @@ const Device = WebexPlugin.extend({
uri: this.url,
body,
headers,
qs: {
includeUpstreamServices: `all${
this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : ''
}`,
},
})
.then((response) => this.processRegistrationSuccess(response))
.catch((reason) => {
Expand Down Expand Up @@ -464,6 +486,11 @@ const Device = WebexPlugin.extend({
resource: 'devices',
body,
headers,
qs: {
includeUpstreamServices: `all${
this.config.energyForecast && this.energyForecastConfig ? ',energyforecast' : ''
}`,
},
})
.catch((error) => {
this.webex.internal.newMetrics.submitInternalEvent({
Expand Down
68 changes: 66 additions & 2 deletions packages/@webex/internal-plugin-device/test/unit/spec/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,14 @@ describe('plugin-device', () => {
describe('#refresh()', () => {
let requestSpy;

const setup = () => {
const setup = (config = {}) => {
sinon.stub(device, 'canRegister').callsFake(() => Promise.resolve());
sinon.stub(device, 'processRegistrationSuccess').callsFake(() => {});
requestSpy = sinon.spy(device, 'request');
device.config.defaults = {};
Object.keys((config)).forEach((key) => {
device.config[key] = config[key];
});
device.set('registered', true);
};

Expand All @@ -207,15 +210,40 @@ describe('plugin-device', () => {

assert.deepEqual(requestSpy.args[0][0].headers, {});
});

it('uses the energy forecast config to append upstream services to the outgoing call', async () => {
setup({energyForecast: true});
device.setEnergyForecastConfig(true);

await device.register();

assert.calledWith(requestSpy, sinon.match({
qs: { includeUpstreamServices: 'all,energyforecast' }
}))
});

it('uses the energy forecast config to not append upstream services to the outgoing call', async () => {
setup({energyForecast: true});
device.setEnergyForecastConfig(false);

await device.register();

assert.calledWith(requestSpy, sinon.match({
qs: { includeUpstreamServices: 'all' }
}))
});
});

describe('#register()', () => {
const setup = () => {
const setup = (config = {}) => {
webex.internal.metrics.submitClientMetrics = sinon.stub();

sinon.stub(device, 'processRegistrationSuccess').callsFake(() => {});

device.config.defaults = {};
Object.keys(config).forEach((key) => {
device.config[key] = config[key];
});
device.set('registered', false);
};

Expand Down Expand Up @@ -284,6 +312,42 @@ describe('plugin-device', () => {

});

it('uses the energy forecast config to append upstream services to the outgoing call', async () => {
setup({energyForecast: true});
sinon.stub(device, 'canRegister').callsFake(() => Promise.resolve());
const spy = sinon.spy(device, 'request');
device.setEnergyForecastConfig(true);

await device.register();

assert.calledWith(spy, {
method: 'POST',
service: 'wdm',
resource: 'devices',
body: {},
headers: {},
qs: { includeUpstreamServices: 'all,energyforecast' }
} )
});

it('uses the energy forecast config to not append upstream services to the outgoing call', async () => {
setup({energyForecast: true});
sinon.stub(device, 'canRegister').callsFake(() => Promise.resolve());
const spy = sinon.spy(device, 'request');
device.setEnergyForecastConfig(false);

await device.register();

assert.calledWith(spy, {
method: 'POST',
service: 'wdm',
resource: 'devices',
body: {},
headers: {},
qs: { includeUpstreamServices: 'all' }
} )
});

});

describe('#processRegistrationSuccess()', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ export default class CallDiagnosticMetrics extends StatelessWebexPlugin {
},
intervals: payload.intervals,
callingServiceType: 'LOCUS',
meetingJoinInfo: {
clientSignallingProtocol: 'WebRTC',
},
sourceMetadata: {
applicationSoftwareType: CLIENT_NAME,
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,9 @@ describe('internal-plugin-metrics', () => {
eventData: {webClientDomain: 'whatever'},
intervals: [{}],
callingServiceType: 'LOCUS',
meetingJoinInfo: {
clientSignallingProtocol: 'WebRTC',
},
sourceMetadata: {
applicationSoftwareType: 'webex-js-sdk',
applicationSoftwareVersion: 'webex-version',
Expand Down Expand Up @@ -1490,6 +1493,9 @@ describe('internal-plugin-metrics', () => {
eventData: {webClientDomain: 'whatever'},
intervals: [{}],
callingServiceType: 'LOCUS',
meetingJoinInfo: {
clientSignallingProtocol: 'WebRTC',
},
sourceMetadata: {
applicationSoftwareType: 'webex-js-sdk',
applicationSoftwareVersion: 'webex-version',
Expand Down Expand Up @@ -1524,6 +1530,9 @@ describe('internal-plugin-metrics', () => {
eventData: {webClientDomain: 'whatever'},
intervals: [{}],
callingServiceType: 'LOCUS',
meetingJoinInfo: {
clientSignallingProtocol: 'WebRTC',
},
sourceMetadata: {
applicationSoftwareType: 'webex-js-sdk',
applicationSoftwareVersion: 'webex-version',
Expand Down
2 changes: 1 addition & 1 deletion packages/@webex/media-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"deploy:npm": "yarn npm publish"
},
"dependencies": {
"@webex/internal-media-core": "2.9.1",
"@webex/internal-media-core": "2.10.2",
"@webex/ts-events": "^1.1.0",
"@webex/web-media-effects": "2.18.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,24 @@ const Authorization = WebexPlugin.extend({
this._verifySecurityToken(location.query);
this._cleanUrl(location);

let preauthCatalogParams;

const orgId = this._extractOrgIdFromCode(code);

if (emailhash) {
preauthCatalogParams = {emailhash};
} else if (orgId) {
preauthCatalogParams = {orgId};
}

// Wait until nextTick in case `credentials` hasn't initialized yet
process.nextTick(() => {
this.webex.internal.services
.collectPreauthCatalog(emailhash ? {emailhash}: undefined)
.collectPreauthCatalog(preauthCatalogParams)
.catch(() => Promise.resolve())
.then(() => this.requestAuthorizationCodeGrant({code, codeVerifier}))
.catch((error) => {
this.logger.warn('authorization: failed initial authorization code grant request', error)
this.logger.warn('authorization: failed initial authorization code grant request', error);
})
.then(() => {
this.ready = true;
Expand Down Expand Up @@ -230,6 +240,20 @@ const Authorization = WebexPlugin.extend({
});
},

/**
* Extracts the orgId from the returned code from idbroker
* Description of how to parse the code can be found here:
* https://wiki.cisco.com/display/IDENTITY/Federated+Token+Validation
* @instance
* @memberof AuthorizationBrowserFirstParty
* @param {String} code
* @private
* @returns {String}
*/
_extractOrgIdFromCode(code) {
return code?.split('_')[2] || undefined;
},

/**
* Checks if the result of the login redirect contains an error string
* @instance
Expand Down
Loading

0 comments on commit ce687dc

Please sign in to comment.