aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/basicAuth/index.ts
blob: 149ab6c19eacd0914e674a036c33acd0b2c673c3 (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
33
34
import { AuthInfo, BrowserWindow, ipcRenderer } from 'electron';

import BasicAuthComponent from './Component';

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

const debug = require('debug')('Ferdi:feature:basicAuth');

const state = ModalState;

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

  window['ferdi'].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 const Component = BasicAuthComponent;