Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//independent features
import { loadDialPadInterface } from "./components/dialpad"
import { loadExternalTransferInterface } from "./components/external-transfer"
// common libraries
import { registerReservationCreatedExtensions } from "./eventListeners/workerClient/reservationCreated";
import { registerActionExtensions } from "./eventListeners/actionsFramework"
import "./notifications/CustomNotifications";
const PLUGIN_NAME = "OutboundDialingWithConferencePlugin";
export const FUNCTIONS_HOSTNAME = '';
export const DEFAULT_FROM_NUMBER = ""; // twilio account or verified number
export const SYNC_CLIENT = new SyncClient(Manager.getInstance().user.token);
function tokenUpdateHandler() {
console.log("OUTBOUND DIALPAD: Refreshing SYNC_CLIENT Token");
const loginHandler = Manager.getInstance().store.getState().flex.session.loginHandler;
const tokenInfo = loginHandler.getTokenInfo();
const accessToken = tokenInfo.token;
SYNC_CLIENT.updateToken(accessToken);
}
export default class OutboundDialingWithConferencePlugin extends FlexPlugin {
initSyncMapClient(queueStatsSyncMapName) {
// create syncClient on component mount
this.syncClient = new SyncClient(Manager.getInstance().user.token);
// fetch initial data map
this.syncClient
.map(queueStatsSyncMapName)
.then(map => {
map
.getItems()
.then(paginator => {
this.syncMapPageHandler(paginator);
})
.catch(function(error) {
console.error("Map getItems() failed", error);
});
})
.catch(function(error) {
Notifications.showNotification("SyncMapNotAvailable", {
createClient(token) {
const client = new SyncClient(token);
client.on('connectionStateChanged', ({ connectionState }) => {
if (
connectionState === 'disconnected' ||
connectionState === 'error' ||
connectionState === 'denied'
) {
console.error('lost connection...');
this.emit('disconnected');
this.client = undefined;
}
});
return client;
}
.then(({ token }) => {
console.log(token);
client = new SyncClient(token);
return client;
})
.then(client => {