sidechat.js 2.6.6 → 2.7.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/dist/classes/SidechatAPIClient.d.ts +166 -11
- package/dist/classes/SidechatAPIClient.d.ts.map +1 -1
- package/dist/index.cjs +853 -311
- package/dist/index.mjs +853 -311
- package/dist/types/SidechatTypes.d.ts +260 -9
- package/dist/types/SidechatTypes.d.ts.map +1 -1
- package/docs/sidechat.js/2.7.0/SidechatAPIClient.html +3 -0
- package/docs/sidechat.js/2.7.0/SidechatAPIError.html +3 -0
- package/docs/sidechat.js/2.7.0/SidechatColorList.html +3 -0
- package/docs/sidechat.js/2.7.0/classes_SidechatAPIClient.js.html +1897 -0
- package/docs/sidechat.js/2.7.0/classes_SidechatAPIError.js.html +16 -0
- package/docs/sidechat.js/2.7.0/classes_SidechatColorList.js.html +79 -0
- package/docs/sidechat.js/2.7.0/data/search.json +1 -0
- package/docs/sidechat.js/2.7.0/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/sidechat.js/2.7.0/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/sidechat.js/2.7.0/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/sidechat.js/2.7.0/global.html +3 -0
- package/docs/sidechat.js/2.7.0/index.html +4 -0
- package/docs/sidechat.js/2.7.0/scripts/core.js +726 -0
- package/docs/sidechat.js/2.7.0/scripts/core.min.js +23 -0
- package/docs/sidechat.js/2.7.0/scripts/resize.js +90 -0
- package/docs/sidechat.js/2.7.0/scripts/search.js +265 -0
- package/docs/sidechat.js/2.7.0/scripts/search.min.js +6 -0
- package/docs/sidechat.js/2.7.0/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/sidechat.js/2.7.0/scripts/third-party/fuse.js +9 -0
- package/docs/sidechat.js/2.7.0/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/sidechat.js/2.7.0/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/sidechat.js/2.7.0/scripts/third-party/hljs-original.js +5171 -0
- package/docs/sidechat.js/2.7.0/scripts/third-party/hljs.js +1 -0
- package/docs/sidechat.js/2.7.0/scripts/third-party/popper.js +5 -0
- package/docs/sidechat.js/2.7.0/scripts/third-party/tippy.js +1 -0
- package/docs/sidechat.js/2.7.0/scripts/third-party/tocbot.js +672 -0
- package/docs/sidechat.js/2.7.0/scripts/third-party/tocbot.min.js +1 -0
- package/docs/sidechat.js/2.7.0/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/sidechat.js/2.7.0/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/sidechat.js/2.7.0/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/sidechat.js/2.7.0/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/sidechat.js/2.7.0/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/sidechat.js/2.7.0/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/sidechat.js/2.7.0/tutorial-Authentication.html +16 -0
- package/docs/sidechat.js/2.7.0/tutorial-Email Registration.html +6 -0
- package/docs/sidechat.js/2.7.0/tutorial-Feeds and Pagination.html +10 -0
- package/docs/sidechat.js/2.7.0/tutorial-Posting and Media.html +19 -0
- package/docs/sidechat.js/2.7.0/types_SidechatTypes.js.html +297 -0
- package/docs/tutorials/Authentication.md +63 -52
- package/docs/tutorials/Email Registration.md +19 -16
- package/docs/tutorials/Feeds and Pagination.md +45 -0
- package/docs/tutorials/Posting and Media.md +63 -0
- package/package.json +55 -55
- package/src/classes/SidechatAPIClient.js +477 -27
- package/src/types/SidechatTypes.js +294 -202
package/dist/index.mjs
CHANGED
|
@@ -1,216 +1,308 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A user-created post or comment, depending on the "type" prop
|
|
3
|
-
* @typedef {Object} SidechatPostOrComment
|
|
4
|
-
* @prop {"post"|"comment"} type - whether this object represents a post or a comment on a post
|
|
5
|
-
* @prop {String} id - alphanumeric ID of post or comment
|
|
6
|
-
* @prop {Boolean} authored_by_user - whether or not the post or comment was created by the current user
|
|
7
|
-
* @prop {String} alias - post creator's name in-app
|
|
8
|
-
* @prop {String} group_id - alphanumeric ID of group
|
|
9
|
-
* @prop {SidechatGroup} group - group in which post or comment was created
|
|
10
|
-
* @prop {String} text - text content of post or comment
|
|
11
|
-
* @prop {String} created_at - date string of post or comment creation time
|
|
12
|
-
* @prop {Number} vote_total - sum of upvotes and downvotes
|
|
13
|
-
* @prop {SidechatVoteString} vote_status - current user's vote on post or comment
|
|
14
|
-
* @prop {SidechatSimpleAsset[]} assets - array of simple assets attached to post or comment
|
|
15
|
-
* @prop {
|
|
16
|
-
* @prop {Boolean} dms_disabled - whether or not you can send a DM to creator of post
|
|
17
|
-
* @prop {String[]} tags - undocumented
|
|
18
|
-
* @prop {SidechatIdentity} identity - creator's identity information
|
|
19
|
-
* @prop {Boolean} pinned - undocumented
|
|
20
|
-
* @prop {Boolean} is_saved - whether or not the current user has saved the post
|
|
21
|
-
* @prop {"following"|"not_following"} follow_status - whether or not the current user should recieve activity notifications for the post
|
|
22
|
-
* @prop {"group"} [destination] -
|
|
23
|
-
* @prop {
|
|
24
|
-
* @prop {Boolean} [
|
|
25
|
-
* @prop {
|
|
26
|
-
* @prop {
|
|
27
|
-
* @prop {
|
|
28
|
-
* @prop {String} [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
* @
|
|
36
|
-
* @prop {String}
|
|
37
|
-
* @prop {
|
|
38
|
-
* @prop {String}
|
|
39
|
-
* @prop {"
|
|
40
|
-
* @prop {
|
|
41
|
-
* @prop {"
|
|
42
|
-
* @prop {
|
|
43
|
-
* @prop {
|
|
44
|
-
* @prop {
|
|
45
|
-
* @prop {
|
|
46
|
-
* @prop {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
54
|
-
* @prop {
|
|
55
|
-
* @prop {
|
|
56
|
-
* @prop {
|
|
57
|
-
* @prop {
|
|
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
|
-
* @prop {
|
|
101
|
-
* @prop {
|
|
102
|
-
* @prop {
|
|
103
|
-
* @prop {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
*
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*
|
|
112
|
-
* @
|
|
113
|
-
* @prop {String}
|
|
114
|
-
* @prop {String}
|
|
115
|
-
* @prop {
|
|
116
|
-
* @prop {
|
|
117
|
-
* @prop {String}
|
|
118
|
-
* @prop {
|
|
119
|
-
* @prop {
|
|
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
|
-
* @prop {String}
|
|
164
|
-
* @prop {String}
|
|
165
|
-
* @prop {
|
|
166
|
-
* @prop {
|
|
167
|
-
* @prop {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
176
|
-
* @prop {String}
|
|
177
|
-
* @prop {String}
|
|
178
|
-
* @prop {String}
|
|
179
|
-
* @prop {
|
|
180
|
-
* @prop {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
*
|
|
188
|
-
* @
|
|
189
|
-
* @prop {
|
|
190
|
-
* @prop {
|
|
191
|
-
* @prop {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
*
|
|
199
|
-
* @
|
|
200
|
-
|
|
201
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A user-created post or comment, depending on the "type" prop
|
|
3
|
+
* @typedef {Object} SidechatPostOrComment
|
|
4
|
+
* @prop {"post"|"comment"} type - whether this object represents a post or a comment on a post
|
|
5
|
+
* @prop {String} id - alphanumeric ID of post or comment
|
|
6
|
+
* @prop {Boolean} authored_by_user - whether or not the post or comment was created by the current user
|
|
7
|
+
* @prop {String} alias - post creator's name in-app
|
|
8
|
+
* @prop {String} group_id - alphanumeric ID of group
|
|
9
|
+
* @prop {SidechatGroup} group - group in which post or comment was created
|
|
10
|
+
* @prop {String} text - text content of post or comment
|
|
11
|
+
* @prop {String} created_at - date string of post or comment creation time
|
|
12
|
+
* @prop {Number} vote_total - sum of upvotes and downvotes
|
|
13
|
+
* @prop {SidechatVoteString} vote_status - current user's vote on post or comment
|
|
14
|
+
* @prop {SidechatSimpleAsset[]} assets - array of simple assets attached to post or comment
|
|
15
|
+
* @prop {SidechatAttachment[]} attachments - link attachments on the post
|
|
16
|
+
* @prop {Boolean} dms_disabled - whether or not you can send a DM to creator of post
|
|
17
|
+
* @prop {String[]} tags - undocumented
|
|
18
|
+
* @prop {SidechatIdentity} identity - creator's identity information
|
|
19
|
+
* @prop {Boolean} pinned - undocumented
|
|
20
|
+
* @prop {Boolean} is_saved - whether or not the current user has saved the post
|
|
21
|
+
* @prop {"following"|"following_commented"|"not_following"} follow_status - whether or not the current user should recieve activity notifications for the post
|
|
22
|
+
* @prop {"group"|"account"} [destination] - whether the post was made in a group or on the author's profile
|
|
23
|
+
* @prop {Boolean} [is_deleted] - whether or not the post or comment has been deleted
|
|
24
|
+
* @prop {{post: SidechatPostOrComment, is_unavailable: Boolean}} [quote_post] - the post being quoted, if this is a repost
|
|
25
|
+
* @prop {Number} [comment_count] - number of comments on post (only if type=post)
|
|
26
|
+
* @prop {Boolean} [comments_disabled] - whether or not you can comment on post (only if type=post)
|
|
27
|
+
* @prop {SidechatPoll} [poll] - poll attached to post (only if the post has a poll)
|
|
28
|
+
* @prop {String} [parent_post_id] - alphanumeric ID of parent post (only if type=comment)
|
|
29
|
+
* @prop {String} [reply_post_id] - alphanumeric ID of comment being replied to, falls back to parent_post_id (only if type=comment)
|
|
30
|
+
* @prop {String} [context] - text content of comment being replied to, falls back to text (only if type=comment)
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A group object, containing metadata about a group as well as its join conditions and states. Some properties vary based on the endpoint the object came from.
|
|
35
|
+
* @typedef {Object} SidechatGroup
|
|
36
|
+
* @prop {String} id - alphanumeric ID of group
|
|
37
|
+
* @prop {String} name - human-readable name of group
|
|
38
|
+
* @prop {String} analytics_name - name to file group under
|
|
39
|
+
* @prop {"non_member"|"member"} membership_type - whether or not current user is a member of group
|
|
40
|
+
* @prop {String} color - group's theme color as hex code (e.g., #FFFFFF)
|
|
41
|
+
* @prop {"open"|"closed"|"email_domain"} group_join_type - basis on which group accepts new members
|
|
42
|
+
* @prop {"private"|"public_to_all"|"public_to_schools"} group_visibility - group's visibility setting
|
|
43
|
+
* @prop {"show"|"hide"} asset_library_visibility - whether or not group's asset library is visible
|
|
44
|
+
* @prop {Array} [roles] - undocumented
|
|
45
|
+
* @prop {String} [description] - description of group
|
|
46
|
+
* @prop {SidechatPrivateAssetURL} [icon_url] - image URL for group icon
|
|
47
|
+
* @prop {Number} [member_count] - number of users in group
|
|
48
|
+
* @prop {Boolean} [should_show_leaderboard] - undocumented
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* An asset object, containing information about an image within a post or comment
|
|
53
|
+
* @typedef {Object} SidechatSimpleAsset
|
|
54
|
+
* @prop {String} id - alphanumeric ID of asset
|
|
55
|
+
* @prop {"image"|"video"} type - whether the asset is an image or a video
|
|
56
|
+
* @prop {"jpeg"|"png"|"gif"|"webp"|"mp4"|"mov"} content_type - file type of asset
|
|
57
|
+
* @prop {Number} width - width of asset
|
|
58
|
+
* @prop {Number} height - height of asset
|
|
59
|
+
* @prop {SidechatPrivateAssetURL} [url] - URL string of asset's location (an HLS .m3u8 stream for processed videos)
|
|
60
|
+
* @prop {SidechatSimpleAsset} [thumbnail_asset] - preview image (only if type=video)
|
|
61
|
+
* @prop {"not_started"|"ingest"|"complete"|"error"} [vod_status] - processing status (only if type=video)
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* An asset object, containing information about an image from the asset library
|
|
66
|
+
* @typedef {Object} SidechatLibraryAsset
|
|
67
|
+
* @prop {String} id - alphanumeric ID of asset
|
|
68
|
+
* @prop {String} created_at - date string of asset creation time
|
|
69
|
+
* @prop {SidechatAssetMetadata} metadata - metadata associated with asset
|
|
70
|
+
* @prop {SidechatPrivateAssetURL} url - URL string of asset's location
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* An asset object, containing information about an image from the asset library
|
|
75
|
+
* @typedef {Object} SidechatAssetMetadata
|
|
76
|
+
* @prop {Number} width - width of asset
|
|
77
|
+
* @prop {Number} height - height of asset
|
|
78
|
+
* @prop {"image"} type - undocumented
|
|
79
|
+
* @prop {"jpeg"|"png"|"gif"} content_type - file type of asset
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A user's anonymous identity information
|
|
84
|
+
* @typedef {Object} SidechatIdentity
|
|
85
|
+
* @prop {String} name - representation of user's name (varies across app)
|
|
86
|
+
* @prop {Boolean} posted_with_username - undocumented
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A conversation icon associated with a user
|
|
91
|
+
* @typedef {Object} SidechatIcon
|
|
92
|
+
* @prop {String} emoji - unicode emoji character
|
|
93
|
+
* @prop {String} color - primary hex color code
|
|
94
|
+
* @prop {String} secondary_color - secondary hex color code
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The current user's information
|
|
99
|
+
* @typedef {Object} SidechatCurrentUser
|
|
100
|
+
* @prop {String} id - alphanumeric ID of current user
|
|
101
|
+
* @prop {String} hashedVerifiedEmail - verified email of current user in an unreadable hashed form
|
|
102
|
+
* @prop {Boolean} isGlobalModerator - whether or not user is a moderator
|
|
103
|
+
* @prop {Boolean} isGlobalAdmin - whether or not user is an admin
|
|
104
|
+
* @prop {SidechatMembership[]} memberships
|
|
105
|
+
* @prop {Array} roles - undocumented
|
|
106
|
+
* @prop {String} emailDomain - domain of verified email address on account
|
|
107
|
+
* @prop {String} wildcardEmailDomain - domain of verified email address on account, preceeded by *. to support subdomains
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* A user's public profile
|
|
112
|
+
* @typedef {Object} SidechatProfile
|
|
113
|
+
* @prop {String} id - alphanumeric ID of user
|
|
114
|
+
* @prop {String} name - public-facing username
|
|
115
|
+
* @prop {SidechatIcon} conversation_icon - icon associated with user
|
|
116
|
+
* @prop {Boolean} description - the user bio
|
|
117
|
+
* @prop {String} index_name - undocumented
|
|
118
|
+
* @prop {String} analytics_name - undocumented
|
|
119
|
+
* @prop {String} color - undocumented
|
|
120
|
+
* @prop {String} share_color_start - undocumented
|
|
121
|
+
* @prop {String} share_color_end - undocumented
|
|
122
|
+
* @prop {"account"} group_join_type - undocumented
|
|
123
|
+
* @prop {"public_to_all"} group_visibility - the profile visibility status
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Representation of a group membership
|
|
128
|
+
* @typedef {Object} SidechatMembership
|
|
129
|
+
* @prop {String} groupId - alphanumeric ID of group
|
|
130
|
+
* @prop {String} type - role of current user in group
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* An asset URL that can only be accessed by making a request with a user's bearer token attached in the Authorization header
|
|
135
|
+
* @typedef {String} SidechatPrivateAssetURL
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* A cursor for paginating through post lists
|
|
140
|
+
* @typedef {String} SidechatCursorString
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A vote on a comment or post
|
|
145
|
+
* @typedef {"upvote"|"downvote"|"none"} SidechatVoteString
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* A user's bearer authentication token needed for most requests
|
|
150
|
+
* @typedef {String} SidechatAuthToken
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* A list of posts and the associated cursor
|
|
155
|
+
* @typedef {Object} SidechatPostsAndCursor
|
|
156
|
+
* @prop {SidechatPostOrComment[]} posts
|
|
157
|
+
* @prop {SidechatCursorString} cursor
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* A direct message thread
|
|
162
|
+
* @typedef {Object} SidechatDirectThread
|
|
163
|
+
* @prop {String} id - alphanumeric ID of thread
|
|
164
|
+
* @prop {String} group_id - alphanumeric ID of group in which the thread exists
|
|
165
|
+
* @prop {String} updated_at - date string of when the last message in the chat was sent
|
|
166
|
+
* @prop {String} post_id - post or comment from which the thread was originally sent
|
|
167
|
+
* @prop {String} post_context - the context of the DM thread (only "feed" is known at the moment)
|
|
168
|
+
* @prop {"accepted"} accept_status - whether or not the other user has accepted this DM
|
|
169
|
+
* @prop {"post"|"comment"} type - the type of the content from which the DM was originally sent
|
|
170
|
+
* @prop {SidechatDirectMessage[]} messages - array of direct message objects
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* A single direct message
|
|
175
|
+
* @typedef {Object} SidechatDirectMessage
|
|
176
|
+
* @prop {String} created_at - time at which the message was sent
|
|
177
|
+
* @prop {String} client_id - alphanumeric ID of the device the message was sent on
|
|
178
|
+
* @prop {String} obfuscatedUserId - obfuscated version of the sender's alphanumeric ID
|
|
179
|
+
* @prop {String} text - body text of the message
|
|
180
|
+
* @prop {String} id - alphanumeric ID of the message
|
|
181
|
+
* @prop {String} chat_id - alphanumeric ID of the thread in which the message resides
|
|
182
|
+
* @prop {Boolean} authored_by_user - whether or not the current user sent the message
|
|
183
|
+
* @prop {"message"} type - undocumented
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Represents a poll with choices
|
|
188
|
+
* @typedef {Object} SidechatPoll
|
|
189
|
+
* @prop {String} id - alphanumeric ID of poll
|
|
190
|
+
* @prop {String} post_id - alphanumeric ID of post to which poll is attached
|
|
191
|
+
* @prop {SidechatPollChoice[]} choices - array of poll choices
|
|
192
|
+
* @prop {Boolean} allows_view_results - whether or not poll results are publicly visible
|
|
193
|
+
* @prop {Number} view_results_count - number of users who have viewed poll results
|
|
194
|
+
* @prop {Boolean} participated - whether or not current user has voted in poll
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Represents a poll choice
|
|
199
|
+
* @typedef {Object} SidechatPollChoice
|
|
200
|
+
* @prop {Number} count - number of votes for choice
|
|
201
|
+
* @prop {String} text - user-visible text of choice
|
|
202
|
+
* @prop {Boolean} selected - whether or not current user has voted for choice
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* A link attachment on a post
|
|
207
|
+
* @typedef {Object} SidechatAttachment
|
|
208
|
+
* @prop {String} id - alphanumeric ID of attachment
|
|
209
|
+
* @prop {"link"|"youtube"} type - whether the link is a regular link or a YouTube video
|
|
210
|
+
* @prop {String} link_url - URL the attachment points to
|
|
211
|
+
* @prop {String} [display_url] - shortened URL for display
|
|
212
|
+
* @prop {String} [title] - title of the linked page
|
|
213
|
+
* @prop {{id: String, url: String, width: Number, height: Number, content_type: "png"|"gif"}} [asset] - preview image of the linked page
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* A page of the home feed
|
|
218
|
+
* @typedef {Object} SidechatFeed
|
|
219
|
+
* @prop {SidechatFeedItem[]} feed_items - items in the feed
|
|
220
|
+
* @prop {SidechatCursorString} cursor
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* A single item in the home feed
|
|
225
|
+
* @typedef {Object} SidechatFeedItem
|
|
226
|
+
* @prop {String} item_type - type of item (posts have a type of "post")
|
|
227
|
+
* @prop {SidechatPostOrComment} [post] - the post, if this item is a post
|
|
228
|
+
*/
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* A page of the user's activity
|
|
232
|
+
* @typedef {Object} SidechatActivityList
|
|
233
|
+
* @prop {SidechatActivityItem[]} items - activity items
|
|
234
|
+
* @prop {SidechatCursorString} cursor
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A single activity item (in-app notification)
|
|
239
|
+
* @typedef {Object} SidechatActivityItem
|
|
240
|
+
* @prop {String} id - alphanumeric ID of activity item
|
|
241
|
+
* @prop {String} type - kind of activity (e.g. "comment", "comment_reply", "votes", "new_follower", "quote", "trending_post")
|
|
242
|
+
* @prop {String} text - user-facing description of the activity
|
|
243
|
+
* @prop {String} timestamp - date string of when the activity happened
|
|
244
|
+
* @prop {Boolean} is_seen - whether or not the user has seen the activity
|
|
245
|
+
* @prop {String} [post_id] - alphanumeric ID of related post
|
|
246
|
+
* @prop {String} [comment_id] - alphanumeric ID of related comment
|
|
247
|
+
* @prop {String} [group_id] - alphanumeric ID of related group
|
|
248
|
+
* @prop {Number} [yakarma] - yakarma gained
|
|
249
|
+
* @prop {String} [username] - username of the other user involved, if any
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* A group leaderboard and the current user's place in it
|
|
254
|
+
* @typedef {Object} SidechatLeaderboard
|
|
255
|
+
* @prop {Array<{value: Number}>} leaderboard - all-time leaderboard entries
|
|
256
|
+
* @prop {Array<{value: Number}>} season_leaderboard - leaderboard entries for the current season
|
|
257
|
+
* @prop {{year: Number, season: String, remaining_days: Number}} season - the current season
|
|
258
|
+
* @prop {SidechatKarma} karma - current user's all-time karma in the group
|
|
259
|
+
* @prop {SidechatKarma} season_karma - current user's karma this season
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* A user's karma within a group
|
|
264
|
+
* @typedef {Object} SidechatKarma
|
|
265
|
+
* @prop {String} group_id - alphanumeric ID of group
|
|
266
|
+
* @prop {Number} post - karma from posts
|
|
267
|
+
* @prop {Number} comment - karma from comments
|
|
268
|
+
* @prop {Number} yakarma - total karma
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Which push notifications a user receives
|
|
273
|
+
* @typedef {Object} SidechatNotificationPreferences
|
|
274
|
+
* @prop {Boolean} [chats] - direct messages
|
|
275
|
+
* @prop {Boolean} [followed_posts_activity] - new comments on followed posts
|
|
276
|
+
* @prop {Boolean} [new_followers] - new followers
|
|
277
|
+
* @prop {Boolean} [post_activity] - comments and votes on the user's own posts
|
|
278
|
+
* @prop {Boolean} [trending] - trending posts
|
|
279
|
+
* @prop {Boolean} [community_activity] - undocumented
|
|
280
|
+
* @prop {Boolean} [leaderboards] - leaderboard updates
|
|
281
|
+
* @prop {Boolean} [rewards] - undocumented
|
|
282
|
+
* @prop {Boolean} [feature_updates] - announcements about new features
|
|
283
|
+
* @prop {Boolean} [yak_ball_updates] - undocumented
|
|
284
|
+
* @prop {Boolean} [game_reminders] - undocumented
|
|
285
|
+
* @prop {Boolean} [daily_game_reminders] - undocumented
|
|
286
|
+
* @prop {Boolean} [game_invitations] - undocumented
|
|
287
|
+
* @prop {Boolean} [game_match_updates] - undocumented
|
|
288
|
+
*/
|
|
289
|
+
/**
|
|
290
|
+
* A reason for reporting a post, comment, or direct message thread
|
|
291
|
+
* @typedef {"username"|"spam"|"offTopic"|"pii"|"selfHarmDangerousActs"|"illegalActivities"|"offensiveHateSpeech"|"harassmentBullying"|"minorSafety"|"sexualContent"|"violentGraphicContent"|"misinformation"|"other"} SidechatReportReason
|
|
292
|
+
*/
|
|
293
|
+
|
|
202
294
|
var SidechatTypes = {};
|
|
203
295
|
|
|
204
|
-
/**
|
|
205
|
-
* Throwable error caused by the Sidechat API
|
|
206
|
-
* @class
|
|
207
|
-
* @extends Error
|
|
208
|
-
*/
|
|
209
|
-
class SidechatAPIError extends Error {
|
|
210
|
-
constructor(message) {
|
|
211
|
-
super(message);
|
|
212
|
-
this.name = "SidechatAPIError";
|
|
213
|
-
}
|
|
296
|
+
/**
|
|
297
|
+
* Throwable error caused by the Sidechat API
|
|
298
|
+
* @class
|
|
299
|
+
* @extends Error
|
|
300
|
+
*/
|
|
301
|
+
class SidechatAPIError extends Error {
|
|
302
|
+
constructor(message) {
|
|
303
|
+
super(message);
|
|
304
|
+
this.name = "SidechatAPIError";
|
|
305
|
+
}
|
|
214
306
|
}
|
|
215
307
|
|
|
216
308
|
/** @import * as types from "../types/SidechatTypes.js" */
|
|
@@ -280,6 +372,16 @@ class SidechatAPIClient {
|
|
|
280
372
|
this.apiRoot = url;
|
|
281
373
|
};
|
|
282
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Set an identifier for this device, which will be sent with every request in the `X-Device-ID` header. Should be stable across sessions on the same device.
|
|
377
|
+
* @method
|
|
378
|
+
* @param {String} deviceIdentifier - stable identifier for this device
|
|
379
|
+
* @since 2.7.0
|
|
380
|
+
*/
|
|
381
|
+
setDeviceIdentifier = (deviceIdentifier) => {
|
|
382
|
+
this.defaultHeaders["X-Device-ID"] = deviceIdentifier;
|
|
383
|
+
};
|
|
384
|
+
|
|
283
385
|
/**
|
|
284
386
|
* Run an arbitrary API request using the current client's authentication
|
|
285
387
|
* @method
|
|
@@ -310,19 +412,32 @@ class SidechatAPIClient {
|
|
|
310
412
|
};
|
|
311
413
|
|
|
312
414
|
/**
|
|
313
|
-
* Initiate the login process with a phone number. Should be followed up with verifySMSCode().
|
|
415
|
+
* Initiate the login process with a phone number. Should be followed up with verifySMSCode(). If the response has an `error_code` of `"captcha_required"`, the server wants a captcha solved before it will send a code, and the request should be repeated with a captcha response. I haven't been able to recreate this yet, so I honestly don't know what captcha provider they want.
|
|
314
416
|
* @method
|
|
315
417
|
* @since 1.0.0
|
|
316
418
|
* @param {Number} phoneNumber - US phone number (WITHOUT +1) to send verification code to
|
|
419
|
+
* @param {Boolean} [useFallback] - send the code through the backup SMS route, which the official app offers when a code doesn't arrive
|
|
420
|
+
* @param {String} [captchaMethod] - type of captcha being answered
|
|
421
|
+
* @param {String} [captchaResponse] - solved captcha token
|
|
317
422
|
*/
|
|
318
|
-
loginViaSMS = async (
|
|
423
|
+
loginViaSMS = async (
|
|
424
|
+
phoneNumber,
|
|
425
|
+
useFallback = false,
|
|
426
|
+
captchaMethod = undefined,
|
|
427
|
+
captchaResponse = undefined,
|
|
428
|
+
) => {
|
|
319
429
|
try {
|
|
320
|
-
const
|
|
430
|
+
const endpoint = useFallback
|
|
431
|
+
? "/v1/login_register_sms_fallback"
|
|
432
|
+
: "/v1/login_register";
|
|
433
|
+
const res = await fetch(`${this.apiRoot}${endpoint}`, {
|
|
321
434
|
method: "POST",
|
|
322
435
|
headers: this.defaultHeaders,
|
|
323
436
|
body: JSON.stringify({
|
|
324
437
|
phone_number: `+1${phoneNumber}`,
|
|
325
438
|
version: 3,
|
|
439
|
+
captcha_method: captchaMethod,
|
|
440
|
+
captcha_response: captchaResponse,
|
|
326
441
|
}),
|
|
327
442
|
});
|
|
328
443
|
const json = await res.json();
|
|
@@ -367,8 +482,15 @@ class SidechatAPIClient {
|
|
|
367
482
|
* @since 1.0.0
|
|
368
483
|
* @param {Number} age - user's age in years
|
|
369
484
|
* @param {String} registrationID - the registration ID generated by verifySMSCode()
|
|
485
|
+
* @param {String} [timeZone] - time zone of the user (e.g. "America/Chicago"). Falls back to the system time zone.
|
|
486
|
+
* @param {String} [inviteLinkURL] - group invite link that the user signed up through
|
|
370
487
|
*/
|
|
371
|
-
setAge = async (
|
|
488
|
+
setAge = async (
|
|
489
|
+
age,
|
|
490
|
+
registrationID,
|
|
491
|
+
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
492
|
+
inviteLinkURL = undefined,
|
|
493
|
+
) => {
|
|
372
494
|
if (age < 13) {
|
|
373
495
|
throw new SidechatAPIError("You're too young to use Offsides.");
|
|
374
496
|
}
|
|
@@ -379,6 +501,9 @@ class SidechatAPIClient {
|
|
|
379
501
|
body: JSON.stringify({
|
|
380
502
|
age: Number(age),
|
|
381
503
|
registration_id: registrationID,
|
|
504
|
+
time_zone: timeZone,
|
|
505
|
+
invite_link_url: inviteLinkURL,
|
|
506
|
+
device_id: this.defaultHeaders["X-Device-ID"],
|
|
382
507
|
}),
|
|
383
508
|
});
|
|
384
509
|
const json = await res.json();
|
|
@@ -461,8 +586,9 @@ class SidechatAPIClient {
|
|
|
461
586
|
* @method
|
|
462
587
|
* @since 1.0.0
|
|
463
588
|
* @param {String} deviceId - the device ID to set
|
|
589
|
+
* @param {"com.flowerave.sidechat"|"com.flowerave.yikyak"} [bundleID] - bundle ID of the app the push token belongs to
|
|
464
590
|
*/
|
|
465
|
-
setDeviceID = async (deviceID) => {
|
|
591
|
+
setDeviceID = async (deviceID, bundleID = "com.flowerave.sidechat") => {
|
|
466
592
|
if (!this.userToken) {
|
|
467
593
|
throw new SidechatAPIError("User is not authenticated.");
|
|
468
594
|
}
|
|
@@ -475,7 +601,7 @@ class SidechatAPIClient {
|
|
|
475
601
|
},
|
|
476
602
|
body: JSON.stringify({
|
|
477
603
|
build_type: "release",
|
|
478
|
-
bundle_id:
|
|
604
|
+
bundle_id: bundleID,
|
|
479
605
|
device_token: deviceID,
|
|
480
606
|
}),
|
|
481
607
|
});
|
|
@@ -535,9 +661,10 @@ class SidechatAPIClient {
|
|
|
535
661
|
* @param {String} groupID - group ID
|
|
536
662
|
* @param {"hot"|"recent"|"top"} category - category to filter posts
|
|
537
663
|
* @param {types.SidechatCursorString} [cursor] - cursor string
|
|
664
|
+
* @param {"day"|"week"|"month"|"year"|"all_time"} [period] - time period to pull top posts from (only if category is "top")
|
|
538
665
|
* @returns {Promise<types.SidechatPostsAndCursor>} List of posts and cursor
|
|
539
666
|
*/
|
|
540
|
-
getGroupPosts = async (groupID, category = "hot", cursor) => {
|
|
667
|
+
getGroupPosts = async (groupID, category = "hot", cursor, period) => {
|
|
541
668
|
if (!this.userToken) {
|
|
542
669
|
throw new SidechatAPIError("User is not authenticated.");
|
|
543
670
|
}
|
|
@@ -545,6 +672,8 @@ class SidechatAPIClient {
|
|
|
545
672
|
const res = await fetch(
|
|
546
673
|
`${this.apiRoot}/v1/posts?${
|
|
547
674
|
cursor ? "cursor=" + encodeURIComponent(cursor) + "&" : ""
|
|
675
|
+
}${
|
|
676
|
+
period ? "period=" + period + "&" : ""
|
|
548
677
|
}group_id=${groupID}&type=${category}&cacheBust=${Date.now()}`,
|
|
549
678
|
{
|
|
550
679
|
method: "GET",
|
|
@@ -641,7 +770,7 @@ class SidechatAPIClient {
|
|
|
641
770
|
contentType = "my_comments";
|
|
642
771
|
}
|
|
643
772
|
try {
|
|
644
|
-
const res = await fetch(`${this.apiRoot}/v1/posts
|
|
773
|
+
const res = await fetch(`${this.apiRoot}/v1/posts?type=${contentType}`, {
|
|
645
774
|
method: "GET",
|
|
646
775
|
headers: {
|
|
647
776
|
...this.defaultHeaders,
|
|
@@ -881,8 +1010,9 @@ class SidechatAPIClient {
|
|
|
881
1010
|
throw new SidechatAPIError("User is not authenticated.");
|
|
882
1011
|
}
|
|
883
1012
|
try {
|
|
1013
|
+
// Joining moved to the v2 endpoint, which takes a list of IDs. Leave still sends group_id by itself, no list.
|
|
884
1014
|
const res = await fetch(
|
|
885
|
-
`${this.apiRoot}
|
|
1015
|
+
`${this.apiRoot}${isMember ? "/v2/groups/join" : "/v1/groups/leave"}`,
|
|
886
1016
|
{
|
|
887
1017
|
method: "POST",
|
|
888
1018
|
headers: {
|
|
@@ -890,7 +1020,8 @@ class SidechatAPIClient {
|
|
|
890
1020
|
Authorization: `Bearer ${this.userToken}`,
|
|
891
1021
|
},
|
|
892
1022
|
body: JSON.stringify({
|
|
893
|
-
group_id: groupID,
|
|
1023
|
+
group_id: isMember ? undefined : groupID,
|
|
1024
|
+
group_ids: [groupID],
|
|
894
1025
|
}),
|
|
895
1026
|
},
|
|
896
1027
|
);
|
|
@@ -949,15 +1080,17 @@ class SidechatAPIClient {
|
|
|
949
1080
|
}),
|
|
950
1081
|
});
|
|
951
1082
|
const json = await res.json();
|
|
1083
|
+
if (!res.ok) throw new SidechatAPIError(json.message);
|
|
952
1084
|
return await json.comment;
|
|
953
1085
|
} catch (err) {
|
|
954
1086
|
console.error(err);
|
|
1087
|
+
if (err instanceof SidechatAPIError && err.message) throw err;
|
|
955
1088
|
throw new SidechatAPIError(`Failed to post comment.`);
|
|
956
1089
|
}
|
|
957
1090
|
};
|
|
958
1091
|
|
|
959
1092
|
/**
|
|
960
|
-
* Creates a new post in the specified group
|
|
1093
|
+
* Creates a new post in the specified group. Users can only make two posts a minute; if a post is rejected, the thrown error contains the reason from the server.
|
|
961
1094
|
* @method
|
|
962
1095
|
* @since 2.2.0
|
|
963
1096
|
* @param {String} text - text content of comment
|
|
@@ -967,6 +1100,7 @@ class SidechatAPIClient {
|
|
|
967
1100
|
* @param {Boolean} [disableComments] - whether or not comments should be disabled on post
|
|
968
1101
|
* @param {Boolean} [anonymous] - whether or not to hide user's name and icon on post
|
|
969
1102
|
* @param {Array<String>} [pollOptions] - List of poll options. If provided, a poll will be created with these options.
|
|
1103
|
+
* @param {Array<String>} [attachmentIDs] - IDs of link attachments created with createLinkAttachment()
|
|
970
1104
|
* @returns {Promise<types.SidechatPostOrComment>} the created post
|
|
971
1105
|
*/
|
|
972
1106
|
createPost = async (
|
|
@@ -978,6 +1112,7 @@ class SidechatAPIClient {
|
|
|
978
1112
|
anonymous = false,
|
|
979
1113
|
repostId = undefined,
|
|
980
1114
|
pollOptions = undefined,
|
|
1115
|
+
attachmentIDs = [],
|
|
981
1116
|
) => {
|
|
982
1117
|
if (!this.userToken) {
|
|
983
1118
|
throw new SidechatAPIError("User is not authenticated.");
|
|
@@ -989,7 +1124,7 @@ class SidechatAPIClient {
|
|
|
989
1124
|
assets: assetList,
|
|
990
1125
|
group_ids: [groupID],
|
|
991
1126
|
text: text,
|
|
992
|
-
attachments:
|
|
1127
|
+
attachments: attachmentIDs,
|
|
993
1128
|
dms_disabled: disableDMs,
|
|
994
1129
|
comments_disabled: disableComments,
|
|
995
1130
|
using_identity: !anonymous,
|
|
@@ -1011,9 +1146,11 @@ class SidechatAPIClient {
|
|
|
1011
1146
|
body: JSON.stringify(body),
|
|
1012
1147
|
});
|
|
1013
1148
|
const json = await res.json();
|
|
1149
|
+
if (!res.ok) throw new SidechatAPIError(json.message);
|
|
1014
1150
|
return await json.posts[0];
|
|
1015
1151
|
} catch (err) {
|
|
1016
1152
|
console.error(err);
|
|
1153
|
+
if (err instanceof SidechatAPIError && err.message) throw err;
|
|
1017
1154
|
throw new SidechatAPIError(`Failed to make post.`);
|
|
1018
1155
|
}
|
|
1019
1156
|
};
|
|
@@ -1090,7 +1227,7 @@ class SidechatAPIClient {
|
|
|
1090
1227
|
}
|
|
1091
1228
|
try {
|
|
1092
1229
|
const res = await fetch(
|
|
1093
|
-
`${this.apiRoot}/v1/polls/view_results
|
|
1230
|
+
`${this.apiRoot}/v1/polls/view_results?cacheBust=${Date.now()}`,
|
|
1094
1231
|
{
|
|
1095
1232
|
method: "POST",
|
|
1096
1233
|
headers: {
|
|
@@ -1111,22 +1248,27 @@ class SidechatAPIClient {
|
|
|
1111
1248
|
};
|
|
1112
1249
|
|
|
1113
1250
|
/**
|
|
1114
|
-
* Uploads an asset to AWS S3 for use in posts and comments.
|
|
1251
|
+
* Uploads an asset to AWS S3 for use in posts and comments. Supports images and videos (videos must be under 50MB and are processed after upload)
|
|
1115
1252
|
* @method
|
|
1116
1253
|
* @param {String} uri - URI of the asset to upload
|
|
1117
|
-
* @param {String} mimeType - mimetype of the asset (e.g. "image/png")
|
|
1254
|
+
* @param {String} mimeType - mimetype of the asset (e.g. "image/png" or "video/mp4")
|
|
1118
1255
|
* @param {String} [name] - filename of the asset
|
|
1256
|
+
* @param {"post"|"post_vod_source"|"chat"|"chat_icon"|"group_icon"|"profile_picture_icon"} [context] - where the asset will be used. Videos default to "post_vod_source", which is required for them to be processed into a playable stream.
|
|
1119
1257
|
* @returns {Promise<String>} URL of the uploaded asset
|
|
1120
1258
|
* @since 2.5.1
|
|
1121
1259
|
*/
|
|
1122
|
-
uploadAsset = async (uri, mimeType, name = "") => {
|
|
1260
|
+
uploadAsset = async (uri, mimeType, name = "", context = undefined) => {
|
|
1123
1261
|
if (!this.userToken) {
|
|
1124
1262
|
throw new SidechatAPIError("User is not authenticated.");
|
|
1125
1263
|
}
|
|
1126
1264
|
|
|
1127
1265
|
let imageType = mimeType.split("/")[1];
|
|
1128
|
-
if (
|
|
1129
|
-
|
|
1266
|
+
if (imageType == "quicktime") imageType = "mov";
|
|
1267
|
+
if (!["png", "jpeg", "gif", "webp", "mp4", "mov"].includes(imageType)) {
|
|
1268
|
+
throw new SidechatAPIError("Unsupported file format.");
|
|
1269
|
+
}
|
|
1270
|
+
if (!context && ["mp4", "mov"].includes(imageType)) {
|
|
1271
|
+
context = "post_vod_source";
|
|
1130
1272
|
}
|
|
1131
1273
|
|
|
1132
1274
|
const data = new FormData();
|
|
@@ -1137,7 +1279,9 @@ class SidechatAPIClient {
|
|
|
1137
1279
|
});
|
|
1138
1280
|
|
|
1139
1281
|
const urlReq = await this.sendRequest(
|
|
1140
|
-
`/v1/assets/upload_url?content_type=${imageType}
|
|
1282
|
+
`/v1/assets/upload_url?content_type=${imageType}${
|
|
1283
|
+
context ? "&context=" + context : ""
|
|
1284
|
+
}`,
|
|
1141
1285
|
);
|
|
1142
1286
|
const urlJson = await urlReq.json();
|
|
1143
1287
|
|
|
@@ -1393,7 +1537,7 @@ class SidechatAPIClient {
|
|
|
1393
1537
|
}
|
|
1394
1538
|
try {
|
|
1395
1539
|
const res = await fetch(
|
|
1396
|
-
`${this.apiRoot}/v1/chats/explore
|
|
1540
|
+
`${this.apiRoot}/v1/chats/explore?cacheBust=${Date.now()}`,
|
|
1397
1541
|
{
|
|
1398
1542
|
method: "GET",
|
|
1399
1543
|
headers: {
|
|
@@ -1458,21 +1602,27 @@ class SidechatAPIClient {
|
|
|
1458
1602
|
/**
|
|
1459
1603
|
* Gets a list of the user's direct messages
|
|
1460
1604
|
* @method
|
|
1605
|
+
* @param {types.SidechatCursorString} [cursor] - cursor string
|
|
1461
1606
|
* @returns {Promise<types.SidechatDirectThread[]>}
|
|
1462
1607
|
* @since 2.4.4
|
|
1463
1608
|
*/
|
|
1464
|
-
getDMs = async () => {
|
|
1609
|
+
getDMs = async (cursor) => {
|
|
1465
1610
|
if (!this.userToken) {
|
|
1466
1611
|
throw new SidechatAPIError("User is not authenticated.");
|
|
1467
1612
|
}
|
|
1468
1613
|
try {
|
|
1469
|
-
const res = await fetch(
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1614
|
+
const res = await fetch(
|
|
1615
|
+
`${this.apiRoot}/v1/chats${
|
|
1616
|
+
cursor ? "?cursor=" + encodeURIComponent(cursor) : ""
|
|
1617
|
+
}`,
|
|
1618
|
+
{
|
|
1619
|
+
method: "GET",
|
|
1620
|
+
headers: {
|
|
1621
|
+
...this.defaultHeaders,
|
|
1622
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
1623
|
+
},
|
|
1474
1624
|
},
|
|
1475
|
-
|
|
1625
|
+
);
|
|
1476
1626
|
const json = await res.json();
|
|
1477
1627
|
const list = await json.chats;
|
|
1478
1628
|
let r = [];
|
|
@@ -1601,6 +1751,7 @@ class SidechatAPIClient {
|
|
|
1601
1751
|
* @method
|
|
1602
1752
|
* @param {String} postID - alphanumeric ID of post to hide
|
|
1603
1753
|
* @since 2.6.2
|
|
1754
|
+
* @deprecated since 2.7.0. Please use `blockUser` instead!
|
|
1604
1755
|
*/
|
|
1605
1756
|
hidePostsFromUser = async (postID) => {
|
|
1606
1757
|
if (!this.userToken) {
|
|
@@ -1631,6 +1782,7 @@ class SidechatAPIClient {
|
|
|
1631
1782
|
* Unhides all posts from all users
|
|
1632
1783
|
* @method
|
|
1633
1784
|
* @since 2.6.2
|
|
1785
|
+
* @deprecated since 2.7.0. No longer used by the official app and may stop working.
|
|
1634
1786
|
*/
|
|
1635
1787
|
unhidePostsFromAllUsers = async () => {
|
|
1636
1788
|
if (!this.userToken) {
|
|
@@ -1652,81 +1804,471 @@ class SidechatAPIClient {
|
|
|
1652
1804
|
throw new SidechatAPIError(`Failed to unhide post.`);
|
|
1653
1805
|
}
|
|
1654
1806
|
};
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* Fetches the home feed, which mixes posts from all of the user's groups
|
|
1810
|
+
* @method
|
|
1811
|
+
* @param {"for_you"|"hot"|"recent"} [type] - how the feed should be sorted
|
|
1812
|
+
* @param {String} [schoolGroupID] - alphanumeric ID of the user's school group
|
|
1813
|
+
* @param {types.SidechatCursorString} [cursor] - cursor string
|
|
1814
|
+
* @returns {Promise<types.SidechatFeed>} feed items and cursor
|
|
1815
|
+
* @since 2.7.0
|
|
1816
|
+
*/
|
|
1817
|
+
getHomeFeed = async (type = "for_you", schoolGroupID, cursor) => {
|
|
1818
|
+
if (!this.userToken) {
|
|
1819
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1820
|
+
}
|
|
1821
|
+
try {
|
|
1822
|
+
const params = new URLSearchParams({ type: type });
|
|
1823
|
+
if (schoolGroupID) params.set("school_group_id", schoolGroupID);
|
|
1824
|
+
if (cursor) params.set("cursor", cursor);
|
|
1825
|
+
const res = await this.sendRequest(`/v1/posts/home?${params}`);
|
|
1826
|
+
return await res.json();
|
|
1827
|
+
} catch (err) {
|
|
1828
|
+
console.error(err);
|
|
1829
|
+
throw new SidechatAPIError(`Failed to get home feed.`);
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
|
|
1833
|
+
/**
|
|
1834
|
+
* Follows or unfollows a post. Followed posts send activity notifications when they get new comments.
|
|
1835
|
+
* @method
|
|
1836
|
+
* @param {String} postID - alphanumeric ID of post
|
|
1837
|
+
* @param {Boolean} following - whether or not the user should follow the post
|
|
1838
|
+
* @returns {Promise<{post: types.SidechatPostOrComment}>} the updated post
|
|
1839
|
+
* @since 2.7.0
|
|
1840
|
+
*/
|
|
1841
|
+
setPostFollowing = async (postID, following) => {
|
|
1842
|
+
if (!this.userToken) {
|
|
1843
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1844
|
+
}
|
|
1845
|
+
try {
|
|
1846
|
+
const res = await this.sendRequest(
|
|
1847
|
+
`/v1/posts/${following ? "follow" : "unfollow"}`,
|
|
1848
|
+
"POST",
|
|
1849
|
+
JSON.stringify({ post_id: postID }),
|
|
1850
|
+
);
|
|
1851
|
+
return await res.json();
|
|
1852
|
+
} catch (err) {
|
|
1853
|
+
console.error(err);
|
|
1854
|
+
throw new SidechatAPIError(`Failed to change post follow status.`);
|
|
1855
|
+
}
|
|
1856
|
+
};
|
|
1857
|
+
|
|
1858
|
+
/**
|
|
1859
|
+
* Reports a post or comment to the group's moderators
|
|
1860
|
+
* @method
|
|
1861
|
+
* @param {String} postID - alphanumeric ID of post or comment to report
|
|
1862
|
+
* @param {types.SidechatReportReason} reason - why the content is being reported
|
|
1863
|
+
* @param {String} [note] - explanation to send along with the report
|
|
1864
|
+
* @since 2.7.0
|
|
1865
|
+
*/
|
|
1866
|
+
flagPost = async (postID, reason, note = undefined) => {
|
|
1867
|
+
if (!this.userToken) {
|
|
1868
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1869
|
+
}
|
|
1870
|
+
try {
|
|
1871
|
+
const res = await this.sendRequest(
|
|
1872
|
+
"/v1/posts/flag",
|
|
1873
|
+
"POST",
|
|
1874
|
+
JSON.stringify({ post_id: postID, reason: reason, note: note }),
|
|
1875
|
+
);
|
|
1876
|
+
return await res.json();
|
|
1877
|
+
} catch (err) {
|
|
1878
|
+
console.error(err);
|
|
1879
|
+
throw new SidechatAPIError(`Failed to report post.`);
|
|
1880
|
+
}
|
|
1881
|
+
};
|
|
1882
|
+
|
|
1883
|
+
/**
|
|
1884
|
+
* Blocks the author of a post or comment, hiding all of their content from the user. Replaces `hidePostsFromUser`.
|
|
1885
|
+
* @method
|
|
1886
|
+
* @param {String} postID - alphanumeric ID of a post or comment by the user to block
|
|
1887
|
+
* @param {Boolean} [report] - whether or not to also report the content
|
|
1888
|
+
* @param {"feed"|"chat"} [postContext] - where the content was seen
|
|
1889
|
+
* @since 2.7.0
|
|
1890
|
+
*/
|
|
1891
|
+
blockUser = async (postID, report = false, postContext = "feed") => {
|
|
1892
|
+
if (!this.userToken) {
|
|
1893
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1894
|
+
}
|
|
1895
|
+
try {
|
|
1896
|
+
const res = await this.sendRequest(
|
|
1897
|
+
"/v1/posts/block_user",
|
|
1898
|
+
"POST",
|
|
1899
|
+
JSON.stringify({
|
|
1900
|
+
post_id: postID,
|
|
1901
|
+
post_context: postContext,
|
|
1902
|
+
report: report,
|
|
1903
|
+
}),
|
|
1904
|
+
);
|
|
1905
|
+
return await res.json();
|
|
1906
|
+
} catch (err) {
|
|
1907
|
+
console.error(err);
|
|
1908
|
+
throw new SidechatAPIError(`Failed to block user.`);
|
|
1909
|
+
}
|
|
1910
|
+
};
|
|
1911
|
+
|
|
1912
|
+
/**
|
|
1913
|
+
* Creates a link attachment that can be added to a post with createPost(). YouTube links are recognized and shown as embedded videos.
|
|
1914
|
+
* @method
|
|
1915
|
+
* @param {String} url - URL to attach
|
|
1916
|
+
* @returns {Promise<types.SidechatAttachment>} the created attachment
|
|
1917
|
+
* @since 2.7.0
|
|
1918
|
+
*/
|
|
1919
|
+
createLinkAttachment = async (url) => {
|
|
1920
|
+
if (!this.userToken) {
|
|
1921
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1922
|
+
}
|
|
1923
|
+
try {
|
|
1924
|
+
const res = await this.sendRequest(
|
|
1925
|
+
"/v1/attachments/upload_link",
|
|
1926
|
+
"POST",
|
|
1927
|
+
JSON.stringify({ link_url: url }),
|
|
1928
|
+
);
|
|
1929
|
+
return await res.json();
|
|
1930
|
+
} catch (err) {
|
|
1931
|
+
console.error(err);
|
|
1932
|
+
throw new SidechatAPIError(`Failed to create link attachment.`);
|
|
1933
|
+
}
|
|
1934
|
+
};
|
|
1935
|
+
|
|
1936
|
+
/**
|
|
1937
|
+
* Gets the user's activity feed (notifications for comments, votes, followers, etc.)
|
|
1938
|
+
* @method
|
|
1939
|
+
* @param {types.SidechatCursorString} [cursor] - cursor string
|
|
1940
|
+
* @returns {Promise<types.SidechatActivityList>} activity items and cursor
|
|
1941
|
+
* @since 2.7.0
|
|
1942
|
+
*/
|
|
1943
|
+
getActivity = async (cursor) => {
|
|
1944
|
+
if (!this.userToken) {
|
|
1945
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1946
|
+
}
|
|
1947
|
+
try {
|
|
1948
|
+
const res = await this.sendRequest(
|
|
1949
|
+
`/v1/activity${cursor ? "?cursor=" + encodeURIComponent(cursor) : ""}`,
|
|
1950
|
+
);
|
|
1951
|
+
return await res.json();
|
|
1952
|
+
} catch (err) {
|
|
1953
|
+
console.error(err);
|
|
1954
|
+
throw new SidechatAPIError(`Failed to get activity.`);
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
|
|
1958
|
+
/**
|
|
1959
|
+
* Gets the groups the user is a member of
|
|
1960
|
+
* @method
|
|
1961
|
+
* @returns {Promise<types.SidechatGroup[]>}
|
|
1962
|
+
* @since 2.7.0
|
|
1963
|
+
*/
|
|
1964
|
+
getGroups = async () => {
|
|
1965
|
+
if (!this.userToken) {
|
|
1966
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1967
|
+
}
|
|
1968
|
+
try {
|
|
1969
|
+
const res = await this.sendRequest("/v1/groups");
|
|
1970
|
+
const json = await res.json();
|
|
1971
|
+
return json.groups;
|
|
1972
|
+
} catch (err) {
|
|
1973
|
+
console.error(err);
|
|
1974
|
+
throw new SidechatAPIError(`Failed to get groups.`);
|
|
1975
|
+
}
|
|
1976
|
+
};
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* Gets groups suggested for the user to join
|
|
1980
|
+
* @method
|
|
1981
|
+
* @param {Number} [limit] - maximum number of groups to return
|
|
1982
|
+
* @returns {Promise<types.SidechatGroup[]>}
|
|
1983
|
+
* @since 2.7.0
|
|
1984
|
+
*/
|
|
1985
|
+
getSuggestedGroups = async (limit = 10) => {
|
|
1986
|
+
if (!this.userToken) {
|
|
1987
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1988
|
+
}
|
|
1989
|
+
try {
|
|
1990
|
+
const res = await this.sendRequest(
|
|
1991
|
+
`/v1/groups/suggestions?limit=${limit}`,
|
|
1992
|
+
);
|
|
1993
|
+
const json = await res.json();
|
|
1994
|
+
return json.groups;
|
|
1995
|
+
} catch (err) {
|
|
1996
|
+
console.error(err);
|
|
1997
|
+
throw new SidechatAPIError(`Failed to get suggested groups.`);
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
|
|
2001
|
+
/**
|
|
2002
|
+
* Gets a shareable invite link for a group. School groups don't have invite links and will throw an error.
|
|
2003
|
+
* @method
|
|
2004
|
+
* @param {String} groupID - alphanumeric ID of group
|
|
2005
|
+
* @returns {Promise<String>} invite link URL
|
|
2006
|
+
* @since 2.7.0
|
|
2007
|
+
*/
|
|
2008
|
+
getGroupInviteLink = async (groupID) => {
|
|
2009
|
+
if (!this.userToken) {
|
|
2010
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
2011
|
+
}
|
|
2012
|
+
try {
|
|
2013
|
+
const res = await this.sendRequest(
|
|
2014
|
+
`/v1/groups/invite_link?group_id=${groupID}`,
|
|
2015
|
+
);
|
|
2016
|
+
const json = await res.json();
|
|
2017
|
+
return json.link;
|
|
2018
|
+
} catch (err) {
|
|
2019
|
+
console.error(err);
|
|
2020
|
+
throw new SidechatAPIError(`Failed to get invite link.`);
|
|
2021
|
+
}
|
|
2022
|
+
};
|
|
2023
|
+
|
|
2024
|
+
/**
|
|
2025
|
+
* Gets the yakarma leaderboard for a group, along with the user's own karma
|
|
2026
|
+
* @method
|
|
2027
|
+
* @param {String} groupID - alphanumeric ID of group
|
|
2028
|
+
* @returns {Promise<types.SidechatLeaderboard>}
|
|
2029
|
+
* @since 2.7.0
|
|
2030
|
+
*/
|
|
2031
|
+
getLeaderboard = async (groupID) => {
|
|
2032
|
+
if (!this.userToken) {
|
|
2033
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
2034
|
+
}
|
|
2035
|
+
try {
|
|
2036
|
+
const res = await this.sendRequest(`/v1/leaderboard?group_id=${groupID}`);
|
|
2037
|
+
return await res.json();
|
|
2038
|
+
} catch (err) {
|
|
2039
|
+
console.error(err);
|
|
2040
|
+
throw new SidechatAPIError(`Failed to get leaderboard.`);
|
|
2041
|
+
}
|
|
2042
|
+
};
|
|
2043
|
+
|
|
2044
|
+
/**
|
|
2045
|
+
* Gets the existing direct message thread for a post or comment. Returns undefined if the user hasn't started one.
|
|
2046
|
+
* @method
|
|
2047
|
+
* @param {String} postID - alphanumeric ID of post or comment
|
|
2048
|
+
* @returns {Promise<types.SidechatDirectThread>}
|
|
2049
|
+
* @since 2.7.0
|
|
2050
|
+
*/
|
|
2051
|
+
getDMForPost = async (postID) => {
|
|
2052
|
+
if (!this.userToken) {
|
|
2053
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
2054
|
+
}
|
|
2055
|
+
try {
|
|
2056
|
+
const res = await this.sendRequest(`/v1/chats/by_post?post_id=${postID}`);
|
|
2057
|
+
const json = await res.json();
|
|
2058
|
+
return json.chat;
|
|
2059
|
+
} catch (err) {
|
|
2060
|
+
console.error(err);
|
|
2061
|
+
throw new SidechatAPIError(`Failed to get DM thread for post.`);
|
|
2062
|
+
}
|
|
2063
|
+
};
|
|
2064
|
+
|
|
2065
|
+
/**
|
|
2066
|
+
* Reports a direct message thread
|
|
2067
|
+
* @method
|
|
2068
|
+
* @param {String} chatID - alphanumeric ID of the thread to report
|
|
2069
|
+
* @param {types.SidechatReportReason} reason - why the thread is being reported
|
|
2070
|
+
* @since 2.7.0
|
|
2071
|
+
*/
|
|
2072
|
+
reportDM = async (chatID, reason) => {
|
|
2073
|
+
if (!this.userToken) {
|
|
2074
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
2075
|
+
}
|
|
2076
|
+
try {
|
|
2077
|
+
const res = await this.sendRequest(
|
|
2078
|
+
"/v1/chats/report",
|
|
2079
|
+
"POST",
|
|
2080
|
+
JSON.stringify({ chat_id: chatID, reason: reason }),
|
|
2081
|
+
);
|
|
2082
|
+
return await res.json();
|
|
2083
|
+
} catch (err) {
|
|
2084
|
+
console.error(err);
|
|
2085
|
+
throw new SidechatAPIError(`Failed to report DM.`);
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
|
|
2089
|
+
/**
|
|
2090
|
+
* Sets which push notifications the user receives
|
|
2091
|
+
* @method
|
|
2092
|
+
* @param {types.SidechatNotificationPreferences} preferences - notification types to enable or disable
|
|
2093
|
+
* @since 2.7.0
|
|
2094
|
+
*/
|
|
2095
|
+
setNotificationPreferences = async (preferences) => {
|
|
2096
|
+
if (!this.userToken) {
|
|
2097
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
2098
|
+
}
|
|
2099
|
+
try {
|
|
2100
|
+
const res = await this.sendRequest(
|
|
2101
|
+
"/v1/users/set_notification_preferences",
|
|
2102
|
+
"POST",
|
|
2103
|
+
JSON.stringify({ notification_preferences: preferences }),
|
|
2104
|
+
);
|
|
2105
|
+
return await res.json();
|
|
2106
|
+
} catch (err) {
|
|
2107
|
+
console.error(err);
|
|
2108
|
+
throw new SidechatAPIError(`Failed to set notification preferences.`);
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
|
|
2112
|
+
/**
|
|
2113
|
+
* Verifies the user's school email by signing in with Google or Microsoft instead of clicking an emailed link. Returns the same object as checkEmailVerification(). This was discovered from me decompiling the new Android app, I haven't tested this but based on the implementation it should work fine and might resolve the problem that a lot of people have with their accounts not being associated with their school automatically.
|
|
2114
|
+
* @method
|
|
2115
|
+
* @param {String} authToken - token from the Google or Microsoft sign-in
|
|
2116
|
+
* @param {"google"|"microsoft"} authType - provider the token came from
|
|
2117
|
+
* @param {Boolean} [isIncomingFreshman] - whether or not the user is an incoming freshman
|
|
2118
|
+
* @since 2.7.0
|
|
2119
|
+
* @tutorial Email Registration
|
|
2120
|
+
*/
|
|
2121
|
+
verifyEmailWithThirdParty = async (
|
|
2122
|
+
authToken,
|
|
2123
|
+
authType,
|
|
2124
|
+
isIncomingFreshman = false,
|
|
2125
|
+
) => {
|
|
2126
|
+
if (!this.userToken) {
|
|
2127
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
2128
|
+
}
|
|
2129
|
+
try {
|
|
2130
|
+
const res = await this.sendRequest(
|
|
2131
|
+
"/v1/users/third_party_email_verified",
|
|
2132
|
+
"POST",
|
|
2133
|
+
JSON.stringify({
|
|
2134
|
+
auth: authToken,
|
|
2135
|
+
auth_type: authType,
|
|
2136
|
+
is_incoming_freshman: isIncomingFreshman,
|
|
2137
|
+
}),
|
|
2138
|
+
);
|
|
2139
|
+
const json = await res.json();
|
|
2140
|
+
if (json.verified_email_updates_response) {
|
|
2141
|
+
return json.verified_email_updates_response;
|
|
2142
|
+
} else {
|
|
2143
|
+
throw new SidechatAPIError(json?.message || "Email is not verified.");
|
|
2144
|
+
}
|
|
2145
|
+
} catch (err) {
|
|
2146
|
+
console.error(err);
|
|
2147
|
+
throw new SidechatAPIError("Failed to verify email.");
|
|
2148
|
+
}
|
|
2149
|
+
};
|
|
2150
|
+
|
|
2151
|
+
/**
|
|
2152
|
+
* Authorizes a realtime (Pusher) connection to subscribe to a private channel, such as `private-chat-<chatID>` for live direct messages. Pass the result to your Pusher client's channel authorizer. This hasn't been tested, and is mostly theoretical.
|
|
2153
|
+
* @method
|
|
2154
|
+
* @param {String} socketID - socket ID assigned by Pusher
|
|
2155
|
+
* @param {String} channelName - name of the private channel to subscribe to
|
|
2156
|
+
* @returns {Promise<{auth: String}>} signed channel authorization
|
|
2157
|
+
* @since 2.7.0
|
|
2158
|
+
*/
|
|
2159
|
+
authorizeRealtimeChannel = async (socketID, channelName) => {
|
|
2160
|
+
if (!this.userToken) {
|
|
2161
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
2162
|
+
}
|
|
2163
|
+
try {
|
|
2164
|
+
const res = await this.sendRequest(
|
|
2165
|
+
"/pusher/auth",
|
|
2166
|
+
"POST",
|
|
2167
|
+
JSON.stringify({ socket_id: socketID, channel_name: channelName }),
|
|
2168
|
+
);
|
|
2169
|
+
return await res.json();
|
|
2170
|
+
} catch (err) {
|
|
2171
|
+
console.error(err);
|
|
2172
|
+
throw new SidechatAPIError(`Failed to authorize realtime channel.`);
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
|
|
2176
|
+
/**
|
|
2177
|
+
* Permanently deletes the current user's account. This cannot be undone!
|
|
2178
|
+
* @method
|
|
2179
|
+
* @since 2.7.0
|
|
2180
|
+
*/
|
|
2181
|
+
deleteAccount = async () => {
|
|
2182
|
+
if (!this.userToken) {
|
|
2183
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
2184
|
+
}
|
|
2185
|
+
try {
|
|
2186
|
+
const res = await this.sendRequest(
|
|
2187
|
+
"/v1/users/delete",
|
|
2188
|
+
"POST",
|
|
2189
|
+
JSON.stringify({}),
|
|
2190
|
+
);
|
|
2191
|
+
return await res.json();
|
|
2192
|
+
} catch (err) {
|
|
2193
|
+
console.error(err);
|
|
2194
|
+
throw new SidechatAPIError(`Failed to delete account.`);
|
|
2195
|
+
}
|
|
2196
|
+
};
|
|
1655
2197
|
}
|
|
1656
2198
|
|
|
1657
|
-
/**
|
|
1658
|
-
* @typedef SidechatColor
|
|
1659
|
-
* @prop {String} primary - hex code of primary color
|
|
1660
|
-
* @prop {String} secondary - hex code of secondary color
|
|
1661
|
-
*/
|
|
1662
|
-
|
|
1663
|
-
/**
|
|
1664
|
-
* List of colors compatible with user conversation icons
|
|
1665
|
-
* @prop {SidechatColor[]} colors - list of color themes for user icons
|
|
1666
|
-
*/
|
|
1667
|
-
class SidechatColorList {
|
|
1668
|
-
colors = [
|
|
1669
|
-
{
|
|
1670
|
-
primary: "#74DEEE",
|
|
1671
|
-
secondary: "#239EAB",
|
|
1672
|
-
},
|
|
1673
|
-
{
|
|
1674
|
-
primary: "#15FF46",
|
|
1675
|
-
secondary: "#3FC0FF",
|
|
1676
|
-
},
|
|
1677
|
-
{
|
|
1678
|
-
primary: "#D9FB8A",
|
|
1679
|
-
secondary: "#B1FD00",
|
|
1680
|
-
},
|
|
1681
|
-
{
|
|
1682
|
-
primary: "#FC40FF",
|
|
1683
|
-
secondary: "#0DD5B2",
|
|
1684
|
-
},
|
|
1685
|
-
{
|
|
1686
|
-
primary: "#3E973C",
|
|
1687
|
-
secondary: "#0F430E",
|
|
1688
|
-
},
|
|
1689
|
-
{
|
|
1690
|
-
primary: "#FFD305",
|
|
1691
|
-
secondary: "#F4B320",
|
|
1692
|
-
},
|
|
1693
|
-
{
|
|
1694
|
-
primary: "#8483FF",
|
|
1695
|
-
secondary: "#5857FF",
|
|
1696
|
-
},
|
|
1697
|
-
{
|
|
1698
|
-
primary: "#FA81FF",
|
|
1699
|
-
secondary: "#722DFF",
|
|
1700
|
-
},
|
|
1701
|
-
{
|
|
1702
|
-
primary: "#00CBFE",
|
|
1703
|
-
secondary: "#0D13D5",
|
|
1704
|
-
},
|
|
1705
|
-
{
|
|
1706
|
-
primary: "#FF7B51",
|
|
1707
|
-
secondary: "#B2431F",
|
|
1708
|
-
},
|
|
1709
|
-
{
|
|
1710
|
-
primary: "#FF47CC",
|
|
1711
|
-
secondary: "#69004C",
|
|
1712
|
-
},
|
|
1713
|
-
{
|
|
1714
|
-
primary: "#00EE6E",
|
|
1715
|
-
secondary: "#0C75E6",
|
|
1716
|
-
},
|
|
1717
|
-
{
|
|
1718
|
-
primary: "#FF1885",
|
|
1719
|
-
secondary: "#FA81FF",
|
|
1720
|
-
},
|
|
1721
|
-
{
|
|
1722
|
-
primary: "#D8DC44",
|
|
1723
|
-
secondary: "#228B3F",
|
|
1724
|
-
},
|
|
1725
|
-
{
|
|
1726
|
-
primary: "#0968E5",
|
|
1727
|
-
secondary: "#091970",
|
|
1728
|
-
},
|
|
1729
|
-
];
|
|
2199
|
+
/**
|
|
2200
|
+
* @typedef SidechatColor
|
|
2201
|
+
* @prop {String} primary - hex code of primary color
|
|
2202
|
+
* @prop {String} secondary - hex code of secondary color
|
|
2203
|
+
*/
|
|
2204
|
+
|
|
2205
|
+
/**
|
|
2206
|
+
* List of colors compatible with user conversation icons
|
|
2207
|
+
* @prop {SidechatColor[]} colors - list of color themes for user icons
|
|
2208
|
+
*/
|
|
2209
|
+
class SidechatColorList {
|
|
2210
|
+
colors = [
|
|
2211
|
+
{
|
|
2212
|
+
primary: "#74DEEE",
|
|
2213
|
+
secondary: "#239EAB",
|
|
2214
|
+
},
|
|
2215
|
+
{
|
|
2216
|
+
primary: "#15FF46",
|
|
2217
|
+
secondary: "#3FC0FF",
|
|
2218
|
+
},
|
|
2219
|
+
{
|
|
2220
|
+
primary: "#D9FB8A",
|
|
2221
|
+
secondary: "#B1FD00",
|
|
2222
|
+
},
|
|
2223
|
+
{
|
|
2224
|
+
primary: "#FC40FF",
|
|
2225
|
+
secondary: "#0DD5B2",
|
|
2226
|
+
},
|
|
2227
|
+
{
|
|
2228
|
+
primary: "#3E973C",
|
|
2229
|
+
secondary: "#0F430E",
|
|
2230
|
+
},
|
|
2231
|
+
{
|
|
2232
|
+
primary: "#FFD305",
|
|
2233
|
+
secondary: "#F4B320",
|
|
2234
|
+
},
|
|
2235
|
+
{
|
|
2236
|
+
primary: "#8483FF",
|
|
2237
|
+
secondary: "#5857FF",
|
|
2238
|
+
},
|
|
2239
|
+
{
|
|
2240
|
+
primary: "#FA81FF",
|
|
2241
|
+
secondary: "#722DFF",
|
|
2242
|
+
},
|
|
2243
|
+
{
|
|
2244
|
+
primary: "#00CBFE",
|
|
2245
|
+
secondary: "#0D13D5",
|
|
2246
|
+
},
|
|
2247
|
+
{
|
|
2248
|
+
primary: "#FF7B51",
|
|
2249
|
+
secondary: "#B2431F",
|
|
2250
|
+
},
|
|
2251
|
+
{
|
|
2252
|
+
primary: "#FF47CC",
|
|
2253
|
+
secondary: "#69004C",
|
|
2254
|
+
},
|
|
2255
|
+
{
|
|
2256
|
+
primary: "#00EE6E",
|
|
2257
|
+
secondary: "#0C75E6",
|
|
2258
|
+
},
|
|
2259
|
+
{
|
|
2260
|
+
primary: "#FF1885",
|
|
2261
|
+
secondary: "#FA81FF",
|
|
2262
|
+
},
|
|
2263
|
+
{
|
|
2264
|
+
primary: "#D8DC44",
|
|
2265
|
+
secondary: "#228B3F",
|
|
2266
|
+
},
|
|
2267
|
+
{
|
|
2268
|
+
primary: "#0968E5",
|
|
2269
|
+
secondary: "#091970",
|
|
2270
|
+
},
|
|
2271
|
+
];
|
|
1730
2272
|
}
|
|
1731
2273
|
|
|
1732
2274
|
export { SidechatAPIClient, SidechatAPIError, SidechatColorList, SidechatTypes };
|