@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.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
6
|
const jsxRuntime = require("react/jsx-runtime");
|
|
7
7
|
const React = require("react");
|
|
8
|
+
const AthenaAuthContext = require("./AthenaAuthContext-B3AwLA5Z.cjs");
|
|
8
9
|
const ReactDOM = require("react-dom");
|
|
9
10
|
function _interopNamespaceDefault(e) {
|
|
10
11
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -16583,17 +16584,47 @@ function createAthenaSpacesUrl({
|
|
|
16583
16584
|
}
|
|
16584
16585
|
return url.toString();
|
|
16585
16586
|
}
|
|
16586
|
-
function isTrustedOrigin(
|
|
16587
|
+
function isTrustedOrigin({
|
|
16588
|
+
origin,
|
|
16589
|
+
trustedOrigins
|
|
16590
|
+
}) {
|
|
16587
16591
|
try {
|
|
16588
|
-
const
|
|
16592
|
+
const normalizedOrigin = new URL(origin).origin;
|
|
16593
|
+
if (trustedOrigins.includes(normalizedOrigin)) {
|
|
16594
|
+
return true;
|
|
16595
|
+
}
|
|
16596
|
+
const { hostname } = new URL(normalizedOrigin);
|
|
16589
16597
|
return hostname === "athenaintel.com" || hostname.endsWith(".athenaintel.com") || hostname === "localhost";
|
|
16590
16598
|
} catch {
|
|
16591
16599
|
return false;
|
|
16592
16600
|
}
|
|
16593
16601
|
}
|
|
16594
16602
|
const BRIDGE_TIMEOUT_MS = 2e3;
|
|
16595
|
-
|
|
16603
|
+
const EMPTY_TRUSTED_ORIGINS = [];
|
|
16604
|
+
const normalizeOrigin = (value) => {
|
|
16605
|
+
try {
|
|
16606
|
+
return new URL(value).origin;
|
|
16607
|
+
} catch {
|
|
16608
|
+
return null;
|
|
16609
|
+
}
|
|
16610
|
+
};
|
|
16611
|
+
function useParentBridge({
|
|
16612
|
+
trustedOrigins = EMPTY_TRUSTED_ORIGINS
|
|
16613
|
+
} = {}) {
|
|
16596
16614
|
const isInIframe = typeof window !== "undefined" && window.parent !== window;
|
|
16615
|
+
const runtimeTrustedOrigins = React.useMemo(() => {
|
|
16616
|
+
const origins = /* @__PURE__ */ new Set();
|
|
16617
|
+
if (typeof window !== "undefined") {
|
|
16618
|
+
origins.add(window.location.origin);
|
|
16619
|
+
}
|
|
16620
|
+
for (const trustedOrigin of trustedOrigins) {
|
|
16621
|
+
const normalizedOrigin = normalizeOrigin(trustedOrigin);
|
|
16622
|
+
if (normalizedOrigin) {
|
|
16623
|
+
origins.add(normalizedOrigin);
|
|
16624
|
+
}
|
|
16625
|
+
}
|
|
16626
|
+
return [...origins];
|
|
16627
|
+
}, [trustedOrigins]);
|
|
16597
16628
|
const [state, setState] = React.useState({
|
|
16598
16629
|
token: null,
|
|
16599
16630
|
apiUrl: null,
|
|
@@ -16607,7 +16638,9 @@ function useParentBridge() {
|
|
|
16607
16638
|
React.useEffect(() => {
|
|
16608
16639
|
if (!isInIframe) return;
|
|
16609
16640
|
const handler = (event) => {
|
|
16610
|
-
if (!isTrustedOrigin(event.origin))
|
|
16641
|
+
if (!isTrustedOrigin({ origin: event.origin, trustedOrigins: runtimeTrustedOrigins })) {
|
|
16642
|
+
return;
|
|
16643
|
+
}
|
|
16611
16644
|
if (!event.data || typeof event.data !== "object") return;
|
|
16612
16645
|
if (event.data.type === "athena-config") {
|
|
16613
16646
|
configReceived.current = true;
|
|
@@ -16642,7 +16675,7 @@ function useParentBridge() {
|
|
|
16642
16675
|
window.removeEventListener("message", handler);
|
|
16643
16676
|
clearTimeout(timer);
|
|
16644
16677
|
};
|
|
16645
|
-
}, [isInIframe]);
|
|
16678
|
+
}, [isInIframe, runtimeTrustedOrigins]);
|
|
16646
16679
|
return state;
|
|
16647
16680
|
}
|
|
16648
16681
|
function useParentAuth() {
|
|
@@ -24990,8 +25023,13 @@ function AthenaProvider({
|
|
|
24990
25023
|
const configuredApiUrl = (config2 == null ? void 0 : config2.apiUrl) ?? apiUrl;
|
|
24991
25024
|
const configuredBackendUrl = (config2 == null ? void 0 : config2.backendUrl) ?? backendUrl;
|
|
24992
25025
|
const configuredAppUrl = (config2 == null ? void 0 : config2.appUrl) ?? appUrl;
|
|
24993
|
-
const
|
|
24994
|
-
const
|
|
25026
|
+
const configuredTrustedParentOrigins = config2 == null ? void 0 : config2.trustedParentOrigins;
|
|
25027
|
+
const bridge = useParentBridge({
|
|
25028
|
+
trustedOrigins: configuredTrustedParentOrigins
|
|
25029
|
+
});
|
|
25030
|
+
const authContext = React.useContext(AthenaAuthContext.AthenaAuthContext);
|
|
25031
|
+
const authProviderToken = (authContext == null ? void 0 : authContext.accessToken) ?? null;
|
|
25032
|
+
const effectiveToken = configuredToken !== void 0 ? configuredToken : authProviderToken ?? bridge.token;
|
|
24995
25033
|
const effectiveApiUrl = configuredApiUrl ?? bridge.apiUrl ?? environmentUrls.apiUrl;
|
|
24996
25034
|
const effectiveBackendUrl = configuredBackendUrl ?? bridge.backendUrl ?? environmentUrls.backendUrl;
|
|
24997
25035
|
const effectiveAppUrl = configuredAppUrl ?? bridge.appUrl ?? deriveAthenaAppUrl({ apiUrl: effectiveApiUrl, backendUrl: effectiveBackendUrl }) ?? environmentUrls.appUrl;
|
|
@@ -62374,7 +62412,9 @@ const TOOL_META = {
|
|
|
62374
62412
|
create_email_draft: { displayName: "Drafting email", icon: Mail },
|
|
62375
62413
|
unified_email_create_draft: { displayName: "Drafting email", icon: Mail },
|
|
62376
62414
|
edit_email_draft: { displayName: "Editing email draft", icon: Mail },
|
|
62377
|
-
|
|
62415
|
+
unified_email_edit_draft: { displayName: "Editing email draft", icon: Mail },
|
|
62416
|
+
unified_email_fetch_attachments: { displayName: "Fetching email attachments", icon: Mail },
|
|
62417
|
+
unified_email_forward: { displayName: "Forwarding email", icon: Mail },
|
|
62378
62418
|
// Documents
|
|
62379
62419
|
read_full_asset: { displayName: "Reading document", icon: BookOpen },
|
|
62380
62420
|
create_new_document: { displayName: "Creating document", icon: FileText },
|