@krak-stack/auth 0.1.34 → 0.1.36

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.
@@ -12,8 +12,24 @@ const blockedRequestHeaders = [
12
12
  "upgrade",
13
13
  "cdn-loop",
14
14
  ];
15
+ const parseUrl = (value) => {
16
+ if (!value)
17
+ return null;
18
+ try {
19
+ return new URL(value);
20
+ }
21
+ catch {
22
+ return null;
23
+ }
24
+ };
25
+ const forwardedUrl = (request) => {
26
+ return (parseUrl(request.headers.get("origin")) ??
27
+ parseUrl(request.headers.get("referer")) ??
28
+ new URL(request.url));
29
+ };
15
30
  const proxyHeaders = (request) => {
16
31
  const headers = new Headers(request.headers);
32
+ const url = forwardedUrl(request);
17
33
  for (const header of blockedRequestHeaders)
18
34
  headers.delete(header);
19
35
  for (const header of Array.from(headers.keys())) {
@@ -21,6 +37,8 @@ const proxyHeaders = (request) => {
21
37
  headers.delete(header);
22
38
  }
23
39
  }
40
+ headers.set("x-forwarded-host", url.host);
41
+ headers.set("x-forwarded-proto", url.protocol.replace(":", ""));
24
42
  return headers;
25
43
  };
26
44
  export const proxyAuthRequest = (request, baseUrl) => {
@@ -94,6 +94,7 @@ export declare const ServerCreateDomainPayload: Schema.Struct<{
94
94
  readonly managed: Schema.Boolean;
95
95
  }>;
96
96
  export declare const ServerUpdateDomainPayload: Schema.Struct<{
97
+ readonly hostname: Schema.NonEmptyString;
97
98
  readonly rootHostname: Schema.NonEmptyString;
98
99
  readonly projectId: Schema.optional<Schema.NullOr<Schema.String>>;
99
100
  readonly organizationId: Schema.optional<Schema.NullOr<Schema.String>>;
@@ -130,6 +130,7 @@ export const ServerCreateDomainPayload = Schema.Struct({
130
130
  ],
131
131
  });
132
132
  export const ServerUpdateDomainPayload = Schema.Struct({
133
+ hostname: Schema.NonEmptyString,
133
134
  rootHostname: Schema.NonEmptyString,
134
135
  projectId: Schema.optional(Schema.NullOr(Schema.String)),
135
136
  organizationId: Schema.optional(Schema.NullOr(Schema.String)),
@@ -140,6 +141,7 @@ export const ServerUpdateDomainPayload = Schema.Struct({
140
141
  description: "Payload used by administrators to update an auth hostname's trust target, ownership links, and Cloudflare management mode.",
141
142
  examples: [
142
143
  {
144
+ hostname: "auth.institute.example.com",
143
145
  rootHostname: "institute.example.com",
144
146
  projectId: "kokobi",
145
147
  organizationId: "org_1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/auth",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "description": "Effect HttpApi clients and schemas for KrakStack Auth.",
5
5
  "license": "MIT",
6
6
  "files": [