@cagent/chat-embedding-core 0.0.17 → 0.0.22

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.
@@ -76,6 +76,8 @@ export type BotProps = {
76
76
  apiHost?: string;
77
77
  onRequest?: (request: RequestInit) => Promise<void>;
78
78
  chatflowConfig?: Record<string, unknown>;
79
+ /** Path fragment of the host site's logout URL (e.g. '/dang-xuat'); navigating there ends the C-Agent SSO session. */
80
+ ssoLogoutUrlPattern?: string;
79
81
  welcomeMessage?: string;
80
82
  secondMessage?: string;
81
83
  errorMessage?: string;
@@ -0,0 +1,7 @@
1
+ import type { SsoStatus } from '../ssoSession';
2
+ export type SsoLoginOverlayProps = {
3
+ status: SsoStatus;
4
+ buttonColor?: string;
5
+ onLogin: () => void;
6
+ };
7
+ export declare const SsoLoginOverlay: (props: SsoLoginOverlayProps) => import("solid-js").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './ssoSession';
2
+ export * from './components/SsoLoginOverlay';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * SSO for chatflows that need a signed-in C-Gov user. The C-Agent server does the OIDC exchange; this module only
3
+ * starts a login, waits for the result and keeps the short-lived C-Agent session token. SSO tokens never reach the page.
4
+ */
5
+ export type SsoStatus = 'not_required' | 'checking' | 'needs_login' | 'signing_in' | 'failed' | 'ready';
6
+ export declare const clearSsoSession: () => void;
7
+ export declare const getSsoToken: () => string | null;
8
+ /**
9
+ * Ends the C-Agent session only (never the SSO session of the host site). The local copy goes first and synchronously,
10
+ * because the page may be unloading; the server call is best effort and `keepalive` lets it outlive the page.
11
+ */
12
+ export declare const signOutSso: (apiHost: string) => void;
13
+ /**
14
+ * The host site (e.g. IOC) signs the user out with a full-page navigation, which destroys the widget before it can react,
15
+ * and the session in sessionStorage would be inherited by the next user of this tab. The Navigation API reports the
16
+ * navigation while the page is still alive, so the C-Agent session is ended first. Returns a function that stops watching.
17
+ * Browsers without the Navigation API are not covered; there the server-side back-channel logout is the only signal.
18
+ */
19
+ export declare const watchHostLogout: (apiHost: string, logoutUrlPattern: string) => (() => void);
20
+ /**
21
+ * Login without any user action: a hidden frame asks the SSO server with prompt=none. It only succeeds when the browser
22
+ * sends the SSO cookie inside the frame; otherwise the caller falls back to the popup.
23
+ */
24
+ export declare const trySilentSignIn: (apiHost: string) => Promise<boolean>;
25
+ /** Browsers only allow a popup inside the click that asked for it, so this must run before any await. */
26
+ export declare const openLoginPopup: () => Window | null;
27
+ /**
28
+ * The popup is not watched for closing: under Cross-Origin-Opener-Policy `popup.closed` turns true as soon as the SSO
29
+ * page loads, so the only reliable signal is the server-side result.
30
+ */
31
+ export declare const signInWithPopup: (apiHost: string, popup: Window | null) => Promise<boolean>;
package/dist/web.d.ts CHANGED
@@ -4,6 +4,7 @@ declare const chatbot: {
4
4
  apiHost?: string | undefined;
5
5
  onRequest?: ((request: RequestInit) => Promise<void>) | undefined;
6
6
  chatflowConfig?: Record<string, unknown> | undefined;
7
+ ssoLogoutUrlPattern?: string | undefined;
7
8
  observersConfig?: import("./components/Bot").observersConfigType | undefined;
8
9
  theme?: import("./features/bubble/types").BubbleTheme | undefined;
9
10
  chatwootUrl?: string | undefined;
@@ -20,6 +21,7 @@ declare const chatbot: {
20
21
  apiHost?: string | undefined;
21
22
  onRequest?: ((request: RequestInit) => Promise<void>) | undefined;
22
23
  chatflowConfig?: Record<string, unknown> | undefined;
24
+ ssoLogoutUrlPattern?: string | undefined;
23
25
  observersConfig?: import("./components/Bot").observersConfigType | undefined;
24
26
  theme?: import("./features/bubble/types").BubbleTheme | undefined;
25
27
  chatwootUrl?: string | undefined;