@@ -591,11 +596,15 @@ export default connect(
const pso = state.global.get('pso')
+ const loginDefault = state.user.get('loginDefault')
+ const loginBlurring = loginDefault && loginDefault.get('blurring')
+
return {
...props,
username,
prevPosts,
- pso: pso ? pso.toJS() : null
+ pso: pso ? pso.toJS() : null,
+ loginBlurring
}
},
diff --git a/app/components/cards/PostSummary.jsx b/app/components/cards/PostSummary.jsx
index c32423d4..82f48ded 100644
--- a/app/components/cards/PostSummary.jsx
+++ b/app/components/cards/PostSummary.jsx
@@ -28,6 +28,7 @@ import { authRegisterUrl, } from 'app/utils/AuthApiClient'
import { hideSummary } from 'app/utils/ContentAccess'
import extractContent from 'app/utils/ExtractContent'
import {authorNameAndRep} from 'app/utils/ComponentFormatters'
+import { randomString } from 'app/utils/helpers'
import { addHighlight, unsubscribePost } from 'app/utils/NotifyApiClient'
import { detransliterate } from 'app/utils/ParsersAndFormatters'
import { proxifyImageUrl } from 'app/utils/ProxifyUrl'
@@ -85,7 +86,8 @@ class PostSummary extends React.Component {
state.revealNsfw !== this.state.revealNsfw ||
props.visited !== this.props.visited ||
props.gray !== this.props.gray ||
- props.encrypted !== this.props.encrypted
+ props.encrypted !== this.props.encrypted ||
+ props.loginBlurring !== this.props.loginBlurring
}
componentDidUpdate(prevProps) {
@@ -149,7 +151,7 @@ class PostSummary extends React.Component {
const {currentCategory, thumbSize, onClick} = this.props;
const {post, content, pending_payout, total_payout, cashout_time, blockEye} = this.props;
const {account} = this.props;
- const {nsfwPref, username} = this.props
+ const {nsfwPref, username, loginBlurring} = this.props
if (!content) return null;
let reblogged_by;
@@ -224,6 +226,11 @@ class PostSummary extends React.Component {
comments_link = p.link + '#comments';
}
+ if (loginBlurring) {
+ title_text = randomString(title_text)
+ desc = randomString(desc)
+ }
+
if (title_link_url.includes('fm-') && $STM_Config.forums) {
let parts = title_link_url.split('/');
for (let [_id, forum] of Object.entries($STM_Config.forums)) {
@@ -354,6 +361,7 @@ class PostSummary extends React.Component {
}
const commentClasses = []
if(gray) commentClasses.push('downvoted') // rephide
+ if (loginBlurring) commentClasses.push('blurring')
total_search = total_search ?
{tt('g.and_more_search_posts_COUNT', { COUNT: total_search })}
@@ -434,9 +442,12 @@ export default connect(
const stats = content.get('stats', Map()).toJS()
gray = stats.gray
}
+ const loginDefault = state.user.get('loginDefault')
+ const loginBlurring = loginDefault && loginDefault.get('blurring')
return {
post, content, gray, pending_payout, total_payout, event_count, encrypted,
- username: state.user.getIn(['current', 'username']) || state.offchain.get('account')
+ username: state.user.getIn(['current', 'username']) || state.offchain.get('account'),
+ loginBlurring
};
},
diff --git a/app/components/modules/Modals.jsx b/app/components/modules/Modals.jsx
index 547d18a4..d51bb37a 100644
--- a/app/components/modules/Modals.jsx
+++ b/app/components/modules/Modals.jsx
@@ -47,7 +47,7 @@ class Modals extends React.Component {
this.shouldComponentUpdate = shouldComponentUpdate(this, 'Modals');
}
- onLoginBackdropClick = (e) => {
+ onLoginTryClose = (e) => {
const { loginUnclosable } = this.props;
if (loginUnclosable)
throw new Error('Closing login modal is forbidden here');
@@ -56,6 +56,7 @@ class Modals extends React.Component {
render() {
const {
show_login_modal,
+ loginBlurring,
show_confirm_modal,
show_donate_modal,
show_gift_nft_modal,
@@ -84,9 +85,11 @@ class Modals extends React.Component {
return n;
}) : [];
+ const loginClass = loginBlurring ? 'reveal-blurring' : undefined
+
return (
- {show_login_modal &&
+ {show_login_modal &&
}
{show_confirm_modal &&
@@ -129,9 +132,11 @@ export default connect(
state => {
const loginDefault = state.user.get('loginDefault');
const loginUnclosable = loginDefault && loginDefault.get('unclosable');
+ const loginBlurring = loginDefault && loginDefault.get('blurring')
return {
show_login_modal: state.user.get('show_login_modal'),
loginUnclosable,
+ loginBlurring,
show_confirm_modal: state.transaction.get('show_confirm_modal'),
show_donate_modal: state.user.get('show_donate_modal'),
show_gift_nft_modal: state.user.get('show_gift_nft_modal'),
diff --git a/app/redux/User.js b/app/redux/User.js
index 49c4c5c5..d39cb1f0 100644
--- a/app/redux/User.js
+++ b/app/redux/User.js
@@ -33,6 +33,19 @@ export default createModule({
name: 'user',
initialState: defaultState,
transformations: [
+ {
+ action: 'REQUIRE_LOGIN',
+ reducer: (state, {payload}) => {
+ return state.merge({
+ show_login_modal: true,
+ loginDefault: {
+ unclosable: true,
+ cancelIsRegister: true,
+ blurring: true
+ }
+ })
+ }
+ },
{
action: 'SHOW_LOGIN',
reducer: (state, {payload}) => {
diff --git a/app/utils/helpers.js b/app/utils/helpers.js
index 4d79d5d6..ec3d88e7 100644
--- a/app/utils/helpers.js
+++ b/app/utils/helpers.js
@@ -1,3 +1,18 @@
+export function randomString(str) {
+ let res = ''
+ const abc = 'abcdefghijklmnopqrstuvwxz'
+ for (let i = 0; i < str.length; ++i) {
+ const c = str[i]
+ if (c === ' ') {
+ res += c
+ continue
+ }
+ const nc = abc[Math.floor(Math.random() * abc.length)]
+ res += nc
+ }
+ return res
+}
+
export function encode(str) {
let hash = 0, chr;
if (str.length === 0) return hash;
diff --git a/server/index.js b/server/index.js
index c325c4a3..39d07941 100755
--- a/server/index.js
+++ b/server/index.js
@@ -52,6 +52,7 @@ global.$STM_Config = {
forums: config.get('forums'),
blocked_users,
blocked_posts,
+ authorization_required: config.has('authorization_required') && config.get('authorization_required'),
ui_version: version || '1.0-unknown',
};
diff --git a/shared/UniversalRender.jsx b/shared/UniversalRender.jsx
index ffa71cfa..cfa97848 100644
--- a/shared/UniversalRender.jsx
+++ b/shared/UniversalRender.jsx
@@ -11,7 +11,6 @@ import {
match,
applyRouterMiddleware
} from 'react-router';
-import * as api from 'app/utils/APIWrapper'
import { Provider } from 'react-redux';
import RootRoute from 'app/RootRoute';
import {createStore, applyMiddleware, compose} from 'redux';
@@ -19,6 +18,8 @@ import { browserHistory } from 'react-router';
import { useScroll } from 'react-router-scroll';
import createSagaMiddleware from 'redux-saga';
import { syncHistoryWithStore } from 'react-router-redux';
+
+import * as api from 'app/utils/APIWrapper'
import rootReducer from 'app/redux/RootReducer';
import rootSaga from 'app/redux/RootSaga';
import {component as NotFound} from 'app/components/pages/NotFound';
@@ -26,6 +27,7 @@ import extractMeta from 'app/utils/ExtractMeta';
import Translator from 'app/Translator';
import getState from 'app/utils/StateBuilder';
import {routeRegex} from "app/ResolveRoute";
+import session from 'app/utils/session'
import {contentStats} from 'app/utils/StateFunctions'
import {APP_NAME, SEO_TITLE} from 'app/client_config';
import constants from 'app/redux/constants';
@@ -80,6 +82,9 @@ export async function serverRender({
if (process.env.BROWSER) {
const store = createStore(rootReducer, initial_state, middleware);
+ if (!session.load().currentName && $STM_Config.authorization_required) {
+ store.dispatch({type: 'user/REQUIRE_LOGIN', payload: {}});
+ }
// sagaMiddleware.run(PollDataSaga).done
// .then(() => console.log('PollDataSaga is finished'))
// .catch(err => console.log('PollDataSaga is finished with error', err));
@@ -116,7 +121,7 @@ export async function serverRender({
}
// below is only executed on the server
- let serverStore, onchain;
+ let serverStore, onchain, noMeta;
try {
let url = location === '/' ? 'trending' : location;
// Replace these URLs with /transfers for UserProfile to resolve data correctly
@@ -161,6 +166,10 @@ export async function serverRender({
offchain.server_location = location;
serverStore = createStore(rootReducer, { global: onchain, offchain});
+ if (!offchain.account && $STM_Config.authorization_required) {
+ noMeta = true
+ serverStore.dispatch({type: 'user/REQUIRE_LOGIN', payload: {}});
+ }
serverStore.dispatch({type: '@@router/LOCATION_CHANGE', payload: {pathname: location}});
// TODO: maybe use request to golosnotify to fetch counters?
/*if (offchain.account) {
@@ -202,7 +211,7 @@ export async function serverRender({
);
- meta = extractMeta(onchain, renderProps.params);
+ meta = noMeta ? [] : extractMeta(onchain, renderProps.params);
status = 200;
} catch (re) {
console.error('Rendering error: ', re, re.stack);
@@ -221,6 +230,9 @@ export async function serverRender({
export function clientRender(initialState) {
const store = createStore(rootReducer, initialState, middleware);
+ if (!session.load().currentName && $STM_Config.authorization_required) {
+ store.dispatch({type: 'user/REQUIRE_LOGIN', payload: {}});
+ }
sagaMiddleware.run(rootSaga)
const history = syncHistoryWithStore(browserHistory, store);
From 68afacd28c8f14463f7cda28ac0f3b9440f13fad Mon Sep 17 00:00:00 2001
From: 1aerostorm
Date: Sat, 4 May 2024 23:16:48 +0300
Subject: [PATCH 13/16] Update golos-lib-js to 0.9.71, support check-integrity
---
.gitignore | 1 +
app/components/App.jsx | 2 ++
check_integrity.js | 59 ++++++++++++++++++++++++++++++++++++++++++
package.json | 10 ++++---
yarn.lock | 18 +++++++++----
5 files changed, 81 insertions(+), 9 deletions(-)
create mode 100644 check_integrity.js
diff --git a/.gitignore b/.gitignore
index 2498620f..99d72176 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ app/assets/static/*.js
app/assets/static/*.json
app/assets/sitemap.xml
default_cfg.js
+app/JsLibHash.json
config/golos.json
config/golos-dev.json
diff --git a/app/components/App.jsx b/app/components/App.jsx
index 2f0c2721..f44da0d7 100644
--- a/app/components/App.jsx
+++ b/app/components/App.jsx
@@ -33,6 +33,7 @@ import { authRegisterUrl, } from 'app/utils/AuthApiClient';
import { APP_ICON, VEST_TICKER, } from 'app/client_config';
import session from 'app/utils/session'
import { loadGrayHideSettings } from 'app/utils/ContentAccess'
+import libInfo from 'app/JsLibHash.json'
const GlobalStyle = createGlobalStyle`
body {
@@ -109,6 +110,7 @@ class App extends React.Component {
componentDidMount() {
if (process.env.BROWSER) {
console.log('ui-blogs version:', $STM_Config.ui_version);
+ console.log('golos-lib-js version:', libInfo.version, 'hash:', libInfo.hash)
}
const { nightmodeEnabled } = this.props;
diff --git a/check_integrity.js b/check_integrity.js
new file mode 100644
index 00000000..0183f12b
--- /dev/null
+++ b/check_integrity.js
@@ -0,0 +1,59 @@
+const fs = require('fs')
+const { hashElement } = require('folder-hash')
+
+async function main(argv) {
+ try {
+ const hashOut = './lib/my_hash.js'
+
+ const path = 'node_modules/golos-lib-js'
+
+ const res = await hashElement(path, {
+ files: {
+ exclude: [
+ path + '/lib/my_hash.js',
+ path + '/dist/golos.min.js.gz',
+ path + '/dist/golos-tests.min.js.gz',
+ path + '/dist/stats.html',
+ // These not including when NPM publishes
+ '.npmrc',
+ '.babelrc',
+ '.gitignore',
+ '.npmignore',
+ 'yarn.lock',
+ ],
+ matchBasename: true,
+ matchPath: true,
+ },
+ folders: {
+ exclude: [
+ 'node_modules',
+ path + '/src',
+ path + '/examples'
+ ],
+ matchPath: true,
+ ignoreRootName: true
+ }
+ })
+
+ console.log(res.children)
+ //console.log(res.children.filter(o => o.name === 'lib')[0].children.filter(o => o.name === 'auth')[0].children)
+
+ console.log('LIBRARY HASH IS', res.hash)
+
+ if (argv[2] === '--save') {
+ let json = 'node_modules/golos-lib-js/package.json'
+ json = fs.readFileSync(json, 'utf8')
+ json = JSON.parse(json)
+
+ const appPath = 'app/JsLibHash.json'
+ let data = {}
+ data.version = json.version
+ data.hash = res.hash
+ fs.writeFileSync(appPath, JSON.stringify(data))
+ }
+ } catch (err) {
+ console.error('LIBRARY HASH FAILED:', err)
+ }
+}
+
+main(process.argv)
diff --git a/package.json b/package.json
index a7412b2e..34cb2d8c 100644
--- a/package.json
+++ b/package.json
@@ -9,18 +9,19 @@
"main": "dist/electron/electron.js",
"scripts": {
"build-version": "./server/build-version.sh",
- "build": "NODE_ENV=production NODE_CONFIG_ENV=production,blacklist ./node_modules/.bin/webpack --config ./webpack/prod.config.js",
+ "build-hash": "node check_integrity --save",
+ "build": "npm run build-hash && NODE_ENV=production NODE_CONFIG_ENV=production,blacklist ./node_modules/.bin/webpack --config ./webpack/prod.config.js",
"mocha": "NODE_ENV=test mocha ./mocha.setup.js",
"test": "npm run mocha -- app/**/*.test.js",
"test:watch:all": "npm test -- --watch --watch-extensions jsx",
"test:watch": "npm run mocha -- --watch --watch-extensions jsx",
"prod": "NODE_ENV=production NODE_CONFIG_ENV=production,blacklist ./node_modules/@babel/node/bin/babel-node.js server/index.js",
- "dev": "cross-env NODE_CONFIG_ENV=blacklist ./node_modules/@babel/node/bin/babel-node.js ./webpack/dev-server.js",
+ "dev": "npm run build-hash && cross-env NODE_CONFIG_ENV=blacklist ./node_modules/@babel/node/bin/babel-node.js ./webpack/dev-server.js",
"start:local": "./.env.start.local.sh",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"dev:app": "cross-env NODE_CONFIG_ENV=blacklist IS_APP=1 ./node_modules/@babel/node/bin/babel-node.js ./webpack/dev-server.js",
- "build:app": "cross-env NODE_ENV=production NODE_CONFIG_ENV=production,desktop ./node_modules/.bin/webpack --config ./webpack/prod-app.config.js",
+ "build:app": "npm run build-hash && cross-env NODE_ENV=production NODE_CONFIG_ENV=production,desktop ./node_modules/.bin/webpack --config ./webpack/prod-app.config.js",
"build:app-entry": "cross-env NODE_ENV=production NODE_CONFIG_ENV=production,desktop ./node_modules/@babel/node/bin/babel-node.js build_app_entry.js"
},
"author": "Golos ",
@@ -52,7 +53,7 @@
"fs-extra": "^10.0.1",
"git-rev-sync": "^3.0.2",
"golos-dex-lib-js": "^1.0.2",
- "golos-lib-js": "^0.9.68",
+ "golos-lib-js": "^0.9.71",
"history": "^2.0.0-rc2",
"immutable": "^3.8.2",
"intl": "^1.2.5",
@@ -149,6 +150,7 @@
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0",
+ "folder-hash": "^4.0.4",
"jsdom": "^21.0.0",
"mini-css-extract-plugin": "^0.4.0",
"mocha": "^5.2.0",
diff --git a/yarn.lock b/yarn.lock
index 1282c38b..c55f11db 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4826,6 +4826,14 @@ flux-standard-action@^0.6.0:
dependencies:
lodash.isplainobject "^3.2.0"
+folder-hash@^4.0.4:
+ version "4.0.4"
+ resolved "https://registry.yarnpkg.com/folder-hash/-/folder-hash-4.0.4.tgz#f5ffa14e9fc6f3213598f6a367207adf7d419edc"
+ integrity sha512-zEyYH+UsHEfJJcCRSf9ai5I4CTZwZ8ObONRuEI5hcEmJY5pS0FUWKruX9mMnYJrgC7MlPFDYnGsK1R+WFYjLlQ==
+ dependencies:
+ debug "^4.3.3"
+ minimatch "~5.1.2"
+
for-each@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
@@ -5237,10 +5245,10 @@ golos-lib-js@^0.9.64:
stream-browserify "^3.0.0"
ws "^8.2.3"
-golos-lib-js@^0.9.68:
- version "0.9.68"
- resolved "https://registry.yarnpkg.com/golos-lib-js/-/golos-lib-js-0.9.68.tgz#62f3c4a7755eacfbe6dc2f6ebc3111f2ff74e6dd"
- integrity sha512-KoQMFHtINYdM0hhe9dKPpWXZLo3MkFXyRxY/zQq0kbBjAwJBU4P1WEMwmPS+MPujjizfvU6nerUOLI4Lj7ChFw==
+golos-lib-js@^0.9.71:
+ version "0.9.71"
+ resolved "https://registry.yarnpkg.com/golos-lib-js/-/golos-lib-js-0.9.71.tgz#794bc6582a96f0e1a3bc4301e0c5dfac976a15bf"
+ integrity sha512-FkR7nuyMUXj+IT8ErTFhu6BsaEvPaLZAr72r5H+GUhqbD8q98tFfBURCKw0MGfiO9CEv0zdDG3daPTq2TThvxA==
dependencies:
abort-controller "^3.0.0"
assert "^2.0.0"
@@ -7383,7 +7391,7 @@ minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"
-minimatch@^5.0.1:
+minimatch@^5.0.1, minimatch@~5.1.2:
version "5.1.6"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96"
integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==
From 41a264fb99fa5e0eadfb65e76a49b5c4419539b5 Mon Sep 17 00:00:00 2001
From: 1aerostorm
Date: Wed, 8 May 2024 21:48:43 +0300
Subject: [PATCH 14/16] Fix MinusedAccounts
---
app/components/pages/MinusedAccounts.jsx | 12 ++++++------
app/redux/FetchDataSaga.js | 2 +-
app/utils/StateBuilder.js | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/components/pages/MinusedAccounts.jsx b/app/components/pages/MinusedAccounts.jsx
index 5b11d61f..274c2a45 100644
--- a/app/components/pages/MinusedAccounts.jsx
+++ b/app/components/pages/MinusedAccounts.jsx
@@ -3,6 +3,7 @@ import { Link } from 'react-router';
import { connect } from 'react-redux';
import golos from 'golos-lib-js';
import tt from 'counterpart';
+
import Icon from 'app/components/elements/Icon';
import TimeAgoWrapper from 'app/components/elements/TimeAgoWrapper';
import Tooltip from 'app/components/elements/Tooltip';
@@ -51,9 +52,9 @@ class MinusedAccounts extends React.Component {
}
render() {
- let minused_accounts = this.props.minused_accounts.reverse();
+ const reversed = this.props.minused_accounts.reverse()
- let history = minused_accounts.map((operation, index) => {
+ let history = reversed && reversed.map((operation, index) => {
return this._renderHistoryRow(operation, index);
});
@@ -70,11 +71,10 @@ class MinusedAccounts extends React.Component {
{history}
- ) : null}
+ ) :
+ {tt('minused_accounts_jsx.empty')}
+
}
- {!history.length ? (
- {tt('minused_accounts_jsx.empty')}
-
) : null}