@chatsystem/client 1.2.2 → 1.2.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/README.md CHANGED
@@ -82,6 +82,32 @@ available for development.
82
82
  `data-displayMode` is optional and defaults to `launcher`. Set
83
83
  `data-displayMode="chatbox"` when embedding the chat directly in the page.
84
84
 
85
- The current bundled-script integration supports anonymous widgets. Delegated
86
- identity requires the React API until a programmatic script bootstrap is
87
- released; functions must not be serialized into `data-*` attributes.
85
+ The declarative form remains the simplest anonymous integration. For Identity
86
+ Delegation, load the same bundle without `data-appToken`, then use its
87
+ programmatic browser API so the provider functions remain JavaScript values:
88
+
89
+ ```html
90
+ <script src="https://chatsystem.s3.eu-west-3.amazonaws.com/index.js"></script>
91
+ <script>
92
+ window.ChatSystem.mount({
93
+ appToken: "YOUR_TOKEN_ID",
94
+ displayMode: "launcher",
95
+ identityProvider: {
96
+ async getToken(request) {
97
+ const response = await fetch("/api/chatsystem/identity", {
98
+ credentials: "include",
99
+ cache: "no-store",
100
+ });
101
+ if (!response.ok) return null;
102
+ return (await response.json()).token ?? null;
103
+ },
104
+ subscribe(onIdentityChanged) {
105
+ return customerAuth.onAuthStateChanged(onIdentityChanged);
106
+ },
107
+ },
108
+ });
109
+ </script>
110
+ ```
111
+
112
+ This passes the provider to the same internal `App` and identity session used
113
+ by the npm package. Do not place callbacks or secrets in `data-*` attributes.