@choiceform/shared-auth 0.1.12 → 0.1.13
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/README.md +47 -25
- package/dist/components/protected-route.d.ts +1 -1
- package/dist/components/protected-route.d.ts.map +1 -1
- package/dist/components/protected-route.js +9 -3
- package/dist/components/sign-in-page.d.ts +3 -2
- package/dist/components/sign-in-page.d.ts.map +1 -1
- package/dist/components/sign-in-page.js +5 -7
- package/dist/config.d.ts +11 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -2
- package/dist/core/init-auth-sync.d.ts +7 -0
- package/dist/core/init-auth-sync.d.ts.map +1 -0
- package/dist/core/init-auth-sync.js +34 -0
- package/dist/core.d.ts +1 -1
- package/dist/init.d.ts +5 -3
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +4 -4
- package/dist/store/actions.d.ts +3 -1
- package/dist/store/actions.d.ts.map +1 -1
- package/dist/store/actions.js +13 -5
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -54,19 +54,25 @@ import { adminClient, organizationClient } from "better-auth/client/plugins"
|
|
|
54
54
|
export const auth = initAuth({
|
|
55
55
|
baseURL: import.meta.env.VITE_AUTH_API_URL || "http://localhost:4320",
|
|
56
56
|
tokenStorageKey: "auth-token",
|
|
57
|
-
|
|
58
|
-
signInPath: "/sign-in",
|
|
57
|
+
// 可选:如果你想自定义插件
|
|
59
58
|
plugins: [adminClient(), organizationClient({ teams: { enabled: true } })],
|
|
60
59
|
})
|
|
60
|
+
|
|
61
|
+
// 注意:导航相关配置已移至组件层面:
|
|
62
|
+
// - 登录成功后的导航:在 SignInPage 组件中通过 onAuthSuccess 回调处理
|
|
63
|
+
// - 未授权时的导航:在 ProtectedRoute 组件中通过 onUnauthorized 回调处理
|
|
64
|
+
// - 登出后的导航:在调用 signOut 时传入 redirectTo 参数
|
|
61
65
|
```
|
|
62
66
|
|
|
63
67
|
### 2. 在应用中使用
|
|
64
68
|
|
|
65
69
|
```typescript
|
|
66
70
|
import { AuthSync, ProtectedRoute, useAuthInit } from "@choiceform/shared-auth"
|
|
71
|
+
import { useNavigate } from "react-router"
|
|
67
72
|
import { auth } from "./lib/auth"
|
|
68
73
|
|
|
69
74
|
function App() {
|
|
75
|
+
const navigate = useNavigate()
|
|
70
76
|
useAuthInit(auth)
|
|
71
77
|
|
|
72
78
|
return (
|
|
@@ -77,7 +83,10 @@ function App() {
|
|
|
77
83
|
<Route
|
|
78
84
|
path="/*"
|
|
79
85
|
element={
|
|
80
|
-
<ProtectedRoute
|
|
86
|
+
<ProtectedRoute
|
|
87
|
+
auth={auth}
|
|
88
|
+
onUnauthorized={() => navigate("/sign-in", { replace: true })}
|
|
89
|
+
>
|
|
81
90
|
<YourApp />
|
|
82
91
|
</ProtectedRoute>
|
|
83
92
|
}
|
|
@@ -92,17 +101,25 @@ function App() {
|
|
|
92
101
|
|
|
93
102
|
```typescript
|
|
94
103
|
import { SignInPage } from "@choiceform/shared-auth"
|
|
104
|
+
import { useNavigate } from "react-router"
|
|
95
105
|
import { auth } from "./lib/auth"
|
|
96
106
|
|
|
97
107
|
function LoginPage() {
|
|
108
|
+
const navigate = useNavigate()
|
|
109
|
+
|
|
98
110
|
return (
|
|
99
111
|
<SignInPage
|
|
100
112
|
auth={auth}
|
|
101
|
-
logo={<YourLogo />}
|
|
102
113
|
title="Your App Title"
|
|
103
114
|
description="Your app description"
|
|
104
115
|
provider="github"
|
|
105
|
-
|
|
116
|
+
redirectUrl="/dashboard"
|
|
117
|
+
onAuthSuccess={() => navigate("/dashboard")}
|
|
118
|
+
githubButton={(isSigningIn) => (
|
|
119
|
+
<button disabled={isSigningIn}>
|
|
120
|
+
{isSigningIn ? "Redirecting to GitHub..." : "Sign in with GitHub"}
|
|
121
|
+
</button>
|
|
122
|
+
)}
|
|
106
123
|
/>
|
|
107
124
|
)
|
|
108
125
|
}
|
|
@@ -118,9 +135,9 @@ function LoginPage() {
|
|
|
118
135
|
|
|
119
136
|
- `baseURL`: Better Auth API 基础 URL(必需)
|
|
120
137
|
- `tokenStorageKey?`: Token 存储的 localStorage key(默认: `'auth-token'`)
|
|
121
|
-
- `
|
|
122
|
-
- `
|
|
123
|
-
-
|
|
138
|
+
- `plugins?`: Better Auth 插件列表(默认包含 `organizationClient()`)
|
|
139
|
+
- ~~`defaultRedirectAfterLogin?`~~: (已废弃) 建议在 SignInPage 组件中通过 `redirectUrl` prop 传入
|
|
140
|
+
- ~~`signInPath?`~~: (已废弃) 建议在 ProtectedRoute 组件中通过 `onUnauthorized` 回调处理导航
|
|
124
141
|
|
|
125
142
|
**返回:** `AuthInstance`
|
|
126
143
|
|
|
@@ -132,11 +149,11 @@ function LoginPage() {
|
|
|
132
149
|
|
|
133
150
|
- `baseURL`: Better Auth API 基础 URL(必需)
|
|
134
151
|
- `tokenStorageKey?`: Token 存储的 localStorage key(默认: `'auth-token'`)
|
|
135
|
-
- `defaultRedirectAfterLogin?`: 登录后默认跳转地址(默认: `'/explore'`)
|
|
136
|
-
- `signInPath?`: 登录页面路径(默认: `'/sign-in'`)
|
|
137
152
|
- `plugins?`: Better Auth 插件列表
|
|
138
153
|
- `callbackURLBuilder?`: 自定义回调 URL 构建函数
|
|
139
154
|
- `getSessionEndpoint?`: 获取 session 的端点路径(默认: `'/v1/auth/get-session'`)
|
|
155
|
+
- ~~`defaultRedirectAfterLogin?`~~: (已废弃) 建议在 SignInPage 组件中通过 `redirectUrl` prop 传入
|
|
156
|
+
- ~~`signInPath?`~~: (已废弃) 建议在 ProtectedRoute 组件中通过 `onUnauthorized` 回调处理导航
|
|
140
157
|
|
|
141
158
|
**返回:** `AuthInstance`
|
|
142
159
|
|
|
@@ -190,9 +207,9 @@ Better Auth 认证状态同步组件。
|
|
|
190
207
|
|
|
191
208
|
- `auth`: AuthInstance
|
|
192
209
|
- `children`: React.ReactNode
|
|
193
|
-
- `
|
|
194
|
-
- `loadingComponent?`:
|
|
195
|
-
- `loadingMessage?`: 加载中消息(默认: `'Checking authentication...'`)
|
|
210
|
+
- `onUnauthorized`: () => void - 当用户未认证时的回调函数(用于导航到登录页)
|
|
211
|
+
- `loadingComponent?`: React.ComponentType<{ message?: string }> - 自定义加载组件
|
|
212
|
+
- `loadingMessage?`: string - 加载中消息(默认: `'Checking authentication...'`)
|
|
196
213
|
|
|
197
214
|
### `SignInPage`
|
|
198
215
|
|
|
@@ -201,15 +218,16 @@ Better Auth 认证状态同步组件。
|
|
|
201
218
|
**Props:**
|
|
202
219
|
|
|
203
220
|
- `auth`: AuthInstance
|
|
204
|
-
- `className?`: 自定义样式类名
|
|
205
|
-
- `
|
|
206
|
-
- `
|
|
207
|
-
- `
|
|
208
|
-
- `
|
|
209
|
-
- `
|
|
210
|
-
- `
|
|
211
|
-
- `
|
|
212
|
-
- `
|
|
221
|
+
- `className?`: string - 自定义样式类名
|
|
222
|
+
- `title?`: string - 标题
|
|
223
|
+
- `description?`: string - 描述
|
|
224
|
+
- `provider?`: string - OAuth 提供商(默认: `'github'`)
|
|
225
|
+
- `redirectUrl?`: string - OAuth 回调重定向地址(默认: `'/explore'`)
|
|
226
|
+
- `onAuthSuccess?`: () => void - 认证成功后的回调函数(用于导航)
|
|
227
|
+
- `githubButton?`: (isSigningIn: boolean) => React.ReactNode - 自定义 GitHub 登录按钮渲染函数
|
|
228
|
+
- `beforeElement?`: React.ReactNode - 在登录表单之前渲染的元素
|
|
229
|
+
- `afterElement?`: React.ReactNode - 在登录表单之后渲染的元素
|
|
230
|
+
- `footerText?`: React.ReactNode - 页脚文本
|
|
213
231
|
|
|
214
232
|
## 工具函数
|
|
215
233
|
|
|
@@ -440,13 +458,17 @@ try {
|
|
|
440
458
|
|
|
441
459
|
### 5. 退出登录
|
|
442
460
|
|
|
443
|
-
退出登录时使用 `signOut`
|
|
461
|
+
退出登录时使用 `signOut` 方法,可以选择性地传入重定向地址:
|
|
444
462
|
|
|
445
463
|
```typescript
|
|
446
464
|
async function handleSignOut() {
|
|
447
465
|
try {
|
|
448
|
-
|
|
449
|
-
|
|
466
|
+
// 传入重定向地址,登出后会自动跳转
|
|
467
|
+
await auth.authActions.signOut("/sign-in")
|
|
468
|
+
|
|
469
|
+
// 或者不传入地址,由调用方手动处理后续导航
|
|
470
|
+
// await auth.authActions.signOut()
|
|
471
|
+
// navigate("/sign-in")
|
|
450
472
|
} catch (error) {
|
|
451
473
|
console.error("Sign out failed:", error)
|
|
452
474
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protected-route.d.ts","sourceRoot":"","sources":["../../src/components/protected-route.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"protected-route.d.ts","sourceRoot":"","sources":["../../src/components/protected-route.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,UAAU,mBAAmB;IAC3B,IAAI,EAAE,YAAY,CAAA;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,gBAAgB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,EAAE,MAAM,IAAI,CAAA;CAC3B;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAgCxD,CAAA;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { observer } from "@legendapp/state/react";
|
|
3
|
-
import {
|
|
3
|
+
import { useEffect } from "react";
|
|
4
4
|
/**
|
|
5
5
|
* 路由保护组件
|
|
6
6
|
* 等待认证初始化完成,根据认证状态进行路由保护
|
|
7
7
|
*/
|
|
8
|
-
export const ProtectedRoute = observer(({ children, auth,
|
|
8
|
+
export const ProtectedRoute = observer(({ children, auth, loadingComponent, loadingMessage, onUnauthorized }) => {
|
|
9
9
|
const { authStore, authComputed } = auth;
|
|
10
10
|
// 检查各种状态
|
|
11
11
|
const isInitializing = authComputed.isInitializing.get();
|
|
12
12
|
const isAuthenticated = authStore.isAuthenticated.get();
|
|
13
|
+
// 当未认证时调用回调
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!isInitializing && !isAuthenticated) {
|
|
16
|
+
onUnauthorized();
|
|
17
|
+
}
|
|
18
|
+
}, [isInitializing, isAuthenticated, onUnauthorized]);
|
|
13
19
|
// 检查初始化状态
|
|
14
20
|
if (isInitializing) {
|
|
15
21
|
if (loadingComponent) {
|
|
@@ -20,7 +26,7 @@ export const ProtectedRoute = observer(({ children, auth, signInPath = "/sign-in
|
|
|
20
26
|
}
|
|
21
27
|
// 检查认证状态
|
|
22
28
|
if (!isAuthenticated) {
|
|
23
|
-
return
|
|
29
|
+
return null;
|
|
24
30
|
}
|
|
25
31
|
// 所有检查通过,渲染子组件
|
|
26
32
|
return _jsx(_Fragment, { children: children });
|
|
@@ -8,13 +8,14 @@ interface SignInPageProps {
|
|
|
8
8
|
description?: string;
|
|
9
9
|
footerText?: React.ReactNode;
|
|
10
10
|
githubButton?: (isSigningIn: boolean) => React.ReactNode;
|
|
11
|
+
onAuthSuccess?: () => void;
|
|
11
12
|
provider?: string;
|
|
12
|
-
|
|
13
|
+
redirectUrl?: string;
|
|
13
14
|
title?: string;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* 登录页面组件
|
|
17
18
|
*/
|
|
18
|
-
export declare function SignInPage({ afterElement, auth, beforeElement,
|
|
19
|
+
export declare function SignInPage({ afterElement, auth, beforeElement, onAuthSuccess, redirectUrl, provider, title, description, githubButton, className, footerText, }: SignInPageProps): import("react/jsx-runtime").JSX.Element;
|
|
19
20
|
export {};
|
|
20
21
|
//# sourceMappingURL=sign-in-page.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-in-page.d.ts","sourceRoot":"","sources":["../../src/components/sign-in-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"sign-in-page.d.ts","sourceRoot":"","sources":["../../src/components/sign-in-page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,UAAU,eAAe;IACvB,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC9B,IAAI,EAAE,YAAY,CAAA;IAClB,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,KAAK,CAAC,SAAS,CAAA;IACxD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,EACzB,YAAY,EACZ,IAAI,EACJ,aAAa,EACb,aAAa,EACb,WAAwB,EACxB,QAAmB,EACnB,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,GACX,EAAE,eAAe,2CA+CjB"}
|
|
@@ -2,25 +2,23 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Slot } from "@choiceform/design-system";
|
|
3
3
|
import { use$ } from "@legendapp/state/react";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
|
-
import { useNavigate } from "react-router";
|
|
6
5
|
/**
|
|
7
6
|
* 登录页面组件
|
|
8
7
|
*/
|
|
9
|
-
export function SignInPage({ afterElement, auth, beforeElement,
|
|
10
|
-
const navigate = useNavigate();
|
|
8
|
+
export function SignInPage({ afterElement, auth, beforeElement, onAuthSuccess, redirectUrl = "/explore", provider = "github", title, description, githubButton, className, footerText, }) {
|
|
11
9
|
const { authStore, authActions } = auth;
|
|
12
10
|
const { isAuthenticated, error } = use$(authStore);
|
|
13
11
|
const [isSigningIn, setIsSigningIn] = useState(false);
|
|
14
12
|
useEffect(() => {
|
|
15
|
-
if (isAuthenticated) {
|
|
16
|
-
|
|
13
|
+
if (isAuthenticated && onAuthSuccess) {
|
|
14
|
+
onAuthSuccess();
|
|
17
15
|
}
|
|
18
|
-
}, [isAuthenticated,
|
|
16
|
+
}, [isAuthenticated, onAuthSuccess]);
|
|
19
17
|
const handleSignIn = async () => {
|
|
20
18
|
// 设置本地 loading 状态
|
|
21
19
|
setIsSigningIn(true);
|
|
22
20
|
try {
|
|
23
|
-
await authActions.signIn(provider, `${window.location.origin}${
|
|
21
|
+
await authActions.signIn(provider, `${window.location.origin}${redirectUrl}`);
|
|
24
22
|
// OAuth 会重定向,所以这里的代码可能不会执行
|
|
25
23
|
// loading 状态会在页面刷新后重置
|
|
26
24
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -16,8 +16,10 @@ export interface AuthConfig {
|
|
|
16
16
|
*/
|
|
17
17
|
callbackURLBuilder?: (redirectTo: string, baseURL: string) => string;
|
|
18
18
|
/**
|
|
19
|
-
* OAuth
|
|
20
|
-
*
|
|
19
|
+
* OAuth 重定向后的默认跳转地址(可选)
|
|
20
|
+
* 推荐在组件层面通过 props 传入,而不是在配置中设置
|
|
21
|
+
* @default undefined
|
|
22
|
+
* @deprecated 建议在 SignInPage 组件中通过 redirectUrl prop 传入
|
|
21
23
|
*/
|
|
22
24
|
defaultRedirectAfterLogin?: string;
|
|
23
25
|
/**
|
|
@@ -30,8 +32,10 @@ export interface AuthConfig {
|
|
|
30
32
|
*/
|
|
31
33
|
plugins?: BetterAuthPlugin[];
|
|
32
34
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
+
* 登录页面的路由路径(可选)
|
|
36
|
+
* 推荐在组件层面通过回调传入,而不是在配置中设置
|
|
37
|
+
* @default undefined
|
|
38
|
+
* @deprecated 建议在 ProtectedRoute 组件中通过 onUnauthorized 回调处理导航
|
|
35
39
|
*/
|
|
36
40
|
signInPath?: string;
|
|
37
41
|
/**
|
|
@@ -43,8 +47,10 @@ export interface AuthConfig {
|
|
|
43
47
|
/**
|
|
44
48
|
* 默认配置
|
|
45
49
|
*/
|
|
46
|
-
export declare const defaultAuthConfig: Required<Omit<AuthConfig, "plugins" | "callbackURLBuilder">> & {
|
|
50
|
+
export declare const defaultAuthConfig: Required<Omit<AuthConfig, "plugins" | "callbackURLBuilder" | "defaultRedirectAfterLogin" | "signInPath">> & {
|
|
47
51
|
callbackURLBuilder: (redirectTo: string, baseURL: string) => string;
|
|
52
|
+
defaultRedirectAfterLogin: undefined;
|
|
48
53
|
plugins: BetterAuthPlugin[];
|
|
54
|
+
signInPath: undefined;
|
|
49
55
|
};
|
|
50
56
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,CACvC,cAAc,4BAA4B,EAAE,WAAW,CACxD,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAA;IAEpE
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,CACvC,cAAc,4BAA4B,EAAE,WAAW,CACxD,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAA;IAEpE;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAA;IAElC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAE5B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CACtC,IAAI,CAAC,UAAU,EAAE,SAAS,GAAG,oBAAoB,GAAG,2BAA2B,GAAG,YAAY,CAAC,CAChG,GAAG;IACF,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAA;IACnE,yBAAyB,EAAE,SAAS,CAAA;IACpC,OAAO,EAAE,gBAAgB,EAAE,CAAA;IAC3B,UAAU,EAAE,SAAS,CAAA;CAWtB,CAAA"}
|
package/dist/config.js
CHANGED
|
@@ -6,9 +6,9 @@ export const defaultAuthConfig = {
|
|
|
6
6
|
callbackURLBuilder: (redirectTo, baseURL) => {
|
|
7
7
|
return `${baseURL}/v1/auth/redirect?to=${encodeURIComponent(redirectTo)}`;
|
|
8
8
|
},
|
|
9
|
-
defaultRedirectAfterLogin:
|
|
9
|
+
defaultRedirectAfterLogin: undefined,
|
|
10
10
|
getSessionEndpoint: "/v1/auth/get-session",
|
|
11
11
|
plugins: [],
|
|
12
|
-
signInPath:
|
|
12
|
+
signInPath: undefined,
|
|
13
13
|
tokenStorageKey: "auth-token",
|
|
14
14
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-auth-sync.d.ts","sourceRoot":"","sources":["../../src/core/init-auth-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BpE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 同步版本的认证初始化
|
|
3
|
+
* 可以在应用渲染前调用(非 React hook)
|
|
4
|
+
*/
|
|
5
|
+
export async function initAuthSync(auth) {
|
|
6
|
+
const { authActions, tokenStorage } = auth;
|
|
7
|
+
// 检查 URL 中的 token
|
|
8
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
9
|
+
let tokenFromUrl = urlParams.get("token");
|
|
10
|
+
if (tokenFromUrl) {
|
|
11
|
+
if (decodeURIComponent(tokenFromUrl) === tokenFromUrl) {
|
|
12
|
+
tokenFromUrl = encodeURIComponent(tokenFromUrl);
|
|
13
|
+
}
|
|
14
|
+
// 立即清理 URL 中的 token 参数(避免暴露)
|
|
15
|
+
urlParams.delete("token");
|
|
16
|
+
const newUrl = urlParams.toString()
|
|
17
|
+
? `${window.location.pathname}?${urlParams.toString()}`
|
|
18
|
+
: window.location.pathname;
|
|
19
|
+
window.history.replaceState({}, "", newUrl);
|
|
20
|
+
// 使用 token 获取 session
|
|
21
|
+
await authActions.fetchSessionWithToken(tokenFromUrl);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// 检查 localStorage 中是否有存储的 token
|
|
25
|
+
const storedToken = tokenStorage.get();
|
|
26
|
+
if (storedToken) {
|
|
27
|
+
await authActions.fetchSessionWithToken(storedToken);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// 没有 token,标记为已加载
|
|
31
|
+
await authActions.initialize(null, true);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/core.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare function createAuth(config: AuthConfig): {
|
|
|
35
35
|
setLoading(loading: boolean): void;
|
|
36
36
|
setError(error: string | null): void;
|
|
37
37
|
signIn(provider?: string, redirectTo?: string): Promise<void>;
|
|
38
|
-
signOut(): Promise<void>;
|
|
38
|
+
signOut(redirectTo?: string): Promise<void>;
|
|
39
39
|
updateUser(user: import("./types").SessionUser | null): void;
|
|
40
40
|
getUser(): import("./types").SessionUser | null;
|
|
41
41
|
};
|
package/dist/init.d.ts
CHANGED
|
@@ -8,15 +8,17 @@ import type { AuthConfig } from "./config";
|
|
|
8
8
|
*
|
|
9
9
|
* @param config - 认证配置
|
|
10
10
|
* @param config.baseURL - Better Auth API 基础 URL
|
|
11
|
-
* @param config.defaultRedirectAfterLogin - 登录后默认跳转地址,默认为 "/explore"
|
|
12
11
|
* @param config.plugins - Better Auth 插件列表,如果不传则使用默认的 organizationClient
|
|
13
|
-
* @param config.signInPath - 登录页面路径,默认为 "/sign-in"
|
|
14
12
|
* @param config.tokenStorageKey - Token 存储的 localStorage key,默认为 "auth-token"
|
|
13
|
+
* @param config.defaultRedirectAfterLogin - (已废弃) 建议在 SignInPage 组件中通过 redirectUrl prop 传入
|
|
14
|
+
* @param config.signInPath - (已废弃) 建议在 ProtectedRoute 组件中通过 onUnauthorized 回调处理导航
|
|
15
15
|
*/
|
|
16
16
|
export declare function initAuth(config: {
|
|
17
17
|
baseURL: string;
|
|
18
|
+
/** @deprecated 建议在 SignInPage 组件中通过 redirectUrl prop 传入 */
|
|
18
19
|
defaultRedirectAfterLogin?: string;
|
|
19
20
|
plugins?: AuthConfig["plugins"];
|
|
21
|
+
/** @deprecated 建议在 ProtectedRoute 组件中通过 onUnauthorized 回调处理导航 */
|
|
20
22
|
signInPath?: string;
|
|
21
23
|
tokenStorageKey?: string;
|
|
22
24
|
}): {
|
|
@@ -52,7 +54,7 @@ export declare function initAuth(config: {
|
|
|
52
54
|
setLoading(loading: boolean): void;
|
|
53
55
|
setError(error: string | null): void;
|
|
54
56
|
signIn(provider?: string, redirectTo?: string): Promise<void>;
|
|
55
|
-
signOut(): Promise<void>;
|
|
57
|
+
signOut(redirectTo?: string): Promise<void>;
|
|
56
58
|
updateUser(user: import("./types").SessionUser | null): void;
|
|
57
59
|
getUser(): import("./types").SessionUser | null;
|
|
58
60
|
};
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,yBAAyB,CAAC,EAAE,MAAM,CAAA;IAClC,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAG1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,2DAA2D;IAC3D,yBAAyB,CAAC,EAAE,MAAM,CAAA;IAClC,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC/B,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,eAAe,C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- 认证配置
|
|
11
11
|
* @param config.baseURL - Better Auth API 基础 URL
|
|
12
|
-
* @param config.defaultRedirectAfterLogin - 登录后默认跳转地址,默认为 "/explore"
|
|
13
12
|
* @param config.plugins - Better Auth 插件列表,如果不传则使用默认的 organizationClient
|
|
14
|
-
* @param config.signInPath - 登录页面路径,默认为 "/sign-in"
|
|
15
13
|
* @param config.tokenStorageKey - Token 存储的 localStorage key,默认为 "auth-token"
|
|
14
|
+
* @param config.defaultRedirectAfterLogin - (已废弃) 建议在 SignInPage 组件中通过 redirectUrl prop 传入
|
|
15
|
+
* @param config.signInPath - (已废弃) 建议在 ProtectedRoute 组件中通过 onUnauthorized 回调处理导航
|
|
16
16
|
*/
|
|
17
17
|
export function initAuth(config) {
|
|
18
18
|
const { baseURL, tokenStorageKey, defaultRedirectAfterLogin, signInPath, plugins } = config;
|
|
@@ -23,7 +23,7 @@ export function initAuth(config) {
|
|
|
23
23
|
baseURL,
|
|
24
24
|
plugins: finalPlugins,
|
|
25
25
|
tokenStorageKey: tokenStorageKey || "auth-token",
|
|
26
|
-
defaultRedirectAfterLogin
|
|
27
|
-
signInPath
|
|
26
|
+
defaultRedirectAfterLogin,
|
|
27
|
+
signInPath,
|
|
28
28
|
});
|
|
29
29
|
}
|
package/dist/store/actions.d.ts
CHANGED
|
@@ -53,8 +53,10 @@ export declare function createAuthActions(authStore: Observable<AuthState>, toke
|
|
|
53
53
|
signIn(provider?: string, redirectTo?: string): Promise<void>;
|
|
54
54
|
/**
|
|
55
55
|
* 登出
|
|
56
|
+
*
|
|
57
|
+
* @param redirectTo 登出后的重定向地址(可选),如果不提供则不执行自动跳转
|
|
56
58
|
*/
|
|
57
|
-
signOut(): Promise<void>;
|
|
59
|
+
signOut(redirectTo?: string): Promise<void>;
|
|
58
60
|
/**
|
|
59
61
|
* 更新用户信息
|
|
60
62
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/store/actions.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CAAA;KACjF,CAAA;IACD,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CAChC;IAcC;;OAEG;qBACoB,WAAW,GAAG,IAAI,YAAY,OAAO;IAe5D;;;;;;;;;;OAUG;iCACgC,MAAM;IAuDzC;;;OAGG;;IASH;;OAEG;wBACiB,OAAO;IAI3B;;OAEG;oBACa,MAAM,GAAG,IAAI;IAI7B;;;;;;OAMG;sBACoB,MAAM,eAA0B,MAAM;IAqC7D;;;;OAIG;yBACwB,MAAM;IAiCjC;;OAEG;qBACc,WAAW,GAAG,IAAI;IAUnC;;OAEG;eACQ,WAAW,GAAG,IAAI;EAIhC;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
|
package/dist/store/actions.js
CHANGED
|
@@ -58,7 +58,7 @@ function extractUserData(sessionData) {
|
|
|
58
58
|
* 创建认证 actions
|
|
59
59
|
*/
|
|
60
60
|
export function createAuthActions(authStore, tokenStorage, config, authClient) {
|
|
61
|
-
const { baseURL, defaultRedirectAfterLogin
|
|
61
|
+
const { baseURL, defaultRedirectAfterLogin, getSessionEndpoint = "/v1/auth/get-session", callbackURLBuilder, } = config;
|
|
62
62
|
const buildCallbackURL = callbackURLBuilder || ((redirectTo, baseURL) => {
|
|
63
63
|
return `${baseURL}/v1/auth/redirect?to=${encodeURIComponent(redirectTo)}`;
|
|
64
64
|
});
|
|
@@ -149,6 +149,8 @@ export function createAuthActions(authStore, tokenStorage, config, authClient) {
|
|
|
149
149
|
handleUnauthorized() {
|
|
150
150
|
authStore.user.set(null);
|
|
151
151
|
authStore.isAuthenticated.set(false);
|
|
152
|
+
authStore.isLoaded.set(true);
|
|
153
|
+
authStore.loading.set(false);
|
|
152
154
|
tokenStorage.clear();
|
|
153
155
|
},
|
|
154
156
|
/**
|
|
@@ -186,7 +188,9 @@ export function createAuthActions(authStore, tokenStorage, config, authClient) {
|
|
|
186
188
|
? redirectTo.startsWith("http")
|
|
187
189
|
? redirectTo
|
|
188
190
|
: `${window.location.origin}${redirectTo}`
|
|
189
|
-
:
|
|
191
|
+
: defaultRedirectAfterLogin
|
|
192
|
+
? `${window.location.origin}${defaultRedirectAfterLogin}`
|
|
193
|
+
: `${window.location.origin}/explore`;
|
|
190
194
|
const callbackURL = buildCallbackURL(finalRedirectTo, baseURL);
|
|
191
195
|
await authClient.signIn.social({
|
|
192
196
|
provider,
|
|
@@ -202,8 +206,10 @@ export function createAuthActions(authStore, tokenStorage, config, authClient) {
|
|
|
202
206
|
},
|
|
203
207
|
/**
|
|
204
208
|
* 登出
|
|
209
|
+
*
|
|
210
|
+
* @param redirectTo 登出后的重定向地址(可选),如果不提供则不执行自动跳转
|
|
205
211
|
*/
|
|
206
|
-
async signOut() {
|
|
212
|
+
async signOut(redirectTo) {
|
|
207
213
|
// 防止重复调用
|
|
208
214
|
if (authStore.loading.get()) {
|
|
209
215
|
return;
|
|
@@ -216,8 +222,10 @@ export function createAuthActions(authStore, tokenStorage, config, authClient) {
|
|
|
216
222
|
authStore.user.set(null);
|
|
217
223
|
authStore.isAuthenticated.set(false);
|
|
218
224
|
tokenStorage.clear();
|
|
219
|
-
//
|
|
220
|
-
|
|
225
|
+
// 如果提供了重定向地址,则执行跳转
|
|
226
|
+
if (redirectTo) {
|
|
227
|
+
window.location.href = redirectTo;
|
|
228
|
+
}
|
|
221
229
|
}
|
|
222
230
|
catch (error) {
|
|
223
231
|
const message = error instanceof Error ? error.message : "Sign out failed";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@choiceform/shared-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Shared authentication package for Choiceform projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,8 +49,7 @@
|
|
|
49
49
|
"@legendapp/state": "v3.0.0-beta.26",
|
|
50
50
|
"better-auth": "^1.3.8",
|
|
51
51
|
"react": ">=18.0.0",
|
|
52
|
-
"react-dom": ">=18.0.0"
|
|
53
|
-
"react-router": "^7.6.3"
|
|
52
|
+
"react-dom": ">=18.0.0"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"@types/react": "18.2.71",
|