Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

using function keyword instead of fat arrow because of uglifyjs gives error #22

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
yarn.lock
32 changes: 24 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ module.exports = function (config, windowParams) {
var url = config.authorizationUrl + '?' + queryString.stringify(urlParams);

return new Promise(function (resolve, reject) {
const authWindow = new BrowserWindow(windowParams || {'use-content-size': true});
const authWindow = new BrowserWindow(windowParams || { 'use-content-size': true });

authWindow.loadURL(url);
authWindow.show();

authWindow.on('closed', () => {
authWindow.on('closed', function () {
reject(new Error('window was closed by user'));
});

Expand All @@ -64,22 +64,38 @@ module.exports = function (config, windowParams) {
reject(error);
authWindow.removeAllListeners('closed');
setImmediate(function () {
authWindow.close();
setTimeout(function () {
authWindow.webContents.session.clearStorageData({
storages: ['appcache', 'cookies', 'filesystem', 'shadercache'],
quotas: ['persistent', 'syncable']
}, function () {
authWindow.close();
authWindow.destroy()
});
}, 100)
});
} else if (code) {
resolve(code);
authWindow.removeAllListeners('closed');
setImmediate(function () {
authWindow.close();
setTimeout(function () {
authWindow.webContents.session.clearStorageData({
storages: ['appcache', 'cookies', 'filesystem', 'shadercache'],
quotas: ['persistent', 'syncable']
}, function () {
authWindow.close();
authWindow.destroy()
});
}, 100)
});
}
}

authWindow.webContents.on('will-navigate', (event, url) => {
authWindow.webContents.on('will-navigate', function (event, url) {
onCallback(url);
});

authWindow.webContents.on('did-get-redirect-request', (event, oldUrl, newUrl) => {
authWindow.webContents.on('did-get-redirect-request', function (event, oldUrl, newUrl) {
onCallback(newUrl);
});
});
Expand All @@ -104,14 +120,14 @@ module.exports = function (config, windowParams) {
method: 'POST',
headers: header,
body: queryString.stringify(data)
}).then(res => {
}).then(function (res) {
return res.json();
});
}

function getAccessToken(opts) {
return getAuthorizationCode(opts)
.then(authorizationCode => {
.then(function (authorizationCode) {
var tokenRequestData = {
code: authorizationCode,
grant_type: 'authorization_code',
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"name": "electron-oauth2",
"version": "2.4.1",
"name": "electron-oauth",
"version": "2.4.3",
"description": "An OAuth2 module for your Electron app.",
"license": "MIT",
"repository": "mawie81/electron-oauth2",
"repository": "Vishal Isharani/electron-oauth2",
"author": {
"name": "Marcel Wiehle",
"email": "[email protected]",
"url": "marcel.wiehle.me"
"name": "Vishal Isharani",
"email": "[email protected]"
},
"files": [
"index.js"
Expand Down
11 changes: 5 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# electron-oauth2 [![Build Status](https://travis-ci.org/mawie81/electron-oauth2.svg?branch=master)](https://travis-ci.org/mawie81/electron-oauth2)

> A library to handle OAuth2 authentication for your [Electron](http://electron.atom.io) app.


## Install

```
$ npm install --save electron-oauth2
$ npm install --save electron-oauth
```


## Usage

```js
const electronOauth2 = require('electron-oauth2');
const electronOauth = require('electron-oauth');

var config = {
clientId: 'CLIENT_ID',
Expand All @@ -38,7 +37,7 @@ app.on('ready', () => {
accessType: 'ACCESS_TYPE'
};

const myApiOauth = electronOauth2(config, windowParams);
const myApiOauth = electronOauth(config, windowParams);

myApiOauth.getAccessToken(options)
.then(token => {
Expand All @@ -55,7 +54,7 @@ app.on('ready', () => {

## API

### electronOauth2(config, windowParams)
### electronOauth(config, windowParams)

#### config

Expand Down Expand Up @@ -138,4 +137,4 @@ An OAuth2 refresh token.

## License

MIT © [Marcel Wiehle](http://marcel.wiehle.me)
MIT © [Vishal Isharani]
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

xdescribe('electron/oauth2', function () {
xdescribe('electron/oauth', function () {
it('should not throw an error', function () {
require('../index');
});
Expand Down