sidechat.js 2.4.2 → 2.4.4
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 +37 -0
- package/dist/classes/SidechatAPIClient.d.ts.map +1 -1
- package/dist/index.cjs +169 -2
- package/dist/index.mjs +169 -2
- package/dist/types/SidechatTypes.d.ts +74 -0
- package/dist/types/SidechatTypes.d.ts.map +1 -1
- package/docs/sidechat.js/2.4.4/SidechatAPIClient.html +3 -0
- package/docs/sidechat.js/2.4.4/SidechatAPIError.html +3 -0
- package/docs/sidechat.js/2.4.4/SidechatColorList.html +3 -0
- package/docs/sidechat.js/2.4.4/classes_SidechatAPIClient.js.html +1100 -0
- package/docs/sidechat.js/2.4.4/classes_SidechatAPIError.js.html +16 -0
- package/docs/sidechat.js/2.4.4/classes_SidechatColorList.js.html +79 -0
- package/docs/sidechat.js/2.4.4/data/search.json +1 -0
- package/docs/sidechat.js/2.4.4/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/sidechat.js/2.4.4/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/sidechat.js/2.4.4/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/sidechat.js/2.4.4/global.html +3 -0
- package/docs/sidechat.js/2.4.4/index.html +4 -0
- package/docs/sidechat.js/2.4.4/scripts/core.js +726 -0
- package/docs/sidechat.js/2.4.4/scripts/core.min.js +23 -0
- package/docs/sidechat.js/2.4.4/scripts/resize.js +90 -0
- package/docs/sidechat.js/2.4.4/scripts/search.js +265 -0
- package/docs/sidechat.js/2.4.4/scripts/search.min.js +6 -0
- package/docs/sidechat.js/2.4.4/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/sidechat.js/2.4.4/scripts/third-party/fuse.js +9 -0
- package/docs/sidechat.js/2.4.4/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/sidechat.js/2.4.4/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/sidechat.js/2.4.4/scripts/third-party/hljs-original.js +5171 -0
- package/docs/sidechat.js/2.4.4/scripts/third-party/hljs.js +1 -0
- package/docs/sidechat.js/2.4.4/scripts/third-party/popper.js +5 -0
- package/docs/sidechat.js/2.4.4/scripts/third-party/tippy.js +1 -0
- package/docs/sidechat.js/2.4.4/scripts/third-party/tocbot.js +672 -0
- package/docs/sidechat.js/2.4.4/scripts/third-party/tocbot.min.js +1 -0
- package/docs/sidechat.js/2.4.4/styles/clean-jsdoc-theme-base.css +1161 -0
- package/docs/sidechat.js/2.4.4/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/sidechat.js/2.4.4/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/sidechat.js/2.4.4/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/sidechat.js/2.4.4/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/sidechat.js/2.4.4/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/sidechat.js/2.4.4/tutorial-Authentication.html +14 -0
- package/docs/sidechat.js/2.4.4/tutorial-Email Registration.html +6 -0
- package/docs/sidechat.js/2.4.4/types_SidechatTypes.js.html +160 -0
- package/package.json +1 -1
- package/src/classes/SidechatAPIClient.js +142 -1
- package/src/tests/directMessageTest.js +23 -0
- package/src/types/SidechatTypes.js +26 -0
|
@@ -0,0 +1,1100 @@
|
|
|
1
|
+
<!DOCTYPE html><html lang="en" style="font-size:16px"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Source: classes/SidechatAPIClient.js</title><!--[if lt IE 9]>
|
|
2
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
3
|
+
<![endif]--><script src="scripts/third-party/hljs.js" defer="defer"></script><script src="scripts/third-party/hljs-line-num.js" defer="defer"></script><script src="scripts/third-party/popper.js" defer="defer"></script><script src="scripts/third-party/tippy.js" defer="defer"></script><script src="scripts/third-party/tocbot.min.js"></script><script>var baseURL="/",locationPathname="";baseURL=(baseURL=(baseURL="https://micahlindley.com/sidechat.js/").replace(/https?:\/\//i,"")).substr(baseURL.indexOf("/"))</script><link rel="stylesheet" href="styles/clean-jsdoc-theme.min.css"><svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none"><defs><symbol id="copy-icon" viewbox="0 0 488.3 488.3"><g><path d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z"/><path d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z"/></g></symbol><symbol id="search-icon" viewBox="0 0 512 512"><g><g><path d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z"/></g></g><g><g><path d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z"/></g></g></symbol><symbol id="font-size-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.246 15H4.754l-2 5H.6L7 4h2l6.4 16h-2.154l-2-5zm-.8-2L8 6.885 5.554 13h4.892zM21 12.535V12h2v8h-2v-.535a4 4 0 1 1 0-6.93zM19 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></symbol><symbol id="add-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"/></symbol><symbol id="minus-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M5 11h14v2H5z"/></symbol><symbol id="dark-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 7a7 7 0 0 0 12 4.9v.1c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2h.1A6.979 6.979 0 0 0 10 7zm-6 5a8 8 0 0 0 15.062 3.762A9 9 0 0 1 8.238 4.938 7.999 7.999 0 0 0 4 12z"/></symbol><symbol id="light-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></symbol><symbol id="reset-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795z"/></symbol><symbol id="down-icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></symbol><symbol id="codepen-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M16.5 13.202L13 15.535v3.596L19.197 15 16.5 13.202zM14.697 12L12 10.202 9.303 12 12 13.798 14.697 12zM20 10.869L18.303 12 20 13.131V10.87zM19.197 9L13 4.869v3.596l3.5 2.333L19.197 9zM7.5 10.798L11 8.465V4.869L4.803 9 7.5 10.798zM4.803 15L11 19.131v-3.596l-3.5-2.333L4.803 15zM4 13.131L5.697 12 4 10.869v2.262zM2 9a1 1 0 0 1 .445-.832l9-6a1 1 0 0 1 1.11 0l9 6A1 1 0 0 1 22 9v6a1 1 0 0 1-.445.832l-9 6a1 1 0 0 1-1.11 0l-9-6A1 1 0 0 1 2 15V9z"/></symbol><symbol id="close-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></symbol><symbol id="menu-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"/></symbol></defs></svg></head><body data-theme="dark"><div class="sidebar-container"><div class="sidebar" id="sidebar"><a href="/" class="sidebar-title sidebar-title-anchor">Home</a><div class="sidebar-items-container"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-Authentication.html">Authentication</a></div><div class="sidebar-section-children"><a href="tutorial-Email Registration.html">Email Registration</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="SidechatAPIClient.html">SidechatAPIClient</a></div><div class="sidebar-section-children"><a href="SidechatAPIError.html">SidechatAPIError</a></div><div class="sidebar-section-children"><a href="SidechatColorList.html">SidechatColorList</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#SidechatAssetMetadata">SidechatAssetMetadata</a></div><div class="sidebar-section-children"><a href="global.html#SidechatAuthToken">SidechatAuthToken</a></div><div class="sidebar-section-children"><a href="global.html#SidechatColor">SidechatColor</a></div><div class="sidebar-section-children"><a href="global.html#SidechatCurrentUser">SidechatCurrentUser</a></div><div class="sidebar-section-children"><a href="global.html#SidechatCursorString">SidechatCursorString</a></div><div class="sidebar-section-children"><a href="global.html#SidechatDirectMessage">SidechatDirectMessage</a></div><div class="sidebar-section-children"><a href="global.html#SidechatDirectThread">SidechatDirectThread</a></div><div class="sidebar-section-children"><a href="global.html#SidechatGroup">SidechatGroup</a></div><div class="sidebar-section-children"><a href="global.html#SidechatIdentity">SidechatIdentity</a></div><div class="sidebar-section-children"><a href="global.html#SidechatLibraryAsset">SidechatLibraryAsset</a></div><div class="sidebar-section-children"><a href="global.html#SidechatMembership">SidechatMembership</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPostOrComment">SidechatPostOrComment</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPostsAndCursor">SidechatPostsAndCursor</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPrivateAssetURL">SidechatPrivateAssetURL</a></div><div class="sidebar-section-children"><a href="global.html#SidechatSimpleAsset">SidechatSimpleAsset</a></div><div class="sidebar-section-children"><a href="global.html#SidechatVoteString">SidechatVoteString</a></div></div></div></div></div><div class="navbar-container" id="VuAckcnZhf"><nav class="navbar"><div class="navbar-left-items"><div class="navbar-item"><a id="" href="https://github.com/micahlt/offsides#README.md" target="_blank">Offsides (Sidechat for Android)</a></div></div><div class="navbar-right-items"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#light-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div><nav></nav></nav></div><div class="toc-container"><div class="toc-content"><span class="bold">On this page</span><div id="eed4d2a0bfd64539bb9df78095dec881"></div></div></div><div class="body-wrapper"><div class="main-content"><div class="main-wrapper"><section id="source-page" class="source-page"><header><h1 id="title" class="has-anchor">classes_SidechatAPIClient.js</h1></header><article><pre class="prettyprint source lang-js"><code>import "../types/SidechatTypes.js";
|
|
4
|
+
import SidechatAPIError from "../classes/SidechatAPIError.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* API client class for making requests to Sidechat's private API. You'll need to [authenticate]{@tutorial Authentication} before using most of the methods.
|
|
8
|
+
* @class
|
|
9
|
+
* @since 2.0.0-alpha.0
|
|
10
|
+
*/
|
|
11
|
+
class SidechatAPIClient {
|
|
12
|
+
/**
|
|
13
|
+
* User bearer token
|
|
14
|
+
* @type {SidechatAuthToken}
|
|
15
|
+
* */
|
|
16
|
+
userToken;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Default headers for every API request
|
|
20
|
+
* @type {Object}
|
|
21
|
+
* @static
|
|
22
|
+
* @constant
|
|
23
|
+
*/
|
|
24
|
+
defaultHeaders = {
|
|
25
|
+
Accept: "application/json",
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
"App-Version": "6.0.0",
|
|
28
|
+
Dnt: 1,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Root URL for every API request
|
|
33
|
+
* @type {String}
|
|
34
|
+
* @default "https://api.sidechat.lol"
|
|
35
|
+
*/
|
|
36
|
+
apiRoot = "https://api.sidechat.lol";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new instance of the API client
|
|
40
|
+
* @param {SidechatAuthToken} [token] - user bearer token
|
|
41
|
+
* @param {String} rootUrl - custom API root URL for mocking or using other server
|
|
42
|
+
*/
|
|
43
|
+
constructor(token = "", rootUrl = "") {
|
|
44
|
+
if (token) {
|
|
45
|
+
this.userToken = token;
|
|
46
|
+
}
|
|
47
|
+
if (rootUrl) {
|
|
48
|
+
this.apiRoot = rootUrl;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 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
|
|
54
|
+
* @method
|
|
55
|
+
* @param {SidechatAuthToken} token - user bearer token
|
|
56
|
+
*/
|
|
57
|
+
setToken = (token) => {
|
|
58
|
+
this.userToken = token;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Manually set the root URL for all API requests. This can be used for mocking requests or redirecting them to a different server
|
|
63
|
+
* @method
|
|
64
|
+
* @param {String} url - new root URL to set
|
|
65
|
+
* @since 2.3.9
|
|
66
|
+
*/
|
|
67
|
+
setAPIRoot = (url) => {
|
|
68
|
+
this.apiRoot = url;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Initiate the login process with a phone number. Should be followed up with verifySMSCode().
|
|
73
|
+
* @method
|
|
74
|
+
* @since 1.0.0
|
|
75
|
+
* @param {Number} phoneNumber - US phone number (WITHOUT +1) to send verification code to
|
|
76
|
+
*/
|
|
77
|
+
loginViaSMS = async (phoneNumber) => {
|
|
78
|
+
try {
|
|
79
|
+
const res = await fetch(`${this.apiRoot}/v1/login_register`, {
|
|
80
|
+
method: "POST",
|
|
81
|
+
headers: this.defaultHeaders,
|
|
82
|
+
body: JSON.stringify({
|
|
83
|
+
phone_number: `+1${phoneNumber}`,
|
|
84
|
+
version: 3,
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
const json = await res.json();
|
|
88
|
+
return json;
|
|
89
|
+
} catch (err) {
|
|
90
|
+
console.error(err);
|
|
91
|
+
throw new SidechatAPIError("Failed to request SMS verification.");
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Verify the code sent via SMS with loginViaSMS(). If this function succeeds, the user will be authenticated for future requests.
|
|
97
|
+
* @method
|
|
98
|
+
* @since 1.0.0
|
|
99
|
+
* @param {Number} phoneNumber - US phone number (WITHOUT +1) that verification code was sent to
|
|
100
|
+
* @param {String} code - the verification code
|
|
101
|
+
*/
|
|
102
|
+
verifySMSCode = async (phoneNumber, code) => {
|
|
103
|
+
try {
|
|
104
|
+
const res = await fetch(`${this.apiRoot}/v1/verify_phone_number`, {
|
|
105
|
+
method: "POST",
|
|
106
|
+
headers: this.defaultHeaders,
|
|
107
|
+
body: JSON.stringify({
|
|
108
|
+
phone_number: `+1${phoneNumber}`,
|
|
109
|
+
code: code.toUpperCase(),
|
|
110
|
+
}),
|
|
111
|
+
});
|
|
112
|
+
const json = await res.json();
|
|
113
|
+
if (json?.logged_in_user?.token) {
|
|
114
|
+
this.userToken = json.logged_in_user.token;
|
|
115
|
+
}
|
|
116
|
+
return json;
|
|
117
|
+
} catch (err) {
|
|
118
|
+
console.error(err);
|
|
119
|
+
throw new SidechatAPIError("Failed verify this code.");
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Set the user's age. If this function succeeds, the user will be authenticated for future requests.
|
|
125
|
+
* @method
|
|
126
|
+
* @since 1.0.0
|
|
127
|
+
* @param {Number} age - user's age in years
|
|
128
|
+
* @param {String} registrationID - the registration ID generated by verifySMSCode()
|
|
129
|
+
*/
|
|
130
|
+
setAge = async (age, registrationID) => {
|
|
131
|
+
if (age < 13) {
|
|
132
|
+
throw new SidechatAPIError("You're too young to use Offsides.");
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const res = await fetch(`${this.apiRoot}/v1/complete_registration`, {
|
|
136
|
+
method: "POST",
|
|
137
|
+
headers: this.defaultHeaders,
|
|
138
|
+
body: JSON.stringify({
|
|
139
|
+
age: Number(age),
|
|
140
|
+
registration_id: registrationID,
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
143
|
+
const json = await res.json();
|
|
144
|
+
if (json.token) {
|
|
145
|
+
this.userToken = json.token;
|
|
146
|
+
}
|
|
147
|
+
return json;
|
|
148
|
+
} catch (err) {
|
|
149
|
+
console.error(err);
|
|
150
|
+
throw new SidechatAPIError("Failed verify this code.");
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Initiate the email setup process. Should be followed up with checkEmailVerification().
|
|
156
|
+
* @method
|
|
157
|
+
* @since 1.0.0
|
|
158
|
+
* @param {String} email - school email address to send verification code to
|
|
159
|
+
* @tutorial Email Registration
|
|
160
|
+
*/
|
|
161
|
+
registerEmail = async (email) => {
|
|
162
|
+
if (!this.userToken) {
|
|
163
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
const res = await fetch(`${this.apiRoot}/v2/users/register_email`, {
|
|
167
|
+
method: "POST",
|
|
168
|
+
headers: {
|
|
169
|
+
...this.defaultHeaders,
|
|
170
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
171
|
+
},
|
|
172
|
+
body: JSON.stringify({
|
|
173
|
+
email: email,
|
|
174
|
+
}),
|
|
175
|
+
});
|
|
176
|
+
const json = await res.json();
|
|
177
|
+
if (json.message) {
|
|
178
|
+
throw new SidechatAPIError(json.message);
|
|
179
|
+
}
|
|
180
|
+
return json;
|
|
181
|
+
} catch (err) {
|
|
182
|
+
console.error(error);
|
|
183
|
+
throw new SidechatAPIError("Failed to request email verification.");
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Check is the user's email is verified.
|
|
189
|
+
* @method
|
|
190
|
+
* @since 1.0.0
|
|
191
|
+
*/
|
|
192
|
+
checkEmailVerification = async () => {
|
|
193
|
+
if (!this.userToken) {
|
|
194
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
const res = await fetch(`${this.apiRoot}/v1/users/check_email_verified`, {
|
|
198
|
+
method: "GET",
|
|
199
|
+
headers: {
|
|
200
|
+
...this.defaultHeaders,
|
|
201
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
const json = await res.json();
|
|
205
|
+
if (json.verified_email_updates_response) {
|
|
206
|
+
return json.verified_email_updates_response;
|
|
207
|
+
} else {
|
|
208
|
+
throw new SidechatAPIError(json?.message || "Email is not verified.");
|
|
209
|
+
}
|
|
210
|
+
} catch (err) {
|
|
211
|
+
console.error(error);
|
|
212
|
+
throw new SidechatAPIError("Email is not verified.");
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Set the device ID of the current user
|
|
218
|
+
* @method
|
|
219
|
+
* @since 1.0.0
|
|
220
|
+
* @param {String} deviceId - the device ID to set
|
|
221
|
+
*/
|
|
222
|
+
setDeviceID = async (deviceID) => {
|
|
223
|
+
if (!this.userToken) {
|
|
224
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
const res = await fetch(`${this.apiRoot}/v1/register_device_token`, {
|
|
228
|
+
method: "POST",
|
|
229
|
+
headers: {
|
|
230
|
+
...this.defaultHeaders,
|
|
231
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
232
|
+
},
|
|
233
|
+
body: JSON.stringify({
|
|
234
|
+
build_type: "release",
|
|
235
|
+
bundle_id: "com.flowerave.sidechat",
|
|
236
|
+
device_token: deviceID,
|
|
237
|
+
}),
|
|
238
|
+
});
|
|
239
|
+
const json = await res.json();
|
|
240
|
+
await AsyncStorage.setItem("deviceID", deviceID);
|
|
241
|
+
return json;
|
|
242
|
+
} catch (err) {
|
|
243
|
+
console.error(err);
|
|
244
|
+
throw new SidechatAPIError("Failed verify this code.");
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Get updated status for user and group
|
|
250
|
+
* @method
|
|
251
|
+
* @since 1.0.0
|
|
252
|
+
* @deprecated since 2.1.0, will be removed by 3.0.0. Please use `getUpdates` instead!
|
|
253
|
+
* @param {String} [groupID] - ID of a specific group to retrieve info from. Falls back to user's primary group.
|
|
254
|
+
*/
|
|
255
|
+
getUserAndGroup = async (groupID = "") => {
|
|
256
|
+
const json = await this.getUpdates(groupID);
|
|
257
|
+
return json;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Get updated status for user and group
|
|
262
|
+
* @method
|
|
263
|
+
* @since 2.1.0
|
|
264
|
+
* @param {String} [groupID] - ID of a specific group to retrieve info from. Falls back to user's primary group.
|
|
265
|
+
*/
|
|
266
|
+
getUpdates = async (groupID = "") => {
|
|
267
|
+
if (!this.userToken) {
|
|
268
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
269
|
+
}
|
|
270
|
+
try {
|
|
271
|
+
const res = await fetch(
|
|
272
|
+
`${this.apiRoot}/v1/updates?group_id=${groupID}`,
|
|
273
|
+
{
|
|
274
|
+
method: "GET",
|
|
275
|
+
headers: {
|
|
276
|
+
...this.defaultHeaders,
|
|
277
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
278
|
+
},
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
const json = await res.json();
|
|
282
|
+
return json;
|
|
283
|
+
} catch (err) {
|
|
284
|
+
console.error(err);
|
|
285
|
+
throw new SidechatAPIError(`Failed to get posts from group.`);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Fetches posts from the specified category in a group
|
|
291
|
+
* @method
|
|
292
|
+
* @since 1.0.0
|
|
293
|
+
* @param {String} groupID - group ID
|
|
294
|
+
* @param {"hot"|"recent"|"top"} category - category to filter posts
|
|
295
|
+
* @param {SidechatCursorString} [cursor] - cursor string
|
|
296
|
+
* @returns {SidechatPostsAndCursor} List of posts and cursor
|
|
297
|
+
*/
|
|
298
|
+
getGroupPosts = async (groupID, category = "hot", cursor) => {
|
|
299
|
+
if (!this.userToken) {
|
|
300
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
301
|
+
}
|
|
302
|
+
try {
|
|
303
|
+
const res = await fetch(
|
|
304
|
+
`${this.apiRoot}/v1/posts?group_id=${groupID}&type=${category}${
|
|
305
|
+
cursor ? "&cursor=" + cursor : ""
|
|
306
|
+
}`,
|
|
307
|
+
{
|
|
308
|
+
method: "GET",
|
|
309
|
+
headers: {
|
|
310
|
+
...this.defaultHeaders,
|
|
311
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
312
|
+
},
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
const json = await res.json();
|
|
316
|
+
return json;
|
|
317
|
+
} catch (err) {
|
|
318
|
+
console.error(err);
|
|
319
|
+
throw new SidechatAPIError(`Failed to get posts from group.`);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Upvote or downvote, or unvote a post
|
|
325
|
+
* @method
|
|
326
|
+
* @since 2.0.0-alpha.0
|
|
327
|
+
* @param {String} postID - post ID to vote on
|
|
328
|
+
* @param {SidechatVoteString} action - whether to upvote, downvote, or reset vote
|
|
329
|
+
*/
|
|
330
|
+
setVote = async (postID, action) => {
|
|
331
|
+
if (!this.userToken) {
|
|
332
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
333
|
+
}
|
|
334
|
+
try {
|
|
335
|
+
const res = await fetch(`${this.apiRoot}/v1/posts/set_vote`, {
|
|
336
|
+
method: "POST",
|
|
337
|
+
headers: {
|
|
338
|
+
...this.defaultHeaders,
|
|
339
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
340
|
+
},
|
|
341
|
+
body: JSON.stringify({
|
|
342
|
+
post_id: postID,
|
|
343
|
+
vote_status: action,
|
|
344
|
+
}),
|
|
345
|
+
});
|
|
346
|
+
const json = await res.json();
|
|
347
|
+
return json;
|
|
348
|
+
} catch (err) {
|
|
349
|
+
console.error(err);
|
|
350
|
+
throw new SidechatAPIError(`Failed to change the vote on post.`);
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Fetches a single post with just its ID
|
|
356
|
+
* @method
|
|
357
|
+
* @since 2.3.0
|
|
358
|
+
* @param {String} postID - ID of post to fetch
|
|
359
|
+
* @param {Boolean} includeDeleted - undocumented
|
|
360
|
+
* @returns {SidechatPostOrComment} post object
|
|
361
|
+
*/
|
|
362
|
+
getPost = async (postID, includeDeleted = false) => {
|
|
363
|
+
if (!this.userToken) {
|
|
364
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
365
|
+
}
|
|
366
|
+
try {
|
|
367
|
+
const res = await fetch(
|
|
368
|
+
`${this.apiRoot}/v1/posts/get?include_deleted=${includeDeleted}&post_id=${postID}`,
|
|
369
|
+
{
|
|
370
|
+
method: "GET",
|
|
371
|
+
headers: {
|
|
372
|
+
...this.defaultHeaders,
|
|
373
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
374
|
+
},
|
|
375
|
+
}
|
|
376
|
+
);
|
|
377
|
+
const json = await res.json();
|
|
378
|
+
return json.post;
|
|
379
|
+
} catch (err) {
|
|
380
|
+
console.error(err);
|
|
381
|
+
throw new SidechatAPIError(`Failed to get post from ID.`);
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Fetches the posts or comments that the user has created
|
|
387
|
+
* @method
|
|
388
|
+
* @since 2.3.5
|
|
389
|
+
* @param {"posts"|"comments"} contentType - type of user content to fetch
|
|
390
|
+
* @returns {SidechatPostOrComment[]} post object
|
|
391
|
+
*/
|
|
392
|
+
getUserContent = async (contentType) => {
|
|
393
|
+
if (!this.userToken) {
|
|
394
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
395
|
+
}
|
|
396
|
+
if (contentType == "posts") {
|
|
397
|
+
contentType = "my_posts";
|
|
398
|
+
} else if (contentType == "comments") {
|
|
399
|
+
contentType = "my_comments";
|
|
400
|
+
}
|
|
401
|
+
try {
|
|
402
|
+
const res = await fetch(`${this.apiRoot}/v1/posts&type=${contentType}`, {
|
|
403
|
+
method: "GET",
|
|
404
|
+
headers: {
|
|
405
|
+
...this.defaultHeaders,
|
|
406
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
const json = await res.json();
|
|
410
|
+
return json.posts;
|
|
411
|
+
} catch (err) {
|
|
412
|
+
console.error(err);
|
|
413
|
+
throw new SidechatAPIError(`Failed to get content from user.`);
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Get all the commments on a post
|
|
419
|
+
* @method
|
|
420
|
+
* @since 2.0.0-alpha.0
|
|
421
|
+
* @param {String} postID - post ID to get comments for
|
|
422
|
+
* @returns {SidechatPostOrComment[]} list of comments
|
|
423
|
+
*/
|
|
424
|
+
getPostComments = async (postID) => {
|
|
425
|
+
if (!this.userToken) {
|
|
426
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
427
|
+
}
|
|
428
|
+
try {
|
|
429
|
+
const res = await fetch(
|
|
430
|
+
`${this.apiRoot}/v1/posts/comments/?post_id=${postID}`,
|
|
431
|
+
{
|
|
432
|
+
method: "GET",
|
|
433
|
+
headers: {
|
|
434
|
+
...this.defaultHeaders,
|
|
435
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
436
|
+
},
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
const json = await res.json();
|
|
440
|
+
// Function to preprocess the comments and organize them into a nested structure
|
|
441
|
+
function preprocessComments(apiComments) {
|
|
442
|
+
// Map to store comments by their IDs for efficient lookup
|
|
443
|
+
const commentMap = new Map();
|
|
444
|
+
// List to store top-level comments
|
|
445
|
+
const topLevelComments = [];
|
|
446
|
+
|
|
447
|
+
// Iterate through the API comments
|
|
448
|
+
apiComments.forEach((comment) => {
|
|
449
|
+
// Store the comment in the map with its ID as the key
|
|
450
|
+
commentMap.set(comment.id, comment);
|
|
451
|
+
// Get the parent comment using the reply_post_id
|
|
452
|
+
const parentComment = commentMap.get(comment.reply_post_id);
|
|
453
|
+
// Check if the comment is a top-level comment
|
|
454
|
+
if (
|
|
455
|
+
!parentComment ||
|
|
456
|
+
comment.reply_post_id === comment.parent_post_id
|
|
457
|
+
) {
|
|
458
|
+
// If it's a top-level comment, push it to the topLevelComments array
|
|
459
|
+
topLevelComments.push(comment);
|
|
460
|
+
} else {
|
|
461
|
+
// If it's a reply, add it to the parent comment's replies array
|
|
462
|
+
if (!parentComment.replies) parentComment.replies = [];
|
|
463
|
+
parentComment.replies.push(comment);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
// Flatten the nested structure and return a single list of comments
|
|
468
|
+
return flattenComments(topLevelComments);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Function to flatten nested comments into a single list
|
|
472
|
+
function flattenComments(comments) {
|
|
473
|
+
// Use reduce to flatten the nested comments array into a single list
|
|
474
|
+
return comments.reduce((flatComments, comment) => {
|
|
475
|
+
// Push the current comment to the flatComments array
|
|
476
|
+
flatComments.push(comment);
|
|
477
|
+
// If the current comment has replies, recursively flatten them and push to the flatComments array
|
|
478
|
+
if (comment.replies)
|
|
479
|
+
flatComments.push(...flattenComments(comment.replies));
|
|
480
|
+
// Return the flatComments array
|
|
481
|
+
return flatComments;
|
|
482
|
+
}, []);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
const sortedComments = preprocessComments(json.posts);
|
|
486
|
+
return sortedComments;
|
|
487
|
+
} catch (err) {
|
|
488
|
+
console.error(err);
|
|
489
|
+
throw new SidechatAPIError(`Failed to get comments on post.`);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Gets groups to be displayed on the "Explore Groups" page
|
|
495
|
+
* @method
|
|
496
|
+
* @since 2.0.0-alpha.0
|
|
497
|
+
* @param {Boolean} onePage - whether or not results should be returned as a single page
|
|
498
|
+
* @returns {SidechatGroup[]}
|
|
499
|
+
*/
|
|
500
|
+
getAvailableGroups = async (onePage = true) => {
|
|
501
|
+
if (!this.userToken) {
|
|
502
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
503
|
+
}
|
|
504
|
+
try {
|
|
505
|
+
const res = await fetch(`${this.apiRoot}/v1/groups/explore`, {
|
|
506
|
+
method: "GET",
|
|
507
|
+
headers: {
|
|
508
|
+
...this.defaultHeaders,
|
|
509
|
+
"App-Version": onePage ? "0" : this.defaultHeaders["App-Version"],
|
|
510
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
511
|
+
},
|
|
512
|
+
});
|
|
513
|
+
const json = await res.json();
|
|
514
|
+
return await json.groups;
|
|
515
|
+
} catch (err) {
|
|
516
|
+
console.error(err);
|
|
517
|
+
throw new SidechatAPIError(`Failed to get groups from explore.`);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Retrieves the entire accessible asset library. Be warned that as of the time of this documentation, it's a 1.5MB JSON download and this request is very expensive.
|
|
523
|
+
* @method
|
|
524
|
+
* @since 2.0.6
|
|
525
|
+
* @returns {SidechatLibraryAsset[]}
|
|
526
|
+
*/
|
|
527
|
+
getAssetLibrary = async () => {
|
|
528
|
+
if (!this.userToken) {
|
|
529
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
530
|
+
}
|
|
531
|
+
try {
|
|
532
|
+
const res = await fetch(`${this.apiRoot}/v1/assets/library`, {
|
|
533
|
+
method: "GET",
|
|
534
|
+
headers: {
|
|
535
|
+
...this.defaultHeaders,
|
|
536
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
537
|
+
},
|
|
538
|
+
});
|
|
539
|
+
const json = await res.json();
|
|
540
|
+
return await json.items;
|
|
541
|
+
} catch (err) {
|
|
542
|
+
console.error(err);
|
|
543
|
+
throw new SidechatAPIError(`Failed to get asset library.`);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Gets the current authenticated user and a list of the groups of which they are members.
|
|
549
|
+
* @method
|
|
550
|
+
* @since 2.1.0
|
|
551
|
+
* @returns {SidechatCurrentUser}
|
|
552
|
+
*/
|
|
553
|
+
getCurrentUser = async () => {
|
|
554
|
+
if (!this.userToken) {
|
|
555
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
556
|
+
}
|
|
557
|
+
try {
|
|
558
|
+
const res = await fetch(`${this.apiRoot}/v1/users/me`, {
|
|
559
|
+
method: "GET",
|
|
560
|
+
headers: {
|
|
561
|
+
...this.defaultHeaders,
|
|
562
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
563
|
+
},
|
|
564
|
+
});
|
|
565
|
+
const json = await res.json();
|
|
566
|
+
return await json;
|
|
567
|
+
} catch (err) {
|
|
568
|
+
console.error(err);
|
|
569
|
+
throw new SidechatAPIError(`Failed to get asset library.`);
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Gets the metadata of a group from its ID
|
|
575
|
+
* @method
|
|
576
|
+
* @since 2.1.0
|
|
577
|
+
* @param {String} [groupID] - alphanumeric ID of a group to get. Falls back to user's primary group.
|
|
578
|
+
* @returns {SidechatGroup}
|
|
579
|
+
*/
|
|
580
|
+
getGroupMetadata = async (groupID = "") => {
|
|
581
|
+
if (!this.userToken) {
|
|
582
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
583
|
+
}
|
|
584
|
+
try {
|
|
585
|
+
const res = await fetch(`${this.apiRoot}/v1/groups/${groupID}`, {
|
|
586
|
+
method: "GET",
|
|
587
|
+
headers: {
|
|
588
|
+
...this.defaultHeaders,
|
|
589
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
590
|
+
},
|
|
591
|
+
});
|
|
592
|
+
const json = await res.json();
|
|
593
|
+
return await json.group;
|
|
594
|
+
} catch (err) {
|
|
595
|
+
console.error(err);
|
|
596
|
+
throw new SidechatAPIError(`Failed to get group metadata.`);
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Joins or leaves a group
|
|
602
|
+
* @method
|
|
603
|
+
* @param {String} groupID - alphanumeric ID of group to join or leave
|
|
604
|
+
* @param {Boolean} isMember - whether or not the user should be a member of the group
|
|
605
|
+
* @since 2.3.8
|
|
606
|
+
*/
|
|
607
|
+
setGroupMembership = async (groupID, isMember) => {
|
|
608
|
+
if (!this.userToken) {
|
|
609
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
610
|
+
}
|
|
611
|
+
try {
|
|
612
|
+
const res = await fetch(
|
|
613
|
+
`${this.apiRoot}/v1/groups/${isMember ? "join" : "leave"}`,
|
|
614
|
+
{
|
|
615
|
+
method: "POST",
|
|
616
|
+
headers: {
|
|
617
|
+
...this.defaultHeaders,
|
|
618
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
619
|
+
},
|
|
620
|
+
body: JSON.stringify({
|
|
621
|
+
group_id: groupID,
|
|
622
|
+
}),
|
|
623
|
+
}
|
|
624
|
+
);
|
|
625
|
+
const json = await res.json();
|
|
626
|
+
return await json;
|
|
627
|
+
} catch (err) {
|
|
628
|
+
console.error(err);
|
|
629
|
+
throw new SidechatAPIError(`Failed to modify group membership.`);
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Creates a comment on a post
|
|
635
|
+
* @method
|
|
636
|
+
* @since 2.2.0
|
|
637
|
+
* @param {String} parentPostID - alphanumeric ID of post on which this comment is made
|
|
638
|
+
* @param {String} text - text content of comment
|
|
639
|
+
* @param {String} groupID - alphanumeric ID of group in which the parent post resides
|
|
640
|
+
* @param {String} [replyCommentID] - alphanumeric ID of comment to reply to. Falls back to parentPostID
|
|
641
|
+
* @param {SidechatSimpleAsset[]} [assetList] - list of assets to attach
|
|
642
|
+
* @param {Boolean} [disableDMs] - prevent direct messages being sent to comment's author
|
|
643
|
+
* @param {Boolean} [anonymous] - whether or not to hide user's name and icon on comment
|
|
644
|
+
* @returns {SidechatPostOrComment} created comment
|
|
645
|
+
*/
|
|
646
|
+
createComment = async (
|
|
647
|
+
parentPostID,
|
|
648
|
+
text,
|
|
649
|
+
groupID,
|
|
650
|
+
replyCommentID = parentPostID,
|
|
651
|
+
assetList = [],
|
|
652
|
+
disableDMs = false,
|
|
653
|
+
anonymous = false
|
|
654
|
+
) => {
|
|
655
|
+
if (!this.userToken) {
|
|
656
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
657
|
+
}
|
|
658
|
+
try {
|
|
659
|
+
const res = await fetch(`${this.apiRoot}/v1/posts`, {
|
|
660
|
+
method: "POST",
|
|
661
|
+
headers: {
|
|
662
|
+
...this.defaultHeaders,
|
|
663
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
664
|
+
},
|
|
665
|
+
body: JSON.stringify({
|
|
666
|
+
type: "comment",
|
|
667
|
+
assets: assetList,
|
|
668
|
+
group_ids: [groupID],
|
|
669
|
+
text: text,
|
|
670
|
+
reply_post_id: replyCommentID,
|
|
671
|
+
parent_post_id: parentPostID,
|
|
672
|
+
dms_disabled: disableDMs,
|
|
673
|
+
using_identity: !anonymous,
|
|
674
|
+
}),
|
|
675
|
+
});
|
|
676
|
+
const json = await res.json();
|
|
677
|
+
return await json.comment;
|
|
678
|
+
} catch (err) {
|
|
679
|
+
console.error(err);
|
|
680
|
+
throw new SidechatAPIError(`Failed to post comment.`);
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Creates a new post in the specified group
|
|
686
|
+
* @method
|
|
687
|
+
* @since 2.2.0
|
|
688
|
+
* @param {String} text - text content of comment
|
|
689
|
+
* @param {String} groupID - alphanumeric ID of group in which the parent post resides
|
|
690
|
+
* @param {SidechatSimpleAsset[]} [assetList] - list of assets to attach.
|
|
691
|
+
* @param {Boolean} [disableDMs] - prevent direct messages from being sent to post's author
|
|
692
|
+
* @param {Boolean} [disableComments] - whether or not comments should be disabled on post
|
|
693
|
+
* @param {Boolean} [anonymous] - whether or not to hide user's name and icon on post
|
|
694
|
+
* @returns {SidechatPostOrComment} the created post
|
|
695
|
+
*/
|
|
696
|
+
createPost = async (
|
|
697
|
+
text,
|
|
698
|
+
groupID,
|
|
699
|
+
assetList = [],
|
|
700
|
+
disableDMs = false,
|
|
701
|
+
disableComments = false,
|
|
702
|
+
anonymous = false
|
|
703
|
+
) => {
|
|
704
|
+
if (!this.userToken) {
|
|
705
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
706
|
+
}
|
|
707
|
+
try {
|
|
708
|
+
const res = await fetch(`${this.apiRoot}/v1/posts`, {
|
|
709
|
+
method: "POST",
|
|
710
|
+
headers: {
|
|
711
|
+
...this.defaultHeaders,
|
|
712
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
713
|
+
},
|
|
714
|
+
body: JSON.stringify({
|
|
715
|
+
type: "post",
|
|
716
|
+
assets: assetList,
|
|
717
|
+
group_ids: [groupID],
|
|
718
|
+
text: text,
|
|
719
|
+
attachments: [],
|
|
720
|
+
dms_disabled: disableDMs,
|
|
721
|
+
comments_disabled: disableComments,
|
|
722
|
+
using_identity: !anonymous,
|
|
723
|
+
}),
|
|
724
|
+
});
|
|
725
|
+
const json = await res.json();
|
|
726
|
+
return await json.posts[0];
|
|
727
|
+
} catch (err) {
|
|
728
|
+
console.error(err);
|
|
729
|
+
throw new SidechatAPIError(`Failed to make post.`);
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Deletes a post or comment that the user created
|
|
735
|
+
* @method
|
|
736
|
+
* @since 2.2.0
|
|
737
|
+
* @param {String} postOrCommentID - alphanumeric ID of post to delete
|
|
738
|
+
*/
|
|
739
|
+
deletePostOrComment = async (postOrCommentID) => {
|
|
740
|
+
if (!this.userToken) {
|
|
741
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
742
|
+
}
|
|
743
|
+
try {
|
|
744
|
+
const res = await fetch(`${this.apiRoot}/v1/posts/delete`, {
|
|
745
|
+
method: "POST",
|
|
746
|
+
headers: {
|
|
747
|
+
...this.defaultHeaders,
|
|
748
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
749
|
+
},
|
|
750
|
+
body: JSON.stringify({
|
|
751
|
+
post_id: postOrCommentID,
|
|
752
|
+
}),
|
|
753
|
+
});
|
|
754
|
+
const json = await res.json();
|
|
755
|
+
return await json;
|
|
756
|
+
} catch (err) {
|
|
757
|
+
console.error(err);
|
|
758
|
+
throw new SidechatAPIError(`Failed to delete post.`);
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Sets the conversation icon of the current user
|
|
764
|
+
* @method
|
|
765
|
+
* @since 2.2.1
|
|
766
|
+
* @param {String} userID - alphanumeric ID of user
|
|
767
|
+
* @param {String} emoji - emoji to set as icon
|
|
768
|
+
* @param {String} primaryColor - hex string (including #) of primary color
|
|
769
|
+
* @param {String} secondaryColor - hex string (including #) of secondary color
|
|
770
|
+
*/
|
|
771
|
+
setUserIcon = async (userID, emoji, primaryColor, secondaryColor) => {
|
|
772
|
+
if (!this.userToken) {
|
|
773
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
774
|
+
}
|
|
775
|
+
try {
|
|
776
|
+
const res = await fetch(`${this.apiRoot}/v1/users/${userID}`, {
|
|
777
|
+
method: "PATCH",
|
|
778
|
+
headers: {
|
|
779
|
+
...this.defaultHeaders,
|
|
780
|
+
"App-Version": "0",
|
|
781
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
782
|
+
},
|
|
783
|
+
body: JSON.stringify({
|
|
784
|
+
conversation_icon: {
|
|
785
|
+
emoji: emoji,
|
|
786
|
+
secondary_color: secondaryColor,
|
|
787
|
+
is_migrated: true,
|
|
788
|
+
color: primaryColor,
|
|
789
|
+
},
|
|
790
|
+
}),
|
|
791
|
+
});
|
|
792
|
+
const json = await res.json();
|
|
793
|
+
return await json;
|
|
794
|
+
} catch (err) {
|
|
795
|
+
console.error(err);
|
|
796
|
+
throw new SidechatAPIError(`Failed to set icon.`);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Checks if user can set their username to a string
|
|
802
|
+
* @method
|
|
803
|
+
* @since 2.3.6
|
|
804
|
+
* @param {String} username - string to check
|
|
805
|
+
* @returns {Boolean} whether or not username is valid and unused
|
|
806
|
+
*/
|
|
807
|
+
checkUsername = async (username) => {
|
|
808
|
+
if (!this.userToken) {
|
|
809
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
810
|
+
}
|
|
811
|
+
try {
|
|
812
|
+
const res = await fetch(
|
|
813
|
+
`${this.apiRoot}/v1/users/username?username=${username}`,
|
|
814
|
+
{
|
|
815
|
+
method: "GET",
|
|
816
|
+
headers: {
|
|
817
|
+
...this.defaultHeaders,
|
|
818
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
819
|
+
},
|
|
820
|
+
}
|
|
821
|
+
);
|
|
822
|
+
if (res?.status == 200 || res?.status == 204) {
|
|
823
|
+
return true;
|
|
824
|
+
} else {
|
|
825
|
+
return false;
|
|
826
|
+
}
|
|
827
|
+
} catch (err) {
|
|
828
|
+
console.error(err);
|
|
829
|
+
throw new SidechatAPIError(`Failed to check username.`);
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Changes the username of the current user
|
|
835
|
+
* @method
|
|
836
|
+
* @since 2.3.6
|
|
837
|
+
* @param {String} userID - alphanumeric ID of user
|
|
838
|
+
* @param {String} username - new username to set
|
|
839
|
+
*/
|
|
840
|
+
setUsername = async (userID, username) => {
|
|
841
|
+
if (!this.userToken) {
|
|
842
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
843
|
+
}
|
|
844
|
+
try {
|
|
845
|
+
const res = await fetch(`${this.apiRoot}/v1/users/${userID}`, {
|
|
846
|
+
method: "PATCH",
|
|
847
|
+
headers: {
|
|
848
|
+
...this.defaultHeaders,
|
|
849
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
850
|
+
},
|
|
851
|
+
body: JSON.stringify({
|
|
852
|
+
username: username,
|
|
853
|
+
}),
|
|
854
|
+
});
|
|
855
|
+
const json = await res.json();
|
|
856
|
+
return await json.user;
|
|
857
|
+
} catch (err) {
|
|
858
|
+
console.error(err);
|
|
859
|
+
throw new SidechatAPIError(`Failed to set icon.`);
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Marks an activity item as read
|
|
865
|
+
* @method
|
|
866
|
+
* @since 2.3.2
|
|
867
|
+
* @param {String} activityID - alphanumeric ID of activity object
|
|
868
|
+
*/
|
|
869
|
+
readActivity = async (activityID) => {
|
|
870
|
+
if (!this.userToken) {
|
|
871
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
872
|
+
}
|
|
873
|
+
try {
|
|
874
|
+
const res = await fetch(`${this.apiRoot}/v1/activity/seen`, {
|
|
875
|
+
method: "POST",
|
|
876
|
+
headers: {
|
|
877
|
+
...this.defaultHeaders,
|
|
878
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
879
|
+
},
|
|
880
|
+
body: JSON.stringify({
|
|
881
|
+
ids: [activityID],
|
|
882
|
+
}),
|
|
883
|
+
});
|
|
884
|
+
const json = await res.json();
|
|
885
|
+
return await json;
|
|
886
|
+
} catch (err) {
|
|
887
|
+
console.error(err);
|
|
888
|
+
throw new SidechatAPIError(`Failed to mark activity as read.`);
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Retrieves joinable group chats
|
|
894
|
+
* @method
|
|
895
|
+
* @since 2.3.5
|
|
896
|
+
*/
|
|
897
|
+
getGroupChats = async () => {
|
|
898
|
+
if (!this.userToken) {
|
|
899
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
900
|
+
}
|
|
901
|
+
try {
|
|
902
|
+
const res = await fetch(`${this.apiRoot}/v1/chats/explore`, {
|
|
903
|
+
method: "GET",
|
|
904
|
+
headers: {
|
|
905
|
+
...this.defaultHeaders,
|
|
906
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
907
|
+
},
|
|
908
|
+
});
|
|
909
|
+
const json = await res.json();
|
|
910
|
+
return await json.chats;
|
|
911
|
+
} catch (err) {
|
|
912
|
+
console.error(err);
|
|
913
|
+
throw new SidechatAPIError(`Failed to get groupchats.`);
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Joins a group chat
|
|
919
|
+
* @method
|
|
920
|
+
* @since 2.3.5
|
|
921
|
+
*/
|
|
922
|
+
joinGroupChat = async (
|
|
923
|
+
groupChatID,
|
|
924
|
+
displayName,
|
|
925
|
+
emoji,
|
|
926
|
+
primaryColor,
|
|
927
|
+
secondaryColor
|
|
928
|
+
) => {
|
|
929
|
+
if (!this.userToken) {
|
|
930
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
931
|
+
}
|
|
932
|
+
try {
|
|
933
|
+
const res = await fetch(`${this.apiRoot}/v1/chats/groups/join`, {
|
|
934
|
+
method: "POST",
|
|
935
|
+
headers: {
|
|
936
|
+
...this.defaultHeaders,
|
|
937
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
938
|
+
},
|
|
939
|
+
body: JSON.stringify({
|
|
940
|
+
chat_id: groupChatID,
|
|
941
|
+
identity: {
|
|
942
|
+
display_name: displayName,
|
|
943
|
+
emoji: emoji,
|
|
944
|
+
secondary_color: secondaryColor,
|
|
945
|
+
color: primaryColor,
|
|
946
|
+
},
|
|
947
|
+
}),
|
|
948
|
+
});
|
|
949
|
+
const json = await res.json();
|
|
950
|
+
return await json;
|
|
951
|
+
} catch (err) {
|
|
952
|
+
console.error(err);
|
|
953
|
+
throw new SidechatAPIError(`Failed to join groupchat.`);
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Gets a list of the user's direct messages
|
|
959
|
+
* @method
|
|
960
|
+
* @returns {SidechatDirectThread[]}
|
|
961
|
+
* @since 2.4.4
|
|
962
|
+
*/
|
|
963
|
+
getDMs = async () => {
|
|
964
|
+
if (!this.userToken) {
|
|
965
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
966
|
+
}
|
|
967
|
+
try {
|
|
968
|
+
const res = await fetch(`${this.apiRoot}/v1/chats`, {
|
|
969
|
+
method: "GET",
|
|
970
|
+
headers: {
|
|
971
|
+
...this.defaultHeaders,
|
|
972
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
973
|
+
},
|
|
974
|
+
});
|
|
975
|
+
const json = await res.json();
|
|
976
|
+
const list = await json.chats;
|
|
977
|
+
let r = [];
|
|
978
|
+
list.forEach((o) => {
|
|
979
|
+
r.push(o.chat);
|
|
980
|
+
});
|
|
981
|
+
return await r;
|
|
982
|
+
} catch (err) {
|
|
983
|
+
console.error(err);
|
|
984
|
+
throw new SidechatAPIError(`Failed to fetch DMs.`);
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Gets a single direct message thread
|
|
990
|
+
* @method
|
|
991
|
+
* @param {String} id - alphanumeric ID of the chat to fetch
|
|
992
|
+
* @returns {SidechatDirectThread}
|
|
993
|
+
* @since 2.4.4
|
|
994
|
+
*/
|
|
995
|
+
getDMThread = async (id) => {
|
|
996
|
+
if (!this.userToken) {
|
|
997
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
998
|
+
}
|
|
999
|
+
try {
|
|
1000
|
+
const res = await fetch(
|
|
1001
|
+
`${this.apiRoot}/v1/chats/messages?chat_id=${id}`,
|
|
1002
|
+
{
|
|
1003
|
+
method: "GET",
|
|
1004
|
+
headers: {
|
|
1005
|
+
...this.defaultHeaders,
|
|
1006
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
1007
|
+
},
|
|
1008
|
+
}
|
|
1009
|
+
);
|
|
1010
|
+
const json = await res.json();
|
|
1011
|
+
return await json.chat;
|
|
1012
|
+
} catch (err) {
|
|
1013
|
+
console.error(err);
|
|
1014
|
+
throw new SidechatAPIError(`Failed to fetch DM thread.`);
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Sends a message to an existing direct message thread - note that you must first use startDM() to start a thread.
|
|
1020
|
+
* @method
|
|
1021
|
+
* @param {String} chatID - alphanumeric ID of the chat to send to
|
|
1022
|
+
* @param {String} text - text content of message
|
|
1023
|
+
* @param {String} clientID - alphanumeric device ID
|
|
1024
|
+
* @param {SidechatAsset[]} - array of assets to send
|
|
1025
|
+
* @param {Boolean} anonymous - whether the DM should be sent anonymously
|
|
1026
|
+
* @since 2.4.4
|
|
1027
|
+
*/
|
|
1028
|
+
sendDM = async (chatID, text, clientID, assets = [], anonymous = false) => {
|
|
1029
|
+
if (!this.userToken) {
|
|
1030
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1031
|
+
}
|
|
1032
|
+
try {
|
|
1033
|
+
const res = await fetch(`${this.apiRoot}/v1/chats/send`, {
|
|
1034
|
+
method: "POST",
|
|
1035
|
+
headers: {
|
|
1036
|
+
...this.defaultHeaders,
|
|
1037
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
1038
|
+
},
|
|
1039
|
+
body: JSON.stringify({
|
|
1040
|
+
chat_id: chatID,
|
|
1041
|
+
text: text,
|
|
1042
|
+
client_id: clientID,
|
|
1043
|
+
anonymous: anonymous,
|
|
1044
|
+
assets: assets,
|
|
1045
|
+
}),
|
|
1046
|
+
});
|
|
1047
|
+
const json = await res.json();
|
|
1048
|
+
return await json;
|
|
1049
|
+
} catch (err) {
|
|
1050
|
+
console.error(err);
|
|
1051
|
+
throw new SidechatAPIError(`Failed to fetch DMs.`);
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Creates a new direct message thread
|
|
1057
|
+
* @method
|
|
1058
|
+
* @param {String} text - text content of message
|
|
1059
|
+
* @param {String} clientID - alphanumeric ID of devide
|
|
1060
|
+
* @param {String} postID - alphanumeric ID of post or comment
|
|
1061
|
+
* @param {Boolean} anonymous - whether the DM should be sent anonymously
|
|
1062
|
+
* @param {"feed"} postContext - context of post (mostly undocumented, defaults to "feed")
|
|
1063
|
+
* @since 2.4.4
|
|
1064
|
+
*/
|
|
1065
|
+
startDM = async (
|
|
1066
|
+
text,
|
|
1067
|
+
clientID,
|
|
1068
|
+
postID,
|
|
1069
|
+
anonymous = false,
|
|
1070
|
+
postContext = "feed"
|
|
1071
|
+
) => {
|
|
1072
|
+
if (!this.userToken) {
|
|
1073
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
1074
|
+
}
|
|
1075
|
+
try {
|
|
1076
|
+
const res = await fetch(`${this.apiRoot}/v1/chats/send`, {
|
|
1077
|
+
method: "POST",
|
|
1078
|
+
headers: {
|
|
1079
|
+
...this.defaultHeaders,
|
|
1080
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
1081
|
+
},
|
|
1082
|
+
body: JSON.stringify({
|
|
1083
|
+
text: text,
|
|
1084
|
+
client_id: clientID,
|
|
1085
|
+
post_id: postID,
|
|
1086
|
+
anonymous: anonymous,
|
|
1087
|
+
post_context: postContext,
|
|
1088
|
+
}),
|
|
1089
|
+
});
|
|
1090
|
+
const json = await res.json();
|
|
1091
|
+
return await json;
|
|
1092
|
+
} catch (err) {
|
|
1093
|
+
console.error(err);
|
|
1094
|
+
throw new SidechatAPIError(`Failed to fetch DMs.`);
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
export default SidechatAPIClient;
|
|
1100
|
+
</code></pre></article></section></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">Home</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://github.com/micahlt/offsides#README.md" target="_blank">Offsides (Sidechat for Android)</a></div></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-tutorials"><div>Tutorials</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="tutorial-Authentication.html">Authentication</a></div><div class="sidebar-section-children"><a href="tutorial-Email Registration.html">Email Registration</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="SidechatAPIClient.html">SidechatAPIClient</a></div><div class="sidebar-section-children"><a href="SidechatAPIError.html">SidechatAPIError</a></div><div class="sidebar-section-children"><a href="SidechatColorList.html">SidechatColorList</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#SidechatAssetMetadata">SidechatAssetMetadata</a></div><div class="sidebar-section-children"><a href="global.html#SidechatAuthToken">SidechatAuthToken</a></div><div class="sidebar-section-children"><a href="global.html#SidechatColor">SidechatColor</a></div><div class="sidebar-section-children"><a href="global.html#SidechatCurrentUser">SidechatCurrentUser</a></div><div class="sidebar-section-children"><a href="global.html#SidechatCursorString">SidechatCursorString</a></div><div class="sidebar-section-children"><a href="global.html#SidechatDirectMessage">SidechatDirectMessage</a></div><div class="sidebar-section-children"><a href="global.html#SidechatDirectThread">SidechatDirectThread</a></div><div class="sidebar-section-children"><a href="global.html#SidechatGroup">SidechatGroup</a></div><div class="sidebar-section-children"><a href="global.html#SidechatIdentity">SidechatIdentity</a></div><div class="sidebar-section-children"><a href="global.html#SidechatLibraryAsset">SidechatLibraryAsset</a></div><div class="sidebar-section-children"><a href="global.html#SidechatMembership">SidechatMembership</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPostOrComment">SidechatPostOrComment</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPostsAndCursor">SidechatPostsAndCursor</a></div><div class="sidebar-section-children"><a href="global.html#SidechatPrivateAssetURL">SidechatPrivateAssetURL</a></div><div class="sidebar-section-children"><a href="global.html#SidechatSimpleAsset">SidechatSimpleAsset</a></div><div class="sidebar-section-children"><a href="global.html#SidechatVoteString">SidechatVoteString</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#light-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>
|