@hono/auth-js 1.0.9 → 1.0.11

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.js CHANGED
@@ -34,14 +34,13 @@ var import_http_exception = require("hono/http-exception");
34
34
  var import_core2 = require("@auth/core");
35
35
  function setEnvDefaults(env2, config) {
36
36
  config.secret ??= env2.AUTH_SECRET;
37
- config.basePath ||= "/api/auth";
38
37
  (0, import_core2.setEnvDefaults)(env2, config);
39
38
  }
40
- async function cloneRequest(input, request) {
39
+ async function cloneRequest(input, request, headers) {
41
40
  if ((0, import_adapter.getRuntimeKey)() === "bun") {
42
41
  return new Request(input, {
43
42
  method: request.method,
44
- headers: new Headers(request.headers),
43
+ headers: headers ?? new Headers(request.headers),
45
44
  body: request.method === "GET" || request.method === "HEAD" ? void 0 : await request.blob(),
46
45
  // @ts-ignore: TS2353
47
46
  referrer: "referrer" in request ? request.referrer : void 0,
@@ -68,8 +67,9 @@ async function reqWithEnvUrl(req, authUrl) {
68
67
  return cloneRequest(reqUrlObj.href, req);
69
68
  } else {
70
69
  const url = new URL(req.url);
71
- const proto = req.headers.get("x-forwarded-proto");
72
- const host = req.headers.get("x-forwarded-host") ?? req.headers.get("host");
70
+ const headers = new Headers(req.headers);
71
+ const proto = headers.get("x-forwarded-proto");
72
+ const host = headers.get("x-forwarded-host") ?? headers.get("host");
73
73
  if (proto != null)
74
74
  url.protocol = proto.endsWith(":") ? proto : proto + ":";
75
75
  if (host != null) {
@@ -79,11 +79,11 @@ async function reqWithEnvUrl(req, authUrl) {
79
79
  url.port = portMatch[1];
80
80
  else
81
81
  url.port = "";
82
- req.headers.delete("x-forwarded-host");
83
- req.headers.delete("Host");
84
- req.headers.set("Host", host);
82
+ headers.delete("x-forwarded-host");
83
+ headers.delete("Host");
84
+ headers.set("Host", host);
85
85
  }
86
- return cloneRequest(url.href, req);
86
+ return cloneRequest(url.href, req, headers);
87
87
  }
88
88
  }
89
89
  async function getAuthUser(c) {
package/dist/index.mjs CHANGED
@@ -5,14 +5,13 @@ import { HTTPException } from "hono/http-exception";
5
5
  import { setEnvDefaults as coreSetEnvDefaults } from "@auth/core";
6
6
  function setEnvDefaults(env2, config) {
7
7
  config.secret ??= env2.AUTH_SECRET;
8
- config.basePath ||= "/api/auth";
9
8
  coreSetEnvDefaults(env2, config);
10
9
  }
11
- async function cloneRequest(input, request) {
10
+ async function cloneRequest(input, request, headers) {
12
11
  if (getRuntimeKey() === "bun") {
13
12
  return new Request(input, {
14
13
  method: request.method,
15
- headers: new Headers(request.headers),
14
+ headers: headers ?? new Headers(request.headers),
16
15
  body: request.method === "GET" || request.method === "HEAD" ? void 0 : await request.blob(),
17
16
  // @ts-ignore: TS2353
18
17
  referrer: "referrer" in request ? request.referrer : void 0,
@@ -39,8 +38,9 @@ async function reqWithEnvUrl(req, authUrl) {
39
38
  return cloneRequest(reqUrlObj.href, req);
40
39
  } else {
41
40
  const url = new URL(req.url);
42
- const proto = req.headers.get("x-forwarded-proto");
43
- const host = req.headers.get("x-forwarded-host") ?? req.headers.get("host");
41
+ const headers = new Headers(req.headers);
42
+ const proto = headers.get("x-forwarded-proto");
43
+ const host = headers.get("x-forwarded-host") ?? headers.get("host");
44
44
  if (proto != null)
45
45
  url.protocol = proto.endsWith(":") ? proto : proto + ":";
46
46
  if (host != null) {
@@ -50,11 +50,11 @@ async function reqWithEnvUrl(req, authUrl) {
50
50
  url.port = portMatch[1];
51
51
  else
52
52
  url.port = "";
53
- req.headers.delete("x-forwarded-host");
54
- req.headers.delete("Host");
55
- req.headers.set("Host", host);
53
+ headers.delete("x-forwarded-host");
54
+ headers.delete("Host");
55
+ headers.set("Host", host);
56
56
  }
57
- return cloneRequest(url.href, req);
57
+ return cloneRequest(url.href, req, headers);
58
58
  }
59
59
  }
60
60
  async function getAuthUser(c) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono/auth-js",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "A third-party Auth js middleware for Hono",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -57,7 +57,7 @@
57
57
  "react": ">=18"
58
58
  },
59
59
  "devDependencies": {
60
- "@auth/core": "^0.30.0",
60
+ "@auth/core": "^0.35.3",
61
61
  "@types/react": "^18",
62
62
  "hono": "^3.11.7",
63
63
  "jest": "^29.7.0",