aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/basicAuth/index.ts
blob: ae698cba8c9a9e48220a182a4bbefe05d4cc3d10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { AuthInfo, BrowserWindow, ipcRenderer } from 'electron';

import { state as ModalState } from './store';

const debug = require('../../preload-safe-debug')('Ferdium:feature:basicAuth');

const state = ModalState;

export default function initialize() {
  debug('Initialize basicAuth feature');

  window['ferdium'].features.basicAuth = {
    state,
  };

  ipcRenderer.on('feature:basic-auth-request', (e, data) => {
    debug(e, data);
    // state.serviceId = data.serviceId;
    state.authInfo = data.authInfo;
    state.isModalVisible = true;
  });
}

export function mainIpcHandler(mainWindow: BrowserWindow, authInfo: AuthInfo) {
  debug('Sending basic auth call', authInfo);

  mainWindow.webContents.send('feature:basic-auth-request', {
    authInfo,
  });
}

export { default as Component } from './Component';