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",
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
|
||||
"@babel/register": "^7.12.10",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.12.13",
|
||||
"@babel/register": "^7.12.13",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"bluebird": "^3.7.2",
|
||||
"body-parser": "^1.19.0",
|
||||
"connect-redis": "^5.0.0",
|
||||
"connect-redis": "^5.1.0",
|
||||
"connect-session-knex": "^2.0.0",
|
||||
"email-templates": "^8.0.2",
|
||||
"email-templates": "^8.0.3",
|
||||
"express": "^4.17.1",
|
||||
"express-rate-limit": "^5.2.3",
|
||||
"express-rate-limit": "^5.2.5",
|
||||
"express-session": "^1.17.1",
|
||||
"feed": "^4.2.1",
|
||||
"fs-extra": "^9.0.1",
|
||||
"feed": "^4.2.2",
|
||||
"fs-extra": "^9.1.0",
|
||||
"gm": "^1.23.1",
|
||||
"knex": "^0.21.13",
|
||||
"json-web-token": "^3.2.0",
|
||||
"knex": "^0.21.17",
|
||||
"multiparty": "^4.2.2",
|
||||
"mysql": "^2.18.1",
|
||||
"nodemailer": "^6.4.17",
|
||||
"notp": "^2.0.3",
|
||||
"oauth-libre": "^0.9.17",
|
||||
"objection": "^2.2.3",
|
||||
"objection": "^2.2.14",
|
||||
"querystring-es3": "^0.2.1",
|
||||
"redis": "^3.0.2",
|
||||
"serve-favicon": "^2.5.0",
|
||||
@ -61,12 +62,14 @@
|
||||
"vue": "^2.6.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/preset-env": "^7.12.10",
|
||||
"@babel/core": "^7.12.13",
|
||||
"@babel/preset-env": "^7.12.13",
|
||||
"babel-loader": "^8.2.2",
|
||||
"bootstrap": "^4.5.3",
|
||||
"bootstrap": "^4.6.0",
|
||||
"concurrently": "^5.3.0",
|
||||
"eslint": "^7.19.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-vue": "^7.5.0",
|
||||
"jquery": "^3.5.1",
|
||||
"morgan": "^1.10.0",
|
||||
"mustache": "^4.1.0",
|
||||
@ -74,16 +77,16 @@
|
||||
"pug": "^3.0.0",
|
||||
"pug-plain-loader": "^1.1.0",
|
||||
"standard": "^16.0.3",
|
||||
"terser-webpack-plugin": "^5.0.3",
|
||||
"terser-webpack-plugin": "^5.1.1",
|
||||
"vue-clickaway": "^2.2.2",
|
||||
"vue-loader": "^15.9.5",
|
||||
"vue-loader": "^15.9.6",
|
||||
"vue-resource": "^1.5.1",
|
||||
"vue-router": "^3.4.9",
|
||||
"vue-router": "^3.5.1",
|
||||
"vue-template-compiler": "^2.6.12",
|
||||
"watch": "^1.0.2",
|
||||
"webpack": "^5.10.1",
|
||||
"webpack-cli": "^4.2.0",
|
||||
"webpack-merge": "^5.7.0"
|
||||
"webpack": "^5.21.2",
|
||||
"webpack-cli": "^4.5.0",
|
||||
"webpack-merge": "^5.7.3"
|
||||
},
|
||||
"standard": {
|
||||
"env": {
|
||||
|
@ -96,7 +96,7 @@ export function Hash (len) {
|
||||
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) {
|
||||
if (!ppp) ppp = 5
|
||||
if (!dcount) return null
|
||||
@ -545,7 +545,7 @@ export class User {
|
||||
}
|
||||
}
|
||||
|
||||
export class Paymen {
|
||||
export class Payment {
|
||||
static async handleIPN (body) {
|
||||
const sandboxed = body.test_ipn === '1'
|
||||
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)
|
||||
}
|
||||
|
||||
async function cleanArticle (entry, shortenContent = false) {
|
||||
async function cleanArticle (entry) {
|
||||
const poster = await User.get(entry.user_id)
|
||||
const article = {
|
||||
id: entry.id,
|
||||
|
@ -4,13 +4,14 @@ import {
|
||||
InvalidClient,
|
||||
UnauthorizedClient,
|
||||
InvalidScope,
|
||||
AccessDenied
|
||||
AccessDenied,
|
||||
Forbidden
|
||||
} from '../error'
|
||||
import { data as dataResponse } from '../response'
|
||||
import * as model from '../model'
|
||||
import wrap from '../wrap'
|
||||
|
||||
export const authorization = wrap(async (req, res, next) => {
|
||||
export const authorization = wrap(async (req, res) => {
|
||||
let clientId = null
|
||||
let redirectUri = null
|
||||
let responseType = null
|
||||
@ -48,18 +49,18 @@ export const authorization = wrap(async (req, res, next) => {
|
||||
const responseTypes = responseType.split(' ')
|
||||
for (const i in responseTypes) {
|
||||
switch (responseTypes[i]) {
|
||||
case 'code':
|
||||
grantTypes.push('authorization_code')
|
||||
break
|
||||
case 'token':
|
||||
grantTypes.push('implicit')
|
||||
break
|
||||
case 'code':
|
||||
grantTypes.push('authorization_code')
|
||||
break
|
||||
case 'token':
|
||||
grantTypes.push('implicit')
|
||||
break
|
||||
// case 'id_token':
|
||||
case 'none':
|
||||
grantTypes.push(responseTypes[i])
|
||||
break
|
||||
default:
|
||||
throw new UnsupportedResponseType('Unknown response_type parameter passed')
|
||||
case 'none':
|
||||
grantTypes.push(responseTypes[i])
|
||||
break
|
||||
default:
|
||||
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) {
|
||||
let data = null
|
||||
switch (grantTypes[i]) {
|
||||
case 'authorization_code':
|
||||
data = await model.code.create(model.user.getId(user), model.client.getId(client), scope, model.code.ttl)
|
||||
case 'authorization_code':
|
||||
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
|
||||
case 'implicit':
|
||||
data = await model.accessToken.create(model.user.getId(user),
|
||||
model.client.getId(client), scope, model.accessToken.ttl)
|
||||
break
|
||||
case 'implicit':
|
||||
data = await model.accessToken.create(model.user.getId(user),
|
||||
model.client.getId(client), scope, model.accessToken.ttl)
|
||||
|
||||
resObj = Object.assign({
|
||||
token_type: 'bearer',
|
||||
access_token: data,
|
||||
expires_in: req.oauth2.model.accessToken.ttl
|
||||
}, resObj)
|
||||
resObj = Object.assign({
|
||||
token_type: 'bearer',
|
||||
access_token: data,
|
||||
expires_in: req.oauth2.model.accessToken.ttl
|
||||
}, resObj)
|
||||
|
||||
break
|
||||
case 'none':
|
||||
resObj = {}
|
||||
break
|
||||
default:
|
||||
throw new UnsupportedResponseType('Unknown response_type parameter passed')
|
||||
break
|
||||
case 'none':
|
||||
resObj = {}
|
||||
break
|
||||
default:
|
||||
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 })
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
export * from './authorization';
|
||||
export * from './introspection';
|
||||
export * from './token';
|
||||
export * from './authorization'
|
||||
export * from './introspection'
|
||||
export * from './token'
|
||||
|
@ -1,5 +1,10 @@
|
||||
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 wrap from '../wrap'
|
||||
|
||||
@ -63,20 +68,20 @@ export const token = wrap(async (req, res) => {
|
||||
let evt
|
||||
try {
|
||||
switch (grantType) {
|
||||
case 'authorization_code':
|
||||
evt = await tokens.authorizationCode(req.oauth2, client, req.body.code, req.body.redirect_uri)
|
||||
break
|
||||
case 'password':
|
||||
evt = await tokens.password(req.oauth2, client, req.body.username, req.body.password, req.body.scope)
|
||||
break
|
||||
case 'client_credentials':
|
||||
evt = await tokens.clientCredentials(req.oauth2, client, req.body.scope)
|
||||
break
|
||||
case 'refresh_token':
|
||||
evt = await tokens.refreshToken(req.oauth2, client, req.body.refresh_token, req.body.scope)
|
||||
break
|
||||
default:
|
||||
throw new error.UnsupportedGrantType('Grant type does not match any supported type')
|
||||
case 'authorization_code':
|
||||
evt = await tokens.authorizationCode(req.oauth2, client, req.body.code, req.body.redirect_uri)
|
||||
break
|
||||
case 'password':
|
||||
evt = await tokens.password(req.oauth2, client, req.body.username, req.body.password, req.body.scope)
|
||||
break
|
||||
case 'client_credentials':
|
||||
evt = await tokens.clientCredentials(req.oauth2, client, req.body.scope)
|
||||
break
|
||||
case 'refresh_token':
|
||||
evt = await tokens.refreshToken(req.oauth2, client, req.body.refresh_token, req.body.scope)
|
||||
break
|
||||
default:
|
||||
throw new UnsupportedGrantType('Grant type does not match any supported type')
|
||||
}
|
||||
|
||||
if (evt) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { InvalidRequest, ServerError, InvalidGrant } from '../../error'
|
||||
|
||||
export async function authorizationCode (oauth2, client, providedCode, redirectUri) {
|
||||
export async function authorizationCode (oauth2, client, providedCode) {
|
||||
const respObj = {
|
||||
token_type: 'bearer'
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
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 ttl = null
|
||||
let refreshToken = null
|
||||
|
@ -130,7 +130,7 @@ export const client = {
|
||||
|
||||
export const code = {
|
||||
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 expr = new Date(Date.now() + ttl * 1000)
|
||||
|
||||
|
@ -304,7 +304,7 @@ apiRouter.post('/email', csrfVerify, wrap(async (req, res) => {
|
||||
res.jsonp(result)
|
||||
}))
|
||||
|
||||
apiRouter.use((err, req, res, next) => {
|
||||
apiRouter.use((err, req, res) => {
|
||||
console.error(err)
|
||||
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!' })
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
console.error(e)
|
||||
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)
|
||||
}))
|
||||
|
||||
router.get('/donations', wrap(async (req, res, next) => {
|
||||
router.get('/donations', wrap(async (req, res) => {
|
||||
let count = parseInt(req.query.count)
|
||||
if (isNaN(count)) {
|
||||
count = 10
|
||||
@ -523,7 +523,7 @@ router.use((req, res) => {
|
||||
res.status(404).jsonp({ error: 'Not found' })
|
||||
})
|
||||
|
||||
router.use((err, req, res, next) => {
|
||||
router.use((err, req, res) => {
|
||||
console.error(err)
|
||||
res.jsonp({ error: 'Internal server error.' })
|
||||
})
|
||||
|
Reference in New Issue
Block a user