@mcp-b/embedded-agent 1.2.8 → 1.2.10

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.
@@ -1,45 +1,99 @@
1
+ import { TicketAuth, TicketAuth as TicketAuth$1 } from "@char-ai/auth";
2
+
1
3
  //#region src/web-component.d.ts
4
+
2
5
  /**
3
- * Char Agent
4
- *
5
- * An Intercom-like AI chat widget with MCP tool support and voice mode.
6
- * Drop it into your app and you're done - uses your existing SSO token.
7
- *
8
- * Styles are isolated by default using Shadow DOM. Customize appearance
9
- * via CSS variables on the host element.
10
- *
11
- * @example SSO-First (production usage)
12
- * ```tsx
13
- * // Use your existing IDP token - no additional login needed
14
- * const { session } = useOktaAuth() // or Azure, Auth0, Google, etc.
15
- *
16
- * <webmcp-agent auth-token={session.idToken} />
17
- * ```
18
- *
19
- * @example React
20
- * ```tsx
21
- * import '@anthropic/char-embedded-agent/web-component'
6
+ * Connection options for the imperative connect() method.
7
+ * Supports two authentication methods:
8
+ * - `idToken`: Direct IDP token authentication (SPA-friendly)
9
+ * - `ticketAuth`: Pre-fetched ticket authentication (SSR-friendly)
10
+ */
11
+ interface ConnectOptions {
12
+ /**
13
+ * IDP token (ID token) for authentication.
14
+ * Token is stored as a JavaScript property (not as a DOM attribute),
15
+ * preventing exposure to DOM inspection and session replay tools.
16
+ *
17
+ * Either `idToken` or `ticketAuth` must be provided, but not both.
18
+ */
19
+ idToken?: string;
20
+ /**
21
+ * Pre-fetched ticket for SSR-friendly authentication.
22
+ * Use this when your server has already exchanged the IDP token for a ticket.
23
+ *
24
+ * Benefits:
25
+ * - IDP token never exposed to browser (in SSR mode)
26
+ * - No JWKS fetch on every connection (validation done once)
27
+ * - Ticket is short-lived (60s default) and single-use
28
+ *
29
+ * Either `idToken` or `ticketAuth` must be provided, but not both.
30
+ */
31
+ ticketAuth?: TicketAuth$1;
32
+ }
33
+ /**
34
+ * Base Web Component from r2wc
22
35
  *
23
- * function App() {
24
- * const { session } = useOktaAuth()
25
- * return <webmcp-agent auth-token={session.idToken} />
26
- * }
27
- * ```
36
+ * Converts EmbeddedAgent to a <webmcp-agent> custom element.
37
+ * Attributes map to props in kebab-case (e.g., dev-mode -> devMode).
38
+ * Note: Auth props (authToken, ticketAuth) are internal only - use connect() method.
39
+ */
40
+ declare const BaseWebMCPAgentElement: CustomElementConstructor;
41
+ /**
42
+ * Extended Web Component with secure connect() method
28
43
  *
29
- * @example Anonymous (dev mode - localhost only)
30
- * ```tsx
31
- * // No auth token = anonymous mode (requires API key, localhost only)
32
- * <webmcp-agent dev-mode='{"anthropicApiKey":"sk-..."}' />
33
- * ```
44
+ * The connect() method allows passing the auth token imperatively without
45
+ * exposing it as a DOM attribute. This prevents token leakage via:
46
+ * - Session replay tools (e.g., FullStory, LogRocket)
47
+ * - Error monitoring (e.g., Sentry, DataDog)
48
+ * - DOM snapshots and inspection
49
+ * - Browser extensions
34
50
  *
35
- * @example CSS variable theming
36
- * ```css
37
- * webmcp-agent {
38
- * --char-color-primary: #0f766e;
39
- * --char-radius: 12px;
40
- * }
51
+ * @example
52
+ * ```ts
53
+ * const agent = document.querySelector('webmcp-agent')
54
+ * agent.connect({ idToken: 'eyJhbGciOi...' })
41
55
  * ```
42
56
  */
57
+ declare class WebMCPAgentElement extends BaseWebMCPAgentElement {
58
+ /**
59
+ * Connect to the Char agent with authentication.
60
+ *
61
+ * The token is stored as a JavaScript property (not as a DOM attribute),
62
+ * preventing exposure to DOM inspection and session replay tools.
63
+ * This is the recommended way to authenticate.
64
+ *
65
+ * @param options.idToken - IDP token (ID token) for authentication
66
+ * @returns true if connection was initiated, false if idToken was missing
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * // Vanilla JS
71
+ * const agent = document.querySelector('webmcp-agent')
72
+ * const success = agent.connect({ idToken: session.idToken })
73
+ * if (!success) {
74
+ * console.error('Failed to connect - missing token')
75
+ * }
76
+ *
77
+ * // React with ref
78
+ * const agentRef = useRef(null)
79
+ * useEffect(() => {
80
+ * agentRef.current?.connect({ idToken: session.idToken })
81
+ * }, [session.idToken])
82
+ * ```
83
+ */
84
+ connect(options: ConnectOptions): boolean;
85
+ /**
86
+ * Disconnect from the Char agent.
87
+ * Clears the authentication token.
88
+ * @returns true if disconnection succeeded, false if an error occurred
89
+ */
90
+ disconnect(): boolean;
91
+ }
92
+ /**
93
+ * Type declaration for the WebMCP Agent custom element.
94
+ * Useful for TypeScript consumers using refs.
95
+ */
96
+
43
97
  /**
44
98
  * Register the <webmcp-agent> custom element
45
99
  *
@@ -48,5 +102,5 @@
48
102
  */
49
103
  declare function registerWebMCPAgent(tagName?: string): void;
50
104
  //#endregion
51
- export { registerWebMCPAgent };
105
+ export { ConnectOptions, type TicketAuth, type WebMCPAgentElement, registerWebMCPAgent };
52
106
  //# sourceMappingURL=web-component.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-component.d.ts","names":[],"sources":["../src/web-component.tsx"],"sourcesContent":[],"mappings":";;AAiPA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,mBAAA"}
1
+ {"version":3,"file":"web-component.d.ts","names":[],"sources":["../src/web-component.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;UA0EiB,cAAA;;;;;;;;;;;;;;;;;;;;eAqBH;;;;;;;;;cA6KR,wBAAsB;;;;;;;;;;;;;;;;;cAqCtB,kBAAA,SAA2B,sBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA2Bf;;;;;;;;;;;;;;;;;;;iBAoEF,mBAAA"}