comty.js 0.64.0 → 0.65.2
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 +0 -1
- package/dist/models/auth/index.js +1 -1
- package/dist/models/e2e/index.js +30 -0
- package/dist/models/music/getters/isItemFavorited.js +25 -0
- package/dist/models/music/getters/library.js +44 -0
- package/dist/models/music/getters/myReleases.js +14 -18
- package/dist/models/music/getters/releases.js +14 -21
- package/dist/models/music/getters/trackLyrics.js +16 -16
- package/dist/models/music/getters/tracks.js +14 -21
- package/dist/models/music/index.js +34 -147
- package/dist/models/music/setters/putTrackLyrics.js +8 -8
- package/dist/models/music/setters/toggleItemFavorite.js +26 -0
- package/dist/models/radio/getters/trendings.js +10 -0
- package/dist/models/radio/index.js +3 -1
- package/dist/models/session/index.js +165 -160
- package/dist/models/spectrum/index.js +88 -49
- package/dist/models/user/index.js +34 -1
- package/dist/remotes.js +1 -1
- package/dist/utils/measurePing.js +10 -7
- package/dist/ws.js +2 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var _session = require('../session'); var _session2 = _interopRequireDefault(_se
|
|
|
35
35
|
_session2.default.refreshToken = response.data.refreshToken
|
|
36
36
|
|
|
37
37
|
if (typeof callback === "function") {
|
|
38
|
-
await callback()
|
|
38
|
+
await callback(response.data)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
__comty_shared_state.eventBus.emit("auth:login_success")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
var _request = require('../../request'); var _request2 = _interopRequireDefault(_request);
|
|
3
|
+
|
|
4
|
+
class E2EModel {
|
|
5
|
+
static async getKeyPair() {
|
|
6
|
+
const response = await _request2.default.call(void 0, {
|
|
7
|
+
method: "GET",
|
|
8
|
+
url: "/users/self/keypair",
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
return response.data
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// WARNING: updating keypair makes all decryption fail
|
|
15
|
+
static async updateKeyPair(str, { imSure = false } = {}) {
|
|
16
|
+
if (imSure !== true) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"Missing confirmation to update the keypair. Use `imSure = true` to proceed.",
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const response = await _request2.default.call(void 0, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
url: "/users/self/keypair",
|
|
25
|
+
data: { str: str },
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return response.data
|
|
29
|
+
}
|
|
30
|
+
} exports.default = E2EModel;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../../request'); var _request2 = _interopRequireDefault(_request);
|
|
2
|
+
|
|
3
|
+
exports. default = async (type, item_id) => {
|
|
4
|
+
if (!type) {
|
|
5
|
+
throw new Error("type is required")
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (!item_id) {
|
|
9
|
+
throw new Error("item_id is required")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type = type.toLowerCase()
|
|
13
|
+
|
|
14
|
+
const response = await _request2.default.call(void 0, {
|
|
15
|
+
method: "GET",
|
|
16
|
+
url: `/music/my/library/favorite`,
|
|
17
|
+
params: {
|
|
18
|
+
kind: type,
|
|
19
|
+
item_id: item_id,
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
return response.data
|
|
25
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../../request'); var _request2 = _interopRequireDefault(_request);
|
|
2
|
+
var _processWithAddons = require('../../../helpers/processWithAddons'); var _processWithAddons2 = _interopRequireDefault(_processWithAddons);
|
|
3
|
+
var _standartListMerge = require('../../../utils/standartListMerge'); var _standartListMerge2 = _interopRequireDefault(_standartListMerge);
|
|
4
|
+
|
|
5
|
+
exports. default = async ({ limit = 100, offset = 0, order = "desc", kind }) => {
|
|
6
|
+
const addons = __comty_shared_state.addons.getByOperation("getMyLibrary")
|
|
7
|
+
|
|
8
|
+
const dividedLimit = limit / (addons.length + 1)
|
|
9
|
+
|
|
10
|
+
const { data } = await _request2.default.call(void 0, {
|
|
11
|
+
method: "GET",
|
|
12
|
+
url: "/music/my/library",
|
|
13
|
+
params: {
|
|
14
|
+
limit: dividedLimit,
|
|
15
|
+
offset: offset,
|
|
16
|
+
order: order,
|
|
17
|
+
kind: kind,
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
let results = await _processWithAddons2.default.call(void 0, {
|
|
22
|
+
operation: "getMyLibrary",
|
|
23
|
+
initialData: data,
|
|
24
|
+
fnArguments: [{ limit: dividedLimit, offset: offset, order: order }],
|
|
25
|
+
normalizeAddonResult: ({ currentData, addonResult }) => {
|
|
26
|
+
return _standartListMerge2.default.call(void 0, currentData, addonResult)
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
// sort tracks by liked_at
|
|
31
|
+
if (results.tracks) {
|
|
32
|
+
results.tracks.items.sort((a, b) => {
|
|
33
|
+
if (a.liked_at > b.liked_at) {
|
|
34
|
+
return -1
|
|
35
|
+
}
|
|
36
|
+
if (a.liked_at < b.liked_at) {
|
|
37
|
+
return 1
|
|
38
|
+
}
|
|
39
|
+
return 0
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return results
|
|
44
|
+
}
|
|
@@ -6,21 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
exports. default = async ({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
return response.data
|
|
26
|
-
}
|
|
9
|
+
exports. default = async ({ limit, offset, keywords }) => {
|
|
10
|
+
const response = await _request2.default.call(void 0, {
|
|
11
|
+
method: "GET",
|
|
12
|
+
url: "/music/my/releases",
|
|
13
|
+
params: {
|
|
14
|
+
limit: limit,
|
|
15
|
+
offset: offset,
|
|
16
|
+
keywords: keywords,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
return response.data
|
|
22
|
+
}
|
|
@@ -6,24 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
offset: offset,
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
return response.data
|
|
29
|
-
}
|
|
9
|
+
exports. default = async ({ user_id, limit, page }) => {
|
|
10
|
+
const response = await _request2.default.call(void 0, {
|
|
11
|
+
method: "GET",
|
|
12
|
+
url: "/music/releases",
|
|
13
|
+
params: {
|
|
14
|
+
user_id: user_id,
|
|
15
|
+
limit: limit,
|
|
16
|
+
page: page,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
return response.data
|
|
22
|
+
}
|
|
@@ -9,23 +9,23 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
exports. default = async (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
id,
|
|
13
|
+
options = {
|
|
14
|
+
preferTranslation: false,
|
|
15
|
+
},
|
|
16
16
|
) => {
|
|
17
|
-
|
|
17
|
+
const requestParams = Object()
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (options.preferTranslation) {
|
|
20
|
+
requestParams.translate_lang = app.cores.settings.get("app:language")
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const response = await _request2.default.call(void 0, {
|
|
24
|
+
method: "GET",
|
|
25
|
+
url: `/music/tracks/${id}/lyrics`,
|
|
26
|
+
params: requestParams,
|
|
27
|
+
})
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
return response.data
|
|
31
|
+
}
|
|
@@ -6,24 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
offset: offset,
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
return response.data
|
|
29
|
-
}
|
|
9
|
+
exports. default = async ({ user_id, limit, page }) => {
|
|
10
|
+
const response = await _request2.default.call(void 0, {
|
|
11
|
+
method: "GET",
|
|
12
|
+
url: "/music/tracks",
|
|
13
|
+
params: {
|
|
14
|
+
user_id: user_id,
|
|
15
|
+
limit: limit,
|
|
16
|
+
page: page,
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
return response.data
|
|
22
|
+
}
|
|
@@ -2,150 +2,37 @@
|
|
|
2
2
|
var _setters = require('./setters'); var _setters2 = _interopRequireDefault(_setters);
|
|
3
3
|
|
|
4
4
|
class MusicModel {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* @param {number} options.offset - The offset for pagination.
|
|
40
|
-
* @return {Promise<Object>} Playlist data.
|
|
41
|
-
*/
|
|
42
|
-
static __initStatic5() {this.getPlaylistData = _getters2.default.PlaylistData}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Retrieves releases based on the provided parameters.
|
|
46
|
-
* If user_id is not provided, it will retrieve self authenticated user releases.
|
|
47
|
-
*
|
|
48
|
-
* @param {object} options - The options for retrieving releases.
|
|
49
|
-
* @param {string} options.user_id - The ID of the user.
|
|
50
|
-
* @param {string[]} options.keywords - The keywords to filter releases by.
|
|
51
|
-
* @param {number} options.limit - The maximum number of releases to retrieve.
|
|
52
|
-
* @param {number} options.offset - The offset for paginated results.
|
|
53
|
-
* @return {Promise<Object>} - A promise that resolves to the retrieved releases.
|
|
54
|
-
*/
|
|
55
|
-
static __initStatic6() {this.getReleases = _getters2.default.releases}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Retrieves self releases.
|
|
59
|
-
*
|
|
60
|
-
* @param {object} options - The options for retrieving my releases.
|
|
61
|
-
* @param {number} options.limit - The maximum number of releases to retrieve.
|
|
62
|
-
* @param {number} options.offset - The offset for paginated results.
|
|
63
|
-
* @return {Promise<Object>} - A promise that resolves to the retrieved releases.
|
|
64
|
-
*/
|
|
65
|
-
static __initStatic7() {this.getMyReleases = _getters2.default.myReleases}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Retrieves release data by ID.
|
|
69
|
-
*
|
|
70
|
-
* @param {number} id - The ID of the release.
|
|
71
|
-
* @return {Promise<Object>} The release data.
|
|
72
|
-
*/
|
|
73
|
-
static __initStatic8() {this.getReleaseData = _getters2.default.releaseData}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Retrieves track data for a given ID.
|
|
77
|
-
*
|
|
78
|
-
* @param {string} id - The ID of the track or multiple IDs separated by commas.
|
|
79
|
-
* @return {Promise<Object>} The track data.
|
|
80
|
-
*/
|
|
81
|
-
static __initStatic9() {this.getTrackData = _getters2.default.trackData}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Retrieves the official featured playlists.
|
|
85
|
-
*
|
|
86
|
-
* @return {Promise<Object>} The data containing the featured playlists.
|
|
87
|
-
*/
|
|
88
|
-
static __initStatic10() {this.getFeaturedPlaylists = _getters2.default.featuredPlaylists}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Retrieves track lyrics for a given ID.
|
|
92
|
-
*
|
|
93
|
-
* @param {string} id - The ID of the track.
|
|
94
|
-
* @return {Promise<Object>} The track lyrics.
|
|
95
|
-
*/
|
|
96
|
-
static __initStatic11() {this.getTrackLyrics = _getters2.default.trackLyrics}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
static __initStatic12() {this.putTrackLyrics = _setters2.default.putTrackLyrics}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Create or modify a track.
|
|
103
|
-
*
|
|
104
|
-
* @param {object} TrackManifest - The track manifest.
|
|
105
|
-
* @return {Promise<Object>} The result track data.
|
|
106
|
-
*/
|
|
107
|
-
static __initStatic13() {this.putTrack = _setters2.default.putTrack}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Create or modify a release.
|
|
111
|
-
*
|
|
112
|
-
* @param {object} ReleaseManifest - The release manifest.
|
|
113
|
-
* @return {Promise<Object>} The result release data.
|
|
114
|
-
*/
|
|
115
|
-
static __initStatic14() {this.putRelease = _setters2.default.putRelease}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Deletes a release by its ID.
|
|
119
|
-
*
|
|
120
|
-
* @param {string} id - The ID of the release to delete.
|
|
121
|
-
* @return {Promise<Object>} - A Promise that resolves to the data returned by the API.
|
|
122
|
-
*/
|
|
123
|
-
static __initStatic15() {this.deleteRelease = _setters2.default.deleteRelease}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Retrieves the favourite tracks of the current user.
|
|
127
|
-
*
|
|
128
|
-
* @return {Promise<Object>} The favorite tracks data.
|
|
129
|
-
*/
|
|
130
|
-
static __initStatic16() {this.getFavouriteTracks = null}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Retrieves the favourite tracks/playlists/releases of the current user.
|
|
134
|
-
*
|
|
135
|
-
* @return {Promise<Object>} The favorite playlists data.
|
|
136
|
-
*/
|
|
137
|
-
static __initStatic17() {this.getFavouriteFolder = _getters2.default.favouriteFolder}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Toggles the favourite status of a track, playlist or folder.
|
|
141
|
-
*
|
|
142
|
-
* @param {string} track_id - The ID of the track to toggle the favorite status.
|
|
143
|
-
* @throws {Error} If the track_id is not provided.
|
|
144
|
-
* @return {Promise<Object>} The response data after toggling the favorite status.
|
|
145
|
-
*/
|
|
146
|
-
static __initStatic18() {this.toggleItemFavourite = _setters2.default.toggleItemFavourite}
|
|
147
|
-
|
|
148
|
-
static __initStatic19() {this.isItemFavourited = _getters2.default.isItemFavourited}
|
|
149
|
-
|
|
150
|
-
static __initStatic20() {this.getRecentyPlayed = _getters2.default.recentlyPlayed}
|
|
151
|
-
} MusicModel.__initStatic(); MusicModel.__initStatic2(); MusicModel.__initStatic3(); MusicModel.__initStatic4(); MusicModel.__initStatic5(); MusicModel.__initStatic6(); MusicModel.__initStatic7(); MusicModel.__initStatic8(); MusicModel.__initStatic9(); MusicModel.__initStatic10(); MusicModel.__initStatic11(); MusicModel.__initStatic12(); MusicModel.__initStatic13(); MusicModel.__initStatic14(); MusicModel.__initStatic15(); MusicModel.__initStatic16(); MusicModel.__initStatic17(); MusicModel.__initStatic18(); MusicModel.__initStatic19(); MusicModel.__initStatic20(); exports.default = MusicModel;
|
|
5
|
+
static __initStatic() {this.Getters = _getters2.default}
|
|
6
|
+
static __initStatic2() {this.Setters = _setters2.default}
|
|
7
|
+
|
|
8
|
+
// track related methods
|
|
9
|
+
static __initStatic3() {this.getMyTracks = null}
|
|
10
|
+
static __initStatic4() {this.getAllTracks = _getters2.default.tracks}
|
|
11
|
+
static __initStatic5() {this.getTrackData = _getters2.default.trackData}
|
|
12
|
+
static __initStatic6() {this.putTrack = _setters2.default.putTrack}
|
|
13
|
+
static __initStatic7() {this.deleteTrack = null}
|
|
14
|
+
|
|
15
|
+
// lyrics related methods
|
|
16
|
+
static __initStatic8() {this.getTrackLyrics = _getters2.default.trackLyrics}
|
|
17
|
+
static __initStatic9() {this.putTrackLyrics = _setters2.default.putTrackLyrics}
|
|
18
|
+
|
|
19
|
+
// release related methods
|
|
20
|
+
static __initStatic10() {this.getMyReleases = _getters2.default.myReleases}
|
|
21
|
+
static __initStatic11() {this.getAllReleases = _getters2.default.releases}
|
|
22
|
+
static __initStatic12() {this.getReleaseData = _getters2.default.releaseData}
|
|
23
|
+
static __initStatic13() {this.putRelease = _setters2.default.putRelease}
|
|
24
|
+
static __initStatic14() {this.deleteRelease = _setters2.default.deleteRelease}
|
|
25
|
+
|
|
26
|
+
// library related methods
|
|
27
|
+
static __initStatic15() {this.getMyLibrary = _getters2.default.library}
|
|
28
|
+
static __initStatic16() {this.toggleItemFavorite = _setters2.default.toggleItemFavorite}
|
|
29
|
+
static __initStatic17() {this.isItemFavorited = _getters2.default.isItemFavorited}
|
|
30
|
+
|
|
31
|
+
// other methods
|
|
32
|
+
static __initStatic18() {this.getRecentyPlayed = _getters2.default.recentlyPlayed}
|
|
33
|
+
static __initStatic19() {this.search = _getters2.default.search}
|
|
34
|
+
|
|
35
|
+
// aliases
|
|
36
|
+
static __initStatic20() {this.toggleItemFavourite = MusicModel.toggleItemFavorite}
|
|
37
|
+
static __initStatic21() {this.isItemFavourited = MusicModel.isItemFavorited}
|
|
38
|
+
} MusicModel.__initStatic(); MusicModel.__initStatic2(); MusicModel.__initStatic3(); MusicModel.__initStatic4(); MusicModel.__initStatic5(); MusicModel.__initStatic6(); MusicModel.__initStatic7(); MusicModel.__initStatic8(); MusicModel.__initStatic9(); MusicModel.__initStatic10(); MusicModel.__initStatic11(); MusicModel.__initStatic12(); MusicModel.__initStatic13(); MusicModel.__initStatic14(); MusicModel.__initStatic15(); MusicModel.__initStatic16(); MusicModel.__initStatic17(); MusicModel.__initStatic18(); MusicModel.__initStatic19(); MusicModel.__initStatic20(); MusicModel.__initStatic21(); exports.default = MusicModel;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../../request'); var _request2 = _interopRequireDefault(_request);
|
|
2
2
|
|
|
3
3
|
exports. default = async (track_id, data) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const response = await _request2.default.call(void 0, {
|
|
5
|
+
method: "put",
|
|
6
|
+
url: `/music/tracks/${track_id}/lyrics`,
|
|
7
|
+
data: data,
|
|
8
|
+
})
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
return response.data
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../../request'); var _request2 = _interopRequireDefault(_request);
|
|
2
|
+
|
|
3
|
+
exports. default = async (type, item_id, to) => {
|
|
4
|
+
if (!type) {
|
|
5
|
+
throw new Error("type is required")
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (!item_id) {
|
|
9
|
+
throw new Error("item_id is required")
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type = type.toLowerCase()
|
|
13
|
+
|
|
14
|
+
const response = await _request2.default.call(void 0, {
|
|
15
|
+
method: "PUT",
|
|
16
|
+
url: `/music/my/library/favorite`,
|
|
17
|
+
data: {
|
|
18
|
+
item_id: item_id,
|
|
19
|
+
kind: type,
|
|
20
|
+
to: to,
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
return response.data
|
|
26
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../../request'); var _request2 = _interopRequireDefault(_request);
|
|
2
|
+
|
|
3
|
+
exports. default = async () => {
|
|
4
|
+
const { data } = await _request2.default.call(void 0, {
|
|
5
|
+
method: "GET",
|
|
6
|
+
url: "/music/radio/trendings",
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
return data
|
|
10
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _list = require('./getters/list'); var _list2 = _interopRequireDefault(_list);
|
|
2
|
+
var _trendings = require('./getters/trendings'); var _trendings2 = _interopRequireDefault(_trendings);
|
|
2
3
|
|
|
3
4
|
class Radio {
|
|
4
5
|
static __initStatic() {this.getRadioList = _list2.default}
|
|
5
|
-
|
|
6
|
+
static __initStatic2() {this.getTrendings = _trendings2.default}
|
|
7
|
+
} Radio.__initStatic(); Radio.__initStatic2(); exports.default = Radio;
|
|
@@ -3,163 +3,168 @@ var _request = require('../../request'); var _request2 = _interopRequireDefault(
|
|
|
3
3
|
var _withStorage = require('../../helpers/withStorage'); var _withStorage2 = _interopRequireDefault(_withStorage);
|
|
4
4
|
|
|
5
5
|
class Session {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
6
|
+
static __initStatic() {this.storageTokenKey = "token"}
|
|
7
|
+
static __initStatic2() {this.storageRefreshTokenKey = "refreshToken"}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the token from the storage engine.
|
|
11
|
+
*
|
|
12
|
+
* @return {type} description of return value
|
|
13
|
+
*/
|
|
14
|
+
static get token() {
|
|
15
|
+
return _withStorage2.default.engine.get(this.storageTokenKey)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Sets the token in the storage engine.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} token - The token to be set.
|
|
22
|
+
* @return {Promise<void>} A promise that resolves when the token is successfully set.
|
|
23
|
+
*/
|
|
24
|
+
static set token(token) {
|
|
25
|
+
return _withStorage2.default.engine.set(this.storageTokenKey, token)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Retrieves the refresh token from the storage engine.
|
|
30
|
+
*
|
|
31
|
+
* @return {string} The refresh token stored in the storage engine.
|
|
32
|
+
*/
|
|
33
|
+
static get refreshToken() {
|
|
34
|
+
return _withStorage2.default.engine.get(this.storageRefreshTokenKey)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Sets the refresh token in the storage engine.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} token - The refresh token to be set.
|
|
41
|
+
* @return {Promise<void>} A promise that resolves when the refresh token is successfully set.
|
|
42
|
+
*/
|
|
43
|
+
static set refreshToken(token) {
|
|
44
|
+
return _withStorage2.default.engine.set(this.storageRefreshTokenKey, token)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the roles from the decoded token object.
|
|
49
|
+
*
|
|
50
|
+
* @return {Array<string>|undefined} The roles if they exist, otherwise undefined.
|
|
51
|
+
*/
|
|
52
|
+
static get roles() {
|
|
53
|
+
return _optionalChain([this, 'access', _ => _.getDecodedToken, 'call', _2 => _2(), 'optionalAccess', _3 => _3.roles])
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Retrieves the user ID from the decoded token object.
|
|
58
|
+
*
|
|
59
|
+
* @return {string|undefined} The user ID if it exists, otherwise undefined.
|
|
60
|
+
*/
|
|
61
|
+
static get user_id() {
|
|
62
|
+
return _optionalChain([this, 'access', _4 => _4.getDecodedToken, 'call', _5 => _5(), 'optionalAccess', _6 => _6.user_id])
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves the session UUID from the decoded token object.
|
|
67
|
+
*
|
|
68
|
+
* @return {string} The session UUID if it exists, otherwise undefined.
|
|
69
|
+
*/
|
|
70
|
+
static get session_uuid() {
|
|
71
|
+
return _optionalChain([this, 'access', _7 => _7.getDecodedToken, 'call', _8 => _8(), 'optionalAccess', _9 => _9.session_uuid])
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Retrieves the decoded token from the session storage.
|
|
76
|
+
*
|
|
77
|
+
* @return {Object|null} The decoded token object if it exists, otherwise null.
|
|
78
|
+
*/
|
|
79
|
+
static getDecodedToken() {
|
|
80
|
+
const token = this.token
|
|
81
|
+
|
|
82
|
+
return token && _jwtdecode.jwtDecode.call(void 0, token)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Removes the token from the storage engine.
|
|
87
|
+
*
|
|
88
|
+
* @return {Promise<void>} A promise that resolves when the token is successfully removed.
|
|
89
|
+
*/
|
|
90
|
+
static removeToken() {
|
|
91
|
+
return _withStorage2.default.engine.remove(Session.storageTokenKey)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Retrieves all sessions from the server.
|
|
96
|
+
*
|
|
97
|
+
* @return {Promise<Object>} The data of all sessions.
|
|
98
|
+
*/
|
|
99
|
+
static async getAllSessions() {
|
|
100
|
+
const response = await _request2.default.call(void 0, {
|
|
101
|
+
method: "get",
|
|
102
|
+
url: "/sessions/all",
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
return response.data
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Retrieves the current session from the server.
|
|
110
|
+
*
|
|
111
|
+
* @return {Promise<Object>} The data of the current session.
|
|
112
|
+
*/
|
|
113
|
+
static async getCurrentSession() {
|
|
114
|
+
const response = await _request2.default.call(void 0, {
|
|
115
|
+
method: "get",
|
|
116
|
+
url: "/sessions/current",
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
return response.data
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Destroys the current session by deleting it from the server.
|
|
124
|
+
*
|
|
125
|
+
* @return {Promise<Object>} The response data from the server after deleting the session.
|
|
126
|
+
*/
|
|
127
|
+
static async destroyCurrentSession() {
|
|
128
|
+
const token = await Session.token
|
|
129
|
+
const session = await Session.getDecodedToken()
|
|
130
|
+
|
|
131
|
+
if (!session || !token) {
|
|
132
|
+
return false
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const response = await _request2.default.call(void 0, {
|
|
136
|
+
method: "delete",
|
|
137
|
+
url: "/sessions/current",
|
|
138
|
+
}).catch((error) => {
|
|
139
|
+
console.error(error)
|
|
140
|
+
|
|
141
|
+
return false
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
Session.removeToken()
|
|
145
|
+
|
|
146
|
+
__comty_shared_state.eventBus.emit("session.destroyed")
|
|
147
|
+
|
|
148
|
+
return response.data
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static async destroyAll() {
|
|
152
|
+
const response = await _request2.default.call(void 0, {
|
|
153
|
+
method: "delete",
|
|
154
|
+
url: "/sessions/all",
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
return response.data
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Retrieves the validity of the current token.
|
|
162
|
+
*
|
|
163
|
+
* @return {boolean} The validity status of the current token.
|
|
164
|
+
*/
|
|
165
|
+
static async isCurrentTokenValid() {
|
|
166
|
+
const health = await Session.getTokenValidation()
|
|
167
|
+
|
|
168
|
+
return health.valid
|
|
169
|
+
}
|
|
170
|
+
} Session.__initStatic(); Session.__initStatic2(); exports.default = Session;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
var _request = require('../../request'); var _request2 = _interopRequireDefault(_request);
|
|
3
|
+
|
|
4
|
+
var _linebridgeclient = require('linebridge-client');
|
|
5
|
+
|
|
2
6
|
var _session = require('../session'); var _session2 = _interopRequireDefault(_session);
|
|
3
7
|
var _user = require('../user'); var _user2 = _interopRequireDefault(_user);
|
|
4
|
-
var _src = require('linebridge-client/src');
|
|
5
|
-
//import { RTEngineClient } from "../../../../linebridge/client/src"
|
|
6
8
|
|
|
7
9
|
async function injectUserDataOnList(list) {
|
|
8
10
|
if (!Array.isArray(list)) {
|
|
@@ -36,34 +38,12 @@ async function injectUserDataOnList(list) {
|
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
class Streaming {
|
|
39
|
-
static
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const baseInstance = _axios2.default.create({
|
|
43
|
-
baseURL: Streaming.apiHostname,
|
|
44
|
-
headers: {
|
|
45
|
-
Accept: "application/json",
|
|
46
|
-
"ngrok-skip-browser-warning": "any",
|
|
47
|
-
},
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
if (_session2.default.token) {
|
|
51
|
-
baseInstance.defaults.headers.common["Authorization"] =
|
|
52
|
-
`Bearer ${_session2.default.token}`
|
|
41
|
+
static get baseUrl() {
|
|
42
|
+
if (process.env.NODE_ENV === "production") {
|
|
43
|
+
return "https://live.ragestudio.net"
|
|
53
44
|
}
|
|
54
45
|
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static async serverInfo() {
|
|
59
|
-
const { data } = await Streaming.base({
|
|
60
|
-
method: "get",
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
...data,
|
|
65
|
-
hostname: Streaming.apiHostname,
|
|
66
|
-
}
|
|
46
|
+
return __comty_shared_state.baseRequest.defaults.baseURL + "/spectrum"
|
|
67
47
|
}
|
|
68
48
|
|
|
69
49
|
static async getStream(stream_id) {
|
|
@@ -71,52 +51,72 @@ async function injectUserDataOnList(list) {
|
|
|
71
51
|
return null
|
|
72
52
|
}
|
|
73
53
|
|
|
74
|
-
const { data } = await
|
|
54
|
+
const { data } = await _request2.default.call(void 0, {
|
|
55
|
+
baseURL: Streaming.baseUrl,
|
|
75
56
|
method: "get",
|
|
76
|
-
url: `/
|
|
57
|
+
url: `/stream/${stream_id}/data`,
|
|
77
58
|
})
|
|
78
59
|
|
|
79
60
|
return data
|
|
80
61
|
}
|
|
81
62
|
|
|
82
63
|
static async getOwnProfiles() {
|
|
83
|
-
const { data } = await
|
|
84
|
-
|
|
64
|
+
const { data } = await _request2.default.call(void 0, {
|
|
65
|
+
baseURL: Streaming.baseUrl,
|
|
66
|
+
method: "GET",
|
|
85
67
|
url: "/streaming/profiles/self",
|
|
86
68
|
})
|
|
87
69
|
|
|
88
70
|
return data
|
|
89
71
|
}
|
|
90
72
|
|
|
91
|
-
static async getProfile(
|
|
73
|
+
static async getProfile(profile_id) {
|
|
92
74
|
if (!profile_id) {
|
|
93
75
|
return null
|
|
94
76
|
}
|
|
95
77
|
|
|
96
|
-
const { data } = await
|
|
97
|
-
|
|
78
|
+
const { data } = await _request2.default.call(void 0, {
|
|
79
|
+
baseURL: Streaming.baseUrl,
|
|
80
|
+
method: "GET",
|
|
98
81
|
url: `/streaming/profiles/${profile_id}`,
|
|
99
82
|
})
|
|
100
83
|
|
|
101
84
|
return data
|
|
102
85
|
}
|
|
103
86
|
|
|
104
|
-
static async
|
|
105
|
-
const { data } = await
|
|
106
|
-
|
|
107
|
-
|
|
87
|
+
static async createProfile(payload) {
|
|
88
|
+
const { data } = await _request2.default.call(void 0, {
|
|
89
|
+
baseURL: Streaming.baseUrl,
|
|
90
|
+
method: "POST",
|
|
91
|
+
url: "/streaming/profiles/new",
|
|
92
|
+
data: payload,
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
return data
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static async updateProfile(profile_id, update) {
|
|
99
|
+
if (!profile_id) {
|
|
100
|
+
return null
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const { data } = await _request2.default.call(void 0, {
|
|
104
|
+
baseURL: Streaming.baseUrl,
|
|
105
|
+
method: "PUT",
|
|
106
|
+
url: `/streaming/profiles/${profile_id}`,
|
|
108
107
|
data: update,
|
|
109
108
|
})
|
|
110
109
|
|
|
111
110
|
return data
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
static async deleteProfile(
|
|
113
|
+
static async deleteProfile(profile_id) {
|
|
115
114
|
if (!profile_id) {
|
|
116
115
|
return null
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
const { data } = await
|
|
118
|
+
const { data } = await _request2.default.call(void 0, {
|
|
119
|
+
baseURL: Streaming.baseUrl,
|
|
120
120
|
method: "delete",
|
|
121
121
|
url: `/streaming/profiles/${profile_id}`,
|
|
122
122
|
})
|
|
@@ -124,8 +124,41 @@ async function injectUserDataOnList(list) {
|
|
|
124
124
|
return data
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
static async addRestreamToProfile(profileId, restreamData) {
|
|
128
|
+
if (!profileId) {
|
|
129
|
+
console.error("profileId is required to add a restream")
|
|
130
|
+
return null
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const { data } = await _request2.default.call(void 0, {
|
|
134
|
+
baseURL: Streaming.baseUrl,
|
|
135
|
+
method: "put",
|
|
136
|
+
url: `/streaming/profiles/${profileId}/restreams`,
|
|
137
|
+
data: restreamData,
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
return data
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static async deleteRestreamFromProfile(profileId, restreamIndexData) {
|
|
144
|
+
if (!profileId) {
|
|
145
|
+
console.error("profileId is required to delete a restream")
|
|
146
|
+
return null
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const { data } = await _request2.default.call(void 0, {
|
|
150
|
+
baseURL: Streaming.baseUrl,
|
|
151
|
+
method: "delete",
|
|
152
|
+
url: `/streaming/profiles/${profileId}/restreams`,
|
|
153
|
+
data: restreamIndexData,
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
return data
|
|
157
|
+
}
|
|
158
|
+
|
|
127
159
|
static async list({ limit, offset } = {}) {
|
|
128
|
-
let { data } = await
|
|
160
|
+
let { data } = await _request2.default.call(void 0, {
|
|
161
|
+
baseURL: Streaming.baseUrl,
|
|
129
162
|
method: "get",
|
|
130
163
|
url: "/streaming/list",
|
|
131
164
|
params: {
|
|
@@ -139,17 +172,23 @@ async function injectUserDataOnList(list) {
|
|
|
139
172
|
return data
|
|
140
173
|
}
|
|
141
174
|
|
|
175
|
+
static createWebsocket(params = {}) {
|
|
176
|
+
const client = new (0, _linebridgeclient.RTEngineClient)({
|
|
177
|
+
...params,
|
|
178
|
+
url: Streaming.baseUrl,
|
|
179
|
+
token: _session2.default.token,
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
return client
|
|
183
|
+
}
|
|
184
|
+
|
|
142
185
|
static async createStreamWebsocket(stream_id, params = {}) {
|
|
143
186
|
if (!stream_id) {
|
|
144
187
|
console.error("stream_id is required")
|
|
145
188
|
return null
|
|
146
189
|
}
|
|
147
190
|
|
|
148
|
-
const client =
|
|
149
|
-
...params,
|
|
150
|
-
url: Streaming.apiHostname,
|
|
151
|
-
token: _session2.default.token,
|
|
152
|
-
})
|
|
191
|
+
const client = Streaming.createWebsocket(params)
|
|
153
192
|
|
|
154
193
|
client._destroy = client.destroy
|
|
155
194
|
|
|
@@ -171,4 +210,4 @@ async function injectUserDataOnList(list) {
|
|
|
171
210
|
|
|
172
211
|
return client
|
|
173
212
|
}
|
|
174
|
-
}
|
|
213
|
+
} exports.default = Streaming;
|
|
@@ -14,7 +14,15 @@ var _request = require('../../request'); var _request2 = _interopRequireDefault(
|
|
|
14
14
|
let { username, user_id, basic = false } = payload
|
|
15
15
|
|
|
16
16
|
if (!username && !user_id) {
|
|
17
|
-
|
|
17
|
+
const response = await _request2.default.call(void 0, {
|
|
18
|
+
method: "GET",
|
|
19
|
+
url: `/users/self`,
|
|
20
|
+
params: {
|
|
21
|
+
basic,
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return response.data
|
|
18
26
|
}
|
|
19
27
|
|
|
20
28
|
if (username && !user_id) {
|
|
@@ -132,4 +140,29 @@ var _request = require('../../request'); var _request2 = _interopRequireDefault(
|
|
|
132
140
|
|
|
133
141
|
return data
|
|
134
142
|
}
|
|
143
|
+
|
|
144
|
+
static async getPublicKey(user_id) {
|
|
145
|
+
if (!user_id) {
|
|
146
|
+
user_id = _session2.default.user_id
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const { data } = await _request2.default.call(void 0, {
|
|
150
|
+
method: "GET",
|
|
151
|
+
url: `/users/${user_id}/public-key`,
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
return data
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
static async updatePublicKey(public_key) {
|
|
158
|
+
const { data } = await _request2.default.call(void 0, {
|
|
159
|
+
method: "PUT",
|
|
160
|
+
url: `/users/self/public-key`,
|
|
161
|
+
data: {
|
|
162
|
+
public_key: public_key,
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
return data
|
|
167
|
+
}
|
|
135
168
|
} exports.default = User;
|
package/dist/remotes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }const envOrigins = {
|
|
2
|
-
development:
|
|
2
|
+
development: `${location.origin}/api`,
|
|
3
3
|
indev: "https://indev.comty.app/api",
|
|
4
4
|
production: "https://api.comty.app",
|
|
5
5
|
}
|
|
@@ -31,15 +31,18 @@ const fetchers = {
|
|
|
31
31
|
resolve("failed")
|
|
32
32
|
}, 5000)
|
|
33
33
|
|
|
34
|
-
globalThis.__comty_shared_state.ws.sockets
|
|
35
|
-
|
|
36
|
-
.once("pong", () => {
|
|
37
|
-
failTimeout && clearTimeout(failTimeout)
|
|
34
|
+
const sockets = globalThis.__comty_shared_state.ws.sockets
|
|
35
|
+
let firstSocket = sockets.keys().next().value
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
firstSocket = sockets.get(firstSocket)
|
|
38
|
+
|
|
39
|
+
firstSocket.once("pong", () => {
|
|
40
|
+
failTimeout && clearTimeout(failTimeout)
|
|
41
|
+
|
|
42
|
+
resolve(Date.now() - start)
|
|
43
|
+
})
|
|
41
44
|
|
|
42
|
-
|
|
45
|
+
firstSocket.emit("ping")
|
|
43
46
|
}),
|
|
44
47
|
}
|
|
45
48
|
|
package/dist/ws.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
var _withStorage = require('./helpers/withStorage'); var _withStorage2 = _interopRequireDefault(_withStorage);
|
|
3
3
|
|
|
4
4
|
var _socketioclient = require('socket.io-client');
|
|
5
|
-
var
|
|
6
|
-
//import { RTEngineClient } from "../../linebridge/client/src"
|
|
5
|
+
var _linebridgeclient = require('linebridge-client');
|
|
7
6
|
|
|
8
7
|
class WebsocketManager {
|
|
9
8
|
constructor({ origin }) {;WebsocketManager.prototype.__init.call(this);
|
|
@@ -59,7 +58,7 @@ class WebsocketManager {
|
|
|
59
58
|
remote,
|
|
60
59
|
)
|
|
61
60
|
|
|
62
|
-
const client = new (0,
|
|
61
|
+
const client = new (0, _linebridgeclient.RTEngineClient)({
|
|
63
62
|
refName: remote.namespace,
|
|
64
63
|
url: `${this.origin}/${remote.namespace}`,
|
|
65
64
|
token: _withStorage2.default.engine.get("token"),
|