You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
// chat-client.js
|
|
// Copyright (C) 2024 DTP Technologies, LLC
|
|
// All Rights Reserved
|
|
|
|
'use strict';
|
|
|
|
const DTP_COMPONENT_NAME = 'DtpChatApp';
|
|
|
|
import DtpApp from 'dtp/dtp-app.js';
|
|
|
|
export class ChatApp extends DtpApp {
|
|
|
|
constructor (user) {
|
|
super(DTP_COMPONENT_NAME, user, { withAdvertising: false });
|
|
this.log.info('DTP app client online');
|
|
}
|
|
|
|
async confirmNavigation (event) {
|
|
const target = event.currentTarget || event.target;
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
|
|
const href = target.getAttribute('href');
|
|
const hrefTarget = target.getAttribute('target');
|
|
const text = target.textContent;
|
|
const whitelist = [
|
|
'digitaltelepresence.com',
|
|
'www.digitaltelepresence.com',
|
|
'chat.digitaltelepresence.com',
|
|
'sites.digitaltelepresence.com',
|
|
];
|
|
try {
|
|
const url = new URL(href);
|
|
if (!whitelist.includes(url.hostname)) {
|
|
await UIkit.modal.confirm(`<p>You are navigating to <code>${href}</code>, a link or button that was displayed as:</p><p>${text}</p><div class="uk-text-small uk-text-danger">Please only open links to destinations you trust and want to visit.</div>`);
|
|
}
|
|
window.open(href, hrefTarget);
|
|
} catch (error) {
|
|
this.log.info('confirmNavigation', 'navigation canceled', { error });
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|