comty.js 0.1.1 → 0.46.1
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/dist/index.js +24 -10
- package/dist/models/post/index.js +4 -4
- package/dist/models/session/index.js +8 -3
- package/dist/remotes.js +6 -6
- package/package.json +23 -23
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _socketioclient = require('socket.io-client');
|
|
|
5
5
|
|
|
6
6
|
var _remotes = require('./remotes'); var _remotes2 = _interopRequireDefault(_remotes);
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
//import request from "./handlers/request"
|
|
9
9
|
var _withStorage = require('./helpers/withStorage'); var _withStorage2 = _interopRequireDefault(_withStorage);
|
|
10
10
|
|
|
11
11
|
var _session = require('./models/session'); var _session2 = _interopRequireDefault(_session);
|
|
@@ -25,10 +25,11 @@ if (globalThis.isServerMode) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function createClient({
|
|
28
|
-
wsEvents = Object(),
|
|
29
|
-
useWs = false,
|
|
30
28
|
accessKey = null,
|
|
31
29
|
privateKey = null,
|
|
30
|
+
enableWs = false,
|
|
31
|
+
wsEvents = Object(),
|
|
32
|
+
wsParams = Object(),
|
|
32
33
|
} = {}) {
|
|
33
34
|
const sharedState = globalThis.__comty_shared_state = {
|
|
34
35
|
onExpiredExceptionEvent: false,
|
|
@@ -54,12 +55,25 @@ if (globalThis.isServerMode) {
|
|
|
54
55
|
baseURL: remote.origin,
|
|
55
56
|
})
|
|
56
57
|
|
|
57
|
-
if (
|
|
58
|
-
|
|
58
|
+
if (enableWs && remote.hasWebsocket) {
|
|
59
|
+
let opts = {
|
|
59
60
|
transports: ["websocket"],
|
|
60
|
-
autoConnect: true,
|
|
61
|
+
autoConnect: _nullishCoalesce(remote.autoConnect, () => ( true)),
|
|
61
62
|
..._nullishCoalesce(remote.wsParams, () => ( {})),
|
|
62
|
-
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (wsParams[key]) {
|
|
66
|
+
if (typeof wsParams[key] === "function") {
|
|
67
|
+
opts = wsParams[key](opts)
|
|
68
|
+
} else {
|
|
69
|
+
opts = {
|
|
70
|
+
...opts,
|
|
71
|
+
...wsParams[key],
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
sharedState.wsInstances[key] = _socketioclient.io.call(void 0, _nullishCoalesce(remote.wsOrigin, () => ( remote.origin)), opts)
|
|
63
77
|
}
|
|
64
78
|
}
|
|
65
79
|
|
|
@@ -68,9 +82,9 @@ if (globalThis.isServerMode) {
|
|
|
68
82
|
const ws = sharedState.wsInstances[key]
|
|
69
83
|
|
|
70
84
|
ws.on("connect", () => {
|
|
71
|
-
console.
|
|
85
|
+
console.debug(`[WS-API][${key}] Connected`)
|
|
72
86
|
|
|
73
|
-
if (_remotes2.default[key].
|
|
87
|
+
if (_remotes2.default[key].useClassicAuth) {
|
|
74
88
|
// try to auth
|
|
75
89
|
ws.emit("authenticate", {
|
|
76
90
|
token: _session2.default.token,
|
|
@@ -87,7 +101,7 @@ if (globalThis.isServerMode) {
|
|
|
87
101
|
})
|
|
88
102
|
|
|
89
103
|
ws.onAny((event, ...args) => {
|
|
90
|
-
console.
|
|
104
|
+
console.debug(`[WS-API][${key}] Event recived`, event, ...args)
|
|
91
105
|
})
|
|
92
106
|
|
|
93
107
|
const customEvents = wsEvents[key]
|
|
@@ -50,7 +50,7 @@ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 =
|
|
|
50
50
|
throw new Error("Post ID and/or comment are required")
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const
|
|
53
|
+
const { data } = await _request2.default.call(void 0, {
|
|
54
54
|
method: "POST",
|
|
55
55
|
url: `/comments/post/${post_id}`,
|
|
56
56
|
data: {
|
|
@@ -58,7 +58,7 @@ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 =
|
|
|
58
58
|
},
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
-
return
|
|
61
|
+
return data
|
|
62
62
|
}}
|
|
63
63
|
|
|
64
64
|
static __initStatic5() {this.deleteComment = async ({ post_id, comment_id }) => {
|
|
@@ -66,12 +66,12 @@ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 =
|
|
|
66
66
|
throw new Error("Post ID and/or comment ID are required")
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
const
|
|
69
|
+
const { data } = await _request2.default.call(void 0, {
|
|
70
70
|
method: "DELETE",
|
|
71
71
|
url: `/comments/post/${post_id}/${comment_id}`,
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
return
|
|
74
|
+
return data
|
|
75
75
|
}}
|
|
76
76
|
|
|
77
77
|
static __initStatic6() {this.getExplorePosts = async ({ trim, limit }) => {
|
|
@@ -106,9 +106,14 @@ var _withStorage = require('../../helpers/withStorage'); var _withStorage2 = _in
|
|
|
106
106
|
return response.data
|
|
107
107
|
}}
|
|
108
108
|
|
|
109
|
+
// alias for validateToken method
|
|
109
110
|
static __initStatic8() {this.validSession = async (token) => {
|
|
111
|
+
return await Session.validateToken(token)
|
|
112
|
+
}}
|
|
113
|
+
|
|
114
|
+
static __initStatic9() {this.validateToken = async (token) => {
|
|
110
115
|
const response = await _request2.default.call(void 0, {
|
|
111
|
-
method: "
|
|
116
|
+
method: "post",
|
|
112
117
|
url: "/session/validate",
|
|
113
118
|
data: {
|
|
114
119
|
token: token
|
|
@@ -118,9 +123,9 @@ var _withStorage = require('../../helpers/withStorage'); var _withStorage2 = _in
|
|
|
118
123
|
return response.data
|
|
119
124
|
}}
|
|
120
125
|
|
|
121
|
-
static
|
|
126
|
+
static __initStatic10() {this.isCurrentTokenValid = async () => {
|
|
122
127
|
const health = await Session.getTokenValidation()
|
|
123
128
|
|
|
124
129
|
return health.valid
|
|
125
130
|
}}
|
|
126
|
-
} Session.__initStatic(); Session.__initStatic2(); Session.__initStatic3(); Session.__initStatic4(); Session.__initStatic5(); Session.__initStatic6(); Session.__initStatic7(); Session.__initStatic8(); Session.__initStatic9(); exports.default = Session;
|
|
131
|
+
} Session.__initStatic(); Session.__initStatic2(); Session.__initStatic3(); Session.__initStatic4(); Session.__initStatic5(); Session.__initStatic6(); Session.__initStatic7(); Session.__initStatic8(); Session.__initStatic9(); Session.__initStatic10(); exports.default = Session;
|
package/dist/remotes.js
CHANGED
|
@@ -13,13 +13,13 @@ function getCurrentHostname() {
|
|
|
13
13
|
const envOrigins = {
|
|
14
14
|
"development": {
|
|
15
15
|
default: `http://${getCurrentHostname()}:3010`,
|
|
16
|
-
|
|
16
|
+
chat: `http://${getCurrentHostname()}:3020`,
|
|
17
17
|
livestreaming: `http://${getCurrentHostname()}:3030`,
|
|
18
18
|
marketplace: `http://${getCurrentHostname()}:3040`,
|
|
19
19
|
},
|
|
20
20
|
"production": {
|
|
21
21
|
default: "https://api.comty.app",
|
|
22
|
-
|
|
22
|
+
chat: `https://chat_api.comty.app`,
|
|
23
23
|
livestreaming: `https://livestreaming_api.comty.app`,
|
|
24
24
|
marketplace: `https://marketplace_api.comty.app`,
|
|
25
25
|
}
|
|
@@ -29,12 +29,12 @@ exports. default = {
|
|
|
29
29
|
default: {
|
|
30
30
|
origin: composeRemote("default"),
|
|
31
31
|
hasWebsocket: true,
|
|
32
|
-
|
|
32
|
+
useClassicAuth: true,
|
|
33
|
+
autoconnect: true,
|
|
33
34
|
},
|
|
34
|
-
|
|
35
|
-
origin: composeRemote("
|
|
35
|
+
chat: {
|
|
36
|
+
origin: composeRemote("chat"),
|
|
36
37
|
hasWebsocket: true,
|
|
37
|
-
needsAuth: true,
|
|
38
38
|
},
|
|
39
39
|
livestreaming: {
|
|
40
40
|
origin: composeRemote("livestreaming"),
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
2
|
+
"name": "comty.js",
|
|
3
|
+
"version": "0.46.1",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"author": "RageStudio <support@ragestudio.net>",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "corenode-cli build"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@foxify/events": "^2.1.0",
|
|
15
|
+
"axios": "^1.4.0",
|
|
16
|
+
"js-cookie": "^3.0.5",
|
|
17
|
+
"jsonwebtoken": "^9.0.0",
|
|
18
|
+
"jwt-decode": "^3.1.2",
|
|
19
|
+
"linebridge": "^0.15.12"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"corenode": "^0.28.26"
|
|
23
|
+
}
|
|
24
|
+
}
|