2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 17:34:04 +00:00
books/fyo/demux/auth.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
672 B
TypeScript
Raw Normal View History

import { ipcRenderer } from 'electron';
import { AuthDemuxBase, TelemetryCreds } from 'utils/auth/types';
import { IPC_ACTIONS } from 'utils/messages';
export class AuthDemux extends AuthDemuxBase {
#isElectron: boolean = false;
constructor(isElectron: boolean) {
super();
this.#isElectron = isElectron;
}
async getTelemetryCreds(): Promise<TelemetryCreds> {
if (this.#isElectron) {
const creds = await ipcRenderer.invoke(IPC_ACTIONS.GET_CREDS);
const url: string = creds?.telemetryUrl ?? '';
const token: string = creds?.tokenString ?? '';
return { url, token };
} else {
return { url: '', token: '' };
}
}
}