@athenaintel/react 0.9.19 → 0.9.21
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/README.md +57 -1
- package/dist/AthenaAuthContext-B3AwLA5Z.cjs +15 -0
- package/dist/AthenaAuthContext-B3AwLA5Z.cjs.map +1 -0
- package/dist/AthenaAuthContext-DQsdayH2.js +16 -0
- package/dist/AthenaAuthContext-DQsdayH2.js.map +1 -0
- package/dist/auth.cjs +360 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.ts +240 -0
- package/dist/auth.js +361 -0
- package/dist/auth.js.map +1 -0
- package/dist/index.cjs +48 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +83 -1
- package/dist/index.js +48 -8
- package/dist/index.js.map +1 -1
- package/package.json +15 -3
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,47 @@ function createAthenaSpacesUrl({
|
|
|
16565
16566
|
}
|
|
16566
16567
|
return url.toString();
|
|
16567
16568
|
}
|
|
16568
|
-
function isTrustedOrigin(
|
|
16569
|
+
function isTrustedOrigin({
|
|
16570
|
+
origin,
|
|
16571
|
+
trustedOrigins
|
|
16572
|
+
}) {
|
|
16569
16573
|
try {
|
|
16570
|
-
const
|
|
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
|
-
|
|
16585
|
+
const EMPTY_TRUSTED_ORIGINS = [];
|
|
16586
|
+
const normalizeOrigin = (value) => {
|
|
16587
|
+
try {
|
|
16588
|
+
return new URL(value).origin;
|
|
16589
|
+
} catch {
|
|
16590
|
+
return null;
|
|
16591
|
+
}
|
|
16592
|
+
};
|
|
16593
|
+
function useParentBridge({
|
|
16594
|
+
trustedOrigins = EMPTY_TRUSTED_ORIGINS
|
|
16595
|
+
} = {}) {
|
|
16578
16596
|
const isInIframe = typeof window !== "undefined" && window.parent !== window;
|
|
16597
|
+
const runtimeTrustedOrigins = useMemo(() => {
|
|
16598
|
+
const origins = /* @__PURE__ */ new Set();
|
|
16599
|
+
if (typeof window !== "undefined") {
|
|
16600
|
+
origins.add(window.location.origin);
|
|
16601
|
+
}
|
|
16602
|
+
for (const trustedOrigin of trustedOrigins) {
|
|
16603
|
+
const normalizedOrigin = normalizeOrigin(trustedOrigin);
|
|
16604
|
+
if (normalizedOrigin) {
|
|
16605
|
+
origins.add(normalizedOrigin);
|
|
16606
|
+
}
|
|
16607
|
+
}
|
|
16608
|
+
return [...origins];
|
|
16609
|
+
}, [trustedOrigins]);
|
|
16579
16610
|
const [state, setState] = useState({
|
|
16580
16611
|
token: null,
|
|
16581
16612
|
apiUrl: null,
|
|
@@ -16589,7 +16620,9 @@ function useParentBridge() {
|
|
|
16589
16620
|
useEffect(() => {
|
|
16590
16621
|
if (!isInIframe) return;
|
|
16591
16622
|
const handler = (event) => {
|
|
16592
|
-
if (!isTrustedOrigin(event.origin))
|
|
16623
|
+
if (!isTrustedOrigin({ origin: event.origin, trustedOrigins: runtimeTrustedOrigins })) {
|
|
16624
|
+
return;
|
|
16625
|
+
}
|
|
16593
16626
|
if (!event.data || typeof event.data !== "object") return;
|
|
16594
16627
|
if (event.data.type === "athena-config") {
|
|
16595
16628
|
configReceived.current = true;
|
|
@@ -16624,7 +16657,7 @@ function useParentBridge() {
|
|
|
16624
16657
|
window.removeEventListener("message", handler);
|
|
16625
16658
|
clearTimeout(timer);
|
|
16626
16659
|
};
|
|
16627
|
-
}, [isInIframe]);
|
|
16660
|
+
}, [isInIframe, runtimeTrustedOrigins]);
|
|
16628
16661
|
return state;
|
|
16629
16662
|
}
|
|
16630
16663
|
function useParentAuth() {
|
|
@@ -24972,8 +25005,13 @@ function AthenaProvider({
|
|
|
24972
25005
|
const configuredApiUrl = (config2 == null ? void 0 : config2.apiUrl) ?? apiUrl;
|
|
24973
25006
|
const configuredBackendUrl = (config2 == null ? void 0 : config2.backendUrl) ?? backendUrl;
|
|
24974
25007
|
const configuredAppUrl = (config2 == null ? void 0 : config2.appUrl) ?? appUrl;
|
|
24975
|
-
const
|
|
24976
|
-
const
|
|
25008
|
+
const configuredTrustedParentOrigins = config2 == null ? void 0 : config2.trustedParentOrigins;
|
|
25009
|
+
const bridge = useParentBridge({
|
|
25010
|
+
trustedOrigins: configuredTrustedParentOrigins
|
|
25011
|
+
});
|
|
25012
|
+
const authContext = useContext(AthenaAuthContext);
|
|
25013
|
+
const authProviderToken = (authContext == null ? void 0 : authContext.accessToken) ?? null;
|
|
25014
|
+
const effectiveToken = configuredToken !== void 0 ? configuredToken : authProviderToken ?? bridge.token;
|
|
24977
25015
|
const effectiveApiUrl = configuredApiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl;
|
|
24978
25016
|
const effectiveBackendUrl = configuredBackendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl;
|
|
24979
25017
|
const effectiveAppUrl = configuredAppUrl ?? bridge.appUrl ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl;
|
|
@@ -62356,7 +62394,9 @@ const TOOL_META = {
|
|
|
62356
62394
|
create_email_draft: { displayName: "Drafting email", icon: Mail },
|
|
62357
62395
|
unified_email_create_draft: { displayName: "Drafting email", icon: Mail },
|
|
62358
62396
|
edit_email_draft: { displayName: "Editing email draft", icon: Mail },
|
|
62359
|
-
|
|
62397
|
+
unified_email_edit_draft: { displayName: "Editing email draft", icon: Mail },
|
|
62398
|
+
unified_email_fetch_attachments: { displayName: "Fetching email attachments", icon: Mail },
|
|
62399
|
+
unified_email_forward: { displayName: "Forwarding email", icon: Mail },
|
|
62360
62400
|
// Documents
|
|
62361
62401
|
read_full_asset: { displayName: "Reading document", icon: BookOpen },
|
|
62362
62402
|
create_new_document: { displayName: "Creating document", icon: FileText },
|