Skip to content

Commit

Permalink
Merge pull request #18 from baruchiro/eventType
Browse files Browse the repository at this point in the history
Declare event exacctly like AuthClient from google-auth-library
  • Loading branch information
magne4000 committed Oct 12, 2020
2 parents 3472ddf + 35d2dbb commit 4ca9cbe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// inspired by https://github.com/parro-it/electron-google-oauth
import { shell, BrowserWindow, remote } from 'electron';
import { BrowserWindow, remote, shell } from 'electron';
import { EventEmitter } from 'events';
import { OAuth2Client } from 'google-auth-library';
import { Credentials } from 'google-auth-library/build/src/auth/credentials';
Expand Down Expand Up @@ -40,7 +40,7 @@ export const defaultElectronGoogleOAuth2Options: ElectronGoogleOAuth2Options = {
* This class automatically renews expired tokens.
* @fires ElectronGoogleOAuth2#tokens
*/
export default class ElectronGoogleOAuth2 extends EventEmitter {
class ElectronGoogleOAuth2 extends EventEmitter {

public oauth2Client: OAuth2Client;
public scopes: string[];
Expand Down Expand Up @@ -172,3 +172,9 @@ export default class ElectronGoogleOAuth2 extends EventEmitter {
this.oauth2Client.setCredentials(tokens);
}
}

declare interface ElectronGoogleOAuth2 {
on(event: 'tokens', listener: (tokens: Credentials) => void): this;
}

export default ElectronGoogleOAuth2

0 comments on commit 4ca9cbe

Please sign in to comment.