Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public open(id_parameter: string, endpoint_parameter: string) {
// added to simplify development process
const url = environment.production ? window.location.origin : API_URL;
const tunnel = new Guacamole.HTTPTunnel(
`${url}/api/tunnel`, false,
{ 'Authorization': `Bearer ${this.storageService.getToken()}` }
);
const guac = new Guacamole.Client(tunnel);
const display = document.getElementById('display');
display.appendChild(guac.getDisplay().getElement());
this.layer = guac.getDisplay().getDefaultLayer();
guac.connect(`{"host" : "${id_parameter}", "endpoint" : "${endpoint_parameter}"}`);
// Error handler
guac.onerror = (error) => console.log(error.message);
window.onunload = () => guac.disconnect();