@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.d.mts
CHANGED
|
@@ -430,7 +430,7 @@ type HowoneContextValue = {
|
|
|
430
430
|
isAuthenticated: boolean;
|
|
431
431
|
logout: () => void;
|
|
432
432
|
};
|
|
433
|
-
interface
|
|
433
|
+
interface HowOneProviderProps {
|
|
434
434
|
children: React$1.ReactNode;
|
|
435
435
|
autoRedirect?: boolean;
|
|
436
436
|
showFloatingButton?: boolean;
|
|
@@ -438,28 +438,32 @@ interface HowoneProviderProps {
|
|
|
438
438
|
defaultTheme?: Theme$1;
|
|
439
439
|
themeStorageKey?: string;
|
|
440
440
|
forceDefaultTheme?: boolean;
|
|
441
|
+
authUrl?: string;
|
|
442
|
+
redirectOnUnauthenticated?: boolean;
|
|
441
443
|
}
|
|
442
444
|
/**
|
|
443
|
-
*
|
|
445
|
+
* HowOneProvider - All-in-one application provider
|
|
444
446
|
*
|
|
445
447
|
* Includes:
|
|
446
|
-
* - Authentication management
|
|
448
|
+
* - Authentication management with auto-redirect to auth page
|
|
447
449
|
* - Theme management (dark/light/system)
|
|
448
450
|
* - Toast notifications
|
|
449
|
-
* - Floating button
|
|
451
|
+
* - Floating button (shows "Login" when unauthenticated)
|
|
450
452
|
*
|
|
451
453
|
* @example
|
|
452
454
|
* ```tsx
|
|
453
|
-
* <
|
|
455
|
+
* <HowOneProvider
|
|
454
456
|
* defaultTheme="dark"
|
|
455
457
|
* themeStorageKey="my-app-theme"
|
|
456
458
|
* showFloatingButton={true}
|
|
459
|
+
* authUrl="https://howone.dev/auth"
|
|
460
|
+
* redirectOnUnauthenticated={true}
|
|
457
461
|
* >
|
|
458
462
|
* <App />
|
|
459
|
-
* </
|
|
463
|
+
* </HowOneProvider>
|
|
460
464
|
* ```
|
|
461
465
|
*/
|
|
462
|
-
declare const
|
|
466
|
+
declare const HowOneProvider: React$1.FC<HowOneProviderProps>;
|
|
463
467
|
declare function useHowoneContext(): HowoneContextValue;
|
|
464
468
|
|
|
465
469
|
type AuthState = {
|
|
@@ -569,4 +573,4 @@ declare function useDebounce<T>(value: T, delay: number): T;
|
|
|
569
573
|
*/
|
|
570
574
|
declare function injectEarlyErrorHandler(): void;
|
|
571
575
|
|
|
572
|
-
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, ClayxToast, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, GlobalToastContainer,
|
|
576
|
+
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, ClayxToast, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, GlobalToastContainer, HowOneProvider, type HowOneProviderProps, Loading, LoadingSpinner, LoginForm, type SendCodeRequest, type SendCodeResponse, ThemeProvider, ThemeToggle, type Visibility, aiRequest, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, getAuthRoot, getCodeStatus, getDefaultProjectId, getToken, howone, injectEarlyErrorHandler, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, request, sendEmailVerificationCode, setAuthRoot, setDefaultProjectId, setToken, unifiedAuth, unifiedOAuth, useAuth, useDebounce, useHowoneContext, useIsMobile, useTheme, workflowRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -430,7 +430,7 @@ type HowoneContextValue = {
|
|
|
430
430
|
isAuthenticated: boolean;
|
|
431
431
|
logout: () => void;
|
|
432
432
|
};
|
|
433
|
-
interface
|
|
433
|
+
interface HowOneProviderProps {
|
|
434
434
|
children: React$1.ReactNode;
|
|
435
435
|
autoRedirect?: boolean;
|
|
436
436
|
showFloatingButton?: boolean;
|
|
@@ -438,28 +438,32 @@ interface HowoneProviderProps {
|
|
|
438
438
|
defaultTheme?: Theme$1;
|
|
439
439
|
themeStorageKey?: string;
|
|
440
440
|
forceDefaultTheme?: boolean;
|
|
441
|
+
authUrl?: string;
|
|
442
|
+
redirectOnUnauthenticated?: boolean;
|
|
441
443
|
}
|
|
442
444
|
/**
|
|
443
|
-
*
|
|
445
|
+
* HowOneProvider - All-in-one application provider
|
|
444
446
|
*
|
|
445
447
|
* Includes:
|
|
446
|
-
* - Authentication management
|
|
448
|
+
* - Authentication management with auto-redirect to auth page
|
|
447
449
|
* - Theme management (dark/light/system)
|
|
448
450
|
* - Toast notifications
|
|
449
|
-
* - Floating button
|
|
451
|
+
* - Floating button (shows "Login" when unauthenticated)
|
|
450
452
|
*
|
|
451
453
|
* @example
|
|
452
454
|
* ```tsx
|
|
453
|
-
* <
|
|
455
|
+
* <HowOneProvider
|
|
454
456
|
* defaultTheme="dark"
|
|
455
457
|
* themeStorageKey="my-app-theme"
|
|
456
458
|
* showFloatingButton={true}
|
|
459
|
+
* authUrl="https://howone.dev/auth"
|
|
460
|
+
* redirectOnUnauthenticated={true}
|
|
457
461
|
* >
|
|
458
462
|
* <App />
|
|
459
|
-
* </
|
|
463
|
+
* </HowOneProvider>
|
|
460
464
|
* ```
|
|
461
465
|
*/
|
|
462
|
-
declare const
|
|
466
|
+
declare const HowOneProvider: React$1.FC<HowOneProviderProps>;
|
|
463
467
|
declare function useHowoneContext(): HowoneContextValue;
|
|
464
468
|
|
|
465
469
|
type AuthState = {
|
|
@@ -569,4 +573,4 @@ declare function useDebounce<T>(value: T, delay: number): T;
|
|
|
569
573
|
*/
|
|
570
574
|
declare function injectEarlyErrorHandler(): void;
|
|
571
575
|
|
|
572
|
-
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, ClayxToast, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, GlobalToastContainer,
|
|
576
|
+
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, ClayxToast, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, GlobalToastContainer, HowOneProvider, type HowOneProviderProps, Loading, LoadingSpinner, LoginForm, type SendCodeRequest, type SendCodeResponse, ThemeProvider, ThemeToggle, type Visibility, aiRequest, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, getAuthRoot, getCodeStatus, getDefaultProjectId, getToken, howone, injectEarlyErrorHandler, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, request, sendEmailVerificationCode, setAuthRoot, setDefaultProjectId, setToken, unifiedAuth, unifiedOAuth, useAuth, useDebounce, useHowoneContext, useIsMobile, useTheme, workflowRequest };
|
package/dist/index.js
CHANGED
|
@@ -212,7 +212,7 @@ var AUTH_ROOT_VALUE, DEFAULT_PROJECT_ID, AUTH_ROOT, config_default;
|
|
|
212
212
|
var init_config = __esm({
|
|
213
213
|
"src/config.ts"() {
|
|
214
214
|
"use strict";
|
|
215
|
-
AUTH_ROOT_VALUE = "https://howone
|
|
215
|
+
AUTH_ROOT_VALUE = "https://howone.dev";
|
|
216
216
|
DEFAULT_PROJECT_ID = null;
|
|
217
217
|
AUTH_ROOT = getAuthRoot();
|
|
218
218
|
try {
|
|
@@ -240,7 +240,7 @@ __export(index_exports, {
|
|
|
240
240
|
ErrorBoundary: () => ErrorBoundary,
|
|
241
241
|
FloatingButton: () => FloatingButton,
|
|
242
242
|
GlobalToastContainer: () => GlobalToastContainer,
|
|
243
|
-
|
|
243
|
+
HowOneProvider: () => HowOneProvider,
|
|
244
244
|
Loading: () => Loading,
|
|
245
245
|
LoadingSpinner: () => LoadingSpinner,
|
|
246
246
|
LoginForm: () => LoginForm,
|
|
@@ -1629,12 +1629,15 @@ function GlobalToastContainer() {
|
|
|
1629
1629
|
// src/components/auth/HowoneProvider.tsx
|
|
1630
1630
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1631
1631
|
var HowoneContext = (0, import_react5.createContext)(null);
|
|
1632
|
-
var
|
|
1632
|
+
var HowOneProvider = ({
|
|
1633
1633
|
children,
|
|
1634
1634
|
showFloatingButton = true,
|
|
1635
|
+
projectId,
|
|
1635
1636
|
defaultTheme = "system",
|
|
1636
1637
|
themeStorageKey = "howone-theme",
|
|
1637
|
-
forceDefaultTheme = false
|
|
1638
|
+
forceDefaultTheme = false,
|
|
1639
|
+
authUrl = "https://howone.dev/auth",
|
|
1640
|
+
redirectOnUnauthenticated = true
|
|
1638
1641
|
}) => {
|
|
1639
1642
|
const [user, setUser] = (0, import_react5.useState)(() => parseUserFromToken(getToken()));
|
|
1640
1643
|
const [token, setTokenState] = (0, import_react5.useState)(() => getToken());
|
|
@@ -1653,9 +1656,30 @@ var HowoneProvider = ({
|
|
|
1653
1656
|
window.history.replaceState({}, "", newUrl);
|
|
1654
1657
|
}
|
|
1655
1658
|
} catch (e) {
|
|
1656
|
-
console.error("[
|
|
1659
|
+
console.error("[HowOneProvider] Failed to capture token from URL:", e);
|
|
1657
1660
|
}
|
|
1658
1661
|
}, []);
|
|
1662
|
+
(0, import_react5.useEffect)(() => {
|
|
1663
|
+
if (redirectOnUnauthenticated && !token && !user) {
|
|
1664
|
+
const currentUrl = new URL(window.location.href);
|
|
1665
|
+
if (!currentUrl.pathname.includes("/auth")) {
|
|
1666
|
+
console.log("[HowOneProvider] No token found, redirecting to auth page...");
|
|
1667
|
+
try {
|
|
1668
|
+
const authUrlObj = new URL(authUrl);
|
|
1669
|
+
const redirectUri = window.location.href;
|
|
1670
|
+
authUrlObj.searchParams.set("redirect_uri", redirectUri);
|
|
1671
|
+
if (projectId) {
|
|
1672
|
+
authUrlObj.searchParams.set("project_id", projectId);
|
|
1673
|
+
}
|
|
1674
|
+
console.log("[HowOneProvider] Redirecting to:", authUrlObj.toString());
|
|
1675
|
+
window.location.href = authUrlObj.toString();
|
|
1676
|
+
} catch (error) {
|
|
1677
|
+
console.error("[HowOneProvider] Failed to build auth URL:", error);
|
|
1678
|
+
window.location.href = authUrl;
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
}, [token, user, redirectOnUnauthenticated, authUrl, projectId]);
|
|
1659
1683
|
const logout = () => {
|
|
1660
1684
|
try {
|
|
1661
1685
|
setToken(null);
|
|
@@ -2069,7 +2093,7 @@ var ToastContent = ({ type, title, message, component, closeToast }) => {
|
|
|
2069
2093
|
};
|
|
2070
2094
|
var defaultToastOptions = {
|
|
2071
2095
|
position: "bottom-right",
|
|
2072
|
-
autoClose:
|
|
2096
|
+
autoClose: 3e3,
|
|
2073
2097
|
hideProgressBar: true,
|
|
2074
2098
|
closeOnClick: false,
|
|
2075
2099
|
pauseOnHover: true,
|
|
@@ -2484,7 +2508,7 @@ init_config();
|
|
|
2484
2508
|
ErrorBoundary,
|
|
2485
2509
|
FloatingButton,
|
|
2486
2510
|
GlobalToastContainer,
|
|
2487
|
-
|
|
2511
|
+
HowOneProvider,
|
|
2488
2512
|
Loading,
|
|
2489
2513
|
LoadingSpinner,
|
|
2490
2514
|
LoginForm,
|