comty.js 0.1.0 → 0.46.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.
Files changed (36) hide show
  1. package/{src → dist}/handlers/measurePing.js +3 -3
  2. package/{src → dist}/handlers/request.js +8 -8
  3. package/{src → dist}/helpers/handleAfterRequest.js +3 -3
  4. package/{src → dist}/helpers/handleBeforeRequest.js +1 -1
  5. package/dist/helpers/handleRegenerationEvent.js +39 -0
  6. package/dist/helpers/withSettings.js +25 -0
  7. package/{src → dist}/helpers/withStorage.js +4 -4
  8. package/{src → dist}/hooks/useRequest/index.js +6 -6
  9. package/{src → dist}/index.js +20 -20
  10. package/dist/models/auth/index.js +53 -0
  11. package/dist/models/feed/index.js +82 -0
  12. package/dist/models/follows/index.js +48 -0
  13. package/dist/models/index.js +44 -0
  14. package/dist/models/livestream/index.js +84 -0
  15. package/dist/models/playlists/index.js +48 -0
  16. package/dist/models/post/index.js +169 -0
  17. package/dist/models/session/index.js +126 -0
  18. package/{src → dist}/models/sync/cores/spotifyCore.js +2 -2
  19. package/dist/models/sync/index.js +11 -0
  20. package/dist/models/user/index.js +159 -0
  21. package/dist/models/widget/index.js +18 -0
  22. package/{src → dist}/remotes.js +3 -3
  23. package/package.json +23 -20
  24. package/src/helpers/handleRegenerationEvent.js +0 -39
  25. package/src/helpers/withSettings.js +0 -25
  26. package/src/models/auth/index.js +0 -53
  27. package/src/models/feed/index.js +0 -82
  28. package/src/models/follows/index.js +0 -48
  29. package/src/models/index.js +0 -44
  30. package/src/models/livestream/index.js +0 -84
  31. package/src/models/playlists/index.js +0 -48
  32. package/src/models/post/index.js +0 -169
  33. package/src/models/session/index.js +0 -126
  34. package/src/models/sync/index.js +0 -11
  35. package/src/models/user/index.js +0 -159
  36. package/src/models/widget/index.js +0 -18
@@ -0,0 +1,48 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
2
+
3
+ class PlaylistsModel {
4
+ static __initStatic() {this.putPlaylist = async (payload) => {
5
+ if (!payload) {
6
+ throw new Error("Payload is required")
7
+ }
8
+
9
+ const { data } = await _request2.default.call(void 0, {
10
+ method: "PUT",
11
+ url: `/playlist`,
12
+ data: payload,
13
+ })
14
+
15
+ return data
16
+ }}
17
+
18
+ static __initStatic2() {this.getPlaylist = async (id) => {
19
+ const { data } = await _request2.default.call(void 0, {
20
+ method: "GET",
21
+ url: `/playlist/data/${id}`,
22
+ })
23
+
24
+ return data
25
+ }}
26
+
27
+ static __initStatic3() {this.getMyReleases = async () => {
28
+ const { data } = await _request2.default.call(void 0, {
29
+ method: "GET",
30
+ url: `/playlist/self`,
31
+ })
32
+
33
+ return data
34
+ }}
35
+
36
+ static __initStatic4() {this.deletePlaylist = async (id) => {
37
+ if (!id) {
38
+ throw new Error("ID is required")
39
+ }
40
+
41
+ const { data } = await _request2.default.call(void 0, {
42
+ method: "DELETE",
43
+ url: `/playlist/${id}`,
44
+ })
45
+
46
+ return data
47
+ }}
48
+ } PlaylistsModel.__initStatic(); PlaylistsModel.__initStatic2(); PlaylistsModel.__initStatic3(); PlaylistsModel.__initStatic4(); exports.default = PlaylistsModel;
@@ -0,0 +1,169 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
2
+ var _withSettings = require('../../helpers/withSettings'); var _withSettings2 = _interopRequireDefault(_withSettings);
3
+
4
+ class Post {
5
+ static get maxPostTextLength() {
6
+ return 3200
7
+ }
8
+
9
+ static get maxCommentLength() {
10
+ return 1200
11
+ }
12
+
13
+ static __initStatic() {this.getPostingPolicy = async () => {
14
+ const { data } = await _request2.default.call(void 0, {
15
+ method: "GET",
16
+ url: "/posting_policy",
17
+ })
18
+
19
+ return data
20
+ }}
21
+
22
+ static __initStatic2() {this.getPost = async ({ post_id }) => {
23
+ if (!post_id) {
24
+ throw new Error("Post ID is required")
25
+ }
26
+
27
+ const { data } = await _request2.default.call(void 0, {
28
+ method: "GET",
29
+ url: `/posts/post/${post_id}`,
30
+ })
31
+
32
+ return data
33
+ }}
34
+
35
+ static __initStatic3() {this.getPostComments = async ({ post_id }) => {
36
+ if (!post_id) {
37
+ throw new Error("Post ID is required")
38
+ }
39
+
40
+ const { data } = await _request2.default.call(void 0, {
41
+ method: "GET",
42
+ url: `/comments/post/${post_id}`,
43
+ })
44
+
45
+ return data
46
+ }}
47
+
48
+ static __initStatic4() {this.sendComment = async ({ post_id, comment }) => {
49
+ if (!post_id || !comment) {
50
+ throw new Error("Post ID and/or comment are required")
51
+ }
52
+
53
+ const request = await request({
54
+ method: "POST",
55
+ url: `/comments/post/${post_id}`,
56
+ data: {
57
+ message: comment,
58
+ },
59
+ })
60
+
61
+ return request
62
+ }}
63
+
64
+ static __initStatic5() {this.deleteComment = async ({ post_id, comment_id }) => {
65
+ if (!post_id || !comment_id) {
66
+ throw new Error("Post ID and/or comment ID are required")
67
+ }
68
+
69
+ const request = await request({
70
+ method: "DELETE",
71
+ url: `/comments/post/${post_id}/${comment_id}`,
72
+ })
73
+
74
+ return request
75
+ }}
76
+
77
+ static __initStatic6() {this.getExplorePosts = async ({ trim, limit }) => {
78
+ const { data } = await _request2.default.call(void 0, {
79
+ method: "GET",
80
+ url: `/posts/explore`,
81
+ params: {
82
+ trim: _nullishCoalesce(trim, () => ( 0)),
83
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
84
+ }
85
+ })
86
+
87
+ return data
88
+ }}
89
+
90
+ static __initStatic7() {this.getSavedPosts = async ({ trim, limit }) => {
91
+ const { data } = await _request2.default.call(void 0, {
92
+ method: "GET",
93
+ url: `/posts/saved`,
94
+ params: {
95
+ trim: _nullishCoalesce(trim, () => ( 0)),
96
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
97
+ }
98
+ })
99
+
100
+ return data
101
+ }}
102
+
103
+ static __initStatic8() {this.getUserPosts = async ({ user_id, trim, limit }) => {
104
+ if (!user_id) {
105
+ // use current user_id
106
+ user_id = _optionalChain([app, 'access', _3 => _3.userData, 'optionalAccess', _4 => _4._id])
107
+ }
108
+
109
+ const { data } = await _request2.default.call(void 0, {
110
+ method: "GET",
111
+ url: `/posts/user/${user_id}`,
112
+ params: {
113
+ trim: _nullishCoalesce(trim, () => ( 0)),
114
+ limit: _nullishCoalesce(limit, () => ( _withSettings2.default.get("feed_max_fetch"))),
115
+ }
116
+ })
117
+
118
+ return data
119
+ }}
120
+
121
+ static __initStatic9() {this.toogleLike = async ({ post_id }) => {
122
+ if (!post_id) {
123
+ throw new Error("Post ID is required")
124
+ }
125
+
126
+ const { data } = await _request2.default.call(void 0, {
127
+ method: "POST",
128
+ url: `/posts/${post_id}/toogle_like`,
129
+ })
130
+
131
+ return data
132
+ }}
133
+
134
+ static __initStatic10() {this.toogleSave = async ({ post_id }) => {
135
+ if (!post_id) {
136
+ throw new Error("Post ID is required")
137
+ }
138
+
139
+ const { data } = await _request2.default.call(void 0, {
140
+ method: "POST",
141
+ url: `/posts/${post_id}/toogle_save`,
142
+ })
143
+
144
+ return data
145
+ }}
146
+
147
+ static __initStatic11() {this.create = async (payload) => {
148
+ const { data } = await _request2.default.call(void 0, {
149
+ method: "POST",
150
+ url: `/posts/new`,
151
+ data: payload,
152
+ })
153
+
154
+ return data
155
+ }}
156
+
157
+ static __initStatic12() {this.deletePost = async ({ post_id }) => {
158
+ if (!post_id) {
159
+ throw new Error("Post ID is required")
160
+ }
161
+
162
+ const { data } = await _request2.default.call(void 0, {
163
+ method: "DELETE",
164
+ url: `/posts/${post_id}`,
165
+ })
166
+
167
+ return data
168
+ }}
169
+ } Post.__initStatic(); Post.__initStatic2(); Post.__initStatic3(); Post.__initStatic4(); Post.__initStatic5(); Post.__initStatic6(); Post.__initStatic7(); Post.__initStatic8(); Post.__initStatic9(); Post.__initStatic10(); Post.__initStatic11(); Post.__initStatic12(); exports.default = Post;
@@ -0,0 +1,126 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _jwtdecode = require('jwt-decode'); var _jwtdecode2 = _interopRequireDefault(_jwtdecode);
2
+ var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
3
+ var _withStorage = require('../../helpers/withStorage'); var _withStorage2 = _interopRequireDefault(_withStorage);
4
+
5
+ class Session {
6
+ static __initStatic() {this.storageTokenKey = "token"}
7
+
8
+ static get token() {
9
+ return _withStorage2.default.engine.get(this.storageTokenKey)
10
+ }
11
+
12
+ static set token(token) {
13
+ return _withStorage2.default.engine.set(this.storageTokenKey, token)
14
+ }
15
+
16
+ static get user_id() {
17
+ return _optionalChain([this, 'access', _ => _.getDecodedToken, 'call', _2 => _2(), 'optionalAccess', _3 => _3.user_id])
18
+ }
19
+
20
+ static get session_uuid() {
21
+ return _optionalChain([this, 'access', _4 => _4.getDecodedToken, 'call', _5 => _5(), 'optionalAccess', _6 => _6.session_uuid])
22
+ }
23
+
24
+ static __initStatic2() {this.getDecodedToken = () => {
25
+ const token = this.token
26
+
27
+ return token && _jwtdecode2.default.call(void 0, token)
28
+ }}
29
+
30
+ static __initStatic3() {this.getAllSessions = async () => {
31
+ const response = await _request2.default.call(void 0, {
32
+ method: "get",
33
+ url: "/session/all"
34
+ })
35
+
36
+ return response.data
37
+ }}
38
+
39
+ static __initStatic4() {this.getCurrentSession = async () => {
40
+ const response = await _request2.default.call(void 0, {
41
+ method: "get",
42
+ url: "/session/current"
43
+ })
44
+
45
+ return response.data
46
+ }}
47
+
48
+ static __initStatic5() {this.getTokenValidation = async () => {
49
+ const session = await Session.token
50
+
51
+ const response = await _request2.default.call(void 0, {
52
+ method: "get",
53
+ url: "/session/validate",
54
+ data: {
55
+ session: session
56
+ }
57
+ })
58
+
59
+ return response.data
60
+ }}
61
+
62
+ static removeToken() {
63
+ return _withStorage2.default.engine.remove(Session.storageTokenKey)
64
+ }
65
+
66
+ static __initStatic6() {this.destroyCurrentSession = async () => {
67
+ const token = await Session.token
68
+ const session = await Session.getDecodedToken()
69
+
70
+ if (!session || !token) {
71
+ return false
72
+ }
73
+
74
+ const response = await _request2.default.call(void 0, {
75
+ method: "delete",
76
+ url: "/session/current"
77
+ }).catch((error) => {
78
+ console.error(error)
79
+
80
+ return false
81
+ })
82
+
83
+ Session.removeToken()
84
+
85
+ __comty_shared_state.eventBus.emit("session.destroyed")
86
+
87
+ return response.data
88
+ }}
89
+
90
+ static __initStatic7() {this.destroyAllSessions = async () => {
91
+ const session = await Session.getDecodedToken()
92
+
93
+ if (!session) {
94
+ return false
95
+ }
96
+
97
+ const response = await _request2.default.call(void 0, {
98
+ method: "delete",
99
+ url: "/session/all"
100
+ })
101
+
102
+ Session.removeToken()
103
+
104
+ __comty_shared_state.eventBus.emit("session.destroyed")
105
+
106
+ return response.data
107
+ }}
108
+
109
+ static __initStatic8() {this.validSession = async (token) => {
110
+ const response = await _request2.default.call(void 0, {
111
+ method: "POST",
112
+ url: "/session/validate",
113
+ data: {
114
+ token: token
115
+ }
116
+ })
117
+
118
+ return response.data
119
+ }}
120
+
121
+ static __initStatic9() {this.isCurrentTokenValid = async () => {
122
+ const health = await Session.getTokenValidation()
123
+
124
+ return health.valid
125
+ }}
126
+ } Session.__initStatic(); Session.__initStatic2(); Session.__initStatic3(); Session.__initStatic4(); Session.__initStatic5(); Session.__initStatic6(); Session.__initStatic7(); Session.__initStatic8(); Session.__initStatic9(); exports.default = Session;
@@ -1,4 +1,4 @@
1
- export default class SpotifySyncModel {
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); class SpotifySyncModel {
2
2
  static get spotify_redirect_uri() {
3
3
  return window.location.origin + "/callbacks/sync/spotify"
4
4
  }
@@ -84,4 +84,4 @@ export default class SpotifySyncModel {
84
84
 
85
85
  return data
86
86
  }
87
- }
87
+ } exports.default = SpotifySyncModel;
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _spotifyCore = require('./cores/spotifyCore'); var _spotifyCore2 = _interopRequireDefault(_spotifyCore);
2
+
3
+ class SyncModel {
4
+ static get bridge() {
5
+ return _optionalChain([window, 'access', _ => _.app, 'optionalAccess', _2 => _2.cores, 'access', _3 => _3.api, 'access', _4 => _4.withEndpoints, 'call', _5 => _5()])
6
+ }
7
+
8
+ static get spotifyCore() {
9
+ return _spotifyCore2.default
10
+ }
11
+ } exports.default = SyncModel;
@@ -0,0 +1,159 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _session = require('../session'); var _session2 = _interopRequireDefault(_session);
2
+ var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
3
+
4
+ class User {
5
+ static __initStatic() {this.data = async (payload = {}) => {
6
+ let {
7
+ username,
8
+ user_id,
9
+ } = payload
10
+
11
+ if (!username && !user_id) {
12
+ user_id = _session2.default.user_id
13
+ }
14
+
15
+ if (username && !user_id) {
16
+ // resolve user_id from username
17
+ const resolveResponse = await _request2.default.call(void 0, {
18
+ method: "GET",
19
+ url: `/user/user_id/${username}`,
20
+ })
21
+
22
+ user_id = resolveResponse.data.user_id
23
+ }
24
+
25
+ const response = await _request2.default.call(void 0, {
26
+ method: "GET",
27
+ url: `/user/${user_id}/data`,
28
+ })
29
+
30
+ return response.data
31
+ }}
32
+
33
+ static __initStatic2() {this.updateData = async (payload) => {
34
+ const response = await _request2.default.call(void 0, {
35
+ method: "POST",
36
+ url: "/user/self/update_data",
37
+ data: {
38
+ update: payload,
39
+ },
40
+ })
41
+
42
+ return response.data
43
+ }}
44
+
45
+ static __initStatic3() {this.unsetFullName = async () => {
46
+ const response = await _request2.default.call(void 0, {
47
+ method: "DELETE",
48
+ url: "/user/self/public_name",
49
+ })
50
+
51
+ return response.data
52
+ }}
53
+
54
+ static __initStatic4() {this.selfRoles = async () => {
55
+ const response = await _request2.default.call(void 0, {
56
+ method: "GET",
57
+ url: "/roles/self",
58
+ })
59
+
60
+ return response.data
61
+ }}
62
+
63
+ static __initStatic5() {this.haveRole = async (role) => {
64
+ const roles = await User.selfRoles()
65
+
66
+ if (!roles) {
67
+ return false
68
+ }
69
+
70
+ return Array.isArray(roles) && roles.includes(role)
71
+ }}
72
+
73
+ static __initStatic6() {this.haveAdmin = async () => {
74
+ return User.haveRole("admin")
75
+ }}
76
+
77
+ static __initStatic7() {this.getUserBadges = async (user_id) => {
78
+ if (!user_id) {
79
+ user_id = _session2.default.user_id
80
+ }
81
+
82
+ const { data } = await _request2.default.call(void 0, {
83
+ method: "GET",
84
+ url: `/badge/user/${user_id}`,
85
+ })
86
+
87
+ return data
88
+ }}
89
+
90
+ static __initStatic8() {this.changePassword = async (payload) => {
91
+ const { currentPassword, newPassword } = payload
92
+
93
+ const { data } = await _request2.default.call(void 0, {
94
+ method: "POST",
95
+ url: "/self/update_password",
96
+ data: {
97
+ currentPassword,
98
+ newPassword,
99
+ }
100
+ })
101
+
102
+ return data
103
+ }}
104
+
105
+ static __initStatic9() {this.getUserFollowers = async ({
106
+ user_id,
107
+ limit = 20,
108
+ offset = 0,
109
+ }) => {
110
+ // if user_id or username is not provided, set with current user
111
+ if (!user_id && !username) {
112
+ user_id = _session2.default.user_id
113
+ }
114
+
115
+ const { data } = await _request2.default.call(void 0, {
116
+ method: "GET",
117
+ url: `/user/${user_id}/followers`,
118
+ params: {
119
+ limit,
120
+ offset,
121
+ }
122
+ })
123
+
124
+ return data
125
+ }}
126
+
127
+ static __initStatic10() {this.getConnectedUsersFollowing = async () => {
128
+ const { data } = await _request2.default.call(void 0, {
129
+ method: "GET",
130
+ url: "/status/connected/following",
131
+ })
132
+
133
+ return data
134
+ }}
135
+
136
+ static __initStatic11() {this.checkUsernameAvailability = async (username) => {
137
+ const { data } = await _request2.default.call(void 0, {
138
+ method: "GET",
139
+ url: `/user/username_available`,
140
+ params: {
141
+ username,
142
+ }
143
+ })
144
+
145
+ return data
146
+ }}
147
+
148
+ static __initStatic12() {this.checkEmailAvailability = async (email) => {
149
+ const { data } = await _request2.default.call(void 0, {
150
+ method: "GET",
151
+ url: `/user/email_available`,
152
+ params: {
153
+ email,
154
+ }
155
+ })
156
+
157
+ return data
158
+ }}
159
+ } User.__initStatic(); User.__initStatic2(); User.__initStatic3(); User.__initStatic4(); User.__initStatic5(); User.__initStatic6(); User.__initStatic7(); User.__initStatic8(); User.__initStatic9(); User.__initStatic10(); User.__initStatic11(); User.__initStatic12(); exports.default = User;
@@ -0,0 +1,18 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
2
+
3
+ class WidgetModel {
4
+ static __initStatic() {this.browse = async ({ limit, offset, keywords } = {}) => {
5
+ const response = await _request2.default.call(void 0, {
6
+ instance: globalThis.__comty_shared_state.instances["marketplace"],
7
+ method: "GET",
8
+ url: "/widgets",
9
+ params: {
10
+ limit,
11
+ offset,
12
+ keywords: JSON.stringify(keywords),
13
+ },
14
+ })
15
+
16
+ return response.data
17
+ }}
18
+ } WidgetModel.__initStatic(); exports.default = WidgetModel;
@@ -1,4 +1,4 @@
1
- function composeRemote(path) {
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }function composeRemote(path) {
2
2
  return envOrigins[process.env.NODE_ENV][path]
3
3
  }
4
4
 
@@ -7,7 +7,7 @@ function getCurrentHostname() {
7
7
  return "localhost"
8
8
  }
9
9
 
10
- return window?.location?.hostname ?? "localhost"
10
+ return _nullishCoalesce(_optionalChain([window, 'optionalAccess', _ => _.location, 'optionalAccess', _2 => _2.hostname]), () => ( "localhost"))
11
11
  }
12
12
 
13
13
  const envOrigins = {
@@ -25,7 +25,7 @@ const envOrigins = {
25
25
  }
26
26
  }
27
27
 
28
- export default {
28
+ exports. default = {
29
29
  default: {
30
30
  origin: composeRemote("default"),
31
31
  hasWebsocket: true,
package/package.json CHANGED
@@ -1,21 +1,24 @@
1
1
  {
2
- "name": "comty.js",
3
- "version": "0.1.0",
4
- "main": "./dist/index.js",
5
- "author": "RageStudio <support@ragestudio.net>",
6
- "scripts": {
7
- "build": "corenode-cli build"
8
- },
9
- "license": "MIT",
10
- "dependencies": {
11
- "@foxify/events": "^2.1.0",
12
- "axios": "^1.4.0",
13
- "js-cookie": "^3.0.5",
14
- "jsonwebtoken": "^9.0.0",
15
- "jwt-decode": "^3.1.2",
16
- "linebridge": "^0.15.12"
17
- },
18
- "devDependencies": {
19
- "corenode": "^0.28.26"
20
- }
21
- }
2
+ "name": "comty.js",
3
+ "version": "0.46.0",
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
+ }
@@ -1,39 +0,0 @@
1
- import SessionModel from "../models/session"
2
- import request from "../handlers/request"
3
-
4
- export default async (refreshToken) =>{
5
- __comty_shared_state.eventBus.emit("session.expiredExceptionEvent", refreshToken)
6
-
7
- __comty_shared_state.onExpiredExceptionEvent = true
8
-
9
- const expiredToken = await SessionModel.token
10
-
11
- // send request to regenerate token
12
- const response = await request({
13
- method: "POST",
14
- url: "/session/regenerate",
15
- data: {
16
- expiredToken: expiredToken,
17
- refreshToken,
18
- }
19
- }).catch((error) => {
20
- console.error(`Failed to regenerate token: ${error.message}`)
21
- return false
22
- })
23
-
24
- if (!response) {
25
- return __comty_shared_state.eventBus.emit("session.invalid", "Failed to regenerate token")
26
- }
27
-
28
- if (!response.data?.token) {
29
- return __comty_shared_state.eventBus.emit("session.invalid", "Failed to regenerate token, invalid server response.")
30
- }
31
-
32
- // set new token
33
- SessionModel.token = response.data.token
34
-
35
- __comty_shared_state.onExpiredExceptionEvent = false
36
-
37
- // emit event
38
- __comty_shared_state.eventBus.emit("session.regenerated")
39
- }
@@ -1,25 +0,0 @@
1
- export default class Settings {
2
- static get = (key) => {
3
- if (typeof window === "undefined") {
4
- return null
5
- }
6
-
7
- return window?.app?.cores?.settings.get(key)
8
- }
9
-
10
- static set = (key, value) => {
11
- if (typeof window === "undefined") {
12
- return null
13
- }
14
-
15
- return window?.app?.cores?.settings.set(key, value)
16
- }
17
-
18
- static is = (key) => {
19
- if (typeof window === "undefined") {
20
- return null
21
- }
22
-
23
- return window?.app?.cores?.settings.is(key)
24
- }
25
- }