@authhero/proxy 0.8.1 → 0.8.2
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/proxy.cjs +1 -1
- package/dist/proxy.mjs +252 -159
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/proxy.mjs
CHANGED
|
@@ -1944,7 +1944,97 @@ e.object({
|
|
|
1944
1944
|
}).extend(fn.shape).extend({
|
|
1945
1945
|
id: e.string(),
|
|
1946
1946
|
is_control_plane: e.boolean().optional()
|
|
1947
|
-
})
|
|
1947
|
+
});
|
|
1948
|
+
var pn = e.enum([
|
|
1949
|
+
"provision",
|
|
1950
|
+
"seed",
|
|
1951
|
+
"upgrade",
|
|
1952
|
+
"backup",
|
|
1953
|
+
"deprovision"
|
|
1954
|
+
]), mn = e.enum([
|
|
1955
|
+
"pending",
|
|
1956
|
+
"running",
|
|
1957
|
+
"succeeded",
|
|
1958
|
+
"failed",
|
|
1959
|
+
"cancelled"
|
|
1960
|
+
]), hn = e.enum(["inline", "cloudflare-workflows"]);
|
|
1961
|
+
e.object({
|
|
1962
|
+
tenant_id: e.string().max(255).nullable().default(null),
|
|
1963
|
+
rollout_id: e.string().max(255).nullable().optional(),
|
|
1964
|
+
kind: pn,
|
|
1965
|
+
engine: hn,
|
|
1966
|
+
engine_instance_id: e.string().max(100).nullable().optional(),
|
|
1967
|
+
target_worker_version: e.string().max(255).nullable().optional(),
|
|
1968
|
+
target_database_version: e.string().max(255).nullable().optional(),
|
|
1969
|
+
initiated_by: e.string().max(255).nullable().optional()
|
|
1970
|
+
}).extend({
|
|
1971
|
+
id: e.string(),
|
|
1972
|
+
status: mn,
|
|
1973
|
+
current_step: e.string().max(255).nullable().optional(),
|
|
1974
|
+
error: e.string().nullable().optional(),
|
|
1975
|
+
created_at: e.string(),
|
|
1976
|
+
updated_at: e.string(),
|
|
1977
|
+
finished_at: e.string().nullable().optional()
|
|
1978
|
+
}).pick({
|
|
1979
|
+
status: !0,
|
|
1980
|
+
current_step: !0,
|
|
1981
|
+
engine_instance_id: !0,
|
|
1982
|
+
target_worker_version: !0,
|
|
1983
|
+
target_database_version: !0,
|
|
1984
|
+
error: !0,
|
|
1985
|
+
finished_at: !0
|
|
1986
|
+
}).partial();
|
|
1987
|
+
var gn = e.enum([
|
|
1988
|
+
"started",
|
|
1989
|
+
"succeeded",
|
|
1990
|
+
"failed",
|
|
1991
|
+
"retried",
|
|
1992
|
+
"skipped",
|
|
1993
|
+
"reconciled"
|
|
1994
|
+
]);
|
|
1995
|
+
e.object({
|
|
1996
|
+
operation_id: e.string().max(255),
|
|
1997
|
+
step: e.string().max(255),
|
|
1998
|
+
outcome: gn,
|
|
1999
|
+
detail: e.record(e.string(), e.unknown()).nullable().optional(),
|
|
2000
|
+
attempt: e.number().int().min(1).default(1)
|
|
2001
|
+
}).extend({
|
|
2002
|
+
id: e.string(),
|
|
2003
|
+
created_at: e.string()
|
|
2004
|
+
});
|
|
2005
|
+
var _n = e.enum([
|
|
2006
|
+
"upgrade",
|
|
2007
|
+
"reseed",
|
|
2008
|
+
"backup"
|
|
2009
|
+
]), vn = e.enum([
|
|
2010
|
+
"pending",
|
|
2011
|
+
"canary",
|
|
2012
|
+
"rolling",
|
|
2013
|
+
"paused",
|
|
2014
|
+
"done",
|
|
2015
|
+
"failed"
|
|
2016
|
+
]);
|
|
2017
|
+
e.object({
|
|
2018
|
+
kind: _n,
|
|
2019
|
+
target_worker_version: e.string().max(255).nullable().optional(),
|
|
2020
|
+
target_database_version: e.string().max(255).nullable().optional(),
|
|
2021
|
+
wave_size: e.number().int().min(1).default(10),
|
|
2022
|
+
canary_tenant_ids: e.array(e.string()).nullable().optional(),
|
|
2023
|
+
filter: e.record(e.string(), e.unknown()).nullable().optional(),
|
|
2024
|
+
initiated_by: e.string().max(255).nullable().optional()
|
|
2025
|
+
}).extend({
|
|
2026
|
+
id: e.string(),
|
|
2027
|
+
status: vn,
|
|
2028
|
+
created_at: e.string(),
|
|
2029
|
+
updated_at: e.string(),
|
|
2030
|
+
finished_at: e.string().nullable().optional()
|
|
2031
|
+
}).pick({
|
|
2032
|
+
status: !0,
|
|
2033
|
+
wave_size: !0,
|
|
2034
|
+
canary_tenant_ids: !0,
|
|
2035
|
+
filter: !0,
|
|
2036
|
+
finished_at: !0
|
|
2037
|
+
}).partial(), e.object({
|
|
1948
2038
|
access_token: e.string(),
|
|
1949
2039
|
id_token: e.string().optional(),
|
|
1950
2040
|
scope: e.string().optional(),
|
|
@@ -1956,7 +2046,7 @@ e.object({
|
|
|
1956
2046
|
code: e.string(),
|
|
1957
2047
|
state: e.string().optional()
|
|
1958
2048
|
});
|
|
1959
|
-
var
|
|
2049
|
+
var yn = e.object({
|
|
1960
2050
|
button_border_radius: e.number(),
|
|
1961
2051
|
button_border_weight: e.number(),
|
|
1962
2052
|
buttons_style: e.enum([
|
|
@@ -1974,7 +2064,7 @@ var pn = e.object({
|
|
|
1974
2064
|
show_widget_shadow: e.boolean(),
|
|
1975
2065
|
widget_border_weight: e.number(),
|
|
1976
2066
|
widget_corner_radius: e.number()
|
|
1977
|
-
}),
|
|
2067
|
+
}), bn = e.object({
|
|
1978
2068
|
base_focus_color: e.string(),
|
|
1979
2069
|
base_hover_color: e.string(),
|
|
1980
2070
|
body_text: e.string(),
|
|
@@ -2001,7 +2091,7 @@ var pn = e.object({
|
|
|
2001
2091
|
}), A = e.object({
|
|
2002
2092
|
bold: e.boolean(),
|
|
2003
2093
|
size: e.number()
|
|
2004
|
-
}),
|
|
2094
|
+
}), xn = e.object({
|
|
2005
2095
|
body_text: A,
|
|
2006
2096
|
buttons_text: A,
|
|
2007
2097
|
font_url: e.string(),
|
|
@@ -2011,7 +2101,7 @@ var pn = e.object({
|
|
|
2011
2101
|
reference_text_size: e.number(),
|
|
2012
2102
|
subtitle: A,
|
|
2013
2103
|
title: A
|
|
2014
|
-
}),
|
|
2104
|
+
}), Sn = e.object({
|
|
2015
2105
|
background_color: e.string(),
|
|
2016
2106
|
background_image_url: e.string(),
|
|
2017
2107
|
page_layout: e.enum([
|
|
@@ -2024,7 +2114,7 @@ var pn = e.object({
|
|
|
2024
2114
|
"chip",
|
|
2025
2115
|
"none"
|
|
2026
2116
|
]).optional()
|
|
2027
|
-
}),
|
|
2117
|
+
}), Cn = e.object({
|
|
2028
2118
|
header_text_alignment: e.enum([
|
|
2029
2119
|
"center",
|
|
2030
2120
|
"left",
|
|
@@ -2041,39 +2131,39 @@ var pn = e.object({
|
|
|
2041
2131
|
social_buttons_layout: e.enum(["bottom", "top"])
|
|
2042
2132
|
});
|
|
2043
2133
|
e.object({
|
|
2044
|
-
borders:
|
|
2045
|
-
colors:
|
|
2134
|
+
borders: yn,
|
|
2135
|
+
colors: bn,
|
|
2046
2136
|
displayName: e.string(),
|
|
2047
|
-
fonts:
|
|
2048
|
-
page_background:
|
|
2049
|
-
widget:
|
|
2137
|
+
fonts: xn,
|
|
2138
|
+
page_background: Sn,
|
|
2139
|
+
widget: Cn
|
|
2050
2140
|
}).extend({ themeId: e.string() }), e.object({
|
|
2051
2141
|
universal_login_experience: e.enum(["new", "classic"]).default("new"),
|
|
2052
2142
|
identifier_first: e.boolean().default(!0),
|
|
2053
2143
|
password_first: e.boolean().default(!1),
|
|
2054
2144
|
webauthn_platform_first_factor: e.boolean()
|
|
2055
2145
|
});
|
|
2056
|
-
var
|
|
2146
|
+
var wn = e.object({
|
|
2057
2147
|
hosts: e.array(e.string()).optional(),
|
|
2058
2148
|
methods: e.array(e.string()).optional(),
|
|
2059
2149
|
path: e.string().default("/*"),
|
|
2060
2150
|
headers: e.record(e.string(), e.string()).optional(),
|
|
2061
2151
|
query: e.record(e.string(), e.string()).optional()
|
|
2062
|
-
}),
|
|
2152
|
+
}), Tn = e.object({
|
|
2063
2153
|
type: e.string(),
|
|
2064
2154
|
options: e.record(e.string(), e.unknown()).default({})
|
|
2065
2155
|
}), j = e.object({
|
|
2066
2156
|
id: e.string().optional(),
|
|
2067
2157
|
custom_domain_id: e.string(),
|
|
2068
2158
|
priority: e.number().int().default(100),
|
|
2069
|
-
match:
|
|
2070
|
-
handlers: e.array(
|
|
2071
|
-
}),
|
|
2159
|
+
match: wn,
|
|
2160
|
+
handlers: e.array(Tn).min(1)
|
|
2161
|
+
}), En = j.extend({
|
|
2072
2162
|
id: e.string(),
|
|
2073
2163
|
tenant_id: e.string(),
|
|
2074
2164
|
created_at: e.string(),
|
|
2075
2165
|
updated_at: e.string()
|
|
2076
|
-
}),
|
|
2166
|
+
}), Dn = j.partial().omit({
|
|
2077
2167
|
id: !0,
|
|
2078
2168
|
custom_domain_id: !0
|
|
2079
2169
|
});
|
|
@@ -2084,7 +2174,7 @@ e.object({
|
|
|
2084
2174
|
credentials: e.record(e.string(), e.unknown()),
|
|
2085
2175
|
settings: e.object({}).optional()
|
|
2086
2176
|
});
|
|
2087
|
-
var
|
|
2177
|
+
var On = e.enum([
|
|
2088
2178
|
"verify_email",
|
|
2089
2179
|
"verify_email_by_code",
|
|
2090
2180
|
"reset_email",
|
|
@@ -2099,7 +2189,7 @@ var Sn = e.enum([
|
|
|
2099
2189
|
"user_invitation"
|
|
2100
2190
|
]);
|
|
2101
2191
|
e.object({
|
|
2102
|
-
template:
|
|
2192
|
+
template: On,
|
|
2103
2193
|
body: e.string(),
|
|
2104
2194
|
from: e.string(),
|
|
2105
2195
|
subject: e.string(),
|
|
@@ -2137,10 +2227,10 @@ e.object({
|
|
|
2137
2227
|
name: e.string(),
|
|
2138
2228
|
options: e.object({})
|
|
2139
2229
|
});
|
|
2140
|
-
var
|
|
2230
|
+
var kn = e.object({
|
|
2141
2231
|
value: e.string(),
|
|
2142
2232
|
description: e.string().optional()
|
|
2143
|
-
}),
|
|
2233
|
+
}), An = e.object({
|
|
2144
2234
|
token_dialect: e.enum(["access_token", "access_token_authz"]).optional(),
|
|
2145
2235
|
enforce_policies: e.boolean().optional(),
|
|
2146
2236
|
allow_skipping_userinfo: e.boolean().optional(),
|
|
@@ -2148,11 +2238,11 @@ var Cn = e.object({
|
|
|
2148
2238
|
persist_client_authorization: e.boolean().optional(),
|
|
2149
2239
|
enable_introspection_endpoint: e.boolean().optional(),
|
|
2150
2240
|
mtls: e.object({ bound_access_tokens: e.boolean().optional() }).optional()
|
|
2151
|
-
}),
|
|
2241
|
+
}), jn = e.object({
|
|
2152
2242
|
id: e.string().optional(),
|
|
2153
2243
|
name: e.string(),
|
|
2154
2244
|
identifier: e.string(),
|
|
2155
|
-
scopes: e.array(
|
|
2245
|
+
scopes: e.array(kn).optional(),
|
|
2156
2246
|
signing_alg: e.string().optional(),
|
|
2157
2247
|
signing_secret: e.string().optional(),
|
|
2158
2248
|
token_lifetime: e.number().default(86400),
|
|
@@ -2160,20 +2250,20 @@ var Cn = e.object({
|
|
|
2160
2250
|
skip_consent_for_verifiable_first_party_clients: e.boolean().optional(),
|
|
2161
2251
|
allow_offline_access: e.boolean().optional(),
|
|
2162
2252
|
verificationKey: e.string().optional(),
|
|
2163
|
-
options:
|
|
2253
|
+
options: An.optional(),
|
|
2164
2254
|
is_system: e.boolean().optional(),
|
|
2165
2255
|
metadata: e.record(e.string(), e.any()).optional()
|
|
2166
2256
|
}).extend({
|
|
2167
2257
|
created_at: e.string().optional(),
|
|
2168
2258
|
updated_at: e.string().optional()
|
|
2169
2259
|
});
|
|
2170
|
-
e.array(
|
|
2171
|
-
var
|
|
2260
|
+
e.array(jn);
|
|
2261
|
+
var Mn = e.object({
|
|
2172
2262
|
role_id: e.string(),
|
|
2173
2263
|
resource_server_identifier: e.string(),
|
|
2174
2264
|
permission_name: e.string()
|
|
2175
2265
|
}).extend({ created_at: e.string() });
|
|
2176
|
-
e.array(
|
|
2266
|
+
e.array(Mn), e.object({
|
|
2177
2267
|
user_id: e.string().openapi({ description: "The id of the user that granted the consent" }),
|
|
2178
2268
|
clientID: e.string().openapi({ description: "The id of the client the grant was issued to" }),
|
|
2179
2269
|
audience: e.string().optional().openapi({ description: "The audience the grant applies to" }),
|
|
@@ -2186,7 +2276,7 @@ e.array(En), e.object({
|
|
|
2186
2276
|
failed_logins: e.array(e.string()).optional(),
|
|
2187
2277
|
last_password_reset: e.string().optional()
|
|
2188
2278
|
});
|
|
2189
|
-
var
|
|
2279
|
+
var Nn = e.object({
|
|
2190
2280
|
user_id: e.string(),
|
|
2191
2281
|
resource_server_identifier: e.string(),
|
|
2192
2282
|
permission_name: e.string(),
|
|
@@ -2195,8 +2285,8 @@ var Dn = e.object({
|
|
|
2195
2285
|
tenant_id: e.string(),
|
|
2196
2286
|
created_at: e.string().optional()
|
|
2197
2287
|
});
|
|
2198
|
-
e.array(
|
|
2199
|
-
var
|
|
2288
|
+
e.array(Nn);
|
|
2289
|
+
var Pn = e.object({
|
|
2200
2290
|
user_id: e.string(),
|
|
2201
2291
|
resource_server_identifier: e.string(),
|
|
2202
2292
|
resource_server_name: e.string(),
|
|
@@ -2205,8 +2295,8 @@ var On = e.object({
|
|
|
2205
2295
|
created_at: e.string().optional(),
|
|
2206
2296
|
organization_id: e.string().optional()
|
|
2207
2297
|
});
|
|
2208
|
-
e.array(
|
|
2209
|
-
var
|
|
2298
|
+
e.array(Pn);
|
|
2299
|
+
var Fn = e.object({
|
|
2210
2300
|
user_id: e.string(),
|
|
2211
2301
|
role_id: e.string(),
|
|
2212
2302
|
organization_id: e.string().optional()
|
|
@@ -2214,8 +2304,8 @@ var kn = e.object({
|
|
|
2214
2304
|
tenant_id: e.string(),
|
|
2215
2305
|
created_at: e.string().optional()
|
|
2216
2306
|
});
|
|
2217
|
-
e.array(
|
|
2218
|
-
var
|
|
2307
|
+
e.array(Fn);
|
|
2308
|
+
var In = e.object({
|
|
2219
2309
|
id: e.string().optional().openapi({ description: "The unique identifier of the role. If not provided, one will be generated." }),
|
|
2220
2310
|
name: e.string().min(1).max(50).openapi({ description: "The name of the role. Cannot include '<' or '>'" }),
|
|
2221
2311
|
description: e.string().max(255).optional().openapi({ description: "The description of the role" }),
|
|
@@ -2226,19 +2316,19 @@ var An = e.object({
|
|
|
2226
2316
|
created_at: e.string().optional(),
|
|
2227
2317
|
updated_at: e.string().optional()
|
|
2228
2318
|
});
|
|
2229
|
-
e.array(
|
|
2230
|
-
var
|
|
2319
|
+
e.array(In);
|
|
2320
|
+
var Ln = e.object({
|
|
2231
2321
|
logo_url: e.string().optional().openapi({ description: "URL of the organization's logo" }),
|
|
2232
2322
|
colors: e.object({
|
|
2233
2323
|
primary: e.string().optional().openapi({ description: "Primary color in hex format (e.g., #FF0000)" }),
|
|
2234
2324
|
page_background: e.string().optional().openapi({ description: "Page background color in hex format (e.g., #FFFFFF)" })
|
|
2235
2325
|
}).optional()
|
|
2236
|
-
}).optional(),
|
|
2326
|
+
}).optional(), Rn = e.object({
|
|
2237
2327
|
connection_id: e.string().openapi({ description: "ID of the connection" }),
|
|
2238
2328
|
assign_membership_on_login: e.boolean().default(!1).openapi({ description: "Whether to assign membership to the organization on login" }),
|
|
2239
2329
|
show_as_button: e.boolean().default(!0).openapi({ description: "Whether to show this connection as a button in the login screen" }),
|
|
2240
2330
|
is_signup_enabled: e.boolean().default(!0).openapi({ description: "Whether signup is enabled for this connection" })
|
|
2241
|
-
}),
|
|
2331
|
+
}), zn = e.object({ client_credentials: e.object({
|
|
2242
2332
|
enforce: e.boolean().default(!1).openapi({ description: "Whether to enforce token quota limits" }),
|
|
2243
2333
|
per_day: e.number().min(0).default(0).openapi({ description: "Maximum tokens per day (0 = unlimited)" }),
|
|
2244
2334
|
per_hour: e.number().min(0).default(0).openapi({ description: "Maximum tokens per hour (0 = unlimited)" })
|
|
@@ -2247,15 +2337,15 @@ e.object({
|
|
|
2247
2337
|
id: e.string().optional(),
|
|
2248
2338
|
name: e.string().min(1).regex(/^[a-z0-9_-]+$/, { message: "Organization name must be lowercase and can only contain letters, numbers, hyphens, and underscores" }).openapi({ description: "The name of the organization. Must be lowercase and can only contain letters, numbers, hyphens, and underscores." }),
|
|
2249
2339
|
display_name: e.string().optional().openapi({ description: "The display name of the organization" }),
|
|
2250
|
-
branding:
|
|
2340
|
+
branding: Ln,
|
|
2251
2341
|
metadata: e.record(e.string(), e.any()).default({}).optional().openapi({ description: "Custom metadata for the organization" }),
|
|
2252
|
-
enabled_connections: e.array(
|
|
2253
|
-
token_quota:
|
|
2342
|
+
enabled_connections: e.array(Rn).default([]).optional().openapi({ description: "List of enabled connections for the organization" }),
|
|
2343
|
+
token_quota: zn
|
|
2254
2344
|
}).extend(n.shape).extend({
|
|
2255
2345
|
id: e.string(),
|
|
2256
2346
|
name: e.string().min(1).openapi({ description: "The name of the organization" })
|
|
2257
2347
|
});
|
|
2258
|
-
var
|
|
2348
|
+
var Bn = e.object({
|
|
2259
2349
|
connection_id: e.string().openapi({ description: "ID of the tenant-level connection to enable for the org." }),
|
|
2260
2350
|
assign_membership_on_login: e.boolean().optional().default(!1),
|
|
2261
2351
|
show_as_button: e.boolean().optional().default(!0),
|
|
@@ -2268,7 +2358,7 @@ var Pn = e.object({
|
|
|
2268
2358
|
created_at: e.string().optional(),
|
|
2269
2359
|
updated_at: e.string().optional()
|
|
2270
2360
|
});
|
|
2271
|
-
e.array(
|
|
2361
|
+
e.array(Bn), e.object({
|
|
2272
2362
|
user_id: e.string().openapi({ description: "ID of the user" }),
|
|
2273
2363
|
organization_id: e.string().openapi({ description: "ID of the organization" })
|
|
2274
2364
|
}).extend(n.shape).extend({ id: e.string() }), e.object({
|
|
@@ -2406,22 +2496,22 @@ e.array(Pn), e.object({
|
|
|
2406
2496
|
"passwordless",
|
|
2407
2497
|
"enterprise"
|
|
2408
2498
|
]);
|
|
2409
|
-
var
|
|
2499
|
+
var Vn = e.object({
|
|
2410
2500
|
name: e.string(),
|
|
2411
2501
|
type: e.string()
|
|
2412
|
-
}),
|
|
2502
|
+
}), Hn = e.object({
|
|
2413
2503
|
elapsed: e.number(),
|
|
2414
2504
|
rows_read: e.number().optional(),
|
|
2415
2505
|
bytes_read: e.number().optional()
|
|
2416
2506
|
});
|
|
2417
2507
|
e.object({
|
|
2418
|
-
meta: e.array(
|
|
2508
|
+
meta: e.array(Vn),
|
|
2419
2509
|
data: e.array(e.record(e.string(), e.any())),
|
|
2420
2510
|
rows: e.number(),
|
|
2421
2511
|
rows_before_limit_at_least: e.number().optional(),
|
|
2422
|
-
statistics:
|
|
2512
|
+
statistics: Hn.optional()
|
|
2423
2513
|
});
|
|
2424
|
-
var
|
|
2514
|
+
var Un = e.enum(/* @__PURE__ */ "login.login-id.login-password.signup.signup-id.signup-password.reset-password.consent.mfa.mfa-push.mfa-otp.mfa-voice.mfa-phone.mfa-webauthn.mfa-email.mfa-recovery-code.status.device-flow.email-verification.email-otp-challenge.organizations.invitation.common.passkeys.captcha.custom-form.login-passwordless.mfa-login-options".split(".")), Wn = e.record(e.string(), e.record(e.string(), e.string())).openapi({
|
|
2425
2515
|
type: "object",
|
|
2426
2516
|
additionalProperties: {
|
|
2427
2517
|
type: "object",
|
|
@@ -2429,11 +2519,11 @@ var Ln = e.enum(/* @__PURE__ */ "login.login-id.login-password.signup.signup-id.
|
|
|
2429
2519
|
}
|
|
2430
2520
|
});
|
|
2431
2521
|
e.object({
|
|
2432
|
-
prompt:
|
|
2522
|
+
prompt: Un,
|
|
2433
2523
|
language: e.string(),
|
|
2434
|
-
custom_text:
|
|
2524
|
+
custom_text: Wn
|
|
2435
2525
|
});
|
|
2436
|
-
var
|
|
2526
|
+
var Gn = e.enum([
|
|
2437
2527
|
"phone",
|
|
2438
2528
|
"totp",
|
|
2439
2529
|
"email",
|
|
@@ -2443,7 +2533,7 @@ var zn = e.enum([
|
|
|
2443
2533
|
"passkey"
|
|
2444
2534
|
]), M = e.object({
|
|
2445
2535
|
user_id: e.string(),
|
|
2446
|
-
type:
|
|
2536
|
+
type: Gn,
|
|
2447
2537
|
phone_number: e.string().optional(),
|
|
2448
2538
|
totp_secret: e.string().optional(),
|
|
2449
2539
|
credential_id: e.string().optional(),
|
|
@@ -2488,12 +2578,12 @@ M.superRefine(N), M.extend({
|
|
|
2488
2578
|
});
|
|
2489
2579
|
//#endregion
|
|
2490
2580
|
//#region src/data-plane/cache.ts
|
|
2491
|
-
var
|
|
2581
|
+
var Kn = 1e4;
|
|
2492
2582
|
function P(e, t, n) {
|
|
2493
2583
|
let r = typeof t == "number" ? {
|
|
2494
2584
|
freshTtlMs: t,
|
|
2495
2585
|
maxEntries: n
|
|
2496
|
-
} : t, i = r.freshTtlMs, a = r.staleTtlMs ?? 0, o = r.staleIfErrorTtlMs ?? 0, s = r.negativeTtlMs ?? i, c = r.maxEntries ??
|
|
2586
|
+
} : t, i = r.freshTtlMs, a = r.staleTtlMs ?? 0, o = r.staleIfErrorTtlMs ?? 0, s = r.negativeTtlMs ?? i, c = r.maxEntries ?? Kn, l = r.waitUntil, u = /* @__PURE__ */ new Map();
|
|
2497
2587
|
function d(e) {
|
|
2498
2588
|
for (let [t, n] of u) n.stale_if_error_until <= e && n.stale_until <= e && !n.refreshing && u.delete(t);
|
|
2499
2589
|
for (; u.size >= c;) {
|
|
@@ -2576,27 +2666,27 @@ function I(e) {
|
|
|
2576
2666
|
//#endregion
|
|
2577
2667
|
//#region src/data-plane/handlers/util.ts
|
|
2578
2668
|
var L = "__authhero_proxy_request__", R = "__authhero_proxy_tenant_id__", z = "__authhero_proxy_custom_domain_id__", B = "__authhero_proxy_domain__", V = "x-authhero-proxy-mutability-probe";
|
|
2579
|
-
function
|
|
2669
|
+
function qn(e, t) {
|
|
2580
2670
|
e.set(L, t);
|
|
2581
2671
|
}
|
|
2582
2672
|
function H(e) {
|
|
2583
2673
|
return e.get(L) ?? e.req.raw;
|
|
2584
2674
|
}
|
|
2585
|
-
function
|
|
2675
|
+
function Jn(e, t) {
|
|
2586
2676
|
e.set(R, t.tenant_id), e.set(z, t.custom_domain_id), e.set(B, t.domain);
|
|
2587
2677
|
}
|
|
2588
|
-
function
|
|
2678
|
+
function Yn(e) {
|
|
2589
2679
|
return e.get(R);
|
|
2590
2680
|
}
|
|
2591
|
-
function
|
|
2681
|
+
function Xn(e) {
|
|
2592
2682
|
return e.get(z);
|
|
2593
2683
|
}
|
|
2594
|
-
function
|
|
2684
|
+
function Zn(e) {
|
|
2595
2685
|
return e.get(B);
|
|
2596
2686
|
}
|
|
2597
2687
|
function U(e, t) {
|
|
2598
2688
|
let n = H(e), r = new Headers(n.headers);
|
|
2599
|
-
t(r),
|
|
2689
|
+
t(r), qn(e, new Request(n, { headers: r }));
|
|
2600
2690
|
}
|
|
2601
2691
|
function W(e) {
|
|
2602
2692
|
let t = e.res;
|
|
@@ -2613,7 +2703,7 @@ function W(e) {
|
|
|
2613
2703
|
}
|
|
2614
2704
|
//#endregion
|
|
2615
2705
|
//#region src/data-plane/handlers/cors.ts
|
|
2616
|
-
var
|
|
2706
|
+
var Qn = e.object({
|
|
2617
2707
|
origins: e.array(e.string()).optional(),
|
|
2618
2708
|
allow_credentials: e.boolean().optional(),
|
|
2619
2709
|
allow_headers: e.array(e.string()).optional(),
|
|
@@ -2625,9 +2715,9 @@ function G(e, t) {
|
|
|
2625
2715
|
let n = new Headers(), r = e.origins ?? ["*"], i = r.includes("*");
|
|
2626
2716
|
return i && !e.allow_credentials ? n.set("Access-Control-Allow-Origin", "*") : t && (i || r.includes(t)) && (n.set("Access-Control-Allow-Origin", t), n.append("Vary", "Origin")), e.allow_credentials && n.set("Access-Control-Allow-Credentials", "true"), e.allow_methods?.length && n.set("Access-Control-Allow-Methods", e.allow_methods.join(", ")), e.allow_headers?.length && n.set("Access-Control-Allow-Headers", e.allow_headers.join(", ")), e.expose_headers?.length && n.set("Access-Control-Expose-Headers", e.expose_headers.join(", ")), e.max_age !== void 0 && n.set("Access-Control-Max-Age", String(e.max_age)), n;
|
|
2627
2717
|
}
|
|
2628
|
-
var
|
|
2718
|
+
var $n = I({
|
|
2629
2719
|
type: "cors",
|
|
2630
|
-
optionsSchema:
|
|
2720
|
+
optionsSchema: Qn,
|
|
2631
2721
|
build(e) {
|
|
2632
2722
|
return async (t, n) => {
|
|
2633
2723
|
let r = t.req.header("origin") ?? null;
|
|
@@ -2645,20 +2735,20 @@ var qn = I({
|
|
|
2645
2735
|
});
|
|
2646
2736
|
};
|
|
2647
2737
|
}
|
|
2648
|
-
}),
|
|
2738
|
+
}), er = e.object({
|
|
2649
2739
|
username: e.string(),
|
|
2650
2740
|
password: e.string(),
|
|
2651
2741
|
realm: e.string().optional()
|
|
2652
2742
|
});
|
|
2653
|
-
function
|
|
2743
|
+
function tr(e, t) {
|
|
2654
2744
|
let n = `${e}:${t}`;
|
|
2655
2745
|
return typeof btoa == "function" ? btoa(n) : Buffer.from(n, "utf-8").toString("base64");
|
|
2656
2746
|
}
|
|
2657
|
-
var
|
|
2747
|
+
var nr = I({
|
|
2658
2748
|
type: "basic_auth",
|
|
2659
|
-
optionsSchema:
|
|
2749
|
+
optionsSchema: er,
|
|
2660
2750
|
build(e) {
|
|
2661
|
-
let t =
|
|
2751
|
+
let t = tr(e.username, e.password), n = (e.realm ?? "Restricted").replace(/["\\\r\n]/g, "");
|
|
2662
2752
|
return async (e, r) => {
|
|
2663
2753
|
let i = e.req.header("authorization");
|
|
2664
2754
|
if (i) {
|
|
@@ -2674,7 +2764,7 @@ var Xn = I({
|
|
|
2674
2764
|
});
|
|
2675
2765
|
};
|
|
2676
2766
|
}
|
|
2677
|
-
}),
|
|
2767
|
+
}), rr = I({
|
|
2678
2768
|
type: "headers",
|
|
2679
2769
|
optionsSchema: e.object({
|
|
2680
2770
|
request: e.record(e.string(), e.string()).optional(),
|
|
@@ -2689,7 +2779,7 @@ var Xn = I({
|
|
|
2689
2779
|
}), await n(), (e.response || e.remove_response) && (W(t), e.remove_response?.forEach((e) => t.res.headers.delete(e)), e.response)) for (let [n, r] of Object.entries(e.response)) t.res.headers.set(n, r);
|
|
2690
2780
|
};
|
|
2691
2781
|
}
|
|
2692
|
-
}),
|
|
2782
|
+
}), ir = I({
|
|
2693
2783
|
type: "cache",
|
|
2694
2784
|
optionsSchema: e.object({ ttl_seconds: e.number().int().positive() }),
|
|
2695
2785
|
build(e) {
|
|
@@ -2700,7 +2790,7 @@ var Xn = I({
|
|
|
2700
2790
|
}
|
|
2701
2791
|
};
|
|
2702
2792
|
}
|
|
2703
|
-
}),
|
|
2793
|
+
}), ar = I({
|
|
2704
2794
|
type: "forwarded_headers",
|
|
2705
2795
|
optionsSchema: e.object({
|
|
2706
2796
|
client_ip_header: e.string().default("cf-connecting-ip"),
|
|
@@ -2717,33 +2807,33 @@ var Xn = I({
|
|
|
2717
2807
|
}), await n();
|
|
2718
2808
|
};
|
|
2719
2809
|
}
|
|
2720
|
-
}),
|
|
2721
|
-
function
|
|
2810
|
+
}), or = e.object({ upstream_host: e.string().optional() });
|
|
2811
|
+
function sr(e) {
|
|
2722
2812
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2723
2813
|
}
|
|
2724
|
-
function
|
|
2814
|
+
function cr(e) {
|
|
2725
2815
|
if (typeof e.getSetCookie == "function") return e.getSetCookie();
|
|
2726
2816
|
let t = [];
|
|
2727
2817
|
return e.forEach((e, n) => {
|
|
2728
2818
|
n.toLowerCase() === "set-cookie" && t.push(e);
|
|
2729
2819
|
}), t;
|
|
2730
2820
|
}
|
|
2731
|
-
var
|
|
2821
|
+
var lr = I({
|
|
2732
2822
|
type: "rewrite_cookies",
|
|
2733
|
-
optionsSchema:
|
|
2823
|
+
optionsSchema: or,
|
|
2734
2824
|
build(e) {
|
|
2735
2825
|
return async (t, n) => {
|
|
2736
2826
|
await n();
|
|
2737
2827
|
let r = new URL(t.req.url).hostname, i = e.upstream_host ?? t.get("__proxy_upstream_host__");
|
|
2738
2828
|
if (!i) return;
|
|
2739
|
-
let a =
|
|
2829
|
+
let a = cr(t.res.headers);
|
|
2740
2830
|
if (a.length === 0) return;
|
|
2741
|
-
let o =
|
|
2831
|
+
let o = sr(i), s = RegExp(`(?:^|;\\s*)Domain=\\.?${o}(?=;|$)`, "i");
|
|
2742
2832
|
W(t), t.res.headers.delete("set-cookie");
|
|
2743
2833
|
for (let e of a) t.res.headers.append("set-cookie", e.replace(s, `Domain=${r}`));
|
|
2744
2834
|
};
|
|
2745
2835
|
}
|
|
2746
|
-
}),
|
|
2836
|
+
}), ur = I({
|
|
2747
2837
|
type: "rewrite_location",
|
|
2748
2838
|
optionsSchema: e.object({ upstream_origin: e.string().optional() }),
|
|
2749
2839
|
build(e) {
|
|
@@ -2766,14 +2856,14 @@ var rr = I({
|
|
|
2766
2856
|
W(t), t.res.headers.set("location", c);
|
|
2767
2857
|
};
|
|
2768
2858
|
}
|
|
2769
|
-
}),
|
|
2859
|
+
}), dr = class extends Error {
|
|
2770
2860
|
ms;
|
|
2771
2861
|
constructor(e, t) {
|
|
2772
2862
|
super(`${t ?? "Operation"} timed out after ${e}ms`), this.name = "TimeoutError", this.ms = e;
|
|
2773
2863
|
}
|
|
2774
2864
|
};
|
|
2775
2865
|
function K(e) {
|
|
2776
|
-
return e instanceof
|
|
2866
|
+
return e instanceof dr ? !0 : e instanceof Error ? e.name === "AbortError" || e.name === "TimeoutError" : !1;
|
|
2777
2867
|
}
|
|
2778
2868
|
function q(e, t) {
|
|
2779
2869
|
let n = new AbortController(), r = setTimeout(() => n.abort(), e);
|
|
@@ -2781,7 +2871,7 @@ function q(e, t) {
|
|
|
2781
2871
|
}
|
|
2782
2872
|
function J(e, t, n) {
|
|
2783
2873
|
let r, i = new Promise((e, i) => {
|
|
2784
|
-
r = setTimeout(() => i(new
|
|
2874
|
+
r = setTimeout(() => i(new dr(t, n)), t);
|
|
2785
2875
|
});
|
|
2786
2876
|
return Promise.race([e, i]).finally(() => {
|
|
2787
2877
|
r && clearTimeout(r);
|
|
@@ -2789,7 +2879,7 @@ function J(e, t, n) {
|
|
|
2789
2879
|
}
|
|
2790
2880
|
//#endregion
|
|
2791
2881
|
//#region src/data-plane/handlers/http.ts
|
|
2792
|
-
var
|
|
2882
|
+
var fr = /* @__PURE__ */ new Set([
|
|
2793
2883
|
"connection",
|
|
2794
2884
|
"keep-alive",
|
|
2795
2885
|
"proxy-authenticate",
|
|
@@ -2798,24 +2888,24 @@ var or = /* @__PURE__ */ new Set([
|
|
|
2798
2888
|
"trailers",
|
|
2799
2889
|
"transfer-encoding",
|
|
2800
2890
|
"upgrade"
|
|
2801
|
-
]),
|
|
2891
|
+
]), pr = 3e4, mr = e.object({
|
|
2802
2892
|
upstream_url: e.string(),
|
|
2803
2893
|
preserve_host: e.boolean().default(!1),
|
|
2804
2894
|
timeout_ms: e.number().int().positive().optional()
|
|
2805
2895
|
});
|
|
2806
|
-
function
|
|
2896
|
+
function hr(e, t) {
|
|
2807
2897
|
return e === "" || e === "/" ? t : `${e.endsWith("/") ? e.slice(0, -1) : e}${t.startsWith("/") ? t : `/${t}`}`;
|
|
2808
2898
|
}
|
|
2809
|
-
function
|
|
2899
|
+
function gr(e) {
|
|
2810
2900
|
return e !== "GET" && e !== "HEAD";
|
|
2811
2901
|
}
|
|
2812
|
-
function
|
|
2902
|
+
function _r(e, t) {
|
|
2813
2903
|
let n = new URL(t.url), r = new URL(e.upstream_url);
|
|
2814
|
-
r.pathname =
|
|
2904
|
+
r.pathname = hr(r.pathname, n.pathname), r.search = n.search;
|
|
2815
2905
|
let i = new Headers(t.headers);
|
|
2816
|
-
for (let e of
|
|
2906
|
+
for (let e of fr) i.delete(e);
|
|
2817
2907
|
e.preserve_host || i.set("host", r.host), i.has("x-forwarded-host") || i.set("x-forwarded-host", n.host), i.has("x-forwarded-proto") || i.set("x-forwarded-proto", n.protocol.replace(":", ""));
|
|
2818
|
-
let a =
|
|
2908
|
+
let a = gr(t.method) ? t.body : void 0, o = {
|
|
2819
2909
|
method: t.method,
|
|
2820
2910
|
headers: i,
|
|
2821
2911
|
body: a,
|
|
@@ -2826,13 +2916,13 @@ function dr(e, t) {
|
|
|
2826
2916
|
init: o
|
|
2827
2917
|
};
|
|
2828
2918
|
}
|
|
2829
|
-
var
|
|
2919
|
+
var vr = I({
|
|
2830
2920
|
type: "http",
|
|
2831
|
-
optionsSchema:
|
|
2921
|
+
optionsSchema: mr,
|
|
2832
2922
|
build(e) {
|
|
2833
|
-
let t = e.timeout_ms ??
|
|
2923
|
+
let t = e.timeout_ms ?? pr;
|
|
2834
2924
|
return async (n) => {
|
|
2835
|
-
let { target: r, init: i } =
|
|
2925
|
+
let { target: r, init: i } = _r(e, H(n));
|
|
2836
2926
|
n.set("__proxy_upstream_host__", r.hostname), n.set("__proxy_upstream_origin__", `${r.protocol}//${r.host}`);
|
|
2837
2927
|
try {
|
|
2838
2928
|
return await q(t, (e) => fetch(r.toString(), {
|
|
@@ -2844,24 +2934,24 @@ var fr = I({
|
|
|
2844
2934
|
}
|
|
2845
2935
|
};
|
|
2846
2936
|
}
|
|
2847
|
-
}),
|
|
2937
|
+
}), yr = 3e4, br = e.object({
|
|
2848
2938
|
binding: e.string(),
|
|
2849
2939
|
upstream_url: e.string().optional(),
|
|
2850
2940
|
preserve_host: e.boolean().default(!0),
|
|
2851
2941
|
timeout_ms: e.number().int().positive().optional()
|
|
2852
2942
|
});
|
|
2853
|
-
function
|
|
2943
|
+
function xr(e) {
|
|
2854
2944
|
return typeof e == "object" && !!e && typeof e.fetch == "function";
|
|
2855
2945
|
}
|
|
2856
|
-
var
|
|
2946
|
+
var Sr = I({
|
|
2857
2947
|
type: "service_binding",
|
|
2858
|
-
optionsSchema:
|
|
2948
|
+
optionsSchema: br,
|
|
2859
2949
|
build(e, t) {
|
|
2860
2950
|
let n = t.bindings[e.binding];
|
|
2861
|
-
if (!
|
|
2862
|
-
let r = e.upstream_url ?? `https://${e.binding}.binding.invalid/`, i = e.timeout_ms ??
|
|
2951
|
+
if (!xr(n)) throw Error(`Service binding "${e.binding}" is not configured or is not a Fetcher`);
|
|
2952
|
+
let r = e.upstream_url ?? `https://${e.binding}.binding.invalid/`, i = e.timeout_ms ?? yr;
|
|
2863
2953
|
return async (t) => {
|
|
2864
|
-
let a = H(t), { target: o, init: s } =
|
|
2954
|
+
let a = H(t), { target: o, init: s } = _r({
|
|
2865
2955
|
upstream_url: r,
|
|
2866
2956
|
preserve_host: e.preserve_host
|
|
2867
2957
|
}, a);
|
|
@@ -2876,34 +2966,34 @@ var gr = I({
|
|
|
2876
2966
|
}
|
|
2877
2967
|
};
|
|
2878
2968
|
}
|
|
2879
|
-
}),
|
|
2969
|
+
}), Cr = 3e4, wr = e.object({
|
|
2880
2970
|
binding: e.string(),
|
|
2881
2971
|
script_name: e.string(),
|
|
2882
2972
|
cpu_ms: e.number().int().positive().optional(),
|
|
2883
2973
|
subrequests: e.number().int().positive().optional(),
|
|
2884
2974
|
timeout_ms: e.number().int().positive().optional()
|
|
2885
2975
|
});
|
|
2886
|
-
function
|
|
2976
|
+
function Tr(e) {
|
|
2887
2977
|
return typeof e == "object" && !!e && typeof e.get == "function";
|
|
2888
2978
|
}
|
|
2889
2979
|
var Y = /\{(tenant_id|custom_domain_id|domain|host)\}/g;
|
|
2890
|
-
function
|
|
2980
|
+
function Er(e) {
|
|
2891
2981
|
return Y.lastIndex = 0, Y.test(e);
|
|
2892
2982
|
}
|
|
2893
|
-
var
|
|
2983
|
+
var Dr = I({
|
|
2894
2984
|
type: "dispatch_namespace",
|
|
2895
|
-
optionsSchema:
|
|
2985
|
+
optionsSchema: wr,
|
|
2896
2986
|
build(e, t) {
|
|
2897
2987
|
let n = t.bindings[e.binding];
|
|
2898
|
-
if (!
|
|
2899
|
-
let r =
|
|
2988
|
+
if (!Tr(n)) throw Error(`Dispatch namespace binding "${e.binding}" is not configured or does not expose .get()`);
|
|
2989
|
+
let r = Er(e.script_name), i = e.timeout_ms ?? Cr, a = e.cpu_ms || e.subrequests ? { limits: {
|
|
2900
2990
|
...e.cpu_ms ? { cpuMs: e.cpu_ms } : {},
|
|
2901
2991
|
...e.subrequests ? { subrequests: e.subrequests } : {}
|
|
2902
2992
|
} } : void 0;
|
|
2903
2993
|
return async (t) => {
|
|
2904
2994
|
let o = e.script_name;
|
|
2905
2995
|
if (r) {
|
|
2906
|
-
let n =
|
|
2996
|
+
let n = Yn(t), r = Xn(t), i = Zn(t), a = t.req.header("host") ?? t.req.header("x-forwarded-host") ?? "";
|
|
2907
2997
|
if (o = o.replace(Y, (e, t) => {
|
|
2908
2998
|
switch (t) {
|
|
2909
2999
|
case "tenant_id": return n ?? "";
|
|
@@ -2926,7 +3016,7 @@ var xr = I({
|
|
|
2926
3016
|
}
|
|
2927
3017
|
};
|
|
2928
3018
|
}
|
|
2929
|
-
}),
|
|
3019
|
+
}), Or = I({
|
|
2930
3020
|
type: "redirect",
|
|
2931
3021
|
optionsSchema: e.object({
|
|
2932
3022
|
upstream_url: e.string().refine((e) => {
|
|
@@ -2955,7 +3045,7 @@ var xr = I({
|
|
|
2955
3045
|
});
|
|
2956
3046
|
};
|
|
2957
3047
|
}
|
|
2958
|
-
}),
|
|
3048
|
+
}), kr = I({
|
|
2959
3049
|
type: "static",
|
|
2960
3050
|
optionsSchema: e.object({
|
|
2961
3051
|
status: e.number().int().default(200),
|
|
@@ -2975,15 +3065,15 @@ var xr = I({
|
|
|
2975
3065
|
});
|
|
2976
3066
|
//#endregion
|
|
2977
3067
|
//#region src/data-plane/handlers/index.ts
|
|
2978
|
-
function
|
|
2979
|
-
e.add(
|
|
3068
|
+
function Ar(e) {
|
|
3069
|
+
e.add($n).add(nr).add(rr).add(ir).add(ar).add(lr).add(ur).add(vr).add(Sr).add(Dr).add(Or).add(kr);
|
|
2980
3070
|
}
|
|
2981
3071
|
//#endregion
|
|
2982
3072
|
//#region src/data-plane/matcher.ts
|
|
2983
3073
|
function X(e) {
|
|
2984
3074
|
return [...e].sort((e, t) => e.priority === t.priority ? e.created_at.localeCompare(t.created_at) : e.priority - t.priority);
|
|
2985
3075
|
}
|
|
2986
|
-
function
|
|
3076
|
+
function jr(e, t) {
|
|
2987
3077
|
let n = e.toLowerCase(), r = t.toLowerCase();
|
|
2988
3078
|
if (n === r) return !0;
|
|
2989
3079
|
if (n.startsWith("*.")) {
|
|
@@ -2992,13 +3082,16 @@ function Tr(e, t) {
|
|
|
2992
3082
|
}
|
|
2993
3083
|
return !1;
|
|
2994
3084
|
}
|
|
2995
|
-
function
|
|
2996
|
-
return !e || e.length === 0 ? !0 : e.some((e) =>
|
|
3085
|
+
function Mr(e, t) {
|
|
3086
|
+
return !e || e.length === 0 ? !0 : e.some((e) => jr(e, t));
|
|
2997
3087
|
}
|
|
2998
|
-
function
|
|
3088
|
+
function Nr(e) {
|
|
2999
3089
|
let t = (e.headers ? Object.entries(e.headers) : []).map(([e, t]) => [e.toLowerCase(), new RegExp(t)]), n = (e.query ? Object.entries(e.query) : []).map(([e, t]) => [e, new RegExp(t)]), r = e.hosts;
|
|
3000
3090
|
return async (e, i) => {
|
|
3001
|
-
if (r
|
|
3091
|
+
if (r) {
|
|
3092
|
+
let t = e.req.header("host") ?? "";
|
|
3093
|
+
if (!Mr(r, t)) return new Response("No matching route", { status: 404 });
|
|
3094
|
+
}
|
|
3002
3095
|
for (let [n, r] of t) {
|
|
3003
3096
|
let t = e.req.header(n);
|
|
3004
3097
|
if (t === void 0 || !r.test(t)) return new Response("No matching route", { status: 404 });
|
|
@@ -3015,7 +3108,7 @@ function Dr(e) {
|
|
|
3015
3108
|
}
|
|
3016
3109
|
//#endregion
|
|
3017
3110
|
//#region src/data-plane/compile.ts
|
|
3018
|
-
var
|
|
3111
|
+
var Pr = [
|
|
3019
3112
|
"GET",
|
|
3020
3113
|
"POST",
|
|
3021
3114
|
"PUT",
|
|
@@ -3027,34 +3120,34 @@ var Or = [
|
|
|
3027
3120
|
function Z(e, n, r, i) {
|
|
3028
3121
|
let a = new t();
|
|
3029
3122
|
r && a.use("*", async (e, t) => {
|
|
3030
|
-
|
|
3123
|
+
Jn(e, r), await t();
|
|
3031
3124
|
});
|
|
3032
3125
|
let o = X(e);
|
|
3033
3126
|
for (let e of o) {
|
|
3034
3127
|
let t = [];
|
|
3035
|
-
t.push(
|
|
3128
|
+
t.push(Nr(e.match));
|
|
3036
3129
|
for (let r of e.handlers) t.push(n.build(r.type, r.options));
|
|
3037
|
-
let r = e.match.methods?.length ? e.match.methods.map((e) => e.toUpperCase()) :
|
|
3130
|
+
let r = e.match.methods?.length ? e.match.methods.map((e) => e.toUpperCase()) : Pr, i = e.match.path || "/*";
|
|
3038
3131
|
a.on(r, [i], ...t);
|
|
3039
3132
|
}
|
|
3040
|
-
return i && i.length > 0 ? a.on(
|
|
3133
|
+
return i && i.length > 0 ? a.on(Pr, ["*"], ...i) : a.all("*", (e) => e.text("No matching route", 404)), a.onError((e, t) => {
|
|
3041
3134
|
let n = K(e);
|
|
3042
3135
|
return t.text(n ? "Upstream timeout" : "Bad gateway", n ? 504 : 502, { "x-authhero-proxy-error": n ? "handler_timeout" : "handler_failed" });
|
|
3043
3136
|
}), a;
|
|
3044
3137
|
}
|
|
3045
3138
|
//#endregion
|
|
3046
3139
|
//#region src/data-plane/router.ts
|
|
3047
|
-
var
|
|
3048
|
-
function
|
|
3140
|
+
var Fr = 1e4;
|
|
3141
|
+
function Ir(e) {
|
|
3049
3142
|
return e.resolver ? e.resolver : e.cache ? P(e.data, e.cache) : P(e.data, e.cacheTtlMs ?? 3e4);
|
|
3050
3143
|
}
|
|
3051
|
-
function
|
|
3144
|
+
function Lr(e) {
|
|
3052
3145
|
if (e.registry) return e.registry;
|
|
3053
3146
|
let t = new F(e.bindings ?? {});
|
|
3054
|
-
return
|
|
3147
|
+
return Ar(t), t;
|
|
3055
3148
|
}
|
|
3056
3149
|
function Q(e) {
|
|
3057
|
-
let t =
|
|
3150
|
+
let t = Ir(e), n = Lr(e), r = /* @__PURE__ */ new WeakMap(), i = e.resolveHostTimeoutMs ?? Fr, a = e.defaultHandlers && e.defaultHandlers.length > 0 ? e.defaultHandlers.map((e) => n.build(e.type, e.options)) : void 0, o = a ? Z([], n, void 0, a) : void 0;
|
|
3058
3151
|
return async (e) => {
|
|
3059
3152
|
let s = e.req.header("host") ?? e.req.header("x-forwarded-host");
|
|
3060
3153
|
if (!s) return e.text("Missing host", 400);
|
|
@@ -3072,13 +3165,13 @@ function Q(e) {
|
|
|
3072
3165
|
}
|
|
3073
3166
|
};
|
|
3074
3167
|
}
|
|
3075
|
-
function
|
|
3168
|
+
function Rr(e) {
|
|
3076
3169
|
let n = new t();
|
|
3077
3170
|
return n.all("*", Q(e)), n;
|
|
3078
3171
|
}
|
|
3079
3172
|
//#endregion
|
|
3080
3173
|
//#region src/app.ts
|
|
3081
|
-
function
|
|
3174
|
+
function zr(e) {
|
|
3082
3175
|
let n = new t();
|
|
3083
3176
|
return n.all("*", Q({
|
|
3084
3177
|
data: e.data,
|
|
@@ -3096,17 +3189,17 @@ function Nr(e) {
|
|
|
3096
3189
|
}
|
|
3097
3190
|
//#endregion
|
|
3098
3191
|
//#region src/data-plane/cache-api-cache.ts
|
|
3099
|
-
var
|
|
3100
|
-
function
|
|
3192
|
+
var Br = 1e3, Vr = 1e3;
|
|
3193
|
+
function Hr(e, t) {
|
|
3101
3194
|
return new Request(`https://proxy-cache.internal/${encodeURIComponent(e)}/hosts/${encodeURIComponent(t.toLowerCase())}`, { method: "GET" });
|
|
3102
3195
|
}
|
|
3103
|
-
function
|
|
3196
|
+
function Ur() {
|
|
3104
3197
|
return globalThis.caches?.default;
|
|
3105
3198
|
}
|
|
3106
|
-
function
|
|
3107
|
-
let t = e.cache ??
|
|
3199
|
+
function Wr(e) {
|
|
3200
|
+
let t = e.cache ?? Ur();
|
|
3108
3201
|
if (!t) return e.upstream;
|
|
3109
|
-
let n = t, r = e.namespace ?? "authhero-proxy", i = e.cacheTtlSeconds ?? 60, a = e.negativeCacheTtlSeconds ?? 10, o = e.waitUntil, s = e.cacheReadTimeoutMs ??
|
|
3202
|
+
let n = t, r = e.namespace ?? "authhero-proxy", i = e.cacheTtlSeconds ?? 60, a = e.negativeCacheTtlSeconds ?? 10, o = e.waitUntil, s = e.cacheReadTimeoutMs ?? Br, c = e.cacheWriteTimeoutMs ?? Vr;
|
|
3110
3203
|
async function l(e) {
|
|
3111
3204
|
try {
|
|
3112
3205
|
return await J(Promise.resolve(n.match(e)), s, "cache.match");
|
|
@@ -3115,7 +3208,7 @@ function Rr(e) {
|
|
|
3115
3208
|
}
|
|
3116
3209
|
}
|
|
3117
3210
|
return { async resolveHost(t) {
|
|
3118
|
-
let s =
|
|
3211
|
+
let s = Hr(r, t), u = await l(s);
|
|
3119
3212
|
if (u) try {
|
|
3120
3213
|
return (await u.json()).value;
|
|
3121
3214
|
} catch {}
|
|
@@ -3126,14 +3219,14 @@ function Rr(e) {
|
|
|
3126
3219
|
return o ? o(m) : await m, d;
|
|
3127
3220
|
} };
|
|
3128
3221
|
}
|
|
3129
|
-
function
|
|
3130
|
-
return
|
|
3222
|
+
function Gr(e, t) {
|
|
3223
|
+
return Hr(e, t);
|
|
3131
3224
|
}
|
|
3132
3225
|
//#endregion
|
|
3133
3226
|
//#region src/data-plane/cache-adapter-cache.ts
|
|
3134
|
-
var
|
|
3135
|
-
function
|
|
3136
|
-
let { upstream: t, cache: n, freshTtlMs: r, staleTtlMs: i = 0, staleIfErrorTtlMs: a = 0, negativeTtlMs: o = r, keyPrefix: s = "authhero-proxy-host", waitUntil: c, cacheReadTimeoutMs: l =
|
|
3227
|
+
var Kr = 1e3, qr = 1e3;
|
|
3228
|
+
function Jr(e) {
|
|
3229
|
+
let { upstream: t, cache: n, freshTtlMs: r, staleTtlMs: i = 0, staleIfErrorTtlMs: a = 0, negativeTtlMs: o = r, keyPrefix: s = "authhero-proxy-host", waitUntil: c, cacheReadTimeoutMs: l = Kr, cacheWriteTimeoutMs: u = qr } = e, d = /* @__PURE__ */ new Map();
|
|
3137
3230
|
function f(e) {
|
|
3138
3231
|
return `${s}:${e.toLowerCase()}`;
|
|
3139
3232
|
}
|
|
@@ -3186,7 +3279,7 @@ function Hr(e) {
|
|
|
3186
3279
|
}
|
|
3187
3280
|
} };
|
|
3188
3281
|
}
|
|
3189
|
-
function
|
|
3282
|
+
function Yr(e, t) {
|
|
3190
3283
|
return `${e}:${t.toLowerCase()}`;
|
|
3191
3284
|
}
|
|
3192
3285
|
//#endregion
|
|
@@ -3194,7 +3287,7 @@ function Ur(e, t) {
|
|
|
3194
3287
|
function $() {
|
|
3195
3288
|
throw Error("Static proxy adapter is read-only; configure routes at init time");
|
|
3196
3289
|
}
|
|
3197
|
-
function
|
|
3290
|
+
function Xr(e, t, n, r, i, a) {
|
|
3198
3291
|
return {
|
|
3199
3292
|
id: e.id ?? `${n}:${t}`,
|
|
3200
3293
|
tenant_id: r,
|
|
@@ -3209,10 +3302,10 @@ function Wr(e, t, n, r, i, a) {
|
|
|
3209
3302
|
updated_at: e.updated_at ?? a
|
|
3210
3303
|
};
|
|
3211
3304
|
}
|
|
3212
|
-
function
|
|
3305
|
+
function Zr(e) {
|
|
3213
3306
|
let t = (/* @__PURE__ */ new Date()).toISOString(), n = e.defaultTenantId ?? "static", r = /* @__PURE__ */ new Map();
|
|
3214
3307
|
for (let [i, a] of Object.entries(e.hosts)) {
|
|
3215
|
-
let e = i.toLowerCase(), o = Array.isArray(a) ? { routes: a } : a, s = o.tenant_id ?? n, c = o.custom_domain_id ?? e, l = o.routes.map((n, r) =>
|
|
3308
|
+
let e = i.toLowerCase(), o = Array.isArray(a) ? { routes: a } : a, s = o.tenant_id ?? n, c = o.custom_domain_id ?? e, l = o.routes.map((n, r) => Xr(n, r, e, s, c, t)).sort((e, t) => e.priority - t.priority);
|
|
3216
3309
|
r.set(e, {
|
|
3217
3310
|
tenant_id: s,
|
|
3218
3311
|
custom_domain_id: c,
|
|
@@ -3256,7 +3349,7 @@ function Gr(e) {
|
|
|
3256
3349
|
}
|
|
3257
3350
|
};
|
|
3258
3351
|
}
|
|
3259
|
-
function
|
|
3352
|
+
function Qr(e, t = {}) {
|
|
3260
3353
|
return {
|
|
3261
3354
|
priority: t.priority,
|
|
3262
3355
|
match: { path: t.path ?? "/*" },
|
|
@@ -3271,10 +3364,10 @@ function Kr(e, t = {}) {
|
|
|
3271
3364
|
}
|
|
3272
3365
|
//#endregion
|
|
3273
3366
|
//#region src/constants.ts
|
|
3274
|
-
var
|
|
3367
|
+
var $r = "proxy:resolve_host";
|
|
3275
3368
|
//#endregion
|
|
3276
3369
|
//#region src/http-adapter/index.ts
|
|
3277
|
-
function
|
|
3370
|
+
function ei() {
|
|
3278
3371
|
let e = () => {
|
|
3279
3372
|
throw Error("HTTP proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
|
|
3280
3373
|
};
|
|
@@ -3296,7 +3389,7 @@ function Jr() {
|
|
|
3296
3389
|
}
|
|
3297
3390
|
};
|
|
3298
3391
|
}
|
|
3299
|
-
function
|
|
3392
|
+
function ti(e) {
|
|
3300
3393
|
let t = e.fetch ?? fetch, n = e.baseUrl.replace(/\/+$/, ""), r = e.resolveHostPath ?? "/api/v2/proxy/control-plane/hosts/", i = e.audience ?? `${n}/api/v2/`, a = e.scope ?? "proxy:resolve_host", o = e.tokenRefreshSkewSeconds ?? 60, s = e.timeoutMs ?? 2500;
|
|
3301
3394
|
function c(e) {
|
|
3302
3395
|
let t = new AbortController(), n = setTimeout(() => t.abort(), s);
|
|
@@ -3329,7 +3422,7 @@ function Yr(e) {
|
|
|
3329
3422
|
}), u);
|
|
3330
3423
|
}
|
|
3331
3424
|
return {
|
|
3332
|
-
proxyRoutes:
|
|
3425
|
+
proxyRoutes: ei(),
|
|
3333
3426
|
async resolveHost(e) {
|
|
3334
3427
|
let i = await f(), a = `${n}${r}${encodeURIComponent(e.toLowerCase())}`, o = await c((e) => t(a, {
|
|
3335
3428
|
headers: { authorization: `Bearer ${i}` },
|
|
@@ -3343,11 +3436,11 @@ function Yr(e) {
|
|
|
3343
3436
|
}
|
|
3344
3437
|
//#endregion
|
|
3345
3438
|
//#region src/kv-adapter/index.ts
|
|
3346
|
-
var
|
|
3347
|
-
function
|
|
3439
|
+
var ni = "authhero-proxy-host:";
|
|
3440
|
+
function ri(e, t) {
|
|
3348
3441
|
return `${e}${t.toLowerCase()}`;
|
|
3349
3442
|
}
|
|
3350
|
-
function
|
|
3443
|
+
function ii() {
|
|
3351
3444
|
let e = () => {
|
|
3352
3445
|
throw Error("KV proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
|
|
3353
3446
|
};
|
|
@@ -3369,15 +3462,15 @@ function Qr() {
|
|
|
3369
3462
|
}
|
|
3370
3463
|
};
|
|
3371
3464
|
}
|
|
3372
|
-
function
|
|
3373
|
-
let { kv: t, keyPrefix: n =
|
|
3465
|
+
function ai(e) {
|
|
3466
|
+
let { kv: t, keyPrefix: n = ni, timeoutMs: r } = e;
|
|
3374
3467
|
return {
|
|
3375
|
-
proxyRoutes:
|
|
3468
|
+
proxyRoutes: ii(),
|
|
3376
3469
|
async resolveHost(e) {
|
|
3377
|
-
let i =
|
|
3470
|
+
let i = ri(n, e), a = t.get(i, "json");
|
|
3378
3471
|
return (r && r > 0 ? await J(a, r, "kv.get") : await a) ?? null;
|
|
3379
3472
|
}
|
|
3380
3473
|
};
|
|
3381
3474
|
}
|
|
3382
3475
|
//#endregion
|
|
3383
|
-
export {
|
|
3476
|
+
export { ni as DEFAULT_KV_HOST_KEY_PREFIX, F as HandlerRegistry, $r as PROXY_RESOLVE_HOST_SCOPE, nr as basicAuthHandler, Yr as buildCacheAdapterKey, Gr as buildCacheApiKey, ri as buildKvHostKey, Nr as buildMatchFilter, ir as cacheHandler, Z as compileHostApp, $n as corsHandler, Jr as createCacheAdapterHostCache, Wr as createCacheApiHostCache, ti as createHttpProxyAdapter, P as createInMemoryHostCache, ai as createKvProxyAdapter, zr as createProxyApp, Q as createProxyDataPlaneHandler, Rr as createProxyDataPlaneRouter, Zr as createStaticProxyAdapter, I as defineHandler, Dr as dispatchNamespaceHandler, ar as forwardedHeadersHandler, Tn as handlerConfigSchema, rr as headersHandler, vr as httpHandler, Qr as httpRoute, wn as matchSchema, Mr as matchesAnyHost, jr as matchesHost, j as proxyRouteInsertSchema, En as proxyRouteSchema, Dn as proxyRouteUpdateSchema, Or as redirectHandler, Ar as registerBuiltinHandlers, lr as rewriteCookiesHandler, ur as rewriteLocationHandler, Sr as serviceBindingHandler, X as sortRoutes, kr as staticHandler };
|