deskcord 0.11.0 → 0.12.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/README.md CHANGED
@@ -1,3 +1,23 @@
1
1
  # Deskcord widget
2
2
 
3
3
  Minified build for production use
4
+
5
+ ## Identify logged-in users
6
+
7
+ ```js
8
+ window.deskcord.identify({
9
+ name: "Ada",
10
+ email: "ada@example.com",
11
+ avatarUrl: "https://example.com/ada.png", // optional, https only, shown in Discord
12
+ userId: "42", // optional, with userHash: same conversations on every device
13
+ userHash: "…", // HMAC-SHA256(identity secret, userId), computed on the site's server
14
+ });
15
+ window.deskcord.logout(); // on logout: forgets the user on this browser
16
+ ```
17
+
18
+ - Skips the "introduce yourself" form. Without `userId`/`userHash`, conversations stay tied to the browser.
19
+ - The secret comes from `/identity-verification enable` in Discord. It must never reach the browser.
20
+ - To identify before the first render, pass the same object as `window.deskcord.settings.user` in the embed snippet. `identify()` and `logout()` exist once the script has loaded.
21
+ - Server-rendered sites should print `user: null` when nobody is logged in: it ends a verified session left over from a logout that didn't call `logout()`.
22
+ - Call it on every page load: verified sessions last 24h, and one without a token is dropped.
23
+ - Conversations started anonymously in the browser are carried over to the user. Calling `identify()` with another user (or `logout()`) wipes the previous user's conversations from the browser.