Skip to content

Commit

Permalink
Trying to use new eslint for code
Browse files Browse the repository at this point in the history
Activate prettier
  • Loading branch information
GermanBluefox committed Sep 14, 2024
1 parent 7ec5b6d commit a116869
Show file tree
Hide file tree
Showing 18 changed files with 17,862 additions and 12,018 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from '@iobroker/eslint-config';

export default [...config];
32 changes: 16 additions & 16 deletions lib/dropboxLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const axios = require('axios');

const OAUTH_URL = 'https://dropboxauth.simateccloud.de/';
const OAUTH_URL = 'https://googleauth.iobroker.in/dropbox';

class dropbox {
getAuthorizeUrl(log) {
Expand All @@ -15,7 +15,7 @@ class dropbox {
'User-Agent': 'axios/1.6.5'
},
responseType: 'json'
}).catch(err => log.warn('getAuthorizeUrl Dropbox: ' + err));
}).catch(err => log.warn(`getAuthorizeUrl Dropbox: ${err}`));

if (urlRequest && urlRequest.data) {
const url = `${urlRequest.data.authURL}&client_id=${urlRequest.data.client_id}`;
Expand All @@ -24,23 +24,23 @@ class dropbox {
reject();
}
} catch (e) {
console.log('error getAuthorizeUrl Dropbox: ' + e);
console.log(`error getAuthorizeUrl Dropbox: ${e}`);
reject();
}
});
}

getCodeChallage(log, dropboxCodeChallenge) {
getCodeChallenge(log, dropboxCodeChallenge) {
return new Promise((resolve, reject) => {
if (dropboxCodeChallenge && dropboxCodeChallenge.length == 48) {
if (dropboxCodeChallenge?.length === 48) {
log.debug('Dropbox code verifier already exists');
resolve(dropboxCodeChallenge);
} else {
try {
let codeChallenge = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

for (var i = 0; i < 48; i++) {
for (let i = 0; i < 48; i++) {
codeChallenge += characters.charAt(Math.floor(Math.random() * characters.length));
}

Expand All @@ -50,7 +50,7 @@ class dropbox {
reject();
}
} catch (e) {
console.log('error getCodeChallage Dropbox: ' + e);
console.log(`error getCodeChallenge Dropbox: ${e}`);
reject();
}
}
Expand All @@ -68,15 +68,15 @@ class dropbox {
code_verifier: code_verifier,
client_id: await this.getClientID(log)
}
}).catch(err => log.warn('getRefreshToken Dropbox: ' + err));
}).catch(err => log.warn(`getRefreshToken Dropbox: ${err}`));

if (refreshToken && refreshToken.data && refreshToken.data.refresh_token) {
resolve(refreshToken.data.refresh_token);
} else {
reject();
}
} catch (e) {
console.log('error getRefreshToken Dropbox: ' + e);
console.log(`error getRefreshToken Dropbox: ${e}`);
reject();
}
});
Expand All @@ -92,15 +92,15 @@ class dropbox {
'User-Agent': 'axios/1.6.5'
},
responseType: 'json'
}).catch(err => log.warn('getClientID Dropbox: ' + err));
}).catch(err => log.warn(`getClientID Dropbox: ${err}`));

if (urlRequest && urlRequest.data && urlRequest.data.client_id) {
resolve(urlRequest.data.client_id)
} else {
reject();
}
} catch (e) {
console.log('error getClientID Dropbox: ' + e);
console.log(`error getClientID Dropbox: ${e}`);
reject();
}
});
Expand All @@ -116,15 +116,15 @@ class dropbox {
grant_type: 'refresh_token',
client_id: await this.getClientID(log)
}
}).catch(err => log.warn('getToken Dropbox: ' + err));
}).catch(err => log.warn(`getToken Dropbox: ${err}`));

if (accessToken && accessToken.data && accessToken.data.access_token) {
resolve(accessToken.data.access_token);
} else {
reject();
}
} catch (e) {
console.log('error getToken Dropbox: ' + e);
console.log(`error getToken Dropbox: ${e}`);
reject();
}
});
Expand Down Expand Up @@ -192,7 +192,7 @@ class dropbox {
},
}, async (err, result) => {
if (err) {
log.error('sessionStart error: ' + JSON.stringify(err));
log.error(`sessionStart error: ${JSON.stringify(err)}`);
reject(err);
}
if (result && result.session_id) {
Expand All @@ -218,7 +218,7 @@ class dropbox {
readStream: getNextChunkStream(start, end)
}, async (err) => {
if (err) {
log.error(); ('sessionAppend error: ' + JSON.stringify(err));
log.error(); (`sessionAppend error: ${JSON.stringify(err)}`);
reject(err);
}
resolve();
Expand All @@ -244,7 +244,7 @@ class dropbox {
}
}, (err) => {
if (err) {
log.error('sessionFinish error: ' + JSON.stringify(err));
log.error(`sessionFinish error: ${JSON.stringify(err)}`);
reject(err);
}
});
Expand Down
5 changes: 2 additions & 3 deletions lib/googleDriveLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { OAuth2Client } = require('google-auth-library');
const fs = require('node:fs');
const axios = require('axios');

const OAUTH_URL = 'https://googleauth.iobroker.in/googleDriveOAuth';
const OAUTH_URL = 'https://googleauth.iobroker.in/googledrive';

const NOT_FOUND = 'Not found';

Expand Down Expand Up @@ -39,9 +39,8 @@ class GoogleDrive {
return this.oAuth2Client;
}
});
} else {
return Promise.resolve(this.oAuth2Client);
}
return Promise.resolve(this.oAuth2Client);
}

getAuthorizeUrl() {
Expand Down
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function startAdapter(options) {

dropbox.getAuthorizeUrl(adapter.log)
.then(url => auth_url = url)
.then(() => dropbox.getCodeChallage(adapter.log, adapter.config.dropboxCodeChallenge))
.then(() => dropbox.getCodeChallenge(adapter.log, adapter.config.dropboxCodeChallenge))
.then(code_challenge => adapter.sendTo(obj.from, obj.command, { url: auth_url, code_challenge: code_challenge }, obj.callback))
.catch(err => adapter.sendTo(obj.from, obj.command, { error: err }, obj.callback));
}
Expand Down
Loading

0 comments on commit a116869

Please sign in to comment.