@athenaintel/react 0.4.0 → 0.4.2
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.cjs +60 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +60 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -16436,35 +16436,43 @@ function useParentAuth() {
|
|
|
16436
16436
|
const readySignalSent = React.useRef(false);
|
|
16437
16437
|
React.useEffect(() => {
|
|
16438
16438
|
const isInIframe = window.parent !== window;
|
|
16439
|
-
|
|
16440
|
-
|
|
16441
|
-
|
|
16442
|
-
|
|
16443
|
-
|
|
16444
|
-
const handler = (event) => {
|
|
16445
|
-
var _a2, _b, _c;
|
|
16446
|
-
console.log("[AthenaAuth] Received PostMessage", {
|
|
16447
|
-
type: (_a2 = event.data) == null ? void 0 : _a2.type,
|
|
16448
|
-
origin: event.origin,
|
|
16449
|
-
isTrusted: isTrustedOrigin(event.origin),
|
|
16450
|
-
hasToken: !!((_b = event.data) == null ? void 0 : _b.token),
|
|
16451
|
-
tokenPrefix: typeof ((_c = event.data) == null ? void 0 : _c.token) === "string" ? event.data.token.substring(0, 20) + "..." : void 0
|
|
16439
|
+
if (process.env.NODE_ENV !== "production") {
|
|
16440
|
+
console.log("[AthenaAuth] useParentAuth mounted", {
|
|
16441
|
+
isInIframe,
|
|
16442
|
+
currentOrigin: window.location.origin,
|
|
16443
|
+
currentUrl: window.location.href
|
|
16452
16444
|
});
|
|
16445
|
+
}
|
|
16446
|
+
const handler = (event) => {
|
|
16447
|
+
var _a2;
|
|
16448
|
+
if (process.env.NODE_ENV !== "production") {
|
|
16449
|
+
console.log("[AthenaAuth] Received PostMessage", {
|
|
16450
|
+
type: (_a2 = event.data) == null ? void 0 : _a2.type,
|
|
16451
|
+
origin: event.origin,
|
|
16452
|
+
isTrusted: isTrustedOrigin(event.origin)
|
|
16453
|
+
});
|
|
16454
|
+
}
|
|
16453
16455
|
if (!isTrustedOrigin(event.origin)) {
|
|
16454
|
-
|
|
16456
|
+
if (process.env.NODE_ENV !== "production") {
|
|
16457
|
+
console.warn("[AthenaAuth] Rejected PostMessage — untrusted origin:", event.origin);
|
|
16458
|
+
}
|
|
16455
16459
|
return;
|
|
16456
16460
|
}
|
|
16457
16461
|
if (event.data && typeof event.data === "object" && event.data.type === "athena-auth" && typeof event.data.token === "string") {
|
|
16458
|
-
|
|
16462
|
+
if (process.env.NODE_ENV !== "production") {
|
|
16463
|
+
console.log("[AthenaAuth] PropelAuth token received via PostMessage, length:", event.data.token.length);
|
|
16464
|
+
}
|
|
16459
16465
|
setAuthToken(event.data.token);
|
|
16460
16466
|
}
|
|
16461
16467
|
};
|
|
16462
16468
|
window.addEventListener("message", handler);
|
|
16463
16469
|
if (!readySignalSent.current && isInIframe) {
|
|
16464
|
-
|
|
16470
|
+
if (process.env.NODE_ENV !== "production") {
|
|
16471
|
+
console.log("[AthenaAuth] Sending athena-auth-ready signal to parent");
|
|
16472
|
+
}
|
|
16465
16473
|
window.parent.postMessage({ type: "athena-auth-ready" }, "*");
|
|
16466
16474
|
readySignalSent.current = true;
|
|
16467
|
-
} else if (!isInIframe) {
|
|
16475
|
+
} else if (!isInIframe && process.env.NODE_ENV !== "production") {
|
|
16468
16476
|
console.log("[AthenaAuth] Not in iframe — skipping parent auth (standalone mode)");
|
|
16469
16477
|
}
|
|
16470
16478
|
return () => window.removeEventListener("message", handler);
|
|
@@ -20791,13 +20799,15 @@ const useAthenaRuntime = (config2) => {
|
|
|
20791
20799
|
api: apiUrl,
|
|
20792
20800
|
headers: async () => {
|
|
20793
20801
|
const authHeaders = tokenRef.current ? { Authorization: `Bearer ${tokenRef.current}` } : apiKeyRef.current ? { "X-API-KEY": apiKeyRef.current } : {};
|
|
20794
|
-
|
|
20795
|
-
|
|
20796
|
-
|
|
20797
|
-
|
|
20798
|
-
|
|
20799
|
-
|
|
20800
|
-
|
|
20802
|
+
if (process.env.NODE_ENV !== "production") {
|
|
20803
|
+
console.log("[AthenaAuth] Request headers", {
|
|
20804
|
+
authMethod: tokenRef.current ? "Bearer token" : apiKeyRef.current ? "X-API-KEY" : "NONE",
|
|
20805
|
+
hasToken: !!tokenRef.current,
|
|
20806
|
+
tokenPrefix: tokenRef.current ? tokenRef.current.substring(0, 20) + "..." : void 0,
|
|
20807
|
+
apiKeyPrefix: apiKeyRef.current ? apiKeyRef.current.substring(0, 10) + "..." : void 0,
|
|
20808
|
+
apiUrl
|
|
20809
|
+
});
|
|
20810
|
+
}
|
|
20801
20811
|
return {
|
|
20802
20812
|
// Prefer parent-injected PropelAuth token over hardcoded API key
|
|
20803
20813
|
...authHeaders,
|
|
@@ -24161,7 +24171,7 @@ function getAgoraBaseUrl(backendUrl) {
|
|
|
24161
24171
|
}
|
|
24162
24172
|
async function listThreads(backendUrl, auth, opts = {}) {
|
|
24163
24173
|
const base2 = getAgoraBaseUrl(backendUrl);
|
|
24164
|
-
const res = await fetch(`${base2}/api/
|
|
24174
|
+
const res = await fetch(`${base2}/api/conversations/threads/list`, {
|
|
24165
24175
|
method: "POST",
|
|
24166
24176
|
headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
|
|
24167
24177
|
body: JSON.stringify({ limit: opts.limit ?? 50, offset: opts.offset ?? 0 })
|
|
@@ -24173,7 +24183,7 @@ async function listThreads(backendUrl, auth, opts = {}) {
|
|
|
24173
24183
|
}
|
|
24174
24184
|
async function archiveThread(backendUrl, auth, threadId) {
|
|
24175
24185
|
const base2 = getAgoraBaseUrl(backendUrl);
|
|
24176
|
-
const res = await fetch(`${base2}/api/
|
|
24186
|
+
const res = await fetch(`${base2}/api/conversations/threads/archive`, {
|
|
24177
24187
|
method: "POST",
|
|
24178
24188
|
headers: { "Content-Type": "application/json", ...getAuthHeaders(auth) },
|
|
24179
24189
|
body: JSON.stringify({ thread_id: threadId })
|
|
@@ -24202,6 +24212,9 @@ function createThreadListStore(config2) {
|
|
|
24202
24212
|
}
|
|
24203
24213
|
},
|
|
24204
24214
|
switchThread: (threadId) => {
|
|
24215
|
+
if (process.env.NODE_ENV !== "production") {
|
|
24216
|
+
console.log("[AthenaThreads] switchThread called", { threadId, prev: get2().activeThreadId });
|
|
24217
|
+
}
|
|
24205
24218
|
set2({ activeThreadId: threadId });
|
|
24206
24219
|
},
|
|
24207
24220
|
newThread: async () => {
|
|
@@ -24294,6 +24307,17 @@ function AthenaProvider({
|
|
|
24294
24307
|
const parentAuthToken = useParentAuth();
|
|
24295
24308
|
const effectiveToken = tokenProp ?? parentAuthToken;
|
|
24296
24309
|
const effectiveBackendUrl = backendUrl ?? DEFAULT_BACKEND_URL;
|
|
24310
|
+
React.useEffect(() => {
|
|
24311
|
+
if (process.env.NODE_ENV !== "production") {
|
|
24312
|
+
console.log("[AthenaAuth] AthenaProvider auth state", {
|
|
24313
|
+
hasTokenProp: !!tokenProp,
|
|
24314
|
+
hasParentAuthToken: !!parentAuthToken,
|
|
24315
|
+
hasEffectiveToken: !!effectiveToken,
|
|
24316
|
+
hasApiKey: !!apiKey,
|
|
24317
|
+
authMethod: effectiveToken ? "Bearer token (PropelAuth)" : apiKey ? "X-API-KEY" : "NONE"
|
|
24318
|
+
});
|
|
24319
|
+
}
|
|
24320
|
+
}, [tokenProp, parentAuthToken, effectiveToken, apiKey]);
|
|
24297
24321
|
const threadListStoreRef = React.useRef(null);
|
|
24298
24322
|
if (enableThreadList && !threadListStoreRef.current) {
|
|
24299
24323
|
threadListStoreRef.current = createThreadListStore({
|
|
@@ -24306,6 +24330,16 @@ function AthenaProvider({
|
|
|
24306
24330
|
enableThreadList ? threadListStoreRef.current : null
|
|
24307
24331
|
);
|
|
24308
24332
|
const resolvedThreadId = threadIdProp ?? activeThreadId ?? void 0;
|
|
24333
|
+
React.useEffect(() => {
|
|
24334
|
+
if (process.env.NODE_ENV !== "production") {
|
|
24335
|
+
console.log("[AthenaThreads] AthenaProvider render", {
|
|
24336
|
+
activeThreadId,
|
|
24337
|
+
resolvedThreadId,
|
|
24338
|
+
enableThreadList,
|
|
24339
|
+
hasStore: !!threadListStoreRef.current
|
|
24340
|
+
});
|
|
24341
|
+
}
|
|
24342
|
+
}, [activeThreadId, resolvedThreadId, enableThreadList]);
|
|
24309
24343
|
const inner = /* @__PURE__ */ jsxRuntime.jsx(
|
|
24310
24344
|
AthenaRuntimeInner,
|
|
24311
24345
|
{
|