@howone/sdk 0.5.1 → 0.5.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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +84 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -69,16 +69,19 @@ var init_config = __esm({
|
|
|
69
69
|
env = "dev";
|
|
70
70
|
localEnv = {
|
|
71
71
|
AUTH_ROOT_VALUE: "https://howone.dev",
|
|
72
|
+
AUTH_COOKIE_ROOT_VALUE: "https://auth.howone.app",
|
|
72
73
|
baseUrl: "http://localhost:3002/api",
|
|
73
74
|
aiBaseUrl: "https://evoagentx-server.fly.dev"
|
|
74
75
|
};
|
|
75
76
|
devEnv = {
|
|
76
77
|
AUTH_ROOT_VALUE: "https://howone.dev",
|
|
78
|
+
AUTH_COOKIE_ROOT_VALUE: "https://auth.howone.app",
|
|
77
79
|
baseUrl: "https://api.howone.dev/api",
|
|
78
80
|
aiBaseUrl: "https://evoagentx-server-stable.fly.dev"
|
|
79
81
|
};
|
|
80
82
|
prodEnv = {
|
|
81
83
|
AUTH_ROOT_VALUE: "https://howone.ai",
|
|
84
|
+
AUTH_COOKIE_ROOT_VALUE: "https://auth.howone.app",
|
|
82
85
|
baseUrl: "https://api.howone.ai/api",
|
|
83
86
|
aiBaseUrl: "https://eax.services"
|
|
84
87
|
};
|
|
@@ -202,6 +205,13 @@ function useAuth() {
|
|
|
202
205
|
setTokenState(null);
|
|
203
206
|
setUser(null);
|
|
204
207
|
notifyAuthStateChanged();
|
|
208
|
+
try {
|
|
209
|
+
fetch(`${env2.AUTH_COOKIE_ROOT_VALUE}/logout`, {
|
|
210
|
+
method: "POST",
|
|
211
|
+
credentials: "include"
|
|
212
|
+
}).catch(() => void 0);
|
|
213
|
+
} catch {
|
|
214
|
+
}
|
|
205
215
|
if (typeof window !== "undefined") {
|
|
206
216
|
const loc = window.location.href;
|
|
207
217
|
const pid = getDefaultProjectId();
|
|
@@ -1314,6 +1324,49 @@ var HowOneProvider = ({
|
|
|
1314
1324
|
const [token, setTokenState] = useState7(() => getToken());
|
|
1315
1325
|
const [hasCheckedUrlToken, setHasCheckedUrlToken] = useState7(false);
|
|
1316
1326
|
const [pendingRedirect, setPendingRedirect] = useState7(false);
|
|
1327
|
+
const authCookieRoot = useMemo(() => {
|
|
1328
|
+
const env3 = getGlobalEnvironment() ?? "dev";
|
|
1329
|
+
return setEnvironment(env3).AUTH_COOKIE_ROOT_VALUE;
|
|
1330
|
+
}, []);
|
|
1331
|
+
const consumeTokenToCookie = useCallback4(async (value2) => {
|
|
1332
|
+
try {
|
|
1333
|
+
await fetch(`${authCookieRoot}/consume`, {
|
|
1334
|
+
method: "POST",
|
|
1335
|
+
credentials: "include",
|
|
1336
|
+
headers: {
|
|
1337
|
+
Authorization: `Bearer ${value2}`
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
} catch (error) {
|
|
1341
|
+
console.error("[HowOneProvider] Failed to consume token:", error);
|
|
1342
|
+
}
|
|
1343
|
+
}, [authCookieRoot]);
|
|
1344
|
+
const logoutFromCookie = useCallback4(async () => {
|
|
1345
|
+
try {
|
|
1346
|
+
await fetch(`${authCookieRoot}/logout`, {
|
|
1347
|
+
method: "POST",
|
|
1348
|
+
credentials: "include"
|
|
1349
|
+
});
|
|
1350
|
+
} catch (error) {
|
|
1351
|
+
console.error("[HowOneProvider] Failed to logout from cookie:", error);
|
|
1352
|
+
}
|
|
1353
|
+
}, [authCookieRoot]);
|
|
1354
|
+
const readAccessTokenCookie = useCallback4(() => {
|
|
1355
|
+
if (typeof document === "undefined") return null;
|
|
1356
|
+
try {
|
|
1357
|
+
const parts = document.cookie.split("; ");
|
|
1358
|
+
for (const part of parts) {
|
|
1359
|
+
const [key, ...rest] = part.split("=");
|
|
1360
|
+
if (key === "access_token") {
|
|
1361
|
+
const raw = rest.join("=");
|
|
1362
|
+
return raw ? decodeURIComponent(raw) : null;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
} catch {
|
|
1366
|
+
return null;
|
|
1367
|
+
}
|
|
1368
|
+
return null;
|
|
1369
|
+
}, []);
|
|
1317
1370
|
useEffect6(() => {
|
|
1318
1371
|
try {
|
|
1319
1372
|
const params = new URLSearchParams(window.location.search);
|
|
@@ -1322,10 +1375,11 @@ var HowOneProvider = ({
|
|
|
1322
1375
|
const hashParams = new URLSearchParams(window.location.hash.slice(1));
|
|
1323
1376
|
urlToken = hashParams.get("access_token") || hashParams.get("token");
|
|
1324
1377
|
}
|
|
1325
|
-
if (urlToken) {
|
|
1378
|
+
if (urlToken && isTokenValid(urlToken)) {
|
|
1326
1379
|
setToken(urlToken);
|
|
1327
1380
|
setTokenState(urlToken);
|
|
1328
1381
|
setUser(parseUserFromToken(urlToken));
|
|
1382
|
+
void consumeTokenToCookie(urlToken);
|
|
1329
1383
|
params.delete("access_token");
|
|
1330
1384
|
params.delete("token");
|
|
1331
1385
|
params.delete("project_id");
|
|
@@ -1333,12 +1387,20 @@ var HowOneProvider = ({
|
|
|
1333
1387
|
const newUrl = window.location.pathname + (newSearch ? "?" + newSearch : "");
|
|
1334
1388
|
window.history.replaceState({}, "", newUrl);
|
|
1335
1389
|
}
|
|
1390
|
+
if (!urlToken) {
|
|
1391
|
+
const cookieToken = readAccessTokenCookie();
|
|
1392
|
+
if (cookieToken && isTokenValid(cookieToken)) {
|
|
1393
|
+
setToken(cookieToken);
|
|
1394
|
+
setTokenState(cookieToken);
|
|
1395
|
+
setUser(parseUserFromToken(cookieToken));
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1336
1398
|
} catch (e) {
|
|
1337
1399
|
console.error("[HowOneProvider] Failed to capture token from URL:", e);
|
|
1338
1400
|
} finally {
|
|
1339
1401
|
setHasCheckedUrlToken(true);
|
|
1340
1402
|
}
|
|
1341
|
-
}, []);
|
|
1403
|
+
}, [consumeTokenToCookie, readAccessTokenCookie]);
|
|
1342
1404
|
const resolvedAuthUrl = useMemo(() => {
|
|
1343
1405
|
const env3 = getGlobalEnvironment() ?? "dev";
|
|
1344
1406
|
switch (env3) {
|
|
@@ -1416,6 +1478,7 @@ var HowOneProvider = ({
|
|
|
1416
1478
|
}
|
|
1417
1479
|
setTokenState(null);
|
|
1418
1480
|
setUser(null);
|
|
1481
|
+
void logoutFromCookie();
|
|
1419
1482
|
redirectToAuth();
|
|
1420
1483
|
};
|
|
1421
1484
|
const value = {
|
|
@@ -2274,6 +2337,7 @@ var Request = class {
|
|
|
2274
2337
|
this.abortControllers = /* @__PURE__ */ new Map();
|
|
2275
2338
|
this.instance = axios.create({
|
|
2276
2339
|
...config,
|
|
2340
|
+
withCredentials: true,
|
|
2277
2341
|
validateStatus: (status) => {
|
|
2278
2342
|
return status >= 200 && status < 300;
|
|
2279
2343
|
}
|
|
@@ -2650,6 +2714,17 @@ async function executeSSEWorkflow(request, options = {}) {
|
|
|
2650
2714
|
options.onStreamContent(logData.delta);
|
|
2651
2715
|
}
|
|
2652
2716
|
}
|
|
2717
|
+
if (rawEvent.type === "execution_error" && rawEvent.data) {
|
|
2718
|
+
const errorData = rawEvent.data;
|
|
2719
|
+
if (errorData.log_type === "execution_display_error") {
|
|
2720
|
+
const errorContent = errorData.content;
|
|
2721
|
+
const displayMessage = errorContent || "Workflow execution failed";
|
|
2722
|
+
ClayxToast.error({
|
|
2723
|
+
title: "Execution Error",
|
|
2724
|
+
message: displayMessage
|
|
2725
|
+
});
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2653
2728
|
if (rawEvent.type === "stream" && rawEvent.delta && options.onStreamContent) {
|
|
2654
2729
|
options.onStreamContent(rawEvent.delta);
|
|
2655
2730
|
}
|
|
@@ -3715,6 +3790,13 @@ function createClient(opts) {
|
|
|
3715
3790
|
applyToken(null);
|
|
3716
3791
|
rememberExternalToken(null, 0);
|
|
3717
3792
|
pendingExternalTokenPromise = null;
|
|
3793
|
+
try {
|
|
3794
|
+
fetch(`${env3.AUTH_COOKIE_ROOT_VALUE}/logout`, {
|
|
3795
|
+
method: "POST",
|
|
3796
|
+
credentials: "include"
|
|
3797
|
+
}).catch(() => void 0);
|
|
3798
|
+
} catch {
|
|
3799
|
+
}
|
|
3718
3800
|
if (typeof window !== "undefined") {
|
|
3719
3801
|
const loc = window.location.href;
|
|
3720
3802
|
try {
|