@hono/auth-js
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -14,2 +14,3 @@ import { AuthConfig as AuthConfig$1 } from '@auth/core'; | ||
type AuthEnv = { | ||
AUTH_URL?: string; | ||
AUTH_SECRET: string; | ||
@@ -16,0 +17,0 @@ AUTH_REDIRECT_PROXY_URL?: string; |
@@ -64,4 +64,5 @@ "use strict"; | ||
const config = c.get("authConfig"); | ||
setEnvDefaults((0, import_adapter.env)(c), config); | ||
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; | ||
let ctxEnv = (0, import_adapter.env)(c); | ||
setEnvDefaults(ctxEnv, config); | ||
const origin = ctxEnv.AUTH_URL ? new URL(ctxEnv.AUTH_URL).origin : new URL(c.req.url).origin; | ||
const request = new Request(`${origin}${config.basePath}/session`, { | ||
@@ -111,7 +112,8 @@ headers: { cookie: c.req.header("cookie") ?? "" } | ||
const config = c.get("authConfig"); | ||
setEnvDefaults((0, import_adapter.env)(c), config); | ||
let ctxEnv = (0, import_adapter.env)(c); | ||
setEnvDefaults(ctxEnv, config); | ||
if (!config.secret) { | ||
throw new import_http_exception.HTTPException(500, { message: "Missing AUTH_SECRET" }); | ||
} | ||
const res = await (0, import_core.Auth)(reqWithEnvUrl(c.req.raw, (0, import_adapter.env)(c)["AUTH_URL"]), config); | ||
const res = await (0, import_core.Auth)(reqWithEnvUrl(c.req.raw, ctxEnv.AUTH_URL), config); | ||
return new Response(res.body, res); | ||
@@ -118,0 +120,0 @@ }; |
@@ -135,9 +135,2 @@ import { BuiltInProviderType, ProviderType, RedirectableProviderType } from '@auth/core/providers'; | ||
declare function getSession(params?: GetSessionParams): Promise<Session | null>; | ||
/** | ||
* Returns the current Cross-Site Request Forgery Token (CSRF Token) | ||
* required to make requests that changes state. (e.g. signing in or out, or updating the session). | ||
* | ||
* [CSRF Prevention: Double Submit Cookie](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#double-submit-cookie) | ||
* @internal | ||
*/ | ||
declare function getCsrfToken(): Promise<string>; | ||
@@ -144,0 +137,0 @@ type ProvidersType = Record<LiteralUnion<BuiltInProviderType>, ClientSafeProvider>; |
@@ -118,4 +118,4 @@ "use strict"; | ||
_config = { | ||
baseUrl: parseUrl(window.location.origin).origin, | ||
basePath: parseUrl(window.location.origin).path, | ||
baseUrl: typeof window !== "undefined" ? parseUrl(window.location.origin).origin : "", | ||
basePath: typeof window !== "undefined" ? parseUrl(window.location.origin).path : "/api/auth", | ||
credentials: "same-origin", | ||
@@ -122,0 +122,0 @@ _lastSync: 0, |
{ | ||
"name": "@hono/auth-js", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "A third-party Auth js middleware for Hono", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
51242
1175