some weird old code cleanup that was left hanging, /shrug
This commit is contained in:
parent
08c196684b
commit
c7ce387685
36
.eslintrc.js
Normal file
36
.eslintrc.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
module.exports = {
|
||||||
|
'env': {
|
||||||
|
'browser': true,
|
||||||
|
'es2021': true,
|
||||||
|
'node': true
|
||||||
|
},
|
||||||
|
'extends': [
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:vue/essential'
|
||||||
|
],
|
||||||
|
'parserOptions': {
|
||||||
|
'ecmaVersion': 12,
|
||||||
|
'sourceType': 'module'
|
||||||
|
},
|
||||||
|
'plugins': [
|
||||||
|
'vue'
|
||||||
|
],
|
||||||
|
'rules': {
|
||||||
|
'indent': [
|
||||||
|
'error',
|
||||||
|
2
|
||||||
|
],
|
||||||
|
'linebreak-style': [
|
||||||
|
'error',
|
||||||
|
'unix'
|
||||||
|
],
|
||||||
|
'quotes': [
|
||||||
|
'error',
|
||||||
|
'single'
|
||||||
|
],
|
||||||
|
'semi': [
|
||||||
|
'error',
|
||||||
|
'never'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
2848
package-lock.json
generated
2848
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
39
package.json
39
package.json
@ -30,27 +30,28 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://icynet.eu",
|
"homepage": "https://icynet.eu",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
|
"@babel/plugin-transform-modules-commonjs": "^7.12.13",
|
||||||
"@babel/register": "^7.12.10",
|
"@babel/register": "^7.12.13",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"bluebird": "^3.7.2",
|
"bluebird": "^3.7.2",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"connect-redis": "^5.0.0",
|
"connect-redis": "^5.1.0",
|
||||||
"connect-session-knex": "^2.0.0",
|
"connect-session-knex": "^2.0.0",
|
||||||
"email-templates": "^8.0.2",
|
"email-templates": "^8.0.3",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-rate-limit": "^5.2.3",
|
"express-rate-limit": "^5.2.5",
|
||||||
"express-session": "^1.17.1",
|
"express-session": "^1.17.1",
|
||||||
"feed": "^4.2.1",
|
"feed": "^4.2.2",
|
||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^9.1.0",
|
||||||
"gm": "^1.23.1",
|
"gm": "^1.23.1",
|
||||||
"knex": "^0.21.13",
|
"json-web-token": "^3.2.0",
|
||||||
|
"knex": "^0.21.17",
|
||||||
"multiparty": "^4.2.2",
|
"multiparty": "^4.2.2",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"nodemailer": "^6.4.17",
|
"nodemailer": "^6.4.17",
|
||||||
"notp": "^2.0.3",
|
"notp": "^2.0.3",
|
||||||
"oauth-libre": "^0.9.17",
|
"oauth-libre": "^0.9.17",
|
||||||
"objection": "^2.2.3",
|
"objection": "^2.2.14",
|
||||||
"querystring-es3": "^0.2.1",
|
"querystring-es3": "^0.2.1",
|
||||||
"redis": "^3.0.2",
|
"redis": "^3.0.2",
|
||||||
"serve-favicon": "^2.5.0",
|
"serve-favicon": "^2.5.0",
|
||||||
@ -61,12 +62,14 @@
|
|||||||
"vue": "^2.6.12"
|
"vue": "^2.6.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.12.10",
|
"@babel/core": "^7.12.13",
|
||||||
"@babel/preset-env": "^7.12.10",
|
"@babel/preset-env": "^7.12.13",
|
||||||
"babel-loader": "^8.2.2",
|
"babel-loader": "^8.2.2",
|
||||||
"bootstrap": "^4.5.3",
|
"bootstrap": "^4.6.0",
|
||||||
"concurrently": "^5.3.0",
|
"concurrently": "^5.3.0",
|
||||||
|
"eslint": "^7.19.0",
|
||||||
"eslint-plugin-import": "^2.22.1",
|
"eslint-plugin-import": "^2.22.1",
|
||||||
|
"eslint-plugin-vue": "^7.5.0",
|
||||||
"jquery": "^3.5.1",
|
"jquery": "^3.5.1",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"mustache": "^4.1.0",
|
"mustache": "^4.1.0",
|
||||||
@ -74,16 +77,16 @@
|
|||||||
"pug": "^3.0.0",
|
"pug": "^3.0.0",
|
||||||
"pug-plain-loader": "^1.1.0",
|
"pug-plain-loader": "^1.1.0",
|
||||||
"standard": "^16.0.3",
|
"standard": "^16.0.3",
|
||||||
"terser-webpack-plugin": "^5.0.3",
|
"terser-webpack-plugin": "^5.1.1",
|
||||||
"vue-clickaway": "^2.2.2",
|
"vue-clickaway": "^2.2.2",
|
||||||
"vue-loader": "^15.9.5",
|
"vue-loader": "^15.9.6",
|
||||||
"vue-resource": "^1.5.1",
|
"vue-resource": "^1.5.1",
|
||||||
"vue-router": "^3.4.9",
|
"vue-router": "^3.5.1",
|
||||||
"vue-template-compiler": "^2.6.12",
|
"vue-template-compiler": "^2.6.12",
|
||||||
"watch": "^1.0.2",
|
"watch": "^1.0.2",
|
||||||
"webpack": "^5.10.1",
|
"webpack": "^5.21.2",
|
||||||
"webpack-cli": "^4.2.0",
|
"webpack-cli": "^4.5.0",
|
||||||
"webpack-merge": "^5.7.0"
|
"webpack-merge": "^5.7.3"
|
||||||
},
|
},
|
||||||
"standard": {
|
"standard": {
|
||||||
"env": {
|
"env": {
|
||||||
|
@ -96,7 +96,7 @@ export function Hash (len) {
|
|||||||
return crypto.randomBytes(len).toString('hex')
|
return crypto.randomBytes(len).toString('hex')
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ppp - Posts Per Page; dcount - Post Count; page - number of current page */
|
/* ppp - Posts Per Page; dcount - Post Count; page - number of current page */
|
||||||
export function Pagination (ppp, dcount, page) {
|
export function Pagination (ppp, dcount, page) {
|
||||||
if (!ppp) ppp = 5
|
if (!ppp) ppp = 5
|
||||||
if (!dcount) return null
|
if (!dcount) return null
|
||||||
@ -545,7 +545,7 @@ export class User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Paymen {
|
export class Payment {
|
||||||
static async handleIPN (body) {
|
static async handleIPN (body) {
|
||||||
const sandboxed = body.test_ipn === '1'
|
const sandboxed = body.test_ipn === '1'
|
||||||
const url = 'https://ipnpb.' + (sandboxed ? 'sandbox.' : '') + 'paypal.com/cgi-bin/webscr'
|
const url = 'https://ipnpb.' + (sandboxed ? 'sandbox.' : '') + 'paypal.com/cgi-bin/webscr'
|
||||||
|
@ -12,7 +12,7 @@ function slugify (title) {
|
|||||||
return title.toLowerCase().replace(/\W/g, '-').substring(0, 32)
|
return title.toLowerCase().replace(/\W/g, '-').substring(0, 32)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cleanArticle (entry, shortenContent = false) {
|
async function cleanArticle (entry) {
|
||||||
const poster = await User.get(entry.user_id)
|
const poster = await User.get(entry.user_id)
|
||||||
const article = {
|
const article = {
|
||||||
id: entry.id,
|
id: entry.id,
|
||||||
|
@ -4,13 +4,14 @@ import {
|
|||||||
InvalidClient,
|
InvalidClient,
|
||||||
UnauthorizedClient,
|
UnauthorizedClient,
|
||||||
InvalidScope,
|
InvalidScope,
|
||||||
AccessDenied
|
AccessDenied,
|
||||||
|
Forbidden
|
||||||
} from '../error'
|
} from '../error'
|
||||||
import { data as dataResponse } from '../response'
|
import { data as dataResponse } from '../response'
|
||||||
import * as model from '../model'
|
import * as model from '../model'
|
||||||
import wrap from '../wrap'
|
import wrap from '../wrap'
|
||||||
|
|
||||||
export const authorization = wrap(async (req, res, next) => {
|
export const authorization = wrap(async (req, res) => {
|
||||||
let clientId = null
|
let clientId = null
|
||||||
let redirectUri = null
|
let redirectUri = null
|
||||||
let responseType = null
|
let responseType = null
|
||||||
@ -48,18 +49,18 @@ export const authorization = wrap(async (req, res, next) => {
|
|||||||
const responseTypes = responseType.split(' ')
|
const responseTypes = responseType.split(' ')
|
||||||
for (const i in responseTypes) {
|
for (const i in responseTypes) {
|
||||||
switch (responseTypes[i]) {
|
switch (responseTypes[i]) {
|
||||||
case 'code':
|
case 'code':
|
||||||
grantTypes.push('authorization_code')
|
grantTypes.push('authorization_code')
|
||||||
break
|
break
|
||||||
case 'token':
|
case 'token':
|
||||||
grantTypes.push('implicit')
|
grantTypes.push('implicit')
|
||||||
break
|
break
|
||||||
// case 'id_token':
|
// case 'id_token':
|
||||||
case 'none':
|
case 'none':
|
||||||
grantTypes.push(responseTypes[i])
|
grantTypes.push(responseTypes[i])
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedResponseType('Unknown response_type parameter passed')
|
throw new UnsupportedResponseType('Unknown response_type parameter passed')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,28 +148,28 @@ export const authorization = wrap(async (req, res, next) => {
|
|||||||
for (const i in grantTypes) {
|
for (const i in grantTypes) {
|
||||||
let data = null
|
let data = null
|
||||||
switch (grantTypes[i]) {
|
switch (grantTypes[i]) {
|
||||||
case 'authorization_code':
|
case 'authorization_code':
|
||||||
data = await model.code.create(model.user.getId(user), model.client.getId(client), scope, model.code.ttl)
|
data = await model.code.create(model.user.getId(user), model.client.getId(client), scope, model.code.ttl)
|
||||||
|
|
||||||
resObj = Object.assign({ code: data }, resObj)
|
resObj = Object.assign({ code: data }, resObj)
|
||||||
|
|
||||||
break
|
break
|
||||||
case 'implicit':
|
case 'implicit':
|
||||||
data = await model.accessToken.create(model.user.getId(user),
|
data = await model.accessToken.create(model.user.getId(user),
|
||||||
model.client.getId(client), scope, model.accessToken.ttl)
|
model.client.getId(client), scope, model.accessToken.ttl)
|
||||||
|
|
||||||
resObj = Object.assign({
|
resObj = Object.assign({
|
||||||
token_type: 'bearer',
|
token_type: 'bearer',
|
||||||
access_token: data,
|
access_token: data,
|
||||||
expires_in: req.oauth2.model.accessToken.ttl
|
expires_in: req.oauth2.model.accessToken.ttl
|
||||||
}, resObj)
|
}, resObj)
|
||||||
|
|
||||||
break
|
break
|
||||||
case 'none':
|
case 'none':
|
||||||
resObj = {}
|
resObj = {}
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedResponseType('Unknown response_type parameter passed')
|
throw new UnsupportedResponseType('Unknown response_type parameter passed')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export function decision (req, res, client, scope, user) {
|
export function decision (req, res, client, scope) {
|
||||||
res.render('authorization', { client: client, scope: scope })
|
res.render('authorization', { client: client, scope: scope })
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export * from './authorization';
|
export * from './authorization'
|
||||||
export * from './introspection';
|
export * from './introspection'
|
||||||
export * from './token';
|
export * from './token'
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import * as tokens from './tokens'
|
import * as tokens from './tokens'
|
||||||
import { InvalidRequest, InvalidClient, UnauthorizedClient } from '../error'
|
import {
|
||||||
|
InvalidRequest,
|
||||||
|
InvalidClient,
|
||||||
|
UnauthorizedClient,
|
||||||
|
UnsupportedGrantType
|
||||||
|
} from '../error'
|
||||||
import { data as dataResponse, error as errorResponse } from '../response'
|
import { data as dataResponse, error as errorResponse } from '../response'
|
||||||
import wrap from '../wrap'
|
import wrap from '../wrap'
|
||||||
|
|
||||||
@ -63,20 +68,20 @@ export const token = wrap(async (req, res) => {
|
|||||||
let evt
|
let evt
|
||||||
try {
|
try {
|
||||||
switch (grantType) {
|
switch (grantType) {
|
||||||
case 'authorization_code':
|
case 'authorization_code':
|
||||||
evt = await tokens.authorizationCode(req.oauth2, client, req.body.code, req.body.redirect_uri)
|
evt = await tokens.authorizationCode(req.oauth2, client, req.body.code, req.body.redirect_uri)
|
||||||
break
|
break
|
||||||
case 'password':
|
case 'password':
|
||||||
evt = await tokens.password(req.oauth2, client, req.body.username, req.body.password, req.body.scope)
|
evt = await tokens.password(req.oauth2, client, req.body.username, req.body.password, req.body.scope)
|
||||||
break
|
break
|
||||||
case 'client_credentials':
|
case 'client_credentials':
|
||||||
evt = await tokens.clientCredentials(req.oauth2, client, req.body.scope)
|
evt = await tokens.clientCredentials(req.oauth2, client, req.body.scope)
|
||||||
break
|
break
|
||||||
case 'refresh_token':
|
case 'refresh_token':
|
||||||
evt = await tokens.refreshToken(req.oauth2, client, req.body.refresh_token, req.body.scope)
|
evt = await tokens.refreshToken(req.oauth2, client, req.body.refresh_token, req.body.scope)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
throw new error.UnsupportedGrantType('Grant type does not match any supported type')
|
throw new UnsupportedGrantType('Grant type does not match any supported type')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt) {
|
if (evt) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { InvalidRequest, ServerError, InvalidGrant } from '../../error'
|
import { InvalidRequest, ServerError, InvalidGrant } from '../../error'
|
||||||
|
|
||||||
export async function authorizationCode (oauth2, client, providedCode, redirectUri) {
|
export async function authorizationCode (oauth2, client, providedCode) {
|
||||||
const respObj = {
|
const respObj = {
|
||||||
token_type: 'bearer'
|
token_type: 'bearer'
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { InvalidRequest, ServerError, InvalidGrant, InvalidClient } from '../../error'
|
import { InvalidRequest, ServerError, InvalidGrant, InvalidClient } from '../../error'
|
||||||
|
|
||||||
export async function refreshToken (oauth2, client, pRefreshToken, scope) {
|
export async function refreshToken (oauth2, client, pRefreshToken) {
|
||||||
let user = null
|
let user = null
|
||||||
let ttl = null
|
let ttl = null
|
||||||
let refreshToken = null
|
let refreshToken = null
|
||||||
|
@ -130,7 +130,7 @@ export const client = {
|
|||||||
|
|
||||||
export const code = {
|
export const code = {
|
||||||
ttl: config.oauth2.code_life,
|
ttl: config.oauth2.code_life,
|
||||||
create: async (userId, clientId, scope, ttl, special = false) => {
|
create: async (userId, clientId, scope, ttl) => {
|
||||||
const newCode = crypto.randomBytes(config.oauth2.token_length).toString('hex')
|
const newCode = crypto.randomBytes(config.oauth2.token_length).toString('hex')
|
||||||
const expr = new Date(Date.now() + ttl * 1000)
|
const expr = new Date(Date.now() + ttl * 1000)
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ apiRouter.post('/email', csrfVerify, wrap(async (req, res) => {
|
|||||||
res.jsonp(result)
|
res.jsonp(result)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
apiRouter.use((err, req, res, next) => {
|
apiRouter.use((err, req, res) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
return res.status(400).jsonp({ error: err.message })
|
return res.status(400).jsonp({ error: err.message })
|
||||||
})
|
})
|
||||||
|
@ -438,7 +438,7 @@ router.post('/avatar/gravatar', wrap(async (req, res, next) => {
|
|||||||
|
|
||||||
req.flash('message', { error: false, text: 'Success!' })
|
req.flash('message', { error: false, text: 'Success!' })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e)
|
||||||
req.flash('message', { error: true, text: 'Failed to use gravatar avatar.' })
|
req.flash('message', { error: true, text: 'Failed to use gravatar avatar.' })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ router.get('/donations/user', wrap(async (req, res, next) => {
|
|||||||
res.jsonp(contribs)
|
res.jsonp(contribs)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
router.get('/donations', wrap(async (req, res, next) => {
|
router.get('/donations', wrap(async (req, res) => {
|
||||||
let count = parseInt(req.query.count)
|
let count = parseInt(req.query.count)
|
||||||
if (isNaN(count)) {
|
if (isNaN(count)) {
|
||||||
count = 10
|
count = 10
|
||||||
@ -523,7 +523,7 @@ router.use((req, res) => {
|
|||||||
res.status(404).jsonp({ error: 'Not found' })
|
res.status(404).jsonp({ error: 'Not found' })
|
||||||
})
|
})
|
||||||
|
|
||||||
router.use((err, req, res, next) => {
|
router.use((err, req, res) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
res.jsonp({ error: 'Internal server error.' })
|
res.jsonp({ error: 'Internal server error.' })
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user