@nka212bg/backend-utils 0.1.41 → 0.1.43
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/README.md +0 -0
- package/db/dbUtils.js +0 -0
- package/db/mysql2.js +0 -0
- package/db/sqlite3.js +0 -0
- package/index.js +0 -0
- package/location/GeoLite2-City.mmdb +0 -0
- package/location/VPNs-master.zip +0 -0
- package/location/index.js +0 -0
- package/location/localelib.js +0 -0
- package/mailSmsTools/defaultTemplate.html +0 -0
- package/mailSmsTools/index.js +0 -0
- package/markdown/index.js +0 -0
- package/markdown/markdown.js +0 -0
- package/misc.js +0 -0
- package/os.js +0 -0
- package/package.json +1 -1
- package/session.js +6 -4
- package/socket.js +9 -7
- package/stripe.js +0 -0
- package/systemLog.js +0 -0
package/README.md
CHANGED
|
File without changes
|
package/db/dbUtils.js
CHANGED
|
File without changes
|
package/db/mysql2.js
CHANGED
|
File without changes
|
package/db/sqlite3.js
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
File without changes
|
|
File without changes
|
package/location/VPNs-master.zip
CHANGED
|
File without changes
|
package/location/index.js
CHANGED
|
File without changes
|
package/location/localelib.js
CHANGED
|
File without changes
|
|
File without changes
|
package/mailSmsTools/index.js
CHANGED
|
File without changes
|
package/markdown/index.js
CHANGED
|
File without changes
|
package/markdown/markdown.js
CHANGED
|
File without changes
|
package/misc.js
CHANGED
|
File without changes
|
package/os.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
package/session.js
CHANGED
|
@@ -44,7 +44,7 @@ exports.serverState = new Proxy(
|
|
|
44
44
|
// const s = serverState["abc123"]; // => {name: 'alice', ..., expireIn: 604859999}
|
|
45
45
|
// const s = serverState[req.headers.authorization];
|
|
46
46
|
// const all = serverState.getAll; // => whole STATE map
|
|
47
|
-
// const alices = serverState["name=alice"]; // => all entries where name == "alice",
|
|
47
|
+
// const alices = serverState["name=alice"]; // => all entries where name == "alice", keyed by token, same shape as STATE
|
|
48
48
|
get(_, token) {
|
|
49
49
|
if (/^\s*(undefined|null|0)?\s*$/.test(token)) return false;
|
|
50
50
|
token = String(token).trim();
|
|
@@ -53,9 +53,11 @@ exports.serverState = new Proxy(
|
|
|
53
53
|
|
|
54
54
|
if (token.includes("=")) {
|
|
55
55
|
const [field, value] = token.trim().split(/\s*=\s*/);
|
|
56
|
-
return Object.
|
|
57
|
-
.
|
|
58
|
-
|
|
56
|
+
return Object.fromEntries(
|
|
57
|
+
Object.entries(STATE)
|
|
58
|
+
.filter(([, s]) => s[field] == value)
|
|
59
|
+
.map(([token, s]) => [token, { ...s }]),
|
|
60
|
+
);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
if (!STATE[token]) return false;
|
package/socket.js
CHANGED
|
@@ -8,15 +8,17 @@ const parseParams = (url) => {
|
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
// options.authenticate (params, req) => boolean, rejects the connection with 401 during the handshake when falsy
|
|
12
11
|
module.exports = (server, { authenticate } = {}) => {
|
|
13
|
-
const socket = new WebSocket.Server({
|
|
14
|
-
server,
|
|
15
|
-
noServer: !server,
|
|
16
|
-
verifyClient: authenticate && (({ req }) => !!authenticate(parseParams(req.url), req)),
|
|
17
|
-
});
|
|
12
|
+
const socket = new WebSocket.Server({ server, noServer: !server });
|
|
18
13
|
socket.on("connection", (ws, req) => {
|
|
19
|
-
|
|
14
|
+
const params = parseParams(req.url);
|
|
15
|
+
|
|
16
|
+
if (authenticate && !authenticate(params, req)) {
|
|
17
|
+
ws.params = {};
|
|
18
|
+
return ws.close(4001, "Unauthorized");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
ws.params = params;
|
|
20
22
|
const userId = ws.params.userId;
|
|
21
23
|
|
|
22
24
|
// first tab of this user -> online
|
package/stripe.js
CHANGED
|
File without changes
|
package/systemLog.js
CHANGED
|
File without changes
|