@chatsystem/client 1.1.82 → 1.1.83

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/index.d.ts CHANGED
@@ -1,12 +1,59 @@
1
1
  import { JSX as JSX_2 } from 'react/jsx-runtime';
2
2
 
3
+ /**
4
+ * Embeds the ChatSystem chatbot in a React application.
5
+ *
6
+ * Identity integration is optional. Without `identityProvider`, all existing
7
+ * anonymous behavior remains unchanged.
8
+ */
3
9
  export declare function App({ cssHref, appToken, agentId, displayMode, shouldDisplayLogs, ...contentProps }: AppProps): JSX_2.Element;
4
10
 
5
- declare type AppProps = {
11
+ /** Public configuration for the ChatSystem React widget. */
12
+ export declare type AppProps = {
13
+ /**
14
+ * Public ChatSystem app token identifying the customer installation.
15
+ * This is not a secret and does not authenticate the end user.
16
+ */
6
17
  appToken: string;
18
+ /** Optional agent to use instead of the company's default agent. */
7
19
  agentId?: number;
20
+ /** Displays either the launcher widget or the inline chatbox. */
8
21
  displayMode?: DisplayModesTypes;
22
+ /** Enables diagnostic widget logs. Keep disabled in normal production use. */
9
23
  shouldDisplayLogs?: boolean;
24
+ /**
25
+ * Optional bridge to the host website's existing authenticated session.
26
+ *
27
+ * Implement this in the customer's frontend integration code, normally next
28
+ * to the component that renders `<App />`. Its `getToken()` method should
29
+ * call one same-origin customer endpoint, such as
30
+ * `/api/chatsystem/identity`. That customer endpoint authenticates the user
31
+ * with the host's existing cookie/session/SSO and returns a short-lived
32
+ * ChatSystem widget identity JWT.
33
+ *
34
+ * Never return the company API key, the host's primary access token, session
35
+ * cookie, or SSO token. The widget keeps the returned ChatSystem JWT in
36
+ * memory only. Omit this property to keep the widget fully anonymous.
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * <App
41
+ * appToken="public-app-token"
42
+ * identityProvider={{
43
+ * getToken: async ({ interactive }) => {
44
+ * const response = await fetch('/api/chatsystem/identity', {
45
+ * credentials: 'include',
46
+ * });
47
+ * if (!response.ok) return null;
48
+ * return (await response.json()).token ?? null;
49
+ * },
50
+ * subscribe: (onIdentityChanged) =>
51
+ * customerAuth.onAuthStateChanged(onIdentityChanged),
52
+ * }}
53
+ * />
54
+ * ```
55
+ */
56
+ identityProvider?: WidgetIdentityProvider;
10
57
  } & ShadowControls;
11
58
 
12
59
  declare enum DisplayModeEnum {
@@ -14,10 +61,77 @@ declare enum DisplayModeEnum {
14
61
  CHATBOX = "chatbox"
15
62
  }
16
63
 
17
- declare type DisplayModesTypes = `${DisplayModeEnum}`;
64
+ export declare type DisplayModesTypes = `${DisplayModeEnum}`;
18
65
 
19
- declare type ShadowControls = {
66
+ /** Controls how the widget's Shadow DOM receives its stylesheet. */
67
+ export declare type ShadowControls = {
68
+ /**
69
+ * Optional URL for a prebuilt widget stylesheet. When omitted, the package
70
+ * injects its bundled CSS into the Shadow DOM.
71
+ */
20
72
  cssHref?: string;
21
73
  };
22
74
 
75
+ /**
76
+ * Connects the ChatSystem widget to the host website's existing authentication
77
+ * system without exposing passwords, cookies, company API keys, or primary
78
+ * access tokens to ChatSystem.
79
+ *
80
+ * The customer implements this object in frontend integration code. The
81
+ * customer needs only one new same-origin backend endpoint that validates its
82
+ * existing session and obtains a short-lived widget identity JWT from
83
+ * ChatSystem.
84
+ */
85
+ export declare type WidgetIdentityProvider = {
86
+ /**
87
+ * Returns a short-lived ChatSystem widget identity JWT, or `null` when the
88
+ * visitor is not authenticated.
89
+ *
90
+ * This method may be called when the widget opens and before a prompt when a
91
+ * token is missing or near expiry. It should call the customer's same-origin
92
+ * identity endpoint with the host session, usually using
93
+ * `credentials: 'include'`.
94
+ *
95
+ * When `request.interactive` is `false`, do not display login UI. When it is
96
+ * `true`, the implementation may open the host's existing login modal,
97
+ * popup, SSO flow, or login route and retry the same identity endpoint.
98
+ *
99
+ * Never return a company API key or the host's primary authentication token.
100
+ */
101
+ getToken(request: WidgetIdentityRequest): Promise<string | null | undefined>;
102
+ /**
103
+ * Registers the widget's identity-change listener.
104
+ *
105
+ * The host must invoke `onIdentityChanged` after its own login, logout, or
106
+ * account switch has completed. On logout, destroy the host session first,
107
+ * then notify the widget. The widget will clear its in-memory JWT and perform
108
+ * a new silent lookup.
109
+ *
110
+ * Return an unsubscribe function that removes the listener. If the host's
111
+ * authentication SDK already exposes an auth-state subscription, return its
112
+ * cleanup function directly.
113
+ */
114
+ subscribe?(onIdentityChanged: () => void): () => void;
115
+ };
116
+
117
+ /** Context supplied whenever the widget asks the host for delegated identity. */
118
+ export declare type WidgetIdentityRequest = {
119
+ /**
120
+ * When `false`, the provider must perform a silent lookup and must not open
121
+ * login UI. When `true`, it may invoke the host's existing login or SSO UI
122
+ * before retrying the same identity endpoint.
123
+ *
124
+ * The current identity-only widget requests silent lookup. Interactive mode
125
+ * is reserved for the forthcoming reconnect/protected-tool flow.
126
+ */
127
+ interactive: boolean;
128
+ /** Optional user-facing reason why authentication is being requested. */
129
+ reason?: string;
130
+ /**
131
+ * Capabilities required by the pending operation. The host backend remains
132
+ * responsible for deriving and authorizing the capabilities it grants.
133
+ */
134
+ requiredCapabilities?: string[];
135
+ };
136
+
23
137
  export { }