@helpai/elements 1.9.0 → 1.10.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/docs/api-reference.md +15 -0
- package/docs/configuration.md +13 -0
- package/docs/frameworks.md +3 -0
- package/docs/security-privacy.md +64 -3
- package/elements-web-component.esm.js +17 -17
- package/elements-web-component.esm.js.map +3 -3
- package/elements.cjs.js +9 -9
- package/elements.cjs.js.map +3 -3
- package/elements.esm.js +9 -9
- package/elements.esm.js.map +3 -3
- package/elements.js +20 -20
- package/elements.js.map +3 -3
- package/index.d.ts +24 -1
- package/index.mjs +3 -3
- package/llms-full.txt +225 -133
- package/llms.txt +19 -18
- package/package.json +1 -1
- package/react.d.ts +24 -1
- package/react.mjs +14 -14
- package/web-component.d.ts +23 -1
- package/web-component.mjs +3 -3
package/index.d.ts
CHANGED
|
@@ -898,6 +898,8 @@ interface ResolvedTracking {
|
|
|
898
898
|
* alongside at the top level — they're function / DOM types that can't be
|
|
899
899
|
* serialised on the wire.
|
|
900
900
|
*/
|
|
901
|
+
/** A signed user token, or a function that returns a fresh one (see {@link ChatWidgetOptions.userToken}). */
|
|
902
|
+
type UserTokenSource = string | (() => string | Promise<string>);
|
|
901
903
|
interface ChatWidgetOptions {
|
|
902
904
|
/**
|
|
903
905
|
* Stable identifier for this widget instance. Use when mounting more
|
|
@@ -973,6 +975,14 @@ interface ChatWidgetOptions {
|
|
|
973
975
|
* interface (`get` / `set` / `remove` / `clear`).
|
|
974
976
|
*/
|
|
975
977
|
storage?: ClientStorage;
|
|
978
|
+
/**
|
|
979
|
+
* Proves who the logged-in visitor is: a JWT your server signs (HS256) with the deployment's secret key, carrying
|
|
980
|
+
* `sub` (your user id) and `exp`, optionally `name` and `email`. A function is called when a token is first
|
|
981
|
+
* needed and again when the server rejects the current one as expired, so return a fresh token from it. Their
|
|
982
|
+
* conversations then follow them to any device; `chat.login(token)` sets it after sign-in, `chat.reset()` on
|
|
983
|
+
* sign-out. Sent only to the agent API, as `x-user-token`.
|
|
984
|
+
*/
|
|
985
|
+
userToken?: UserTokenSource;
|
|
976
986
|
onMessage?: (msg: {
|
|
977
987
|
role: string;
|
|
978
988
|
text: string;
|
|
@@ -1083,6 +1093,7 @@ interface ResolvedOptions {
|
|
|
1083
1093
|
tracking: ResolvedTracking;
|
|
1084
1094
|
/** Resolved storage adapter — defaults to `LocalStorageAdapter`. */
|
|
1085
1095
|
storage: ClientStorage;
|
|
1096
|
+
userToken?: UserTokenSource;
|
|
1086
1097
|
onMessage?: ChatWidgetOptions['onMessage'];
|
|
1087
1098
|
onOpen?: ChatWidgetOptions['onOpen'];
|
|
1088
1099
|
onClose?: ChatWidgetOptions['onClose'];
|
|
@@ -3383,6 +3394,18 @@ export interface ChatWidgetInstance {
|
|
|
3383
3394
|
* Listeners added with `on()` stay.
|
|
3384
3395
|
*/
|
|
3385
3396
|
reset: () => void;
|
|
3397
|
+
/**
|
|
3398
|
+
* Sign the visitor in as your logged-in user, after they log in to your site: `userToken` is a JWT your server
|
|
3399
|
+
* signs with the deployment's secret key (`sub`, `exp`; optional `name`, `email`), or a function that returns a
|
|
3400
|
+
* fresh one. The widget reconnects as that user: their earlier chats on this browser move to them, and their
|
|
3401
|
+
* conversations follow them to any device. Call `reset()` when they log out.
|
|
3402
|
+
*
|
|
3403
|
+
* @example
|
|
3404
|
+
* ```ts
|
|
3405
|
+
* chat.login(async () => (await fetch('/api/help-ai-token')).text());
|
|
3406
|
+
* ```
|
|
3407
|
+
*/
|
|
3408
|
+
login: (userToken: UserTokenSource) => void;
|
|
3386
3409
|
/**
|
|
3387
3410
|
* Subscribe to a lifecycle event. Returns an `off` function. See
|
|
3388
3411
|
* {@link EventMap} for the full set + payload shapes — currently
|
|
@@ -3526,4 +3549,4 @@ export declare const brand: {
|
|
|
3526
3549
|
readonly domain: string;
|
|
3527
3550
|
readonly siteUrl: string;
|
|
3528
3551
|
};
|
|
3529
|
-
export type { AskOptions, Asset, BlocksConfig, ChatWidgetOptions, ConnectionConfig, ConnectionConfigPartial, EventMap, EventName, HandshakeResponse, HookListener, Link, LogEntry, LogLevel, OpenTarget, ResolvedOptions, ServerConfig, SiteConfig, WidgetConfig, WidgetConfigPartial, WidgetSettings, WidgetSettingsPartial, WidgetState };
|
|
3552
|
+
export type { AskOptions, Asset, BlocksConfig, ChatWidgetOptions, ConnectionConfig, ConnectionConfigPartial, EventMap, EventName, HandshakeResponse, HookListener, Link, LogEntry, LogLevel, OpenTarget, ResolvedOptions, ServerConfig, SiteConfig, UserTokenSource, WidgetConfig, WidgetConfigPartial, WidgetSettings, WidgetSettingsPartial, WidgetState };
|