sidechat.js 2.3.8 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/classes/SidechatAPIClient.d.ts +17 -2
  2. package/dist/classes/SidechatAPIClient.d.ts.map +1 -1
  3. package/dist/index.cjs +99 -92
  4. package/dist/index.mjs +99 -92
  5. package/docs/sidechat.js/2.4.0/SidechatAPIClient.html +3 -0
  6. package/docs/sidechat.js/{2.3.8 → 2.4.0}/classes_SidechatAPIClient.js.html +95 -91
  7. package/docs/sidechat.js/2.4.0/data/search.json +1 -0
  8. package/package.json +54 -54
  9. package/src/classes/SidechatAPIClient.js +99 -92
  10. package/src/tests/postTest.js +2 -1
  11. package/docs/sidechat.js/2.3.8/SidechatAPIClient.html +0 -3
  12. package/docs/sidechat.js/2.3.8/data/search.json +0 -1
  13. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/SidechatAPIError.html +0 -0
  14. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/SidechatColorList.html +0 -0
  15. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/classes_SidechatAPIError.js.html +0 -0
  16. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/classes_SidechatColorList.js.html +0 -0
  17. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/fonts/Inconsolata-Regular.ttf +0 -0
  18. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/fonts/OpenSans-Regular.ttf +0 -0
  19. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/fonts/WorkSans-Bold.ttf +0 -0
  20. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/global.html +0 -0
  21. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/index.html +0 -0
  22. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/core.js +0 -0
  23. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/core.min.js +0 -0
  24. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/resize.js +0 -0
  25. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/search.js +0 -0
  26. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/search.min.js +0 -0
  27. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/third-party/Apache-License-2.0.txt +0 -0
  28. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/third-party/fuse.js +0 -0
  29. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/third-party/hljs-line-num-original.js +0 -0
  30. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/third-party/hljs-line-num.js +0 -0
  31. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/third-party/hljs-original.js +0 -0
  32. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/third-party/hljs.js +0 -0
  33. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/third-party/popper.js +0 -0
  34. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/third-party/tippy.js +0 -0
  35. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/third-party/tocbot.js +0 -0
  36. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/scripts/third-party/tocbot.min.js +0 -0
  37. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/styles/clean-jsdoc-theme-base.css +0 -0
  38. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/styles/clean-jsdoc-theme-dark.css +0 -0
  39. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/styles/clean-jsdoc-theme-light.css +0 -0
  40. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/styles/clean-jsdoc-theme.min.css +0 -0
  41. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/tutorial-Authentication.html +0 -0
  42. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/tutorial-Email Registration.html +0 -0
  43. /package/docs/sidechat.js/{2.3.8 → 2.4.0}/types_SidechatTypes.js.html +0 -0
@@ -8,8 +8,9 @@ declare class SidechatAPIClient {
8
8
  /**
9
9
  * Create a new instance of the API client
10
10
  * @param {SidechatAuthToken} [token] - user bearer token
11
+ * @param {String} rootUrl - custom API root URL for mocking or using other server
11
12
  */
12
- constructor(token?: SidechatAuthToken);
13
+ constructor(token?: SidechatAuthToken, rootUrl?: string);
13
14
  /**
14
15
  * User bearer token
15
16
  * @type {SidechatAuthToken}
@@ -22,12 +23,25 @@ declare class SidechatAPIClient {
22
23
  * @constant
23
24
  */
24
25
  defaultHeaders: any;
26
+ /**
27
+ * Root URL for every API request
28
+ * @type {String}
29
+ * @default "https://api.sidechat.lol"
30
+ */
31
+ apiRoot: string;
25
32
  /**
26
33
  * Manually set the currently signed in user's token. Generally try to avoid this and instead either pass a token to the constructor or login automatically through the auth functions
27
34
  * @method
28
35
  * @param {SidechatAuthToken} token - user bearer token
29
36
  */
30
37
  setToken: (token: SidechatAuthToken) => void;
38
+ /**
39
+ * Manually set the root URL for all API requests. This can be used for mocking requests or redirecting them to a different server
40
+ * @method
41
+ * @param {String} url - new root URL to set
42
+ * @since 2.3.9
43
+ */
44
+ setAPIRoot: (url: string) => void;
31
45
  /**
32
46
  * Initiate the login process with a phone number. Should be followed up with verifySMSCode().
33
47
  * @method
@@ -178,9 +192,10 @@ declare class SidechatAPIClient {
178
192
  * @param {String} [replyCommentID] - alphanumeric ID of comment to reply to. Falls back to parentPostID
179
193
  * @param {SidechatSimpleAsset[]} [assetList] - list of assets to attach
180
194
  * @param {Boolean} [disableDMs] - prevent direct messages being sent to comment's author
195
+ * @param {Boolean} [anonymous] - whether or not to hide user's name and icon on comment
181
196
  * @returns {SidechatPostOrComment} created comment
182
197
  */
183
- createComment: (parentPostID: string, text: string, groupID: string, replyCommentID?: string, assetList?: SidechatSimpleAsset[], disableDMs?: boolean) => SidechatPostOrComment;
198
+ createComment: (parentPostID: string, text: string, groupID: string, replyCommentID?: string, assetList?: SidechatSimpleAsset[], disableDMs?: boolean, anonymous?: boolean) => SidechatPostOrComment;
184
199
  /**
185
200
  * Creates a new post in the specified group
186
201
  * @method
@@ -1 +1 @@
1
- {"version":3,"file":"SidechatAPIClient.d.ts","sourceRoot":"","sources":["../../src/classes/SidechatAPIClient.js"],"names":[],"mappings":";AAGA;;;;GAIG;AACH;IAmBE;;;OAGG;IACH,uCAIC;IA1BD;;;SAGK;IACL,6BAAU;IACV;;;;;OAKG;IACH,oBAKE;IAYF;;;;OAIG;IACH,6CAEE;IAEF;;;;;OAKG;IACH,mDAgBE;IAEF;;;;;;OAMG;IACH,mEAsBE;IAEF;;;;;;OAMG;IACH,8DAyBE;IAEF;;;;;;OAMG;IACH,+CA2BE;IAEF;;;;OAIG;IACH,2CAyBE;IAEF;;;;;OAKG;IACH,6CA2BE;IAEF;;;;;;OAMG;IACH,oDAGE;IAEF;;;;;OAKG;IACH,+CAqBE;IAEF;;;;;;;;OAQG;IACH,4CAJW,KAAK,GAAC,QAAQ,GAAC,KAAK,2DA2B7B;IAEF;;;;;;OAMG;IACH,sEAsBE;IAEF;;;;;;;OAOG;IACH,6EAqBE;IAEF;;;;;;OAMG;IACH,8BAHW,OAAO,GAAC,UAAU,KAChB,uBAAuB,CA4BlC;IAEF;;;;;;OAMG;IACH,qCAFa,uBAAuB,CAqElC;IAEF;;;;;;OAMG;IACH,2CAFa,eAAe,CAqB1B;IAEF;;;;;OAKG;IACH,uBAFa,sBAAsB,CAoBjC;IAEF;;;;;OAKG;IACH,0CAkBE;IAEF;;;;;;OAMG;IACH,sDAkBE;IAEF;;;;;;OAMG;IACH,yEAwBE;IAEF;;;;;;;;;;;OAWG;IACH,0GAJW,qBAAqB,iDAsC9B;IAEF;;;;;;;;;;;OAWG;IACH,wDANW,qBAAqB,iGAyC9B;IAEF;;;;;OAKG;IACH,+DAqBE;IAEF;;;;;;;;OAQG;IACH,2GA2BE;IAEF;;;;;;OAMG;IACH,6CAwBE;IAEF;;;;;;OAMG;IACH,gEAqBE;IAEF;;;;;OAKG;IACH,mDAqBE;IAEF;;;;OAIG;IACH,kCAkBE;IAEF;;;;OAIG;IACH,wHAiCE;CACH"}
1
+ {"version":3,"file":"SidechatAPIClient.d.ts","sourceRoot":"","sources":["../../src/classes/SidechatAPIClient.js"],"names":[],"mappings":";AAGA;;;;GAIG;AACH;IA2BE;;;;OAIG;IACH,yDAOC;IAtCD;;;SAGK;IACL,6BAAU;IAEV;;;;;OAKG;IACH,oBAKE;IAEF;;;;OAIG;IACH,gBAAqC;IAgBrC;;;;OAIG;IACH,6CAEE;IAEF;;;;;OAKG;IACH,kCAEE;IAEF;;;;;OAKG;IACH,mDAgBE;IAEF;;;;;;OAMG;IACH,mEAmBE;IAEF;;;;;;OAMG;IACH,8DAsBE;IAEF;;;;;;OAMG;IACH,+CAwBE;IAEF;;;;OAIG;IACH,2CAsBE;IAEF;;;;;OAKG;IACH,6CAwBE;IAEF;;;;;;OAMG;IACH,oDAGE;IAEF;;;;;OAKG;IACH,+CAqBE;IAEF;;;;;;;;OAQG;IACH,4CAJW,KAAK,GAAC,QAAQ,GAAC,KAAK,2DA2B7B;IAEF;;;;;;OAMG;IACH,sEAsBE;IAEF;;;;;;;OAOG;IACH,6EAqBE;IAEF;;;;;;OAMG;IACH,8BAHW,OAAO,GAAC,UAAU,KAChB,uBAAuB,CAyBlC;IAEF;;;;;;OAMG;IACH,qCAFa,uBAAuB,CAqElC;IAEF;;;;;;OAMG;IACH,2CAFa,eAAe,CAqB1B;IAEF;;;;;OAKG;IACH,uBAFa,sBAAsB,CAoBjC;IAEF;;;;;OAKG;IACH,0CAkBE;IAEF;;;;;;OAMG;IACH,sDAkBE;IAEF;;;;;;OAMG;IACH,yEAwBE;IAEF;;;;;;;;;;;;OAYG;IACH,0GALW,qBAAqB,sEAyC9B;IAEF;;;;;;;;;;;OAWG;IACH,wDANW,qBAAqB,iGAyC9B;IAEF;;;;;OAKG;IACH,+DAqBE;IAEF;;;;;;;;OAQG;IACH,2GA2BE;IAEF;;;;;;OAMG;IACH,6CAwBE;IAEF;;;;;;OAMG;IACH,gEAqBE;IAEF;;;;;OAKG;IACH,mDAqBE;IAEF;;;;OAIG;IACH,kCAkBE;IAEF;;;;OAIG;IACH,wHAiCE;CACH"}
package/dist/index.cjs CHANGED
@@ -25,6 +25,7 @@ class SidechatAPIClient {
25
25
  * @type {SidechatAuthToken}
26
26
  * */
27
27
  userToken;
28
+
28
29
  /**
29
30
  * Default headers for every API request
30
31
  * @type {Object}
@@ -38,14 +39,25 @@ class SidechatAPIClient {
38
39
  Dnt: 1,
39
40
  };
40
41
 
42
+ /**
43
+ * Root URL for every API request
44
+ * @type {String}
45
+ * @default "https://api.sidechat.lol"
46
+ */
47
+ apiRoot = "https://api.sidechat.lol";
48
+
41
49
  /**
42
50
  * Create a new instance of the API client
43
51
  * @param {SidechatAuthToken} [token] - user bearer token
52
+ * @param {String} rootUrl - custom API root URL for mocking or using other server
44
53
  */
45
- constructor(token = "") {
54
+ constructor(token = "", rootUrl = "") {
46
55
  if (token) {
47
56
  this.userToken = token;
48
57
  }
58
+ if (rootUrl) {
59
+ this.apiRoot = rootUrl;
60
+ }
49
61
  }
50
62
 
51
63
  /**
@@ -57,6 +69,16 @@ class SidechatAPIClient {
57
69
  this.userToken = token;
58
70
  };
59
71
 
72
+ /**
73
+ * Manually set the root URL for all API requests. This can be used for mocking requests or redirecting them to a different server
74
+ * @method
75
+ * @param {String} url - new root URL to set
76
+ * @since 2.3.9
77
+ */
78
+ setAPIRoot = (url) => {
79
+ this.apiRoot = url;
80
+ };
81
+
60
82
  /**
61
83
  * Initiate the login process with a phone number. Should be followed up with verifySMSCode().
62
84
  * @method
@@ -65,7 +87,7 @@ class SidechatAPIClient {
65
87
  */
66
88
  loginViaSMS = async (phoneNumber) => {
67
89
  try {
68
- const res = await fetch(`https://api.sidechat.lol/v1/login_register`, {
90
+ const res = await fetch(`${this.apiRoot}/v1/login_register`, {
69
91
  method: "POST",
70
92
  headers: this.defaultHeaders,
71
93
  body: JSON.stringify({
@@ -90,17 +112,14 @@ class SidechatAPIClient {
90
112
  */
91
113
  verifySMSCode = async (phoneNumber, code) => {
92
114
  try {
93
- const res = await fetch(
94
- `https://api.sidechat.lol/v1/verify_phone_number`,
95
- {
96
- method: "POST",
97
- headers: this.defaultHeaders,
98
- body: JSON.stringify({
99
- phone_number: `+1${phoneNumber}`,
100
- code: code.toUpperCase(),
101
- }),
102
- }
103
- );
115
+ const res = await fetch(`${this.apiRoot}/v1/verify_phone_number`, {
116
+ method: "POST",
117
+ headers: this.defaultHeaders,
118
+ body: JSON.stringify({
119
+ phone_number: `+1${phoneNumber}`,
120
+ code: code.toUpperCase(),
121
+ }),
122
+ });
104
123
  const json = await res.json();
105
124
  if (json?.logged_in_user?.token) {
106
125
  this.userToken = json.logged_in_user.token;
@@ -124,17 +143,14 @@ class SidechatAPIClient {
124
143
  throw new SidechatAPIError("You're too young to use Offsides.");
125
144
  }
126
145
  try {
127
- const res = await fetch(
128
- `https://api.sidechat.lol/v1/complete_registration`,
129
- {
130
- method: "POST",
131
- headers: this.defaultHeaders,
132
- body: JSON.stringify({
133
- age: Number(age),
134
- registration_id: registrationID,
135
- }),
136
- }
137
- );
146
+ const res = await fetch(`${this.apiRoot}/v1/complete_registration`, {
147
+ method: "POST",
148
+ headers: this.defaultHeaders,
149
+ body: JSON.stringify({
150
+ age: Number(age),
151
+ registration_id: registrationID,
152
+ }),
153
+ });
138
154
  const json = await res.json();
139
155
  if (json.token) {
140
156
  this.userToken = json.token;
@@ -158,19 +174,16 @@ class SidechatAPIClient {
158
174
  throw new SidechatAPIError("User is not authenticated.");
159
175
  }
160
176
  try {
161
- const res = await fetch(
162
- `https://api.sidechat.lol/v2/users/register_email`,
163
- {
164
- method: "POST",
165
- headers: {
166
- ...this.defaultHeaders,
167
- Authorization: `Bearer ${this.userToken}`,
168
- },
169
- body: JSON.stringify({
170
- email: email,
171
- }),
172
- }
173
- );
177
+ const res = await fetch(`${this.apiRoot}/v2/users/register_email`, {
178
+ method: "POST",
179
+ headers: {
180
+ ...this.defaultHeaders,
181
+ Authorization: `Bearer ${this.userToken}`,
182
+ },
183
+ body: JSON.stringify({
184
+ email: email,
185
+ }),
186
+ });
174
187
  const json = await res.json();
175
188
  if (json.message) {
176
189
  throw new SidechatAPIError(json.message);
@@ -192,16 +205,13 @@ class SidechatAPIClient {
192
205
  throw new SidechatAPIError("User is not authenticated.");
193
206
  }
194
207
  try {
195
- const res = await fetch(
196
- `https://api.sidechat.lol/v1/users/check_email_verified`,
197
- {
198
- method: "GET",
199
- headers: {
200
- ...this.defaultHeaders,
201
- Authorization: `Bearer ${this.userToken}`,
202
- },
203
- }
204
- );
208
+ const res = await fetch(`${this.apiRoot}/v1/users/check_email_verified`, {
209
+ method: "GET",
210
+ headers: {
211
+ ...this.defaultHeaders,
212
+ Authorization: `Bearer ${this.userToken}`,
213
+ },
214
+ });
205
215
  const json = await res.json();
206
216
  if (json.verified_email_updates_response) {
207
217
  return json.verified_email_updates_response;
@@ -225,21 +235,18 @@ class SidechatAPIClient {
225
235
  throw new SidechatAPIError("User is not authenticated.");
226
236
  }
227
237
  try {
228
- const res = await fetch(
229
- `https://api.sidechat.lol/v1/register_device_token`,
230
- {
231
- method: "POST",
232
- headers: {
233
- ...this.defaultHeaders,
234
- Authorization: `Bearer ${this.userToken}`,
235
- },
236
- body: JSON.stringify({
237
- build_type: "release",
238
- bundle_id: "com.flowerave.sidechat",
239
- device_token: deviceID,
240
- }),
241
- }
242
- );
238
+ const res = await fetch(`${this.apiRoot}/v1/register_device_token`, {
239
+ method: "POST",
240
+ headers: {
241
+ ...this.defaultHeaders,
242
+ Authorization: `Bearer ${this.userToken}`,
243
+ },
244
+ body: JSON.stringify({
245
+ build_type: "release",
246
+ bundle_id: "com.flowerave.sidechat",
247
+ device_token: deviceID,
248
+ }),
249
+ });
243
250
  const json = await res.json();
244
251
  await AsyncStorage.setItem("deviceID", deviceID);
245
252
  return json;
@@ -273,7 +280,7 @@ class SidechatAPIClient {
273
280
  }
274
281
  try {
275
282
  const res = await fetch(
276
- `https://api.sidechat.lol/v1/updates?group_id=${groupID}`,
283
+ `${this.apiRoot}/v1/updates?group_id=${groupID}`,
277
284
  {
278
285
  method: "GET",
279
286
  headers: {
@@ -305,7 +312,7 @@ class SidechatAPIClient {
305
312
  }
306
313
  try {
307
314
  const res = await fetch(
308
- `https://api.sidechat.lol/v1/posts?group_id=${groupID}&type=${category}${
315
+ `${this.apiRoot}/v1/posts?group_id=${groupID}&type=${category}${
309
316
  cursor ? "&cursor=" + cursor : ""
310
317
  }`,
311
318
  {
@@ -336,7 +343,7 @@ class SidechatAPIClient {
336
343
  throw new SidechatAPIError("User is not authenticated.");
337
344
  }
338
345
  try {
339
- const res = await fetch(`https://api.sidechat.lol/v1/posts/set_vote`, {
346
+ const res = await fetch(`${this.apiRoot}/v1/posts/set_vote`, {
340
347
  method: "POST",
341
348
  headers: {
342
349
  ...this.defaultHeaders,
@@ -369,7 +376,7 @@ class SidechatAPIClient {
369
376
  }
370
377
  try {
371
378
  const res = await fetch(
372
- `https://api.sidechat.lol/v1/posts/get?include_deleted=${includeDeleted}&post_id=${postID}`,
379
+ `${this.apiRoot}/v1/posts/get?include_deleted=${includeDeleted}&post_id=${postID}`,
373
380
  {
374
381
  method: "GET",
375
382
  headers: {
@@ -403,16 +410,13 @@ class SidechatAPIClient {
403
410
  contentType = "my_comments";
404
411
  }
405
412
  try {
406
- const res = await fetch(
407
- `https://api.sidechat.lol/v1/posts&type=${contentType}`,
408
- {
409
- method: "GET",
410
- headers: {
411
- ...this.defaultHeaders,
412
- Authorization: `Bearer ${this.userToken}`,
413
- },
414
- }
415
- );
413
+ const res = await fetch(`${this.apiRoot}/v1/posts&type=${contentType}`, {
414
+ method: "GET",
415
+ headers: {
416
+ ...this.defaultHeaders,
417
+ Authorization: `Bearer ${this.userToken}`,
418
+ },
419
+ });
416
420
  const json = await res.json();
417
421
  return json.posts;
418
422
  } catch (err) {
@@ -434,7 +438,7 @@ class SidechatAPIClient {
434
438
  }
435
439
  try {
436
440
  const res = await fetch(
437
- `https://api.sidechat.lol/v1/posts/comments/?post_id=${postID}`,
441
+ `${this.apiRoot}/v1/posts/comments/?post_id=${postID}`,
438
442
  {
439
443
  method: "GET",
440
444
  headers: {
@@ -509,7 +513,7 @@ class SidechatAPIClient {
509
513
  throw new SidechatAPIError("User is not authenticated.");
510
514
  }
511
515
  try {
512
- const res = await fetch(`https://api.sidechat.lol/v1/groups/explore`, {
516
+ const res = await fetch(`${this.apiRoot}/v1/groups/explore`, {
513
517
  method: "GET",
514
518
  headers: {
515
519
  ...this.defaultHeaders,
@@ -536,7 +540,7 @@ class SidechatAPIClient {
536
540
  throw new SidechatAPIError("User is not authenticated.");
537
541
  }
538
542
  try {
539
- const res = await fetch(`https://api.sidechat.lol/v1/assets/library`, {
543
+ const res = await fetch(`${this.apiRoot}/v1/assets/library`, {
540
544
  method: "GET",
541
545
  headers: {
542
546
  ...this.defaultHeaders,
@@ -562,7 +566,7 @@ class SidechatAPIClient {
562
566
  throw new SidechatAPIError("User is not authenticated.");
563
567
  }
564
568
  try {
565
- const res = await fetch(`https://api.sidechat.lol/v1/users/me`, {
569
+ const res = await fetch(`${this.apiRoot}/v1/users/me`, {
566
570
  method: "GET",
567
571
  headers: {
568
572
  ...this.defaultHeaders,
@@ -589,7 +593,7 @@ class SidechatAPIClient {
589
593
  throw new SidechatAPIError("User is not authenticated.");
590
594
  }
591
595
  try {
592
- const res = await fetch(`https://api.sidechat.lol/v1/groups/${groupID}`, {
596
+ const res = await fetch(`${this.apiRoot}/v1/groups/${groupID}`, {
593
597
  method: "GET",
594
598
  headers: {
595
599
  ...this.defaultHeaders,
@@ -617,7 +621,7 @@ class SidechatAPIClient {
617
621
  }
618
622
  try {
619
623
  const res = await fetch(
620
- `https://api.sidechat.lol/v1/groups/${isMember ? "join" : "leave"}`,
624
+ `${this.apiRoot}/v1/groups/${isMember ? "join" : "leave"}`,
621
625
  {
622
626
  method: "POST",
623
627
  headers: {
@@ -647,6 +651,7 @@ class SidechatAPIClient {
647
651
  * @param {String} [replyCommentID] - alphanumeric ID of comment to reply to. Falls back to parentPostID
648
652
  * @param {SidechatSimpleAsset[]} [assetList] - list of assets to attach
649
653
  * @param {Boolean} [disableDMs] - prevent direct messages being sent to comment's author
654
+ * @param {Boolean} [anonymous] - whether or not to hide user's name and icon on comment
650
655
  * @returns {SidechatPostOrComment} created comment
651
656
  */
652
657
  createComment = async (
@@ -655,13 +660,14 @@ class SidechatAPIClient {
655
660
  groupID,
656
661
  replyCommentID = parentPostID,
657
662
  assetList = [],
658
- disableDMs = false
663
+ disableDMs = false,
664
+ anonymous = false
659
665
  ) => {
660
666
  if (!this.userToken) {
661
667
  throw new SidechatAPIError("User is not authenticated.");
662
668
  }
663
669
  try {
664
- const res = await fetch(`https://api.sidechat.lol/v1/posts`, {
670
+ const res = await fetch(`${this.apiRoot}/v1/posts`, {
665
671
  method: "POST",
666
672
  headers: {
667
673
  ...this.defaultHeaders,
@@ -675,6 +681,7 @@ class SidechatAPIClient {
675
681
  reply_post_id: replyCommentID,
676
682
  parent_post_id: parentPostID,
677
683
  dms_disabled: disableDMs,
684
+ using_identity: !anonymous,
678
685
  }),
679
686
  });
680
687
  const json = await res.json();
@@ -709,7 +716,7 @@ class SidechatAPIClient {
709
716
  throw new SidechatAPIError("User is not authenticated.");
710
717
  }
711
718
  try {
712
- const res = await fetch(`https://api.sidechat.lol/v1/posts`, {
719
+ const res = await fetch(`${this.apiRoot}/v1/posts`, {
713
720
  method: "POST",
714
721
  headers: {
715
722
  ...this.defaultHeaders,
@@ -745,7 +752,7 @@ class SidechatAPIClient {
745
752
  throw new SidechatAPIError("User is not authenticated.");
746
753
  }
747
754
  try {
748
- const res = await fetch(`https://api.sidechat.lol/v1/posts/delete`, {
755
+ const res = await fetch(`${this.apiRoot}/v1/posts/delete`, {
749
756
  method: "POST",
750
757
  headers: {
751
758
  ...this.defaultHeaders,
@@ -777,7 +784,7 @@ class SidechatAPIClient {
777
784
  throw new SidechatAPIError("User is not authenticated.");
778
785
  }
779
786
  try {
780
- const res = await fetch(`https://api.sidechat.lol/v1/users/${userID}`, {
787
+ const res = await fetch(`${this.apiRoot}/v1/users/${userID}`, {
781
788
  method: "PATCH",
782
789
  headers: {
783
790
  ...this.defaultHeaders,
@@ -814,7 +821,7 @@ class SidechatAPIClient {
814
821
  }
815
822
  try {
816
823
  const res = await fetch(
817
- `https://api.sidechat.lol/v1/users/username?username=${username}`,
824
+ `${this.apiRoot}/v1/users/username?username=${username}`,
818
825
  {
819
826
  method: "GET",
820
827
  headers: {
@@ -846,7 +853,7 @@ class SidechatAPIClient {
846
853
  throw new SidechatAPIError("User is not authenticated.");
847
854
  }
848
855
  try {
849
- const res = await fetch(`https://api.sidechat.lol/v1/users/${userID}`, {
856
+ const res = await fetch(`${this.apiRoot}/v1/users/${userID}`, {
850
857
  method: "PATCH",
851
858
  headers: {
852
859
  ...this.defaultHeaders,
@@ -875,7 +882,7 @@ class SidechatAPIClient {
875
882
  throw new SidechatAPIError("User is not authenticated.");
876
883
  }
877
884
  try {
878
- const res = await fetch(`https://api.sidechat.lol/v1/activity/seen`, {
885
+ const res = await fetch(`${this.apiRoot}/v1/activity/seen`, {
879
886
  method: "POST",
880
887
  headers: {
881
888
  ...this.defaultHeaders,
@@ -903,7 +910,7 @@ class SidechatAPIClient {
903
910
  throw new SidechatAPIError("User is not authenticated.");
904
911
  }
905
912
  try {
906
- const res = await fetch(`https://api.sidechat.lol/v1/chats/explore`, {
913
+ const res = await fetch(`${this.apiRoot}/v1/chats/explore`, {
907
914
  method: "GET",
908
915
  headers: {
909
916
  ...this.defaultHeaders,
@@ -934,7 +941,7 @@ class SidechatAPIClient {
934
941
  throw new SidechatAPIError("User is not authenticated.");
935
942
  }
936
943
  try {
937
- const res = await fetch(`https://api.sidechat.lol/v1/chats/groups/join`, {
944
+ const res = await fetch(`${this.apiRoot}/v1/chats/groups/join`, {
938
945
  method: "GET",
939
946
  headers: {
940
947
  ...this.defaultHeaders,