@choiceform/shared-auth 0.1.16 → 0.1.17

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.
@@ -9,9 +9,6 @@ export declare function initializeAuth(auth: AuthInstance): Promise<boolean>;
9
9
  /**
10
10
  * 认证初始化 hook
11
11
  * 在应用启动时检查 URL 中的 token 或 localStorage 中的 token
12
- *
13
- * 注意:在 React Router Framework 模式下,应使用 initializeAuth 函数
14
- * 在 clientLoader 中调用,而不是使用此 hook
15
12
  */
16
13
  export declare function useAuthInit(auth: AuthInstance): void;
17
14
  //# sourceMappingURL=use-auth-init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-auth-init.d.ts","sourceRoot":"","sources":["../../src/hooks/use-auth-init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAoDzE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,QAQ7C"}
1
+ {"version":3,"file":"use-auth-init.d.ts","sourceRoot":"","sources":["../../src/hooks/use-auth-init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAiDzE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,QAQ7C"}
@@ -15,12 +15,8 @@ export async function initializeAuth(auth) {
15
15
  const urlParams = new URLSearchParams(window.location.search);
16
16
  let tokenFromUrl = urlParams.get("token");
17
17
  if (tokenFromUrl) {
18
- // URL 中的 token 可能被编码,尝试解码
19
- try {
20
- tokenFromUrl = decodeURIComponent(tokenFromUrl);
21
- }
22
- catch {
23
- // 解码失败,使用原值
18
+ if (decodeURIComponent(tokenFromUrl) === tokenFromUrl) {
19
+ tokenFromUrl = encodeURIComponent(tokenFromUrl);
24
20
  }
25
21
  // 立即清理 URL 中的 token 参数(避免暴露)
26
22
  urlParams.delete("token");
@@ -57,9 +53,6 @@ export async function initializeAuth(auth) {
57
53
  /**
58
54
  * 认证初始化 hook
59
55
  * 在应用启动时检查 URL 中的 token 或 localStorage 中的 token
60
- *
61
- * 注意:在 React Router Framework 模式下,应使用 initializeAuth 函数
62
- * 在 clientLoader 中调用,而不是使用此 hook
63
56
  */
64
57
  export function useAuthInit(auth) {
65
58
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choiceform/shared-auth",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "Shared authentication package for Choiceform projects",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",