@rpcbase/server 0.221.0 → 0.223.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/express/custom_cors.js
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
const debug = require("debug")
|
|
3
3
|
const cors = require("cors")
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
const log = debug("rb:cors")
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
const is_production = process.env.IS_PRODUCTION === "yes"
|
|
6
10
|
|
|
7
11
|
const {RB_SKIP_CORS_PATHS, APP_DOMAIN, CLIENT_PORT} = process.env
|
|
8
12
|
|
|
9
13
|
const custom_cors = (app) => {
|
|
10
14
|
|
|
11
|
-
const skip_paths = (RB_SKIP_CORS_PATHS || "").split(",")
|
|
15
|
+
const skip_paths = (RB_SKIP_CORS_PATHS || "").split(",").filter((p) => !!p)
|
|
12
16
|
|
|
13
17
|
// CORS
|
|
14
18
|
const cors_origins = is_production ?
|
|
@@ -48,8 +52,7 @@ const custom_cors = (app) => {
|
|
|
48
52
|
cors_origins.push(`https://${APP_DOMAIN}`)
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
// console.log("setting up cors with origins", JSON.stringify(cors_origins))
|
|
55
|
+
log("cors origins", JSON.stringify(cors_origins, null, 2))
|
|
53
56
|
|
|
54
57
|
const cors_middleware = cors({
|
|
55
58
|
origin: cors_origins,
|
|
@@ -60,6 +63,7 @@ const custom_cors = (app) => {
|
|
|
60
63
|
app.use((req, res, next) => {
|
|
61
64
|
for (const skip_path of skip_paths) {
|
|
62
65
|
if (req.url.startsWith(skip_path)) {
|
|
66
|
+
log("skip path", req.url)
|
|
63
67
|
next()
|
|
64
68
|
return
|
|
65
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.223.0",
|
|
4
4
|
"license": "SSPL-1.0",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@rpcbase/access-control": "0.
|
|
13
|
+
"@rpcbase/access-control": "0.27.0",
|
|
14
14
|
"@rpcbase/agent": "0.30.0",
|
|
15
15
|
"@rpcbase/std": "0.9.0",
|
|
16
16
|
"bluebird": "3.7.2",
|
|
@@ -17,8 +17,6 @@ const is_development = process.env.NODE_ENV === "development"
|
|
|
17
17
|
// do not serve compression in dev, the assets are only compressed in the github action
|
|
18
18
|
const COMPRESSED_EXTENSIONS = is_development ? [] : Object.keys(COMPRESSED_EXTENSIONS_MAP)
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
20
|
const src_path = path.join(process.cwd(), "./src/")
|
|
23
21
|
const build_dir = path.join(process.cwd(), "build/")
|
|
24
22
|
const client_build_dir = path.join(build_dir, "./client")
|
package/src/models/User.js
CHANGED
|
@@ -6,6 +6,11 @@ const UserSchema = new mongoose.Schema({
|
|
|
6
6
|
type: String,
|
|
7
7
|
index: true,
|
|
8
8
|
},
|
|
9
|
+
is_email_verified: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: false,
|
|
12
|
+
},
|
|
13
|
+
password_hash: String,
|
|
9
14
|
first_name: {
|
|
10
15
|
type: String,
|
|
11
16
|
default: "",
|
|
@@ -18,17 +23,11 @@ const UserSchema = new mongoose.Schema({
|
|
|
18
23
|
type: String,
|
|
19
24
|
default: "",
|
|
20
25
|
},
|
|
21
|
-
avatar_image: {
|
|
22
|
-
type: String,
|
|
23
|
-
},
|
|
24
26
|
avatar_color: {
|
|
25
27
|
type: String,
|
|
26
28
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
default: false,
|
|
30
|
-
},
|
|
31
|
-
password_hash: String,
|
|
29
|
+
profile_picture: Buffer,
|
|
30
|
+
profile_picture_updated_at_ms: Number,
|
|
32
31
|
devices: {
|
|
33
32
|
type: Array,
|
|
34
33
|
default: [],
|
package/src/sessions/index.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
+
const pc = require("picocolors")
|
|
3
|
+
|
|
4
|
+
|
|
2
5
|
const is_development = process.env.NODE_ENV === "development"
|
|
3
6
|
|
|
4
7
|
module.exports = (app) => {
|
|
5
8
|
const has_session_store = process.env.RB_SESSION_STORE === "yes"
|
|
6
9
|
|
|
7
10
|
if (has_session_store) {
|
|
8
|
-
console.log("using
|
|
11
|
+
console.log("using", pc.bold(pc.green("SESSION STORE")))
|
|
9
12
|
|
|
10
13
|
const session_store_middleware = require("./session_store_middleware")
|
|
11
14
|
app.use(session_store_middleware)
|
|
12
15
|
} else {
|
|
13
|
-
console.log("using
|
|
16
|
+
console.log("using", pc.bold(pc.red("REVERSE-PROXY SESSIONS")), "if you want to use the session store, start with the --sessions argument")
|
|
14
17
|
|
|
15
18
|
// warn the user
|
|
16
19
|
if (is_development) {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
|
|
3
|
+
const {SUPPRESS_PROXY_SESSION_WARNING} = process.env
|
|
4
|
+
|
|
5
|
+
const suppress_warning = SUPPRESS_PROXY_SESSION_WARNING === "yes"
|
|
3
6
|
|
|
4
7
|
const warning_proxy_middleware = (req, res, next) => {
|
|
5
8
|
const {host} = req.headers
|
|
6
9
|
|
|
7
|
-
if (host.startsWith("localhost:")) {
|
|
8
|
-
|
|
9
|
-
res.json({status: "error", message: "are you running with the proxy address ? you shouldn't be using localhost when you are running the app with the reverse proxyy"})
|
|
10
|
-
return
|
|
11
|
-
} else {
|
|
12
|
-
next()
|
|
10
|
+
if (!suppress_warning && host.startsWith("localhost:")) {
|
|
11
|
+
console.warn("are you running with the proxy address ? you shouldn't be using localhost when you are running the app with the reverse proxyy")
|
|
13
12
|
}
|
|
13
|
+
|
|
14
|
+
next()
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
module.exports = warning_proxy_middleware
|