@choiceform/shared-auth 0.1.0

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.
Files changed (44) hide show
  1. package/README.md +452 -0
  2. package/dist/components/auth-sync.d.ts +9 -0
  3. package/dist/components/auth-sync.d.ts.map +1 -0
  4. package/dist/components/auth-sync.js +60 -0
  5. package/dist/components/protected-route.d.ts +18 -0
  6. package/dist/components/protected-route.d.ts.map +1 -0
  7. package/dist/components/protected-route.js +28 -0
  8. package/dist/components/sign-in-page.d.ts +49 -0
  9. package/dist/components/sign-in-page.d.ts.map +1 -0
  10. package/dist/components/sign-in-page.js +33 -0
  11. package/dist/config.d.ts +50 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +14 -0
  14. package/dist/core.d.ts +2162 -0
  15. package/dist/core.d.ts.map +1 -0
  16. package/dist/core.js +37 -0
  17. package/dist/hooks/use-auth-init.d.ts +7 -0
  18. package/dist/hooks/use-auth-init.d.ts.map +1 -0
  19. package/dist/hooks/use-auth-init.js +41 -0
  20. package/dist/index.d.ts +22 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +24 -0
  23. package/dist/init.d.ts +2167 -0
  24. package/dist/init.d.ts.map +1 -0
  25. package/dist/init.js +17 -0
  26. package/dist/lib/auth-client.d.ts +2120 -0
  27. package/dist/lib/auth-client.d.ts.map +1 -0
  28. package/dist/lib/auth-client.js +11 -0
  29. package/dist/store/actions.d.ts +60 -0
  30. package/dist/store/actions.d.ts.map +1 -0
  31. package/dist/store/actions.js +234 -0
  32. package/dist/store/computed.d.ts +12 -0
  33. package/dist/store/computed.d.ts.map +1 -0
  34. package/dist/store/computed.js +14 -0
  35. package/dist/store/state.d.ts +16 -0
  36. package/dist/store/state.d.ts.map +1 -0
  37. package/dist/store/state.js +52 -0
  38. package/dist/store/utils.d.ts +103 -0
  39. package/dist/store/utils.d.ts.map +1 -0
  40. package/dist/store/utils.js +198 -0
  41. package/dist/types.d.ts +37 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +4 -0
  44. package/package.json +65 -0
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Better Auth 插件类型
3
+ * 使用更通用的类型定义,兼容 better-auth 的所有插件
4
+ */
5
+ export type BetterAuthPlugin = ReturnType<typeof import("better-auth/client/plugins").adminClient>;
6
+ /**
7
+ * 认证配置接口
8
+ */
9
+ export interface AuthConfig {
10
+ /**
11
+ * Better Auth API 基础 URL
12
+ */
13
+ baseURL: string;
14
+ /**
15
+ * 自定义回调 URL 构建函数
16
+ */
17
+ callbackURLBuilder?: (redirectTo: string, baseURL: string) => string;
18
+ /**
19
+ * OAuth 重定向后的默认跳转地址
20
+ * @default '/explore'
21
+ */
22
+ defaultRedirectAfterLogin?: string;
23
+ /**
24
+ * 获取 session 的端点路径
25
+ * @default '/v1/auth/get-session'
26
+ */
27
+ getSessionEndpoint?: string;
28
+ /**
29
+ * Better Auth 插件列表
30
+ */
31
+ plugins?: BetterAuthPlugin[];
32
+ /**
33
+ * 登录页面的路由路径
34
+ * @default '/sign-in'
35
+ */
36
+ signInPath?: string;
37
+ /**
38
+ * Token 存储的 localStorage key
39
+ * @default 'auth-token'
40
+ */
41
+ tokenStorageKey?: string;
42
+ }
43
+ /**
44
+ * 默认配置
45
+ */
46
+ export declare const defaultAuthConfig: Required<Omit<AuthConfig, "plugins" | "callbackURLBuilder">> & {
47
+ callbackURLBuilder: (redirectTo: string, baseURL: string) => string;
48
+ plugins: BetterAuthPlugin[];
49
+ };
50
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +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;;;OAGG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAA;IAElC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAE5B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,GAAG,oBAAoB,CAAC,CAAC,GAAG;IAC7F,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAA;IACnE,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAW5B,CAAA"}
package/dist/config.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 默认配置
3
+ */
4
+ export const defaultAuthConfig = {
5
+ baseURL: "",
6
+ callbackURLBuilder: (redirectTo, baseURL) => {
7
+ return `${baseURL}/v1/auth/redirect?to=${encodeURIComponent(redirectTo)}`;
8
+ },
9
+ defaultRedirectAfterLogin: "/explore",
10
+ getSessionEndpoint: "/v1/auth/get-session",
11
+ plugins: [],
12
+ signInPath: "/sign-in",
13
+ tokenStorageKey: "auth-token",
14
+ };