@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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -4
- package/dist/index.mjs +6 -4
- package/dist/react.d.mts +0 -7
- package/dist/react.d.ts +0 -7
- package/dist/react.js +2 -2
- package/dist/react.mjs +2 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
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
|
-
|
|
65
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
37
|
-
|
|
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
|
-
|
|
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,
|
|
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,
|