@hono/auth-js 1.0.6 → 1.0.7

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 CHANGED
@@ -11,6 +11,7 @@ declare module 'hono' {
11
11
  }
12
12
  }
13
13
  type AuthEnv = {
14
+ AUTH_URL?: string;
14
15
  AUTH_SECRET: string;
15
16
  AUTH_REDIRECT_PROXY_URL?: string;
16
17
  [key: string]: string | undefined;
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ declare module 'hono' {
11
11
  }
12
12
  }
13
13
  type AuthEnv = {
14
+ AUTH_URL?: string;
14
15
  AUTH_SECRET: string;
15
16
  AUTH_REDIRECT_PROXY_URL?: string;
16
17
  [key: string]: string | undefined;
package/dist/index.js CHANGED
@@ -61,8 +61,9 @@ function setEnvDefaults(env2, config) {
61
61
  }
62
62
  async function getAuthUser(c) {
63
63
  const config = c.get("authConfig");
64
- setEnvDefaults((0, import_adapter.env)(c), config);
65
- const origin = (0, import_adapter.env)(c)["AUTH_URL"] ? new URL((0, import_adapter.env)(c)["AUTH_URL"]).origin : new URL(c.req.url).origin;
64
+ let ctxEnv = (0, import_adapter.env)(c);
65
+ setEnvDefaults(ctxEnv, config);
66
+ const origin = ctxEnv.AUTH_URL ? new URL(ctxEnv.AUTH_URL).origin : new URL(c.req.url).origin;
66
67
  const request = new Request(`${origin}${config.basePath}/session`, {
67
68
  headers: { cookie: c.req.header("cookie") ?? "" }
68
69
  });
@@ -107,11 +108,12 @@ function initAuthConfig(cb) {
107
108
  function authHandler() {
108
109
  return async (c) => {
109
110
  const config = c.get("authConfig");
110
- setEnvDefaults((0, import_adapter.env)(c), config);
111
+ let ctxEnv = (0, import_adapter.env)(c);
112
+ setEnvDefaults(ctxEnv, config);
111
113
  if (!config.secret) {
112
114
  throw new import_http_exception.HTTPException(500, { message: "Missing AUTH_SECRET" });
113
115
  }
114
- const res = await (0, import_core.Auth)(reqWithEnvUrl(c.req.raw, (0, import_adapter.env)(c)["AUTH_URL"]), config);
116
+ const res = await (0, import_core.Auth)(reqWithEnvUrl(c.req.raw, ctxEnv.AUTH_URL), config);
115
117
  return new Response(res.body, res);
116
118
  };
117
119
  }
package/dist/index.mjs CHANGED
@@ -33,8 +33,9 @@ function setEnvDefaults(env2, config) {
33
33
  }
34
34
  async function getAuthUser(c) {
35
35
  const config = c.get("authConfig");
36
- setEnvDefaults(env(c), config);
37
- const origin = env(c)["AUTH_URL"] ? new URL(env(c)["AUTH_URL"]).origin : new URL(c.req.url).origin;
36
+ let ctxEnv = env(c);
37
+ setEnvDefaults(ctxEnv, config);
38
+ const origin = ctxEnv.AUTH_URL ? new URL(ctxEnv.AUTH_URL).origin : new URL(c.req.url).origin;
38
39
  const request = new Request(`${origin}${config.basePath}/session`, {
39
40
  headers: { cookie: c.req.header("cookie") ?? "" }
40
41
  });
@@ -79,11 +80,12 @@ function initAuthConfig(cb) {
79
80
  function authHandler() {
80
81
  return async (c) => {
81
82
  const config = c.get("authConfig");
82
- setEnvDefaults(env(c), config);
83
+ let ctxEnv = env(c);
84
+ setEnvDefaults(ctxEnv, config);
83
85
  if (!config.secret) {
84
86
  throw new HTTPException(500, { message: "Missing AUTH_SECRET" });
85
87
  }
86
- const res = await Auth(reqWithEnvUrl(c.req.raw, env(c)["AUTH_URL"]), config);
88
+ const res = await Auth(reqWithEnvUrl(c.req.raw, ctxEnv.AUTH_URL), config);
87
89
  return new Response(res.body, res);
88
90
  };
89
91
  }
package/dist/react.d.mts CHANGED
@@ -132,13 +132,6 @@ interface GetSessionParams {
132
132
  broadcast?: boolean;
133
133
  }
134
134
  declare function getSession(params?: GetSessionParams): Promise<Session | null>;
135
- /**
136
- * Returns the current Cross-Site Request Forgery Token (CSRF Token)
137
- * required to make requests that changes state. (e.g. signing in or out, or updating the session).
138
- *
139
- * [CSRF Prevention: Double Submit Cookie](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie)
140
- * @internal
141
- */
142
135
  declare function getCsrfToken(): Promise<string>;
143
136
  type ProvidersType = Record<LiteralUnion<BuiltInProviderType>, ClientSafeProvider>;
144
137
  declare function getProviders(): Promise<ProvidersType | null>;
package/dist/react.d.ts CHANGED
@@ -132,13 +132,6 @@ interface GetSessionParams {
132
132
  broadcast?: boolean;
133
133
  }
134
134
  declare function getSession(params?: GetSessionParams): Promise<Session | null>;
135
- /**
136
- * Returns the current Cross-Site Request Forgery Token (CSRF Token)
137
- * required to make requests that changes state. (e.g. signing in or out, or updating the session).
138
- *
139
- * [CSRF Prevention: Double Submit Cookie](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie)
140
- * @internal
141
- */
142
135
  declare function getCsrfToken(): Promise<string>;
143
136
  type ProvidersType = Record<LiteralUnion<BuiltInProviderType>, ClientSafeProvider>;
144
137
  declare function getProviders(): Promise<ProvidersType | null>;
package/dist/react.js CHANGED
@@ -115,8 +115,8 @@ function parseUrl(url) {
115
115
  var AuthConfigManager = class _AuthConfigManager {
116
116
  static instance = null;
117
117
  _config = {
118
- baseUrl: parseUrl(window.location.origin).origin,
119
- basePath: parseUrl(window.location.origin).path,
118
+ baseUrl: typeof window !== "undefined" ? parseUrl(window.location.origin).origin : "",
119
+ basePath: typeof window !== "undefined" ? parseUrl(window.location.origin).path : "/api/auth",
120
120
  credentials: "same-origin",
121
121
  _lastSync: 0,
122
122
  _session: void 0,
package/dist/react.mjs CHANGED
@@ -73,8 +73,8 @@ function parseUrl(url) {
73
73
  var AuthConfigManager = class _AuthConfigManager {
74
74
  static instance = null;
75
75
  _config = {
76
- baseUrl: parseUrl(window.location.origin).origin,
77
- basePath: parseUrl(window.location.origin).path,
76
+ baseUrl: typeof window !== "undefined" ? parseUrl(window.location.origin).origin : "",
77
+ basePath: typeof window !== "undefined" ? parseUrl(window.location.origin).path : "/api/auth",
78
78
  credentials: "same-origin",
79
79
  _lastSync: 0,
80
80
  _session: void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono/auth-js",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "A third-party Auth js middleware for Hono",
5
5
  "main": "dist/index.js",
6
6
  "exports": {