@athenaintel/react 0.9.19 → 0.9.20

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
@@ -87,6 +87,24 @@ export declare interface AthenaAssistantMessageProps {
87
87
  ActionBarComponent?: FC<AthenaAssistantActionBarProps>;
88
88
  }
89
89
 
90
+ /**
91
+ * Auth state exposed by `useAthenaAuth()`.
92
+ */
93
+ export declare interface AthenaAuthState {
94
+ /** Whether the user is currently logged in. */
95
+ isLoggedIn: boolean;
96
+ /** Whether the auth state is still loading. */
97
+ isLoading: boolean;
98
+ /** The authenticated user, or `null` when not logged in. */
99
+ user: AthenaUser | null;
100
+ /** The current access token, or `null` when not logged in. */
101
+ accessToken: string | null;
102
+ /** Organizations the user belongs to. */
103
+ orgs: AthenaOrg[];
104
+ /** Log the user out. Redirects to the login page by default. */
105
+ logout: (redirectOnLogout?: boolean) => Promise<void>;
106
+ }
107
+
90
108
  export declare const AthenaChat: FC<AthenaChatProps>;
91
109
 
92
110
  export declare interface AthenaChatComponents {
@@ -216,6 +234,15 @@ export declare interface AthenaLinkClickOptions {
216
234
 
217
235
  export declare type AthenaLinkKind = 'athena-citation' | 'athena-app' | 'external';
218
236
 
237
+ /**
238
+ * Athena organization membership.
239
+ */
240
+ export declare interface AthenaOrg {
241
+ orgId: string;
242
+ orgName: string;
243
+ urlSafeOrgName: string;
244
+ }
245
+
219
246
  export declare function AthenaProvider({ children, config, apiKey, token: tokenProp, agent, model, tools, frontendTools, apiUrl, backendUrl, appUrl, environment, workbench, knowledgeBase, systemPrompt, threadId: threadIdProp, enableThreadList, theme, linkClicks, citationLinks, }: AthenaProviderProps): JSX.Element | null;
220
247
 
221
248
  export declare interface AthenaProviderConfig {
@@ -229,6 +256,8 @@ export declare interface AthenaProviderConfig {
229
256
  backendUrl?: string;
230
257
  /** URL for the Athena frontend app origin. Defaults to the matching Athena environment. */
231
258
  appUrl?: string;
259
+ /** Exact parent origins allowed to send embedded auth/config via postMessage. */
260
+ trustedParentOrigins?: string[];
232
261
  /** Athena environment preset used when URLs are not explicitly provided. */
233
262
  environment?: AthenaEnvironment;
234
263
  }
@@ -323,6 +352,38 @@ export declare interface AthenaRuntimeConfig {
323
352
  threadId?: string;
324
353
  }
325
354
 
355
+ /**
356
+ * Organization membership returned by the SSO endpoint.
357
+ */
358
+ export declare interface AthenaSSOOrgInfo {
359
+ orgId: string;
360
+ orgName: string;
361
+ urlSafeOrgName: string;
362
+ }
363
+
364
+ /**
365
+ * User data returned by the Athena SSO `/api/sso/userinfo` endpoint.
366
+ * Field names use snake_case to match the backend response format.
367
+ */
368
+ export declare interface AthenaSSOUserData {
369
+ user_id: string;
370
+ email: string;
371
+ first_name: string;
372
+ last_name: string;
373
+ username: string;
374
+ picture_url: string;
375
+ properties: Record<string, unknown>;
376
+ }
377
+
378
+ /**
379
+ * Full response from the Athena SSO `/api/sso/userinfo` endpoint.
380
+ */
381
+ export declare interface AthenaSSOUserInfo {
382
+ user: AthenaSSOUserData;
383
+ orgMemberInfos: AthenaSSOOrgInfo[];
384
+ accessToken: string;
385
+ }
386
+
326
387
  /**
327
388
  * Athena SDK Theming System
328
389
  *
@@ -403,6 +464,19 @@ export declare interface AthenaTheme {
403
464
  threadMaxWidth?: string;
404
465
  }
405
466
 
467
+ /**
468
+ * Athena user information — a simplified, PropelAuth-agnostic representation.
469
+ */
470
+ export declare interface AthenaUser {
471
+ userId: string;
472
+ email: string;
473
+ firstName?: string;
474
+ lastName?: string;
475
+ username?: string;
476
+ pictureUrl?: string;
477
+ properties?: Record<string, unknown>;
478
+ }
479
+
406
480
  export declare const AthenaUserMessage: FC<AthenaUserMessageProps>;
407
481
 
408
482
  export declare interface AthenaUserMessageProps {
@@ -563,6 +637,14 @@ export declare function normalizeResult(result: unknown): Record<string, unknown
563
637
 
564
638
  export declare const OpenAssetToolUI: ToolCallMessagePartComponent;
565
639
 
640
+ declare interface ParentBridgeOptions {
641
+ /**
642
+ * Exact parent origins that are allowed to send auth/config via postMessage.
643
+ * Useful for private-cloud or custom-domain deployments.
644
+ */
645
+ trustedOrigins?: string[];
646
+ }
647
+
566
648
  export declare interface ParentBridgeState {
567
649
  /** PropelAuth access token from the parent window. */
568
650
  token: string | null;
@@ -1110,7 +1192,7 @@ export declare function useParentAuth(): string | null;
1110
1192
  * Parent -> iframe: { type: 'athena-auth', token: '<propel-access-token>' }
1111
1193
  * iframe -> Parent: { type: 'athena-auth-ready' }
1112
1194
  */
1113
- export declare function useParentBridge(): ParentBridgeState;
1195
+ export declare function useParentBridge({ trustedOrigins, }?: ParentBridgeOptions): ParentBridgeState;
1114
1196
 
1115
1197
  export declare function useQuote(): QuoteContextValue;
1116
1198
 
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4
4
  import { jsx, jsxs, Fragment as Fragment$2 } from "react/jsx-runtime";
5
5
  import * as React from "react";
6
6
  import React__default, { useMemo, useReducer, useLayoutEffect, useRef, useState, useContext, createContext, useSyncExternalStore, useDebugValue, useEffect, useCallback, memo, Fragment as Fragment$1, useId as useId$2, forwardRef, createRef, createElement, version as version$1, useImperativeHandle } from "react";
7
+ import { A as AthenaAuthContext } from "./AthenaAuthContext-DQsdayH2.js";
7
8
  import * as ReactDOM from "react-dom";
8
9
  import ReactDOM__default, { flushSync } from "react-dom";
9
10
  function commitAllEffects(renderResult) {
@@ -16565,17 +16566,50 @@ function createAthenaSpacesUrl({
16565
16566
  }
16566
16567
  return url.toString();
16567
16568
  }
16568
- function isTrustedOrigin(origin) {
16569
+ function isTrustedOrigin({
16570
+ origin,
16571
+ trustedOrigins
16572
+ }) {
16569
16573
  try {
16570
- const { hostname } = new URL(origin);
16574
+ const normalizedOrigin = new URL(origin).origin;
16575
+ if (trustedOrigins.includes(normalizedOrigin)) {
16576
+ return true;
16577
+ }
16578
+ const { hostname } = new URL(normalizedOrigin);
16571
16579
  return hostname === "athenaintel.com" || hostname.endsWith(".athenaintel.com") || hostname === "localhost";
16572
16580
  } catch {
16573
16581
  return false;
16574
16582
  }
16575
16583
  }
16576
16584
  const BRIDGE_TIMEOUT_MS = 2e3;
16577
- function useParentBridge() {
16585
+ const normalizeOrigin = (value) => {
16586
+ try {
16587
+ return new URL(value).origin;
16588
+ } catch {
16589
+ return null;
16590
+ }
16591
+ };
16592
+ function useParentBridge({
16593
+ trustedOrigins = []
16594
+ } = {}) {
16578
16595
  const isInIframe = typeof window !== "undefined" && window.parent !== window;
16596
+ const runtimeTrustedOrigins = useMemo(() => {
16597
+ const origins = /* @__PURE__ */ new Set();
16598
+ if (typeof window !== "undefined") {
16599
+ origins.add(window.location.origin);
16600
+ const referrerOrigin = normalizeOrigin(document.referrer);
16601
+ if (referrerOrigin) {
16602
+ origins.add(referrerOrigin);
16603
+ }
16604
+ }
16605
+ for (const trustedOrigin of trustedOrigins) {
16606
+ const normalizedOrigin = normalizeOrigin(trustedOrigin);
16607
+ if (normalizedOrigin) {
16608
+ origins.add(normalizedOrigin);
16609
+ }
16610
+ }
16611
+ return [...origins];
16612
+ }, [trustedOrigins]);
16579
16613
  const [state, setState] = useState({
16580
16614
  token: null,
16581
16615
  apiUrl: null,
@@ -16589,7 +16623,9 @@ function useParentBridge() {
16589
16623
  useEffect(() => {
16590
16624
  if (!isInIframe) return;
16591
16625
  const handler = (event) => {
16592
- if (!isTrustedOrigin(event.origin)) return;
16626
+ if (!isTrustedOrigin({ origin: event.origin, trustedOrigins: runtimeTrustedOrigins })) {
16627
+ return;
16628
+ }
16593
16629
  if (!event.data || typeof event.data !== "object") return;
16594
16630
  if (event.data.type === "athena-config") {
16595
16631
  configReceived.current = true;
@@ -16624,7 +16660,7 @@ function useParentBridge() {
16624
16660
  window.removeEventListener("message", handler);
16625
16661
  clearTimeout(timer);
16626
16662
  };
16627
- }, [isInIframe]);
16663
+ }, [isInIframe, runtimeTrustedOrigins]);
16628
16664
  return state;
16629
16665
  }
16630
16666
  function useParentAuth() {
@@ -24972,8 +25008,13 @@ function AthenaProvider({
24972
25008
  const configuredApiUrl = (config2 == null ? void 0 : config2.apiUrl) ?? apiUrl;
24973
25009
  const configuredBackendUrl = (config2 == null ? void 0 : config2.backendUrl) ?? backendUrl;
24974
25010
  const configuredAppUrl = (config2 == null ? void 0 : config2.appUrl) ?? appUrl;
24975
- const bridge = useParentBridge();
24976
- const effectiveToken = configuredToken !== void 0 ? configuredToken : bridge.token;
25011
+ const configuredTrustedParentOrigins = config2 == null ? void 0 : config2.trustedParentOrigins;
25012
+ const bridge = useParentBridge({
25013
+ trustedOrigins: configuredTrustedParentOrigins
25014
+ });
25015
+ const authContext = useContext(AthenaAuthContext);
25016
+ const authProviderToken = (authContext == null ? void 0 : authContext.accessToken) ?? null;
25017
+ const effectiveToken = configuredToken !== void 0 ? configuredToken : authProviderToken ?? bridge.token;
24977
25018
  const effectiveApiUrl = configuredApiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl;
24978
25019
  const effectiveBackendUrl = configuredBackendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl;
24979
25020
  const effectiveAppUrl = configuredAppUrl ?? bridge.appUrl ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl;
@@ -62356,7 +62397,9 @@ const TOOL_META = {
62356
62397
  create_email_draft: { displayName: "Drafting email", icon: Mail },
62357
62398
  unified_email_create_draft: { displayName: "Drafting email", icon: Mail },
62358
62399
  edit_email_draft: { displayName: "Editing email draft", icon: Mail },
62359
- unified_edit_email_draft: { displayName: "Editing email draft", icon: Mail },
62400
+ unified_email_edit_draft: { displayName: "Editing email draft", icon: Mail },
62401
+ unified_email_fetch_attachments: { displayName: "Fetching email attachments", icon: Mail },
62402
+ unified_email_forward: { displayName: "Forwarding email", icon: Mail },
62360
62403
  // Documents
62361
62404
  read_full_asset: { displayName: "Reading document", icon: BookOpen },
62362
62405
  create_new_document: { displayName: "Creating document", icon: FileText },