cleanup & upgrade

This commit is contained in:
srgooglo 2021-11-16 17:51:00 +01:00
parent 784f97b28c
commit 8ac46f1be5
63 changed files with 223 additions and 24139 deletions

3
.corenode Executable file
View File

@ -0,0 +1,3 @@
{
"version": "0.13.0"
}

View File

@ -1,16 +0,0 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
[Makefile]
indent_style = tab

2
.env
View File

@ -1,2 +0,0 @@
UMI_UI=false
NODE_ENV=development

View File

@ -1,11 +0,0 @@
{
"version": "0.12.8",
"devRuntime": {
"headPackage": "ragestudio"
},
"runtime": {
"src": "/src",
"UUID": "C8mVSr-4nmPp2-pr5Vrz-CU4kg4",
"stage": "alpha"
}
}

View File

@ -1,8 +0,0 @@
**/*.md
**/*.svg
**/*.ejs
**/*.html
package.json
.umi
.umi-production
.umi-test

View File

@ -1,11 +0,0 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 80,
"overrides": [
{
"files": ".prettierrc",
"options": { "parser": "json" }
}
]
}

View File

@ -1,40 +0,0 @@
# Callback Codes
## 000 - 100 > Runtime
| code | type |
|--|--|
| | |
## 100 - 200 > Operations results
| code | type | description
|--|--|--|
| 100 | successful operation | |
| 110 | failed operation | unhandled |
| 115 | invalid operation | |
> API/WS Requests callbacks codes
| | | |
|--|--|--|
| 130 | needs auth | |
| 131 | no user send | |
| 132 | no id_user send | |
| 133 | no password send | |
| 134 | no token send | |
| 135 | no server_key send | |
| 136 | no payload send | |
> API/WS Invalid requests
| | | |
|--|--|--|
| 140 | invalid auth |
| 141 | invalid/notfound user |
| 142 | invalid/notfound id_user |
| 143 | invalid password |
| 144 | invalid/notfound token |
| 145 | invalid server_key | fails when the sended server_key is not valid |
| 146 | invalid payload | bad typeof / missing parameter / bad parameter |
## 200 - 300 > Permissions

4
dumps.log Normal file
View File

@ -0,0 +1,4 @@
> 2021-11-16T16:47:12.984Z (anonymous)[info] : sync versions on package.json [/home/srgooglo/repos/comty/packages/comty] > /home/srgooglo/repos/comty/packages/comty/package.json
> 2021-11-16T16:47:12.985Z (anonymous)[info] : sync versions on package.json [/home/srgooglo/repos/comty/packages/server] > /home/srgooglo/repos/comty/packages/server/package.json
> 2021-11-16T16:47:12.985Z (anonymous)[info] : sync versions on package.json [/home/srgooglo/repos/comty/packages/wrapper] > /home/srgooglo/repos/comty/packages/wrapper/package.json
> 2021-11-16T16:47:12.986Z (anonymous)[info] : sync versions on package.json [/home/srgooglo/repos/comty] > /home/srgooglo/repos/comty/package.json

4170
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,27 +6,8 @@
"workspaces": [
"packages"
],
"lint-staged": {
"*.{js,jsx,less,md,json}": [
"prettier --write"
],
"*.ts?(x)": [
"prettier --parser=typescript --write"
]
},
"scripts": {
"postinstall": "cd ./packages/comty && npm i",
"start": "cd ./packages/comty && npm start",
"update:deps": "yarn upgrade-interactive --latest"
},
"devDependencies": {
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@types/node": "^14.14.20",
"concurrently": "^5.3.0",
"cross-env": "^7.0.3",
"jsdoc": "^3.6.5"
},
"dependencies": {
"@ragestudio/nodecorejs": "^0.15.1"
}
"corenode": "^0.28.26"
},
"version": "0.13.0"
}

View File

@ -1 +0,0 @@
# @undefined/comty-electron

View File

@ -1,12 +0,0 @@
appId: com.example.bruh
productName: Bruh
copyright: Copyright © Bruh
directories:
output: dist
buildResources: resources
files:
- from: .
filter:
- package.json
- app
publish: null

View File

@ -1,3 +0,0 @@
const Config = require('electron-config')
module.exports = new Config({ name: 'config' });

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

View File

@ -1,272 +0,0 @@
const {
app,
BrowserWindow,
ipcMain,
Tray,
Menu,
MenuItem,
dialog,
shell,
screen,
BrowserView,
systemPreferences,
Notification,
globalhortcut
} = require('electron')
const path = require('path')
// const { spawn, exec } = require('child_process')
// const { autoUpdater } = require('electron-updater')
const log = require('electron-log');
const packagejson = require('../../../package.json')
const is = require('electron-is')
const waitOn = require('wait-on');
const { getDoNotDisturb } = require('electron-notification-state');
const RuntimeConfig = require("../../comty/config");
let app_path = is.dev()? "localhost:8000" : `file://${path.join(__dirname, '..', 'renderer')}/index.html`;
let mainWindow;
let tray;
let watcher;
// This gets rid of this: https://github.com/electron/electron/issues/13186
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true
// app.commandLine.appendSwitch("disable-web-security")
//app.commandLine.appendSwitch('disable-gpu-vsync=gpu')
app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors')
const gotTheLock = app.requestSingleInstanceLock()
const notifySupport = Notification.isSupported()
const isNotDisturb = getDoNotDisturb()
// Prevent multiple instances
if (!gotTheLock) {
app.quit()
}
function relaunchApp(){
mainWindow.close()
app.relaunch()
}
function resumeApp(){
if (mainWindow) {
mainWindow.show()
mainWindow.focus()
}else{
createWindow()
}
}
function notify(params) {
if(!notifySupport || !params) return false
let options = {
title: "",
body: "",
icon: null,
timeoutType: "default"
}
const keys = Object.keys(params)
const values = Object.values(params)
for (let i = 0; i < keys.length; i++) {
options[keys[i]] = values[i]
}
new Notification(options).show()
}
async function __init() {
createWindow()
}
function createWindow() {
mainWindow = new BrowserWindow({
title: packagejson.title,
icon: path.join(__dirname, './icon.png'),
width: 1100,
height: 700,
minWidth: 1256,
minHeight: 755,
show: true,
frame: false,
transparent: false,
hasShadow: true,
//webgl: true,
visualEffectState: "followWindow",
backgroundColor: '#00ffffff',
webPreferences: {
//enableRemoteModule: true,
enableBlinkFeatures: true,
experimentalFeatures: true,
nodeIntegration: true,
// Disable in dev since I think hot reload is messing with it
webSecurity: !is.dev()
}
})
if (is.dev()) {
app.commandLine.appendSwitch('remote-debugging-port', '9222')
globalhortcut.register('CommandOrControl+R', () => {
mainWindow.reload()
})
globalhortcut.register('F5', () => {
mainWindow.reload()
})
}
mainWindow.webContents.session.webRequest.onHeadersReceived(
{
urls: ['http://*/*', 'https://*/*']
},
(details, callback) => {
delete details.responseHeaders['Access-Control-Allow-Origin']
delete details.responseHeaders['access-control-allow-origin']
if (details.url.includes('www.google-analytics.com')) {
details.responseHeaders['Access-Control-Allow-Origin'] = [ app_path ]
} else {
details.responseHeaders['Access-Control-Allow-Origin'] = ['*']
}
callback({
cancel: false,
responseHeaders: details.responseHeaders
})
}
)
tray = new Tray(
is.dev()
? path.join(__dirname, './icon.png')
: path.join(__dirname, '../build/icon.png')
);
const trayMenuTemplate = [
{
label: '🧰 Open DevTools',
click: () => mainWindow.webContents.openDevTools()
},
{
label: '🔄 Relaunch',
click: () => {
relaunchApp()
}
},
{
label: '🛑 Quit',
click: () => app.quit()
}
];
tray.setContextMenu(Menu.buildFromTemplate(trayMenuTemplate))
tray.setToolTip(RuntimeConfig.siteName)
tray.on('double-click', () => resumeApp())
mainWindow.loadURL(app_path)
mainWindow.focus()
if (is.dev()) {
mainWindow.webContents.openDevTools()
}
// const handleRedirect = (e, url) => {
// if (url !== mainWindow.webContents.getURL()) {
// e.preventDefault()
// shell.openExternal(url)
// }
// };
// mainWindow.webContents.on('will-navigate', handleRedirect)
// mainWindow.webContents.on('new-window', handleRedirect)
}
app.on('ready', () => {
if (is.dev()) {
loadWindow = new BrowserWindow({
width: 700,
height: 500,
frame: false,
resizable: false,
center: true,
transparent: true,
backgroundColor: "#00000000",
});
loadWindow.loadURL(`file://${__dirname}/statics/loading_dev.html`)
notify({title: "Starting development server..."})
waitOn({ resources: [app_path] }, function (err) {
if (err) {
return log.log(err)
}
__init()
loadWindow.close()
})
}else{
__init()
}
})
app.on('window-all-closed', () => {
mainWindow = null;
})
app.on('before-quit', async () => {
mainWindow.removeAllListeners('close');
mainWindow = null;
})
ipcMain.handle('update-progress-bar', (event, p) => {
mainWindow.setProgressBar(p);
})
ipcMain.handle('hide-window', () => {
if (mainWindow) {
mainWindow.hide();
}
})
ipcMain.handle('show-window', () => {
if (mainWindow) {
mainWindow.show();
mainWindow.focus();
}
})
ipcMain.handle('min-max-window', () => {
if (mainWindow.isMaximized()) {
mainWindow.unmaximize();
} else if (mainWindow.maximizable) {
mainWindow.maximize();
}
})
ipcMain.handle('getSystemPreferences', () => {
return systemPreferences
})
ipcMain.handle('minimize-window', () => {
mainWindow.minimize();
})
ipcMain.handle('quit-app', () => {
app.quit();
})
ipcMain.handle('open-devtools', () => {
mainWindow.webContents.openDevTools({ mode: 'undocked' });
})
ipcMain.handle('appRelaunch', () => {
relaunchApp()
})
ipcMain.handle('app_notify', (event, payload) => {
notify(payload)
})
ipcMain.handle('contextualMenu', (event, payload) => {
contextualMenu(payload)
})
ipcMain.handle('inspectElement', (event, payload) => {
mainWindow.inspectElement(payload.x, payload.y)
})

View File

@ -1,112 +0,0 @@
body {
background-color: transparent;
border-radius: 12px;
font-family: 'Alata', sans-serif;
width: 100vw;
height: 100vh;
overflow: hidden;
user-select: none;
-webkit-app-region: drag;
}
.wrapper {
position: absolute;
top: 0;
right: 0;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
background-color: #efefef;
color: #2d2d2d;
border-radius: 12px;
text-align: center;
width: 100%;
height: 100%;
}
.bouncy-logo{
width: 100%;
height: auto;
margin: auto;
}
.bouncy-logo .ball {
height: auto;
width: 100%;
transform: translate(-10px, 0);
}
.bouncy-logo .ball svg {
width: 200px;
height: 200px;
margin: auto;
-webkit-animation-direction: alternate;
-webkit-animation-duration: 1s;
-webkit-animation-name: my-bounce;
-webkit-animation-iteration-count: infinite;
animation-direction: alternate;
animation-duration: 1s;
animation-name: my-bounce;
animation-iteration-count: infinite;
}
.shadow{
width: 100%;
height: auto;
}
.bouncy-logo .ball-shadow {
margin: auto;
background: radial-gradient(50% 50%, rgba(204, 204, 204, 0.45) 0%, transparent 100%);
height: 50px;
width: 200px;
-webkit-animation-direction: alternate;
-webkit-animation-duration: 1s;
-webkit-animation-name: my-grow;
-webkit-animation-iteration-count: infinite;
animation-direction: alternate;
animation-duration: 1s;
animation-name: my-grow;
animation-iteration-count: infinite;
}
@-webkit-keyframes my-grow {
from {
width: 200px;
height: 50px;
}
to {
width: 150px;
height: 10px;
}
}
@keyframes my-grow {
from {
width: 200px;
height: 50px;
}
to {
width: 150px;
height: 10px;
}
}
@-webkit-keyframes my-bounce {
from {
top: 0;
}
to {
top: 10%;
}
}
@keyframes my-bounce {
from {
top: 0;
}
to {
top: 10%;
}
}

View File

@ -1,23 +0,0 @@
<html>
<link rel="stylesheet" href="./loading.css">
<link href="https://fonts.googleapis.com/css2?family=Alata&display=swap" rel="stylesheet">
<body>
<div class="wrapper">
<div class="bouncy-logo">
<div class="ball">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 120">
<path
d="M77.55,29.69,92,18.78a1.42,1.42,0,0,0,.25-2,39.2,39.2,0,0,0-56.31-4.21A38.05,38.05,0,0,0,23.23,42a38.09,38.09,0,0,0,3.62,15.1A38.65,38.65,0,0,0,37.8,70.84,39.46,39.46,0,0,0,83.37,73a38.26,38.26,0,0,0,8.41-7.4,1.41,1.41,0,0,0-.23-2L77.65,53a1.43,1.43,0,0,0-1.9.15A17,17,0,0,1,72.55,56a17.75,17.75,0,0,1-9,2.88c-8.32.31-13.62-5.69-14-6.13a17.68,17.68,0,0,1-4.13-10.13,17.93,17.93,0,0,1,4.56-13A17.46,17.46,0,0,1,71.7,26.34a17.3,17.3,0,0,1,4,3.2A1.41,1.41,0,0,0,77.55,29.69Z"
style="fill: rgba(51, 51, 51, 0.45); backdrop-filter: blur(2px);"
/>
<path
d="M13,63.17a2.77,2.77,0,0,1,3.75,1.43A48.38,48.38,0,0,0,32.07,84.53,48.83,48.83,0,0,0,52.34,93.3,47.37,47.37,0,0,0,92.57,81.8a2.77,2.77,0,0,1,4,.3l6.23,7.4a2.79,2.79,0,0,1-.21,3.83,63.83,63.83,0,0,1-6,5,62.21,62.21,0,0,1-7.44,4.7A60.84,60.84,0,0,1,77,108a62.3,62.3,0,0,1-27,1.51A62.51,62.51,0,0,1,40.18,107,61.5,61.5,0,0,1,20.1,95.69,61.73,61.73,0,0,1,2.41,71a2.79,2.79,0,0,1,1.42-3.55Z"
style="fill: rgba(51, 51, 51, 0.45); backdrop-filter: blur(2px);"
/>
</svg>
</div>
<div class="shadow"><div class="ball-shadow"></div></div>
</div>
</div>
</body>
</html>

View File

@ -1,24 +0,0 @@
<html>
<link rel="stylesheet" href="./loading.css">
<link href="https://fonts.googleapis.com/css2?family=Alata&display=swap" rel="stylesheet">
<body>
<div class="wrapper">
<div class="bouncy-logo">
<div class="ball">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 120">
<path
d="M77.55,29.69,92,18.78a1.42,1.42,0,0,0,.25-2,39.2,39.2,0,0,0-56.31-4.21A38.05,38.05,0,0,0,23.23,42a38.09,38.09,0,0,0,3.62,15.1A38.65,38.65,0,0,0,37.8,70.84,39.46,39.46,0,0,0,83.37,73a38.26,38.26,0,0,0,8.41-7.4,1.41,1.41,0,0,0-.23-2L77.65,53a1.43,1.43,0,0,0-1.9.15A17,17,0,0,1,72.55,56a17.75,17.75,0,0,1-9,2.88c-8.32.31-13.62-5.69-14-6.13a17.68,17.68,0,0,1-4.13-10.13,17.93,17.93,0,0,1,4.56-13A17.46,17.46,0,0,1,71.7,26.34a17.3,17.3,0,0,1,4,3.2A1.41,1.41,0,0,0,77.55,29.69Z"
style="fill: rgba(51, 51, 51, 0.45); backdrop-filter: blur(2px);"
/>
<path
d="M13,63.17a2.77,2.77,0,0,1,3.75,1.43A48.38,48.38,0,0,0,32.07,84.53,48.83,48.83,0,0,0,52.34,93.3,47.37,47.37,0,0,0,92.57,81.8a2.77,2.77,0,0,1,4,.3l6.23,7.4a2.79,2.79,0,0,1-.21,3.83,63.83,63.83,0,0,1-6,5,62.21,62.21,0,0,1-7.44,4.7A60.84,60.84,0,0,1,77,108a62.3,62.3,0,0,1-27,1.51A62.51,62.51,0,0,1,40.18,107,61.5,61.5,0,0,1,20.1,95.69,61.73,61.73,0,0,1,2.41,71a2.79,2.79,0,0,1,1.42-3.55Z"
style="fill: rgba(51, 51, 51, 0.45); backdrop-filter: blur(2px);"
/>
</svg>
</div>
<div class="shadow"><div class="ball-shadow"></div></div>
</div>
<h2> Starting the development server... </h2>
</div>
</body>
</html>

View File

@ -1,18 +0,0 @@
{
"name": "@ragestudio/comty-electron",
"version": null,
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist",
"src"
],
"repository": {
"type": "git",
"url": false
},
"license": "MIT",
"publishConfig": {
"access": "public"
}
}

View File

@ -1,55 +0,0 @@
import config from './config/index.js'
import { defineConfig } from 'umi'
import { resolve } from 'path'
let configs = {
hash: true,
title: config.app.siteName ?? null,
dynamicImport: {
loading: 'components/Loader',
},
targets: { ie: 11 },
dva: { immer: true, hmr: true },
ignoreMomentLocale: true,
mountElementId: "root",
nodeModulesTransform: {
type: 'none',
},
exportStatic: {
dynamicRoot: false,
},
// ssr: {
// devServerRender: true,
// },
alias: {
antd: resolve(__dirname, './node_modules/antd'),
api: resolve(__dirname, './node_modules/@ragestudio/nodecore-api-lib/src'),
plugins: resolve(__dirname, './plugins'),
schemas: resolve(__dirname, './schemas'),
debuggers: resolve(__dirname, './src/debuggers'),
core: resolve(__dirname, './src/core'),
theme: resolve(__dirname, './src/theme'),
config: resolve(__dirname, './config'),
pages: resolve(__dirname, './src/pages'),
components: resolve(__dirname, './src/components'),
models: resolve(__dirname, './src/models'),
node_modules: resolve(__dirname, './node_modules')
},
extraBabelPlugins: [
[
'import',
{
libraryName: 'lodash',
libraryDirectory: '',
camel2DashComponentName: false,
},
'lodash',
],
],
}
if (typeof(config.runtime) !== "undefined") {
configs = { ...configs, ...config.runtime }
}
export default defineConfig(configs)

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1,11 +0,0 @@
export default {
auth_server: 'POST /auth_server',
auth: 'POST /auth',
sessions: 'POST /sessions',
posts: 'POST /posts',
post_actions: 'POST /post-actions',
get_data: 'POST /get_user_data',
basicData: 'POST /early_user',
profileData: 'POST /get-user-data-username'
};

View File

@ -1,10 +0,0 @@
module.exports = {
SESSION_INVALID: "DISRUPT",
OVERLAY_BADPOSITION: "IGNORE",
INTERNAL_PROCESS_FAILED: "CRITICAL",
INVALID_DATA: "DISRUPT",
INVALID_PROPS: "IGNORE",
INVALID_INDEX: "IGNORE",
MISSING_REQUIRED_PAYLOAD: "IGNORE",
}

View File

@ -1,10 +0,0 @@
module.exports = {
SESSION_INVALID: `This session is not valid`,
OVERLAY_BADPOSITION: `Invalid overlay position! Was expected "primary" or "secondary"`,
INTERNAL_PROCESS_FAILED: `An internal error has occurred! `,
INVALID_DATA: `A function has been executed with invalid data and has caused an error!`,
INVALID_PROPS: `Some props failed!`,
INVALID_INDEX: "This request could not be indexed",
MISSING_REQUIRED_PAYLOAD: "Error has occurred because the function needed data that does not exist"
}

View File

@ -1,34 +0,0 @@
import { notification, message } from 'antd'
import { FieldTimeOutlined } from 'components/Icons'
import errStrings from 'config/handlers/errToStrings.js'
import errNumbers from 'config/handlers/numToError.js'
import errFlags from 'config/handlers/errToFlag.js'
export default {
SESSION_INVALID: (payload) => {
notification.error({
message: payload.msg ?? 'Hey',
icon: <FieldTimeOutlined />,
description: errStrings[payload.out] ?? "This session is not valid",
placement: 'bottomLeft',
})
},
OVERLAY_BADPOSITION: () => {
},
INTERNAL_PROCESS_FAILED: () => {
},
INVALID_DATA: () => {
},
INVALID_PROPS: () => {
},
MISSING_REQUIRED_PAYLOAD: () => {
},
INVALID_INDEX: () => {
}
}

View File

@ -1,10 +0,0 @@
module.exports = {
403: "SESSION_INVALID",
210: "OVERLAY_BADPOSITION",
110: "INTERNAL_PROCESS_FAILED",
120: "INVALID_DATA",
130: "INVALID_PROPS",
140: "INVALID_INDEX",
150: "MISSING_REQUIRED_PAYLOAD"
}

View File

@ -1,7 +0,0 @@
module.exports = {
unsplash_key: 'slrHmuo9FEJajV4xvWl38TUhbib6BhhGI4VIZ1-cqnw',
unsplash_secret: 'dh3UlgLTdunO7a_l_iKjotXbz0xB7w5EuDIBU8Pa8pA',
g_recaptcha_key: '6Lc55uUUAAAAAEIACMVf3BUzAJSNCmI3RrjEirZ6',
g_recaptcha_secret: '6Lc55uUUAAAAAOP4OgUa5DpqJC-70t53AmW0lyYf',
server_key: 'f706b0a535b6c2d36545c4137a0a3a26853ea8b5-1223c9ba7923152cae28e5a2e7501b2b-50600768',
};

File diff suppressed because it is too large Load Diff

View File

@ -1,67 +1,45 @@
{
"name": "comty",
"version": "0.12.8",
"version": "0.13.0",
"description": "An prototype of a social network",
"author": "RageStudio",
"license": "LGPL-2.1",
"types": "index.d.ts",
"scripts": {
"start": "umi dev",
"build": "umi build",
"update:deps": "yarn upgrade-interactive --latest"
"dev": "evite dev"
},
"dependencies": {
"@icons-pack/react-simple-icons": "^3.8.0",
"@lingui/react": "^3.3.0",
"@types/lodash": "4.14.168",
"@umijs/preset-react": "1.8.7",
"antd": "4.15.5",
"axios": "^0.21.1",
"chart.js": "^2.9.4",
"classnames": "^2.2.6",
"colors": "^1.4.0",
"concat-stream": "^2.0.0",
"cookie_js": "^1.4.0",
"cryptr": "^6.0.2",
"dotenv": "^8.2.0",
"timeago.js": "^4.0.2",
"@ant-design/icons": "^4.7.0",
"@corenode/utils": "^0.28.26",
"@react-pdf/renderer": "^1.6.17",
"antd": "^4.17.0",
"chart.js": "^3.5.1",
"classnames": "^2.3.1",
"corenode": "^0.28.26",
"dicebar_lib": "^1.0.0",
"enquire-js": "^0.2.1",
"evite": "^0.8.8",
"faye": "^1.4.0",
"feather-reactjs": "^2.0.13",
"howler": "^2.2.1",
"html2canvas": "^1.0.0-rc.7",
"jsonwebtoken": "^8.5.1",
"fuse.js": "^6.4.6",
"hls.js": "^1.0.12",
"howler": "^2.2.3",
"js-cookie": "^2.2.1",
"less": "^4.1.2",
"less-vars-to-js": "^1.3.0",
"localforage": "^1.7.4",
"lodash": "^4.17.21",
"moment": "^2.28.0",
"path-to-regexp": "^6.1.0",
"platform": "^1.3.6",
"react-animations": "^1.0.0",
"linebridge": "^0.8.4",
"moment": "^2.29.1",
"mpegts.js": "^1.6.10",
"plyr": "^3.6.9",
"react-beautiful-dnd": "^13.1.0",
"react-chartjs-2": "^3.2.0",
"react-color": "^2.19.3",
"react-dazzle": "^1.4.0",
"react-draggable": "^4.4.3",
"react-emoji": "^0.5.0",
"react-google-recaptcha": "^2.0.1",
"react-helmet": "^6.1.0",
"react-linkify": "^1.0.0-alpha",
"react-perfect-scrollbar": "^1.5.8",
"react-redux": "^7.2.2",
"react-resizable": "^1.11.0",
"react-icons": "^4.3.1",
"react-json-view": "^1.21.3",
"react-qr-reader": "^2.2.1",
"react-reveal": "^1.2.2",
"react-rnd": "^10.2.3",
"react-virtualized": "^9.21.2",
"request": "^2.88.2",
"socket.io-client": "^3.0.4",
"stack-trace": "0.0.10",
"store": "^2.0.12",
"timeago.js": "^4.0.2"
},
"devDependencies": {
"@lingui/babel-preset-react": "^2.9.2",
"@lingui/cli": "^3.3.0",
"@lingui/loader": "^3.3.0",
"@types/node": "^14.14.20",
"concurrently": "^5.3.0",
"cross-env": "^7.0.3",
"umi": "3.4.20"
"react-rnd": "^10.3.5",
"socket.io-client": "^4.2.0"
}
}

View File

@ -1,21 +0,0 @@
const http = require('http')
const vm = require("vm")
const concat = require("concat-stream")
const async = require("async")
export function http_require(url, callback) {
http.get(url, (res) => {
res.setEncoding('utf8')
res.pipe(concat({encoding: 'string'}, function(data) {
callback(null, vm.runInThisContext(data))
}))
})
}
export function usePlugins(array, callback){
async.map(array, http_require, function(err, results) {
if(callback){
callback(err, results)
}
})
}

View File

@ -36,7 +36,7 @@ const createTextArea = (): HTMLTextAreaElement => {
}
export const clipboard = {
copyText: (data:String) => {
copyText: (data: String) => {
if (typeof (data) !== "string") {
return false
}
@ -49,7 +49,7 @@ export const clipboard = {
return false
}
},
readText: (data:String) => {
readText: (data: String) => {
if (typeof (data) !== "string") {
return false
}

View File

@ -1,25 +0,0 @@
import localforage from 'localforage'
import { package_json } from 'core'
// Dynamic secure data container processor
export class DynamicSDCP {
constructor(props){
if(props){
this.props = props
}
this.instanceConfig = {
name: props.name? props.name : `dynamicSDCP_${Math.random().toFixed()}`,
driver : localforage.WEBSQL, // Force WebSQL; same as using setDriver()
version : 1.0,
size : 4980736, // Size of database, in bytes. WebSQL-only for now.
storeName : package_json.UUID, // Should be alphanumeric, with underscores.
}
localforage.config(this.instanceConfig)
this.instance = localforage.createInstance(this.instanceConfig)
}
useInstance(){
console.log('Using ', this.instance)
}
}

View File

@ -1,74 +0,0 @@
import { ui } from 'core/libs'
import { verbosity } from '@nodecorejs/utils'
import errStrings from 'config/handlers/errToStrings.js'
import errNumbers from 'config/handlers/numToError.js'
import errFlags from 'config/handlers/errToFlag.js'
import flagToBehavior from 'config/handlers/flagToBehavior.js'
const flagToString = {
CRITICAL: "An critical exception",
DISRUPT: "An wild error appears!",
IGNORE: "Warning"
}
export function notifyErrorHandler(params) {
if (!params) {
return false
}
ui.notify.open({
message: flagToString[params.flag] ?? "Unexpected Error",
description:
<div style={{ display: 'flex', flexDirection: 'column', margin: 'auto', height: "auto" }}>
<div style={{ margin: '10px 0' }}> {params.msg ?? "No exception message"} </div>
<div> {errStrings[params.out] ?? "Unhandled Exception"} | { params.out?? "UNDEFINED_KEY" } </div>
</div>,
})
}
export function ErrorHandler(payload, callback){
if (!payload) {
return false
}
const flags = ["CRITICAL", "DISRUPT", "IGNORE"]
let flag = null
let out = null
const { msg, outFlag, code } = payload
if (!out && code != null) { // This give priority to resolve with `code` than `outFlag`
out = errNumbers[code]
}
if (!out && outFlag != null ) {
out = outFlag
}
verbosity.log(msg?? "unhandled message", {type: "error"})
if (out && typeof(errStrings[out]) !== "undefined") {
flag = errFlags[out]
}else{
console.log("(Aborted) no out key | or invalid flag => ", out)
return false
}
switch (flag) {
case flags[0]:
notifyErrorHandler({ msg, out, flag })
flagToBehavior[out]({ msg, out, flag, code })
return false
case flags[1]:
flagToBehavior[out]({ msg, out, flag, code })
return false
case flags[2]:
flagToBehavior[out]({ msg, out, flag, code })
return false
default:
console.log('Invalid FLAG')
break;
}
}
export default ErrorHandler

View File

@ -1,8 +1,3 @@
import * as v3_model from './v3_model'
import * as ui from './ui'
export * from './settings'
export * from './router'
export * from './dynamicsdcp'
export * from './browser'
export { v3_model, ui }
export * as settings from './settings'
export * as browser from './browser'
export * as style from './style'

View File

@ -1,37 +0,0 @@
import { history } from 'umi';
export const router = {
push: e => {
history.push({
pathname: `${e}`,
});
},
go: e => {
router.push(e);
},
goProfile: e => {
router.push(`/@/${e}`);
},
};
export const goTo = {
top: id => {
const element = document.getElementById(id);
element.scrollTop = element.scrollHeight + element.clientHeight;
},
bottom: id => {
const element = document.getElementById(id);
element.scrollTop = element.scrollHeight - element.clientHeight;
},
element: element => {
try {
document.getElementById(element).scrollIntoView();
} catch (error) {
console.debug(error);
return false;
}
},
};
export default router

View File

@ -1,258 +0,0 @@
import io from 'socket.io-client'
import { verbosity } from '@nodecorejs/utils'
import settings from 'core/libs/settings'
import { notify } from 'core/libs/ui'
const stateCodes = {
0: "closed",
1: "connected",
2: "connecting",
3: "disconnected"
}
interface ioConnTypes {
payload: any;
listenerKey: string;
toState: number;
event: any;
attempNumber: number;
startTime: number;
}
export default class SocketConnection {
ioConn: any
state: {
connAttemps: number;
registeredNamespaces: any;
connectionState: any;
listeners: any;
latency: any;
locked: boolean;
}
props: any
opts: any
dispatcher: any;
then: any;
namespaceConnector: any;
constructor(props: any) {
if (!props) {
throw new Error("Mmm some props are not defined")
}
this.then = props.then
this.props = props.payload
this.dispatcher = props.connector
this.state = {
locked: this.props.locked ?? false,
latency: 0,
listeners: {},
connectionState: "init",
connAttemps: Number(0),
registeredNamespaces: [],
}
this.opts = {
isHeader: false,
namespaceOrigin: "/",
hostname: "localhost:5000",
port: "5000",
reconnection: true,
reconnectionAttempts: Number(2),
reconnectionDelay: 1000,
reconnectionDelayMax: 5000,
randomizationFactor: 0.5,
timeout: 20000,
pingInterval: 5000,
autoConnect: true,
query: {},
upgrade: true,
forceJSONP: false,
jsonp: true,
forceBase64: false,
enablesXDR: false,
timestampRequests: true,
timestampParam: 't',
policyPort: 843,
transports: ['polling', 'websocket'],
transportOptions: {},
rememberUpgrade: false,
onlyBinaryUpgrades: false,
requestTimeout: 0,
protocols: [],
agent: false,
pfx: null,
key: null,
passphrase: null,
cert: null,
ca: null,
ciphers: [],
rejectUnauthorized: true,
perMessageDeflate: true,
forceNode: false,
localAddress: null,
extraHeaders: {}
}
if (typeof (this.props) !== "undefined") {
this.opts = { ...this.opts, ...this.props }
}
this.createConnection().then(() => {
this.ioConn.updateConnectionState(2)
this.setConnectionListeners()
})
this.namespaceConnector = (namespace: string) => {
if (!this.state.locked) {
this.createConnection(namespace).then(() => {
this.ioConn.updateConnectionState(2)
this.setConnectionListeners()
})
}else{
verbosity.log(`[${this.opts.namespaceOrigin}] node is locked, cannot switch the namespace`)
}
}
}
createConnection(namespace: void) {
const getNode = () => {
const defaultNode = `${this.opts.hostname}${this.opts.namespaceOrigin}`
if (typeof (namespace) !== "undefined") {
return `${this.opts.hostname}:${this.opts.port}${namespace}`
}
return defaultNode
}
return new Promise((resolve) => {
this.ioConn = io(getNode(), this.opts)
this.ioConn.updateState = (payload: ioConnTypes) => {
this.state = { ...this.state, ...payload }
const sendBackPayload = { ...this.state, ioConn: this.ioConn, namespaceConnector: this.namespaceConnector }
this.dispatcher({ type: "socket/updateStateFromSocket", node: this.opts.namespaceOrigin, payload: sendBackPayload })
}
this.ioConn.updateListener = (listenerKey: ioConnTypes, toState: ioConnTypes) => {
if (!listenerKey)
return false
const getInvert = () => {
// @ts-ignore
if (this.state.listeners[listenerKey] != null) {
// @ts-ignore
return !this.state.listeners[listenerKey]
} else {
return true // this set activated listener by default if not exist any entries
}
}
let updatedObj: any = []
// @ts-ignore
updatedObj[listenerKey] = toState ?? getInvert()
let updatedState = this.state.listeners
updatedState = { ...updatedState, ...updatedObj }
this.ioConn.updateState({ listeners: updatedState })
}
this.ioConn.updateConnectionState = (code: number) => {
if (code != null && typeof (code) == "number") {
// @ts-ignore
if (this.state.connectionState !== stateCodes[code]) { // avoiding update innecesary
// @ts-ignore
this.ioConn.updateState({ connectionState: stateCodes[code] })
}
}
}
this.ioConn._emit = (...context: any) => {
const listenerKey = context[0]
if (typeof (this.state.listeners[listenerKey]) == "undefined") {
this.ioConn.updateListener(listenerKey, true)
}
if (this.state.listeners[listenerKey] != null && !this.state.listeners[listenerKey]) {
verbosity.log(`Listener [${listenerKey}] is broked!`) // TODO: Add verbosity color
return false
}
return this.ioConn.emit(...context)
}
this.ioConn.lock = () => {
this.ioConn.updateState({ locked: true })
}
this.ioConn.unlock = () => {
this.ioConn.updateState({ locked: false })
}
this.ioConn._close = () => {
this.ioConn.disconnect()
this.ioConn.updateConnectionState(0)
}
this.ioConn.remove = () => {
this.dispatcher({ type: "socket/destroyNode", node: this.opts.namespaceOrigin })
}
resolve(true)
})
}
setConnectionListeners() {
this.ioConn.on('connect', () => {
this.ioConn.updateConnectionState(1)
verbosity.log(`🌐 Connected to socket (${this.opts.namespaceOrigin})`)
this.then(this.ioConn) // sending init data
})
this.ioConn.on("connect_error", (event: ioConnTypes) => {
if (this.state.connectionState !== "connecting") {
this.ioConn.updateConnectionState(2)
}
if (this.state.connAttemps >= this.opts.reconnectionAttempts) {
verbosity.log('Maximun nº of attemps reached => max', this.opts.reconnectionAttempts + 1)
this.ioConn.updateConnectionState(0)
return false
}
verbosity.log(`Strike [${this.state.connAttemps + 1}] / ${this.opts.reconnectionAttempts + 1} !`, event)
this.state.connAttemps = this.state.connAttemps + 1
})
this.ioConn.on('reconnect', (attemptNumber: ioConnTypes) => {
verbosity.log(`✅ Connection reconected with (${attemptNumber}) tries > [socket_event]`)
this.ioConn.updateConnectionState(1)
})
this.ioConn.on('disconnect', (event: ioConnTypes) => {
if (this.opts.isHeader) {
notify.warn("You are offline")
}
verbosity.log(`🔌 Disconnect from socket (${this.opts.namespaceOrigin}) > [socket_event] >`, event)
this.ioConn.updateConnectionState(3)
})
this.ioConn.on('connect_timeout', () => {
verbosity.log(`🕘 Socket timeout (${this.opts.namespaceOrigin}) > [socket_event]`)
this.ioConn.updateConnectionState(3)
})
this.ioConn.on('error', (event: ioConnTypes) => {
verbosity.log(`❌ Socket throw error (${this.opts.namespaceOrigin}) > [socket_event] >`, event)
})
this.ioConn.on('updateState', (event: ioConnTypes) => {
this.ioConn.updateState(event)
})
if (typeof (this.ioConn.io.opts.pingInterval) !== "undefined") {
if (typeof (this.ioConn.io.opts.pingInterval) == "number") {
setInterval(() => {
this.ioConn.emit('latency', Date.now(), (startTime: ioConnTypes) => {
// @ts-ignore
const latency = Date.now() - startTime
this.ioConn.updateState({ latency })
})
}, this.ioConn.io.opts.pingInterval)
}
}
}
}

View File

@ -1,40 +0,0 @@
import * as React from 'react'
import * as antd from 'antd'
import { Code, Download, HardDrive } from 'components/Icons'
import { downloadDecodedURI } from 'core'
export interface exportData_props {
data: string;
type: string;
}
const exportCodeRender = (data) => {
if(data.length > 500){
return <div style={{ textAlign: 'center', width: '100%', padding: '30px 0 30px 0' }}>
<HardDrive style={{ fontSize: '45px', margin: '0' }} />
<h4>Hey, this file is too much large!</h4>
<h3>So it couldn't be displayed.</h3>
</div>
}
return <div>
{data}
</div>
}
const exportData_render = (props: exportData_props) => {
antd.Modal.confirm({
title: <div><Code /> Your export <antd.Tag> {`${props.type.split("/")[1]}`} </antd.Tag></div>,
icon: null,
onOk: () => downloadDecodedURI({data: props.data, type: props.type}),
okText: <><Download />Download as File</> ,
cancelText: "Done",
content: exportCodeRender(props.data),
});
}
exportData_render.defaultProps = {
data: '',
type: 'text/txt',
}
export default exportData_render

View File

@ -1 +0,0 @@
export * from './notify'

View File

@ -1,126 +0,0 @@
import React from 'react'
import * as core from 'core'
import * as antd from 'antd'
import * as Icons from 'components/Icons'
import styles from './modals.less';
import classnames from 'classnames'
const isMobile = localStorage.getItem('mobile_src')
class __Model_postreport extends React.PureComponent {
state = {
step: 1
}
end(){
if(this.props.id){
const payload = { post_id: this.props.id }
core.comty_post.__report((err, res) => {
if (err) {
return false
}
core.notify.info('This post has been reported successfully, our team will review it and inform you about problem resolution ...')
core.RenderFeed.RefreshFeed()
core.RenderFeed.goToElement(this.props.id)
}, payload)
}
setTimeout(() => {
core.SwapMode.close()
}, 500)
}
next(){
let a = this.state.step
if(a<3)a++
this.setState({step: a })
}
status(i){
const a = this.state.step
if (a==i) return 'process'
if (a>i) return 'finish'
if (a<i) return 'wait'
}
renderStep(){
const a = this.state.step
switch (a) {
case 1:
return (
<div className={styles.post_report_body}>
<h1>Report an post</h1>
<p>This tool is intended for the community in a public way to help identify problematic or abusive content and for legitimate purposes.</p><br/>
<p>To ensure the proper use of this tool, before proceeding, you must understand the following:</p>
<antd.Checkbox onChange={this.validate.term_1}>I understand and agree that my complaint may be sent to the party that posted the content in question.</antd.Checkbox>
<antd.Checkbox onChange={this.validate.term_2}>I understand that the abuse of this tool may have consequences for my account</antd.Checkbox>
<br/><br/>{this.state.term_1 && this.state.term_2? <antd.Button onClick={() => this.next()} >Next</antd.Button> : null}
</div>
)
case 2:
return(
<div className={styles.post_report_body}>
<br/>
<h3>For this report or complaint to be fair, make sure that the reason is for the following reasons:</h3>
<br/>
<p>- Harmful content or hate speech</p>
<p>- Violent or repulsive content</p>
<p>- Misleading advertising or spam</p>
<p>- Illegal activities</p>
<p>- Sexual content</p>
<p>- Or any other activity that violates the terms and conditions of use</p>
<antd.Checkbox onChange={this.validate.term_3}>I am sure and understand that the reason for this report is included in the above list.</antd.Checkbox>
<br/><br/>{this.state.term_3? <antd.Button onClick={() => this.next()} >Next</antd.Button> : null}
</div>
)
case 3:
return (
<div className={styles.post_report_body}>
<br/>
<h3>Given the above circumstances, to send this report or report please confirm that you understand and are following that you want to carry out this action</h3>
<antd.Checkbox onChange={this.validate.confirm}>I am sure of what I do and I want to send this complaint or report</antd.Checkbox>
<br/><br/>{this.state.term_confirm? <antd.Button onClick={() => this.end()} >Send report</antd.Button> : null}
</div>
)
default:
return null
}
}
validate = {
term_1: (e) =>{this.setState({ term_1: e.target.checked })},
term_2: (e) =>{this.setState({ term_2: e.target.checked })},
term_3: (e) =>{this.setState({ term_3: e.target.checked })},
confirm: (e) =>{this.setState({ term_confirm: e.target.checked })}
}
render(){
return(
<div className={classnames(styles.post_report_main, {[styles.mobile]: isMobile})}>
<div>
<antd.Steps>
<antd.Steps.Step status={this.status(1)} title="Summary" icon={<Icons.SolutionOutlined />} />
<antd.Steps.Step status={this.status(2)} title="Confirm" icon={<Icons.AuditOutlined />} />
<antd.Steps.Step status={this.status(3)} title="Done" icon={<Icons.CheckCircleOutlined />} />
</antd.Steps>
</div>
{this.renderStep()}
</div>
)
}
}
export const app_modals = {
report_post: (post_id) => {
antd.Modal.confirm({
title: 'Report an post',
icon: <Icons.FrownOutlined />,
content: 'It seems that you want to report this post, first of all it is necessary that you take into account that this tool is only intended for serious cases and we need you to comply with some questions to be able to report this post and to guarantee the quality of service ...',
onOk() {
return core.SwapMode.openFragment(<__Model_postreport id={post_id} />)
},
onCancel() {
return false
},
});
}
}

View File

@ -1,9 +0,0 @@
.post_report_main{
padding: 0 0 0 115px;
&.mobile{
padding: 0 0 60px;
}
}
.post_report_body{
color: #2d2d2d!important;
}

View File

@ -1,92 +0,0 @@
import { notification, message } from 'antd'
import { Triangle, FieldTimeOutlined, LoadingOutlined } from 'components/Icons'
export const notify = {
fatal: (...res) => {
notification.error({
message: 'Fatal Error',
icon: <Triangle style={{ color: '#fa8c16' }} />,
description: res,
placement: 'bottomLeft'
})
},
expire: (...res) => {
notification.error({
message: 'Hey ',
icon: <FieldTimeOutlined />,
description: res,
placement: 'bottomLeft',
})
},
info: (...res) => {
notification.info({
message: 'Well',
description: res.toString(),
placement: 'bottomLeft',
})
},
exception: (...res) => {
notification.error({
message: 'WoW!',
description: res.toString(),
placement: 'bottomLeft',
})
},
warn: (...res) => {
notification.warn({
message: 'Hey!',
description: res.toString(),
placement: 'bottomLeft',
})
},
success: (...res) => {
notification.success({
message: 'Well',
description: res.toString(),
placement: 'bottomLeft',
})
},
error: (...res) => {
notification.error({
message: 'Wopss',
description: (
<div>
<span>An wild error appear! : </span>
<br />
<br />
<div
style={{
position: 'relative',
width: '100%',
backgroundColor: 'rgba(243, 19, 19, 0.329)',
bottom: '0',
color: 'black',
padding: '3px',
}}
>
{res.toString()}
</div>
</div>
),
placement: 'bottomLeft',
})
},
proccess: (...res) => {
notification.open({
icon: <LoadingOutlined style={{ color: '#108ee9' }} />,
message: 'Please wait',
description: <div>{res}</div>,
placement: 'bottomLeft',
})
},
open: (props) => {
notification.open({
placement: props.placement? props.placement : 'bottomLeft',
duration: props.duration? props.placement : 15,
icon: props.icon? props.icon : <Triangle style={{ color: '#fa8c16' }} />,
message: props.message? props.message : '',
description: props.description? props.description : ''
})
},
}

View File

@ -1,25 +0,0 @@
import v3_request from 'api/lib/v3_request'
import endpointList from 'config/endpoints'
import config from 'config'
const { endpoint_v3prefix } = config.app;
export async function api_request(payload, callback) {
if (!payload) return false;
const { endpoint, body, serverKey, userToken } = payload;
let petition = {
prefix: endpoint_v3prefix,
endpointList,
endpoint
}
body ? (petition.body = body) : null;
serverKey ? (petition.server_key = serverKey) : null;
userToken ? (petition.access_token = userToken) : null;
v3_request(petition, (...res) => {
return callback(...res);
})
}

View File

@ -1,89 +0,0 @@
import settings from 'core/libs/settings'
import { objectToArrayMap } from 'core'
import stackTrace from 'stack-trace'
import path from 'path'
import colors from 'colors'
const verbosity_enabled = settings('verbosity')
export function verbosity(data, params, stackTraceParams){
if(!verbosity_enabled) return false
let initData;
initData = data
let opt = {
color: "green",
type: "log"
}
let optStackTrace = {
activeColor: true,
line: false,
method: true,
file: false,
time: true
}
const frame = stackTrace.get()[1]
const stackTraceData = {
time: new Date().toLocaleTimeString(),
line: `(:${frame.getLineNumber()})`,
file: path.basename(frame.getFileName()),
method: `[${frame.getFunctionName()}]`
}
if (typeof(params) !== "undefined" || params != null) {
objectToArrayMap(params).forEach((e) => {
if(typeof(e.value) !== "undefined"){
opt[e.key] = e.value
}
})
}
if (typeof(stackTraceParams) !== "undefined" || stackTraceParams != null) {
objectToArrayMap(stackTraceParams).forEach((e) => {
if(typeof(e.value) !== "undefined"){
optStackTrace[e.key] = e.value
}
})
}
if (opt.color) {
colors.enable()
}
const stackTraceKeys = Object.keys(optStackTrace)
const stackTraceLength = stackTraceKeys.length
let modifyCount = 0
let tmp
for (let i = 0; i < stackTraceLength; i++) {
const key = stackTraceKeys[i]
const value = optStackTrace[stackTraceKeys[i]]
const divisor = (i == (stackTraceLength - 1)? " | " : " > ")
// console.log(`[${key}] is the ${i == stackTraceLength? "last opt" : `n[${i}]` }`)
// console.log(i, "/", stackTraceLength -1)
if(typeof(stackTraceData[key]) !== "undefined" && value){
if (Array.isArray(initData)) {
if (modifyCount == 0) {
tmp = (`${stackTraceData[key]}`[opt.color] + divisor)
}else{
tmp = (`${stackTraceData[key]}`[opt.color] + divisor + tmp)
}
if (i == (stackTraceLength - 1)){
data.unshift(tmp)
}
}else{
data = (`${stackTraceData[key]}`[opt.color] + divisor + data)
}
modifyCount++
}
}
if (Array.isArray(data)) {
return console[opt.type](...data)
}
return console[opt.type](data)
}
export default verbosity

View File

@ -1,5 +0,0 @@
import { connect } from 'umi'
export default (children) => {
return connect(({ app }) => ({ app }))(children)
}

View File

@ -1,10 +0,0 @@
import StreamingOverlay from 'components/StreamingOverlay'
export function goLive(payload) {
window.overlaySwap.open({
id: 'search',
mode: 'half',
size: "50%",
element: <StreamingOverlay />
})
}

View File

@ -1,3 +0,0 @@
import * as session from './session'
export { session }

View File

@ -1,7 +0,0 @@
export function newSearch(payload) {
window.overlaySwap.open({
id: 'search',
mode: 'half',
element: <div>NAH</div>
})
}

View File

@ -1,49 +0,0 @@
import endpoints from 'config/endpoints';
import { v3_model } from 'core/libs';
function auth(payload, callback) {
if (!payload) return false;
const { username, password, server_key } = payload;
if (username && password) {
const frame = { username: atob(username), password: atob(password) }
v3_model.api_request(
{
body: frame,
endpoint: endpoints.auth,
serverKey: server_key
},
(err, res) => {
return callback(err, res);
},
);
} else {
const res = { status: 100, message: 'Invalid Credentials!' };
return callback(res, false);
}
}
function deauth(payload, callback) {
if (!payload) return false;
const frame = { id: payload.id, type: "delete"}
v3_model.api_request(
{
body: frame,
endpoint: endpoints.sessions,
serverKey: payload.server_key,
userToken: payload.userToken
},
(err, res) => {
return callback(err, res);
},
);
}
const backup = {
get: () => {},
set: () => {},
};
export { auth, deauth, backup };

View File

@ -1,19 +0,0 @@
import React from 'react'
import BaseLayout from './BaseLayout'
import { withRouter } from 'umi'
@withRouter
class Layout extends React.Component {
componentDidMount(){
const appBody = document.getElementsByTagName("body")[0]
appBody.setAttribute("id", "appWrapper")
}
render() {
const { children } = this.props
return (
<BaseLayout>{children}</BaseLayout>
)
}
}
export default Layout

View File

@ -1,10 +0,0 @@
declare module '*.css';
declare module '*.less';
declare module '*.png';
declare module '*.svg' {
export function ReactComponent(
props: React.SVGProps<SVGSVGElement>,
): React.ReactElement;
const url: string;
export default url;
}

View File

@ -1,15 +0,0 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": 4
}
}
]
],
"plugins": [
"@babel/plugin-transform-runtime"
]
}

View File

@ -1,30 +1,28 @@
{
"name": "@ragestudio/server",
"version": "0.12.8",
"version": "0.13.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"files": [
"dist",
"src"
],
"scripts": {
"start": "nodemon --inspect --exec babel-node ./src"
"dev": "nodemon --ignore dist/ --exec corenode-node ./src/index.js"
},
"license": "MIT",
"dependencies": {
"@babel/node": "^7.12.10",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
"@babel/plugin-proposal-private-methods": "^7.12.1",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/runtime": "^7.12.5",
"@nodecorejs/cloudlink": "^0.15.1",
"babel-node": "^0.0.1-security",
"nodemon": "^2.0.7"
"corenode": "^0.28.26",
"linebridge": "^0.8.4",
"mongoose": "^6.0.13",
"axios": "^0.24.0",
"bcrypt": "^5.0.1",
"connect-mongo": "^4.6.0",
"jsonwebtoken": "^8.5.1",
"moment": "^2.29.1",
"passport": "^0.5.0",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"path-to-regexp": "^6.2.0",
"socket.io": "^4.2.0"
},
"devDependencies": {
"cross-env": "^7.0.3",
"nodemon": "^2.0.15"
}
}

View File

@ -1,24 +1,163 @@
import cloudlink from '@nodecorejs/cloudlink'
import LinebridgeServer from 'linebridge/server'
import bcrypt from 'bcrypt'
import mongoose from 'mongoose'
import passport from 'passport'
import { User } from './models'
import socketIo from 'socket.io'
import http from "http"
let controllers = {
TestController: {
get: (req, res, next) => {
console.log("Testing controller, it works!")
const b64Decode = global.b64Decode = (data) => {
return Buffer.from(data, 'base64').toString('utf-8')
}
const b64Encode = global.b64Encode = (data) => {
return Buffer.from(data, 'utf-8').toString('base64')
}
const JwtStrategy = require('passport-jwt').Strategy
const ExtractJwt = require('passport-jwt').ExtractJwt
const LocalStrategy = require('passport-local').Strategy
const { Buffer } = require("buffer")
class Server {
constructor() {
this.env = _env
this.listenPort = this.env.listenPort ?? 3000
this.middlewares = require("./middlewares")
this.controllers = require("./controllers")
this.endpoints = require("./endpoints")
this.instance = new LinebridgeServer({
listen: "0.0.0.0",
middlewares: this.middlewares,
controllers: this.controllers,
endpoints: this.endpoints,
port: this.listenPort
})
this.server = this.instance.httpServer
this.ioHttp = http.createServer()
this.io = new socketIo.Server(this.ioHttp, {
maxHttpBufferSize: 100000000,
connectTimeout: 5000,
transports: ['websocket', 'polling'],
pingInterval: 25 * 1000,
pingTimeout: 5000,
allowEIO3: true,
cors: {
origin: "http://localhost:8000",
methods: ["GET", "POST"],
}
}).of("/main")
this.options = {
jwtStrategy: {
sessionLocationSign: this.instance.id,
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
secretOrKey: this.instance.oskid,
algorithms: ['sha1', 'RS256', 'HS256'],
expiresIn: "1h"
}
}
this.initialize()
}
async initialize() {
await this.connectToDB()
await this.initPassport()
// register middlewares
this.instance.middlewares["useJwtStrategy"] = (req, res, next) => {
req.jwtStrategy = this.options.jwtStrategy
next()
}
this.io.on("connection", (socket) => {
console.log(socket.id)
})
this.ioHttp.listen(9001)
await this.instance.init()
}
getDBConnectionString() {
const { db_user, db_driver, db_name, db_pwd, db_hostname, db_port } = _env
return `${db_driver}://${db_user}:${db_pwd}@${db_hostname}:${db_port}/${db_name}`
}
connectToDB = () => {
return new Promise((resolve, reject) => {
try {
console.log("🌐 Trying to connect to DB...")
mongoose.connect(this.getDBConnectionString(), { useNewUrlParser: true, useFindAndModify: false })
.then((res) => { return resolve(true) })
.catch((err) => { return reject(err) })
} catch (err) {
return reject(err)
}
}).then(done => {
console.log(`✅ Connected to DB`)
}).catch((error) => {
console.log(`❌ Failed to connect to DB, retrying...\n`)
console.log(error)
setTimeout(() => {
this.connectToDB()
}, 1000)
})
}
setWebsocketRooms = () => {
this.ws.register("/test", {
onOpen: (socket) => {
console.log(socket)
setInterval(() => {
socket.send("Hello")
}, 1000)
}
})
this.ws.listen()
}
initPassport() {
passport.use(new LocalStrategy({
usernameField: "username",
passwordField: "password",
session: false
}, (username, password, done) => {
User.findOne({ username: b64Decode(username) }).select('+password')
.then((data) => {
if (data === null) {
return done(null, false, this.options.jwtStrategy)
} else if (!bcrypt.compareSync(b64Decode(password), data.password)) {
return done(null, false, this.options.jwtStrategy)
}
// create a token
return done(null, data, this.options.jwtStrategy, { username, password })
})
.catch(err => done(err, null, this.options.jwtStrategy))
}))
passport.use(new JwtStrategy(this.options.jwtStrategy, (token, callback) => {
User.findOne({ _id: token.user_id })
.then((data) => {
if (data === null) {
return callback(null, false)
} else {
return callback(null, data, token)
}
})
.catch((err) => {
return callback(err, null)
})
}))
this.server.use(passport.initialize())
}
}
let endpoints = [
{
"path": "test",
"controller": "TestController"
},
]
cloudlink.register({
origin: "localhost",
originPort: 6050,
listenPort: 5050,
controllers,
endpoints
})
new Server()

View File

@ -1,32 +0,0 @@
{
"ts-node": {
"transpileOnly": true
},
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"sourceMap": true,
"moduleResolution": "node",
"pretty": true,
"declaration": true,
"alwaysStrict": true,
// "allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"esModuleInterop": true,
"noImplicitThis": true,
"noImplicitAny": true,
"downlevelIteration": true,
"lib": [
"dom", // for URLSearchParams
"esnext"
],
"outDir": "dist"
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"text"
]
}

File diff suppressed because it is too large Load Diff

View File

@ -28,5 +28,6 @@
"styled-components": "^5.2.0",
"umi": "^3.4.20",
"yorkie": "^2.0.0"
}
},
"version": "0.13.0"
}

View File

@ -1,24 +0,0 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"jsx": "react",
"esModuleInterop": true,
"sourceMap": true,
"baseUrl": "./",
"strict": true,
"paths": {
"@/*": ["src/*"],
"@@/*": ["src/.umi/*"]
},
"allowSyntheticDefaultImports": true
},
"include": [
"src/**/*",
"packages/comty/config/**/*",
"packages/comty/.umirc.js",
"packages/comty/typings.d.ts"
]
}