Skip to content

Commit 6ec8f9c

Browse files
authored
build: Release (#2510)
2 parents 5b85740 + daba564 commit 6ec8f9c

File tree

363 files changed

+16845
-12481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

363 files changed

+16845
-12481
lines changed

.eslintrc.json

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
11
{
22
"root": true,
3+
"extends": "eslint:recommended",
34
"env": {
45
"es6": true,
56
"node": true,
67
"browser": true
78
},
89
"parser": "@babel/eslint-parser",
9-
"extends": "eslint:recommended",
10+
"plugins": [
11+
"react"
12+
],
1013
"parserOptions": {
11-
"sourceType": "module"
14+
"ecmaVersion": 6,
15+
"sourceType": "module",
16+
"requireConfigFile": false
1217
},
13-
"plugins": ["react"],
1418
"rules": {
19+
"indent": ["error", 2, { "SwitchCase": 1 }],
20+
"linebreak-style": ["error", "unix"],
21+
"no-trailing-spaces": 2,
22+
"eol-last": 2,
23+
"space-in-parens": ["error", "never"],
24+
"no-multiple-empty-lines": 1,
25+
"prefer-const": "error",
26+
"space-infix-ops": "error",
27+
"no-useless-escape": "off",
28+
"require-atomic-updates": "off",
1529
"react/jsx-uses-vars": 1,
1630
"react/jsx-uses-react": 1,
1731
"react/react-in-jsx-scope": 1,
1832
"no-console": 0,
1933
"no-case-declarations": 0,
2034
"quotes": ["error", "single"],
21-
"eol-last": ["error", "always"]
35+
"no-var": "error",
36+
"no-prototype-builtins": "off",
37+
"curly": ["error", "all"]
2238
}
2339
}

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
semi: true
2+
trailingComma: "es5"
3+
singleQuote: true
4+
arrowParens: "avoid"
5+
printWidth: 100

Parse-Dashboard/Authentication.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2-
var bcrypt = require('bcryptjs');
3-
var csrf = require('csurf');
4-
var passport = require('passport');
5-
var LocalStrategy = require('passport-local').Strategy;
2+
const bcrypt = require('bcryptjs');
3+
const csrf = require('csurf');
4+
const passport = require('passport');
5+
const LocalStrategy = require('passport-local').Strategy;
66
const OTPAuth = require('otpauth')
77

88
/**
@@ -20,11 +20,11 @@ function Authentication(validUsers, useEncryptedPasswords, mountPath) {
2020

2121
function initialize(app, options) {
2222
options = options || {};
23-
var self = this;
23+
const self = this;
2424
passport.use('local', new LocalStrategy(
2525
{passReqToCallback:true},
2626
function(req, username, password, cb) {
27-
var match = self.authenticate({
27+
const match = self.authenticate({
2828
name: username,
2929
pass: password,
3030
otpCode: req.body.otpCode
@@ -47,13 +47,13 @@ function initialize(app, options) {
4747
});
4848

4949
passport.deserializeUser(function(username, cb) {
50-
var user = self.authenticate({
50+
const user = self.authenticate({
5151
name: username
5252
}, true);
5353
cb(null, user);
5454
});
5555

56-
var cookieSessionSecret = options.cookieSessionSecret || require('crypto').randomBytes(64).toString('hex');
56+
const cookieSessionSecret = options.cookieSessionSecret || require('crypto').randomBytes(64).toString('hex');
5757
const cookieSessionMaxAge = options.cookieSessionMaxAge;
5858
app.use(require('connect-flash')());
5959
app.use(require('body-parser').urlencoded({ extended: true }));
@@ -67,16 +67,16 @@ function initialize(app, options) {
6767

6868
app.post('/login',
6969
csrf(),
70-
(req,res,next) => {
71-
let redirect = 'apps';
72-
if (req.body.redirect) {
73-
redirect = req.body.redirect.charAt(0) === '/' ? req.body.redirect.substring(1) : req.body.redirect
74-
}
75-
return passport.authenticate('local', {
76-
successRedirect: `${self.mountPath}${redirect}`,
77-
failureRedirect: `${self.mountPath}login${req.body.redirect ? `?redirect=${req.body.redirect}` : ''}`,
78-
failureFlash : true
79-
})(req, res, next)
70+
(req,res,next) => {
71+
let redirect = 'apps';
72+
if (req.body.redirect) {
73+
redirect = req.body.redirect.charAt(0) === '/' ? req.body.redirect.substring(1) : req.body.redirect
74+
}
75+
return passport.authenticate('local', {
76+
successRedirect: `${self.mountPath}${redirect}`,
77+
failureRedirect: `${self.mountPath}login${req.body.redirect ? `?redirect=${req.body.redirect}` : ''}`,
78+
failureFlash : true
79+
})(req, res, next)
8080
},
8181
);
8282

@@ -100,13 +100,13 @@ function authenticate(userToTest, usernameOnly) {
100100
let otpValid = true;
101101

102102
//they provided auth
103-
let isAuthenticated = userToTest &&
103+
const isAuthenticated = userToTest &&
104104
//there are configured users
105105
this.validUsers &&
106106
//the provided auth matches one of the users
107107
this.validUsers.find(user => {
108108
let isAuthenticated = false;
109-
let usernameMatches = userToTest.name == user.user;
109+
const usernameMatches = userToTest.name == user.user;
110110
if (usernameMatches && user.mfa && !usernameOnly) {
111111
if (!userToTest.otpCode) {
112112
otpMissingLength = user.mfaDigits || 6;
@@ -126,7 +126,7 @@ function authenticate(userToTest, usernameOnly) {
126126
}
127127
}
128128
}
129-
let passwordMatches = this.useEncryptedPasswords && !usernameOnly ? bcrypt.compareSync(userToTest.pass, user.pass) : userToTest.pass == user.pass;
129+
const passwordMatches = this.useEncryptedPasswords && !usernameOnly ? bcrypt.compareSync(userToTest.pass, user.pass) : userToTest.pass == user.pass;
130130
if (usernameMatches && (usernameOnly || passwordMatches)) {
131131
isAuthenticated = true;
132132
matchingUsername = user.user;

Parse-Dashboard/CLI/mfa.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const showInstructions = ({ app, username, passwordCopied, encrypt, config }) =>
129129
`\n${getOrder()}. Make sure that "useEncryptedPasswords" is set to "true" in your dashboard configuration.` +
130130
'\n You chose to generate an encrypted password for this user.' +
131131
'\n Any existing users with non-encrypted passwords will require newly created, encrypted passwords.'
132-
);
132+
);
133133
}
134134
console.log(
135135
'\n------------------------------------------------------------------------------\n'
@@ -198,7 +198,7 @@ module.exports = {
198198
}
199199
]);
200200
const { algorithm, digits, period } = await getAlgorithm();
201-
const secret =generateSecret({ app, username, algorithm, digits, period });
201+
const secret = generateSecret({ app, username, algorithm, digits, period });
202202
Object.assign(config, secret.config);
203203
showQR(secret.config.url);
204204
}

Parse-Dashboard/app.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ const path = require('path');
44
const packageJson = require('package-json');
55
const csrf = require('csurf');
66
const Authentication = require('./Authentication.js');
7-
var fs = require('fs');
7+
const fs = require('fs');
88

99
const currentVersionFeatures = require('../package.json').parseDashboardFeatures;
1010

11-
var newFeaturesInLatestVersion = [];
11+
let newFeaturesInLatestVersion = [];
1212
packageJson('parse-dashboard', { version: 'latest', fullMetadata: true })
1313
.then(latestPackage => {
1414
if (latestPackage.parseDashboardFeatures instanceof Array) {
@@ -31,29 +31,29 @@ function getMount(mountPath) {
3131
}
3232

3333
function checkIfIconsExistForApps(apps, iconsFolder) {
34-
for (var i in apps) {
35-
var currentApp = apps[i];
36-
var iconName = currentApp.iconName;
37-
var path = iconsFolder + '/' + iconName;
34+
for (const i in apps) {
35+
const currentApp = apps[i];
36+
const iconName = currentApp.iconName;
37+
const path = iconsFolder + '/' + iconName;
3838

3939
fs.stat(path, function(err) {
4040
if (err) {
41-
if ('ENOENT' == err.code) {// file does not exist
42-
console.warn('Icon with file name: ' + iconName +' couldn\'t be found in icons folder!');
43-
} else {
44-
console.log(
45-
'An error occurd while checking for icons, please check permission!');
46-
}
41+
if ('ENOENT' == err.code) {// file does not exist
42+
console.warn('Icon with file name: ' + iconName + ' couldn\'t be found in icons folder!');
43+
} else {
44+
console.log(
45+
'An error occurd while checking for icons, please check permission!');
46+
}
4747
} else {
48-
//every thing was ok so for example you can read it and send it to client
48+
//every thing was ok so for example you can read it and send it to client
4949
}
50-
} );
50+
});
5151
}
5252
}
5353

5454
module.exports = function(config, options) {
5555
options = options || {};
56-
var app = express();
56+
const app = express();
5757
// Serve public files.
5858
app.use(express.static(path.join(__dirname,'public')));
5959

@@ -72,7 +72,7 @@ module.exports = function(config, options) {
7272

7373
// CSRF error handler
7474
app.use(function (err, req, res, next) {
75-
if (err.code !== 'EBADCSRFTOKEN') return next(err)
75+
if (err.code !== 'EBADCSRFTOKEN') {return next(err)}
7676

7777
// handle CSRF token errors here
7878
res.status(403)
@@ -81,8 +81,8 @@ module.exports = function(config, options) {
8181

8282
// Serve the configuration.
8383
app.get('/parse-dashboard-config.json', function(req, res) {
84-
let apps = config.apps.map((app) => Object.assign({}, app)); // make a copy
85-
let response = {
84+
const apps = config.apps.map((app) => Object.assign({}, app)); // make a copy
85+
const response = {
8686
apps: apps,
8787
newFeaturesInLatestVersion: newFeaturesInLatestVersion,
8888
};
@@ -159,7 +159,7 @@ module.exports = function(config, options) {
159159
// running parse-dashboard from globally installed npm.
160160
if (config.iconsFolder) {
161161
try {
162-
var stat = fs.statSync(config.iconsFolder);
162+
const stat = fs.statSync(config.iconsFolder);
163163
if (stat.isDirectory()) {
164164
app.use('/appicons', express.static(config.iconsFolder));
165165
//Check also if the icons really exist
@@ -213,7 +213,7 @@ module.exports = function(config, options) {
213213
}
214214
return res.redirect(`${mountPath}login`);
215215
}
216-
if (users && req.user && req.user.matchingUsername ) {
216+
if (users && req.user && req.user.matchingUsername) {
217217
res.append('username', req.user.matchingUsername);
218218
}
219219
res.send(`<!DOCTYPE html>

Parse-Dashboard/server.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ module.exports = (options) => {
2727
process.exit(-1);
2828
}
2929

30-
let explicitConfigFileProvided = !!options.config;
30+
const explicitConfigFileProvided = !!options.config;
3131
let configFile = null;
3232
let configFromCLI = null;
33-
let configServerURL = options.serverURL || process.env.PARSE_DASHBOARD_SERVER_URL;
34-
let configGraphQLServerURL = options.graphQLServerURL || process.env.PARSE_DASHBOARD_GRAPHQL_SERVER_URL;
35-
let configMasterKey = options.masterKey || process.env.PARSE_DASHBOARD_MASTER_KEY;
36-
let configAppId = options.appId || process.env.PARSE_DASHBOARD_APP_ID;
37-
let configAppName = options.appName || process.env.PARSE_DASHBOARD_APP_NAME;
38-
let configUserId = options.userId || process.env.PARSE_DASHBOARD_USER_ID;
39-
let configUserPassword = options.userPassword || process.env.PARSE_DASHBOARD_USER_PASSWORD;
40-
let configSSLKey = options.sslKey || process.env.PARSE_DASHBOARD_SSL_KEY;
41-
let configSSLCert = options.sslCert || process.env.PARSE_DASHBOARD_SSL_CERT;
33+
const configServerURL = options.serverURL || process.env.PARSE_DASHBOARD_SERVER_URL;
34+
const configGraphQLServerURL = options.graphQLServerURL || process.env.PARSE_DASHBOARD_GRAPHQL_SERVER_URL;
35+
const configMasterKey = options.masterKey || process.env.PARSE_DASHBOARD_MASTER_KEY;
36+
const configAppId = options.appId || process.env.PARSE_DASHBOARD_APP_ID;
37+
const configAppName = options.appName || process.env.PARSE_DASHBOARD_APP_NAME;
38+
const configUserId = options.userId || process.env.PARSE_DASHBOARD_USER_ID;
39+
const configUserPassword = options.userPassword || process.env.PARSE_DASHBOARD_USER_PASSWORD;
40+
const configSSLKey = options.sslKey || process.env.PARSE_DASHBOARD_SSL_KEY;
41+
const configSSLCert = options.sslCert || process.env.PARSE_DASHBOARD_SSL_CERT;
4242

4343
function handleSIGs(server) {
4444
const signals = {
@@ -143,10 +143,10 @@ module.exports = (options) => {
143143

144144
const app = express();
145145

146-
if (allowInsecureHTTP || trustProxy || dev) app.enable('trust proxy');
146+
if (allowInsecureHTTP || trustProxy || dev) {app.enable('trust proxy');}
147147

148148
config.data.trustProxy = trustProxy;
149-
let dashboardOptions = { allowInsecureHTTP, cookieSessionSecret, dev, cookieSessionMaxAge };
149+
const dashboardOptions = { allowInsecureHTTP, cookieSessionSecret, dev, cookieSessionMaxAge };
150150
app.use(mountPath, parseDashboard(config.data, dashboardOptions));
151151
let server;
152152
if(!configSSLKey || !configSSLCert){
@@ -156,8 +156,8 @@ module.exports = (options) => {
156156
});
157157
} else {
158158
// Start the server using SSL.
159-
var privateKey = fs.readFileSync(configSSLKey);
160-
var certificate = fs.readFileSync(configSSLCert);
159+
const privateKey = fs.readFileSync(configSSLKey);
160+
const certificate = fs.readFileSync(configSSLCert);
161161

162162
server = require('https').createServer({
163163
key: privateKey,

0 commit comments

Comments
 (0)