@hono/auth-js 1.0.17 → 1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @hono/auth-js
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1324](https://github.com/honojs/middleware/pull/1324) [`d89fed7eecfa151c18b0a8cf95dae1dfe83dfec2`](https://github.com/honojs/middleware/commit/d89fed7eecfa151c18b0a8cf95dae1dfe83dfec2) Thanks [@jamestalmage](https://github.com/jamestalmage)! - Allow async authjs Config
8
+
3
9
  ## 1.0.17
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -109,7 +109,7 @@ function verifyAuth() {
109
109
  }
110
110
  function initAuthConfig(cb) {
111
111
  return async (c, next) => {
112
- const config = cb(c);
112
+ const config = await cb(c);
113
113
  c.set("authConfig", config);
114
114
  await next();
115
115
  };
package/dist/index.d.cts CHANGED
@@ -23,7 +23,7 @@ type AuthUser = {
23
23
  };
24
24
  interface AuthConfig extends Omit<AuthConfig$1, 'raw'> {
25
25
  }
26
- type ConfigHandler = (c: Context) => AuthConfig;
26
+ type ConfigHandler = (c: Context) => AuthConfig | Promise<AuthConfig>;
27
27
  declare function setEnvDefaults(env: AuthEnv, config: AuthConfig): void;
28
28
  declare function reqWithEnvUrl(req: Request, authUrl?: string): Request;
29
29
  declare function getAuthUser(c: Context): Promise<AuthUser | null>;
package/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ type AuthUser = {
23
23
  };
24
24
  interface AuthConfig extends Omit<AuthConfig$1, 'raw'> {
25
25
  }
26
- type ConfigHandler = (c: Context) => AuthConfig;
26
+ type ConfigHandler = (c: Context) => AuthConfig | Promise<AuthConfig>;
27
27
  declare function setEnvDefaults(env: AuthEnv, config: AuthConfig): void;
28
28
  declare function reqWithEnvUrl(req: Request, authUrl?: string): Request;
29
29
  declare function getAuthUser(c: Context): Promise<AuthUser | null>;
package/dist/index.js CHANGED
@@ -80,7 +80,7 @@ function verifyAuth() {
80
80
  }
81
81
  function initAuthConfig(cb) {
82
82
  return async (c, next) => {
83
- const config = cb(c);
83
+ const config = await cb(c);
84
84
  c.set("authConfig", config);
85
85
  await next();
86
86
  };
package/dist/react.cjs CHANGED
@@ -84,8 +84,12 @@ function useOnline() {
84
84
  (0, import_react.useEffect)(() => {
85
85
  const abortController = new AbortController();
86
86
  const { signal } = abortController;
87
- const setOnline = () => setIsOnline(true);
88
- const setOffline = () => setIsOnline(false);
87
+ const setOnline = () => {
88
+ setIsOnline(true);
89
+ };
90
+ const setOffline = () => {
91
+ setIsOnline(false);
92
+ };
89
93
  window.addEventListener("online", setOnline, { signal });
90
94
  window.addEventListener("offline", setOffline, { signal });
91
95
  return () => {
@@ -197,7 +201,9 @@ function useVisibilityChangeEventListener(authConfig, refetchOnWindowFocus) {
197
201
  document.addEventListener("visibilitychange", handleVisibilityChange, {
198
202
  signal: abortController.signal
199
203
  });
200
- return () => abortController.abort();
204
+ return () => {
205
+ abortController.abort();
206
+ };
201
207
  }, [refetchOnWindowFocus]);
202
208
  }
203
209
  function useRefetchInterval(authConfig, refetchInterval, shouldRefetch) {
@@ -208,7 +214,9 @@ function useRefetchInterval(authConfig, refetchInterval, shouldRefetch) {
208
214
  authConfig.fetchSession({ event: "poll" });
209
215
  }
210
216
  }, refetchInterval * 1e3);
211
- return () => clearInterval(intervalId);
217
+ return () => {
218
+ clearInterval(intervalId);
219
+ };
212
220
  }
213
221
  }, [refetchInterval, shouldRefetch]);
214
222
  }
package/dist/react.js CHANGED
@@ -41,8 +41,12 @@ function useOnline() {
41
41
  useEffect(() => {
42
42
  const abortController = new AbortController();
43
43
  const { signal } = abortController;
44
- const setOnline = () => setIsOnline(true);
45
- const setOffline = () => setIsOnline(false);
44
+ const setOnline = () => {
45
+ setIsOnline(true);
46
+ };
47
+ const setOffline = () => {
48
+ setIsOnline(false);
49
+ };
46
50
  window.addEventListener("online", setOnline, { signal });
47
51
  window.addEventListener("offline", setOffline, { signal });
48
52
  return () => {
@@ -154,7 +158,9 @@ function useVisibilityChangeEventListener(authConfig, refetchOnWindowFocus) {
154
158
  document.addEventListener("visibilitychange", handleVisibilityChange, {
155
159
  signal: abortController.signal
156
160
  });
157
- return () => abortController.abort();
161
+ return () => {
162
+ abortController.abort();
163
+ };
158
164
  }, [refetchOnWindowFocus]);
159
165
  }
160
166
  function useRefetchInterval(authConfig, refetchInterval, shouldRefetch) {
@@ -165,7 +171,9 @@ function useRefetchInterval(authConfig, refetchInterval, shouldRefetch) {
165
171
  authConfig.fetchSession({ event: "poll" });
166
172
  }
167
173
  }, refetchInterval * 1e3);
168
- return () => clearInterval(intervalId);
174
+ return () => {
175
+ clearInterval(intervalId);
176
+ };
169
177
  }
170
178
  }, [refetchInterval, shouldRefetch]);
171
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono/auth-js",
3
- "version": "1.0.17",
3
+ "version": "1.1.0",
4
4
  "description": "A third-party Auth js middleware for Hono",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -41,7 +41,8 @@
41
41
  "prepack": "yarn build",
42
42
  "publint": "attw --pack --profile node16 && publint",
43
43
  "typecheck": "tsc -b tsconfig.json",
44
- "test": "vitest"
44
+ "test": "vitest",
45
+ "version:jsr": "yarn version:set $npm_package_version"
45
46
  },
46
47
  "license": "MIT",
47
48
  "publishConfig": {
@@ -55,19 +56,20 @@
55
56
  },
56
57
  "homepage": "https://github.com/honojs/middleware",
57
58
  "peerDependencies": {
58
- "@auth/core": "0.*",
59
- "hono": ">=3.*",
59
+ "@auth/core": ">=0.35.0",
60
+ "hono": ">=3.0.0",
60
61
  "react": "^18 || ^19 || ^19.0.0-rc"
61
62
  },
62
63
  "devDependencies": {
63
64
  "@arethetypeswrong/cli": "^0.17.4",
64
65
  "@auth/core": "^0.35.3",
65
66
  "@types/react": "^18",
67
+ "hono": "^4.8.4",
66
68
  "publint": "^0.3.9",
67
69
  "react": "^18.2.0",
68
70
  "tsup": "^8.4.0",
69
71
  "typescript": "^5.8.2",
70
- "vitest": "^3.0.8"
72
+ "vitest": "^3.2.4"
71
73
  },
72
74
  "engines": {
73
75
  "node": ">=18.4.0"