import * as sentry from '@sentry/electron' ; import { contextBridge , ipcRenderer } from 'electron' ; import { URL } from 'url' ; import * as digitalocean_oauth from './digitalocean_oauth' ; import * as gcp_oauth from './gcp_oauth' ; import { redactManagerUrl } from './util' ; const params = new URL ( document . URL ) . searchParams ; const sentryDsn = params . get ( 'sentryDsn' ) ; if ( sentryDsn ) { sentry . init ( { dsn : sentryDsn , beforeBreadcrumb : ( breadcrumb ) => { if ( breadcrumb . category === 'fetch' && breadcrumb . data && breadcrumb . data . url ) { try { breadcrumb . data . url = `(redacted)/${ redactManagerUrl ( breadcrumb . data . url ) }` ; } catch ( e ) { breadcrumb . data . url = `(error redacting)` ; } } return breadcrumb ; } } ) ; } contextBridge . exposeInMainWorld ( 'trustCertificate' , ( fingerprint ) => { return ipcRenderer . sendSync ( 'trust-certificate' , fingerprint ) ; } ) ; contextBridge . exposeInMainWorld ( 'openImage' , ( basename ) => { ipcRenderer . send ( 'open-image' , basename ) ; } ) ; contextBridge . exposeInMainWorld ( 'onUpdateDownloaded' , ( callback ) => { ipcRenderer . on ( 'update-downloaded' , callback ) ; } ) ; contextBridge . exposeInMainWorld ( 'runDigitalOceanOauth' , digitalocean_oauth . runOauth ) ; contextBridge . exposeInMainWorld ( 'runGcpOauth' , gcp_oauth . runOauth ) ; contextBridge . exposeInMainWorld ( 'bringToFront' , ( ) => { return ipcRenderer . send ( 'bring-to-front' ) ; } ) ;