@athenaintel/react 0.4.0 → 0.4.1
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 +36 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -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 })
|