@howone/sdk 0.1.22 → 0.1.24
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 +12 -8
- package/dist/index.d.ts +12 -8
- package/dist/index.js +31 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -201,7 +201,7 @@ var AUTH_ROOT_VALUE, DEFAULT_PROJECT_ID, AUTH_ROOT, config_default;
|
|
|
201
201
|
var init_config = __esm({
|
|
202
202
|
"src/config.ts"() {
|
|
203
203
|
"use strict";
|
|
204
|
-
AUTH_ROOT_VALUE = "https://howone
|
|
204
|
+
AUTH_ROOT_VALUE = "https://howone.dev";
|
|
205
205
|
DEFAULT_PROJECT_ID = null;
|
|
206
206
|
AUTH_ROOT = getAuthRoot();
|
|
207
207
|
try {
|
|
@@ -1569,12 +1569,15 @@ function GlobalToastContainer() {
|
|
|
1569
1569
|
// src/components/auth/HowoneProvider.tsx
|
|
1570
1570
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1571
1571
|
var HowoneContext = createContext2(null);
|
|
1572
|
-
var
|
|
1572
|
+
var HowOneProvider = ({
|
|
1573
1573
|
children,
|
|
1574
1574
|
showFloatingButton = true,
|
|
1575
|
+
projectId,
|
|
1575
1576
|
defaultTheme = "system",
|
|
1576
1577
|
themeStorageKey = "howone-theme",
|
|
1577
|
-
forceDefaultTheme = false
|
|
1578
|
+
forceDefaultTheme = false,
|
|
1579
|
+
authUrl = "https://howone.dev/auth",
|
|
1580
|
+
redirectOnUnauthenticated = true
|
|
1578
1581
|
}) => {
|
|
1579
1582
|
const [user, setUser] = useState4(() => parseUserFromToken(getToken()));
|
|
1580
1583
|
const [token, setTokenState] = useState4(() => getToken());
|
|
@@ -1593,9 +1596,30 @@ var HowoneProvider = ({
|
|
|
1593
1596
|
window.history.replaceState({}, "", newUrl);
|
|
1594
1597
|
}
|
|
1595
1598
|
} catch (e) {
|
|
1596
|
-
console.error("[
|
|
1599
|
+
console.error("[HowOneProvider] Failed to capture token from URL:", e);
|
|
1597
1600
|
}
|
|
1598
1601
|
}, []);
|
|
1602
|
+
useEffect4(() => {
|
|
1603
|
+
if (redirectOnUnauthenticated && !token && !user) {
|
|
1604
|
+
const currentUrl = new URL(window.location.href);
|
|
1605
|
+
if (!currentUrl.pathname.includes("/auth")) {
|
|
1606
|
+
console.log("[HowOneProvider] No token found, redirecting to auth page...");
|
|
1607
|
+
try {
|
|
1608
|
+
const authUrlObj = new URL(authUrl);
|
|
1609
|
+
const redirectUri = window.location.href;
|
|
1610
|
+
authUrlObj.searchParams.set("redirect_uri", redirectUri);
|
|
1611
|
+
if (projectId) {
|
|
1612
|
+
authUrlObj.searchParams.set("project_id", projectId);
|
|
1613
|
+
}
|
|
1614
|
+
console.log("[HowOneProvider] Redirecting to:", authUrlObj.toString());
|
|
1615
|
+
window.location.href = authUrlObj.toString();
|
|
1616
|
+
} catch (error) {
|
|
1617
|
+
console.error("[HowOneProvider] Failed to build auth URL:", error);
|
|
1618
|
+
window.location.href = authUrl;
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
}, [token, user, redirectOnUnauthenticated, authUrl, projectId]);
|
|
1599
1623
|
const logout = () => {
|
|
1600
1624
|
try {
|
|
1601
1625
|
setToken(null);
|
|
@@ -2009,7 +2033,7 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
|
|
|
2009
2033
|
};
|
|
2010
2034
|
var defaultToastOptions = {
|
|
2011
2035
|
position: "bottom-right",
|
|
2012
|
-
autoClose:
|
|
2036
|
+
autoClose: 3e3,
|
|
2013
2037
|
hideProgressBar: true,
|
|
2014
2038
|
closeOnClick: false,
|
|
2015
2039
|
pauseOnHover: true,
|
|
@@ -2423,7 +2447,7 @@ export {
|
|
|
2423
2447
|
ErrorBoundary,
|
|
2424
2448
|
FloatingButton,
|
|
2425
2449
|
GlobalToastContainer,
|
|
2426
|
-
|
|
2450
|
+
HowOneProvider,
|
|
2427
2451
|
Loading,
|
|
2428
2452
|
LoadingSpinner,
|
|
2429
2453
|
LoginForm,
|